Back to index

scribus-ng  1.3.4.dfsg+svn20071115
smstyleimport.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 
00008 #include "smstyleimport.h"
00009 #include "smstyleimport.moc"
00010 #include "commonstrings.h"
00011 
00012 #include <qpixmap.h>
00013 #include <qlayout.h>
00014 #include <qlistview.h>
00015 #include <qpushbutton.h>
00016 #include <qheader.h>
00017 #include <qbuttongroup.h>
00018 #include <qradiobutton.h>
00019 
00020 extern QPixmap loadIcon(QString nam);
00021 
00022 ImportDialog::ImportDialog( QWidget* parent, StyleSet<ParagraphStyle> *pstyleList,
00023                                                 StyleSet<CharStyle> *cstyleList,
00024                                                 QMap<QString, multiLine> *lstyleList)
00025 : QDialog( parent, "ImportDialog", true, 0 )
00026 {
00027        setCaption( tr( "Choose Styles" ) );
00028        setIcon(loadIcon("AppIcon.png"));
00029        ChooseStylesLayout = new QVBoxLayout( this, 10, 5, "ChooseStylesLayout");
00030        StyleView = new QListView( this, "StyleView" );
00031        StyleView->clear();
00032        StyleView->addColumn( tr( "Available Styles" ) );
00033        StyleView->header()->setClickEnabled( false, StyleView->header()->count() - 1 );
00034        StyleView->header()->setResizeEnabled( false, StyleView->header()->count() - 1 );
00035        StyleView->setSorting(-1);
00036 
00037        QListViewItem *croot = new QListViewItem(StyleView, tr("Character Styles"));
00038        for (uint x = 0; x < cstyleList->count(); ++x)
00039        {
00040               CharStyle& vg ((*cstyleList)[x]);
00041               QCheckListItem *item = new QCheckListItem (croot, vg.name(), QCheckListItem::CheckBox);
00042               item->setOn(true);
00043               storedCharStyles.insert(item, vg.name());
00044        }
00045 
00046        QListViewItem *proot = new QListViewItem(StyleView, tr("Paragraph Styles"));
00047        for (uint x = 0; x < pstyleList->count(); ++x)
00048        {
00049               ParagraphStyle& vg ((*pstyleList)[x]);
00050               QCheckListItem *item = new QCheckListItem (proot, vg.name(), QCheckListItem::CheckBox);
00051               item->setOn(true);
00052               storedStyles.insert(item, vg.name());
00053        }
00054 
00055        QListViewItem *lroot = new QListViewItem(StyleView, tr("Line Styles"));
00056        QValueList<QString> lkeys = lstyleList->keys();
00057        for (uint x = 0; x < lkeys.count(); ++x)
00058        {
00059               QCheckListItem *item = new QCheckListItem (lroot, lkeys[x], QCheckListItem::CheckBox);
00060               item->setOn(true);
00061               storedLineStyles.insert(item, lkeys[x]);
00062        }
00063 
00064        StyleView->setSorting(0);
00065        StyleView->setTreeStepSize(10);
00066        StyleView->setRootIsDecorated(true);
00067        StyleView->setOpen(lroot, true);
00068        StyleView->setOpen(croot, true);
00069        StyleView->setOpen(proot, true);
00070 
00071        ChooseStylesLayout->addWidget( StyleView );
00072 
00073        clashBox = new QButtonGroup(2, QGroupBox::Vertical, tr("In case of a name clash"), this, "clashBox");
00074        renameButton = new QRadioButton(tr("Rename imported style"), clashBox, "renameButton");
00075        renameButton->setChecked(true);
00076        replaceButton = new QRadioButton(tr("Replace existing style"), clashBox, "replaceButton");
00077        ChooseStylesLayout->addWidget(clashBox);
00078 
00079        layout2 = new QHBoxLayout( 0, 0, 5, "layout2");
00080        QSpacerItem* spacer1 = new QSpacerItem( 71, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
00081        layout2->addItem( spacer1 );
00082        OkButton = new QPushButton( CommonStrings::tr_OK, this, "OkButton" );
00083        layout2->addWidget( OkButton );
00084        CancelButton = new QPushButton( CommonStrings::tr_Cancel, this, "CancelButton" );
00085        layout2->addWidget( CancelButton );
00086        ChooseStylesLayout->addLayout( layout2 );
00087 
00088        resize(230, 400);
00089        clearWState( WState_Polished );
00090        connect(CancelButton, SIGNAL(clicked()), this, SLOT(reject()));
00091        connect(OkButton, SIGNAL(clicked()), this, SLOT(accept()));
00092 }
00093 
00094 bool ImportDialog::clashRename()
00095 {
00096        return renameButton->isChecked();
00097 }
00098 
00099 
00100 
00101