diff --git a/scribus/ui/mergedoc.cpp b/scribus/ui/mergedoc.cpp index 76ab6197b..3da750105 100644 --- a/scribus/ui/mergedoc.cpp +++ b/scribus/ui/mergedoc.cpp @@ -24,6 +24,7 @@ for which a new license (GPL+exception) is in place. #include #include #include +#include #include #include #include @@ -65,8 +66,9 @@ MergeDoc::MergeDoc(QWidget* parent, bool importMasterPages, int targetDocPageCou if (masterPages) { importPageLabel->setText( tr("&Import Master Page") ); - masterPageNameData = new QComboBox(this); + masterPageNameData = new QListWidget(this); masterPageNameData->setEnabled(false); + masterPageNameData->setSelectionMode(QAbstractItemView::ExtendedSelection); importPageLabel->setBuddy( masterPageNameData ); fromInfoLayout->addWidget( masterPageNameData, 1, 1, 1, 2); } @@ -226,14 +228,20 @@ const QString MergeDoc::getFromDoc() return QDir::fromNativeSeparators(fromDocData->text()); } -const int MergeDoc::getMasterPageNameItem() +const QStringList MergeDoc::getMasterPageNames() const { - return masterPageNameData->currentIndex(); + QStringList result; + for (const auto item : masterPageNameData->selectedItems()) + result << item->text(); + return result; } -const QString MergeDoc::getMasterPageNameText() +QList MergeDoc::getMasterPageIndexes() const { - return masterPageNameData->currentText(); + QList result; + for (const auto& row: masterPageNameData->selectionModel()->selectedRows()) + result << row.row(); + return result; } const int MergeDoc::getImportWhere() diff --git a/scribus/ui/mergedoc.h b/scribus/ui/mergedoc.h index a6f32a747..457f3aed3 100644 --- a/scribus/ui/mergedoc.h +++ b/scribus/ui/mergedoc.h @@ -4,6 +4,9 @@ to the COPYING file provided with the program. Following this notice may exist a copyright and/or license notice that predates the release of Scribus 1.3.2 for which a new license (GPL+exception) is in place. */ +/** + * "page > import" and, "import master pages" from the "master pages" window. + */ #ifndef MERGEDOC_H #define MERGEDOC_H @@ -14,6 +17,8 @@ class QCheckBox; class QComboBox; class QLabel; class QLineEdit; +class QList; +class QListWidget; class QPushButton; class QSpinBox; class QString; @@ -31,8 +36,8 @@ public: ~MergeDoc(); const QString getFromDoc(); - const int getMasterPageNameItem(); - const QString getMasterPageNameText(); + const QStringList getMasterPageNames() const; + QList getMasterPageIndexes() const; const int getImportWhere(); const int getImportWherePage(); const bool getCreatePageChecked(); @@ -49,7 +54,7 @@ private: QPushButton* cancelButton; QPushButton* changeButton; QCheckBox* createPageData; - QComboBox* masterPageNameData; + QListWidget* masterPageNameData; QComboBox* importWhereData; QSpinBox* importWherePageData; QVBoxLayout* dialogLayout; diff --git a/scribus/ui/pagepalette_masterpages.cpp b/scribus/ui/pagepalette_masterpages.cpp index 1ff60ec58..8490292a4 100644 --- a/scribus/ui/pagepalette_masterpages.cpp +++ b/scribus/ui/pagepalette_masterpages.cpp @@ -352,26 +352,31 @@ void PagePalette_MasterPages::importPage() if (m_doc->appMode == modeEditClip) m_view->requestMode(submodeEndNodeEdit); + qApp->setOverrideCursor(QCursor(Qt::WaitCursor)); int nr = m_doc->Pages->count(); - QString masterPageName(dia->getMasterPageNameText()); - QString masterPageName2(masterPageName); - int copyC = 1; - while (m_doc->MasterNames.contains(masterPageName2)) + auto indexes = dia->getMasterPageIndexes(); + QString lastName; + for (auto name: dia->getMasterPageNames()) { - masterPageName2 = tr("Copy #%1 of ").arg(copyC)+masterPageName; - copyC++; + name = getUniqueName(name, m_doc->MasterNames); + m_doc->setCurrentPage(m_doc->addMasterPage(nr, name)); + + nr++; + qApp->processEvents(); + + //CB TODO: If we are loading to a new name, we rely on doc->onpage in + //FileLoader::PasteItem as this call doesn't pass in the new destination page + m_doc->scMW()->loadPage(dia->getFromDoc(), indexes.first(), true, name); + qApp->processEvents(); + + indexes.removeFirst(); + lastName = name; } - m_doc->setCurrentPage(m_doc->addMasterPage(nr, masterPageName2)); - qApp->processEvents(); - //CB TODO: If we are loading to a new name, we rely on doc->onpage in - //FileLoader::PasteItem as this call doesn't pass in the new destination page - m_doc->scMW()->loadPage(dia->getFromDoc(), dia->getMasterPageNameItem(), true, masterPageName2); - qApp->processEvents(); - - updateMasterPageList(masterPageName2); - m_view->showMasterPage(m_doc->MasterNames[masterPageName2]); + + updateMasterPageList(lastName); + m_view->showMasterPage(m_doc->MasterNames[lastName]); qApp->restoreOverrideCursor(); }