r17513 by jghali - merge page palette and masterpage palette
scribus-commit
scribus-commit at lists.scribus.net
Sat May 19 11:40:39 UTC 2012
Author: jghali
Date: Sat May 19 11:40:38 2012
New Revision: 17513
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17513
Log:
merge page palette and masterpage palette
Added:
trunk/Scribus/scribus/ui/pagepalette_masterpages.cpp
trunk/Scribus/scribus/ui/pagepalette_masterpages.h
trunk/Scribus/scribus/ui/pagepalette_masterpagesbase.ui
trunk/Scribus/scribus/ui/pagepalette_pages.cpp
trunk/Scribus/scribus/ui/pagepalette_pages.h
trunk/Scribus/scribus/ui/pagepalette_pagesbase.ui
trunk/Scribus/scribus/ui/pagepalette_widgets.cpp
trunk/Scribus/scribus/ui/pagepalette_widgets.h
Modified:
trunk/Scribus/scribus/CMakeLists.txt
trunk/Scribus/scribus/prefsmanager.cpp
trunk/Scribus/scribus/prefsstructs.h
trunk/Scribus/scribus/scribus.cpp
trunk/Scribus/scribus/scribus.h
trunk/Scribus/scribus/scribuswin.cpp
trunk/Scribus/scribus/scribuswin.h
trunk/Scribus/scribus/ui/newfile.h
trunk/Scribus/scribus/ui/pagelayout.cpp
trunk/Scribus/scribus/ui/pagelayout.h
trunk/Scribus/scribus/ui/pagepalette.cpp
trunk/Scribus/scribus/ui/pagepalette.h
trunk/Scribus/win32/vc9/scribus-main/Scribus.vcproj
Modified: trunk/Scribus/scribus/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17513&path=/trunk/Scribus/scribus/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/CMakeLists.txt Sat May 19 11:40:38 2012
@@ -91,6 +91,8 @@
ui/nftdialog.ui
ui/nftwidget.ui
ui/pageitemattributes.ui
+ ui/pagepalette_pagesbase.ui
+ ui/pagepalette_masterpagesbase.ui
ui/paintmanagerbase.ui
ui/picsearch.ui
ui/picsearchoptions.ui
@@ -315,7 +317,6 @@
ui/marginpresetlayout.h
ui/marginwidget.h
ui/newmarginwidget.h
- ui/masterpagepalette.h
ui/measurements.h
ui/mergedoc.h
ui/missing.h
@@ -332,6 +333,9 @@
ui/pageitemattributes.h
ui/pagelayout.h
ui/pagepalette.h
+ ui/pagepalette_pages.h
+ ui/pagepalette_masterpages.h
+ ui/pagepalette_widgets.h
ui/pageselector.h
ui/paintmanager.h
ui/patternpropsdialog.h
@@ -741,7 +745,6 @@
ui/marginpresetlayout.cpp
ui/marginwidget.cpp
ui/newmarginwidget.cpp
- ui/masterpagepalette.cpp
ui/mergedoc.cpp
ui/missing.cpp
ui/movepage.cpp
@@ -758,6 +761,9 @@
ui/pageitemattributes.cpp
ui/pagelayout.cpp
ui/pagepalette.cpp
+ ui/pagepalette_pages.cpp
+ ui/pagepalette_masterpages.cpp
+ ui/pagepalette_widgets.cpp
ui/pageselector.cpp
ui/paintmanager.cpp
ui/patternpropsdialog.cpp
Modified: trunk/Scribus/scribus/prefsmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17513&path=/trunk/Scribus/scribus/prefsmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/prefsmanager.cpp (original)
+++ trunk/Scribus/scribus/prefsmanager.cpp Sat May 19 11:40:38 2012
@@ -1288,8 +1288,6 @@
QDomElement dcUI=docu.createElement("UI");
- dcUI.setAttribute("PagePaletteShowThumbs", static_cast<int>(appPrefs.uiPrefs.SepalT));
- dcUI.setAttribute("PagePaletteShowNames", static_cast<int>(appPrefs.uiPrefs.SepalN));
dcUI.setAttribute("ShowStartupDialog", static_cast<int>(appPrefs.uiPrefs.showStartupDialog));
dcUI.setAttribute("ShowSplashOnStartup", static_cast<int>(appPrefs.uiPrefs.showSplashOnStartup));
dcUI.setAttribute("UseSmallWidgets", static_cast<int>(appPrefs.uiPrefs.useSmallWidgets));
@@ -1904,8 +1902,6 @@
appPrefs.uiPrefs.useSmallWidgets = dc.attribute("UseSmallWidgets").toInt();
appPrefs.uiPrefs.useTabs = static_cast<bool>(dc.attribute("UseDocumentTabs", "0").toInt());
appPrefs.uiPrefs.stickyTools = static_cast<bool>(dc.attribute("StickyTools", "0").toInt());
- appPrefs.uiPrefs.SepalT = static_cast<bool>(dc.attribute("PagePaletteShowThumbs").toInt());
- appPrefs.uiPrefs.SepalN = static_cast<bool>(dc.attribute("PagePaletteShowNames").toInt());
appPrefs.uiPrefs.grayscaleIcons = static_cast<bool>(dc.attribute("UseGrayscaleIcons",0).toInt());
}
Modified: trunk/Scribus/scribus/prefsstructs.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17513&path=/trunk/Scribus/scribus/prefsstructs.h
==============================================================================
--- trunk/Scribus/scribus/prefsstructs.h (original)
+++ trunk/Scribus/scribus/prefsstructs.h Sat May 19 11:40:38 2012
@@ -113,8 +113,6 @@
bool grayscaleIcons; //! Show icons in toolbars as grayscale
WindowPrefs mainWinSettings;
QByteArray mainWinState;
- bool SepalT; //! Page Palette - show page thumbnails
- bool SepalN; //! Page Palette - show names on pages
};
//Paths
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17513&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Sat May 19 11:40:38 2012
@@ -163,7 +163,6 @@
#include "ui/loremipsum.h"
#include "ui/marginwidget.h"
#include "ui/margindialog.h"
-#include "ui/masterpagepalette.h"
#include "ui/mergedoc.h"
#include "ui/movepage.h"
#include "ui/multipleduplicate.h"
@@ -527,7 +526,6 @@
scrapbookPalette->installEventFilter(this);
pagePalette = new PagePalette(this);
connect( scrActions["toolsPages"], SIGNAL(toggled(bool)) , pagePalette, SLOT(setPaletteShown(bool)) );
- connect( scrActions["toolsPages"], SIGNAL(toggled(bool)) , this, SLOT(setPagePalette(bool)) );
connect( pagePalette, SIGNAL(paletteShown(bool)), scrActions["toolsPages"], SLOT(setChecked(bool)));
pagePalette->installEventFilter(this);
bookmarkPalette = new BookPalette(this);
@@ -5829,7 +5827,6 @@
bookmarkPalette->show();
if (palettesStatus[9])
docCheckerPalette->show();
- setPagePalette(palettesStatus[5]);
setUndoPalette(palettesStatus[8]);
}
else
@@ -5849,7 +5846,6 @@
pagePalette->hide();
layerPalette->hide();
docCheckerPalette->hide();
- setPagePalette(false);
setUndoPalette(false);
palettesStatus[0] = true;
}
@@ -5866,18 +5862,8 @@
scrActions["toolsActionHistory"]->setChecked(visible);
}
-void ScribusMainWindow::setPagePalette(bool visible)
-{
- if (!visible)
- {
- prefsManager->appPrefs.uiPrefs.SepalT = pagePalette->getThumb();
- prefsManager->appPrefs.uiPrefs.SepalN = pagePalette->getNamen();
- }
-}
-
void ScribusMainWindow::togglePagePalette()
{
- setPagePalette(!pagePalette->isVisible());
palettesStatus[0] = false;
}
@@ -8605,52 +8591,46 @@
if (HaveDoc)
{
view->Deselect(true);
+
if (doc->masterPageMode())
{
- ActWin->masterPagesPalette()->updateMasterPageList(temp);
- ActWin->masterPagesPalette()->selectMasterPage(temp);
- }
- else
- {
- storedPageNum = doc->currentPageNumber();
- storedViewXCoor = view->contentsX();
- storedViewYCoor = view->contentsY();
- storedViewScale = view->scale();
- MasterPagesPalette *dia = new MasterPagesPalette(this, doc, view, temp);
- //connect(dia, SIGNAL(createNew(int)), this, SLOT(slotNewMasterPage(int)));
- connect(dia, SIGNAL(removePage(int )), this, SLOT(deletePage2(int )));
- //connect(dia, SIGNAL(loadPage(QString, int, bool)), this, SLOT(loadPage(QString, int, bool)));
- connect(dia, SIGNAL(finished()), this, SLOT(manageMasterPagesEnd()));
- scrActions["pageInsert"]->setEnabled(false);
- scrActions["pageImport"]->setEnabled(false);
- scrActions["pageDelete"]->setEnabled(false);
- scrActions["pageCopy"]->setEnabled(false);
- scrActions["pageMove"]->setEnabled(false);
- scrActions["pageApplyMasterPage"]->setEnabled(false);
- scrActions["pageCopyToMasterPage"]->setEnabled(false);
- scrActions["editMasterPages"]->setEnabled(false);
- scrActions["fileNew"]->setEnabled(false);
- scrActions["fileNewFromTemplate"]->setEnabled(false);
- scrActions["fileOpen"]->setEnabled(false);
- scrActions["fileClose"]->setEnabled(false);
- scrMenuMgr->setMenuEnabled("FileOpenRecent", false);
- scrActions["fileRevert"]->setEnabled(false);
- scrActions["fileDocSetup150"]->setEnabled(false);
- scrActions["filePrint"]->setEnabled(false);
- scrActions["PrintPreview"]->setEnabled(false);
- scrActions["toolsPDFPushButton"]->setEnabled(false);
- scrActions["toolsPDFTextField"]->setEnabled(false);
- scrActions["toolsPDFCheckBox"]->setEnabled(false);
- scrActions["toolsPDFComboBox"]->setEnabled(false);
- scrActions["toolsPDFListBox"]->setEnabled(false);
- scrActions["toolsPDFAnnotText"]->setEnabled(false);
+ pagePalette->startMasterPageMode(temp);
+ return;
+ }
+
+ storedPageNum = doc->currentPageNumber();
+ storedViewXCoor = view->contentsX();
+ storedViewYCoor = view->contentsY();
+ storedViewScale = view->scale();
+
+ pagePalette->startMasterPageMode(temp);
+
+ scrActions["pageInsert"]->setEnabled(false);
+ scrActions["pageImport"]->setEnabled(false);
+ scrActions["pageDelete"]->setEnabled(false);
+ scrActions["pageCopy"]->setEnabled(false);
+ scrActions["pageMove"]->setEnabled(false);
+ scrActions["pageApplyMasterPage"]->setEnabled(false);
+ scrActions["pageCopyToMasterPage"]->setEnabled(false);
+ scrActions["editMasterPages"]->setEnabled(false);
+ scrActions["fileNew"]->setEnabled(false);
+ scrActions["fileNewFromTemplate"]->setEnabled(false);
+ scrActions["fileOpen"]->setEnabled(false);
+ scrActions["fileClose"]->setEnabled(false);
+ scrMenuMgr->setMenuEnabled("FileOpenRecent", false);
+ scrActions["fileRevert"]->setEnabled(false);
+ scrActions["fileDocSetup150"]->setEnabled(false);
+ scrActions["filePrint"]->setEnabled(false);
+ scrActions["PrintPreview"]->setEnabled(false);
+ scrActions["toolsPDFPushButton"]->setEnabled(false);
+ scrActions["toolsPDFTextField"]->setEnabled(false);
+ scrActions["toolsPDFCheckBox"]->setEnabled(false);
+ scrActions["toolsPDFComboBox"]->setEnabled(false);
+ scrActions["toolsPDFListBox"]->setEnabled(false);
+ scrActions["toolsPDFAnnotText"]->setEnabled(false);
#ifdef HAVE_OSG
- scrActions["toolsPDFAnnot3D"]->setEnabled(false);
+ scrActions["toolsPDFAnnot3D"]->setEnabled(false);
#endif
- pagePalette->enablePalette(false);
- dia->show();
- ActWin->setMasterPagesPalette(dia);
- }
}
}
@@ -8692,18 +8672,13 @@
uint pageCount=doc->DocPages.count();
for (uint c=0; c<pageCount; ++c)
Apply_MasterPage(doc->DocPages.at(c)->MPageNam, c, false);
-// doc->setMasterPageMode(false);
- pagePalette->enablePalette(true);
- pagePalette->rebuildMasters();
- ActWin->setMasterPagesPalette(NULL);
+
+ pagePalette->endMasterPageMode();
+
doc->setCurrentPage(doc->DocPages.at(storedPageNum));
view->reformPages(false);
view->setContentsPos(static_cast<int>(storedViewXCoor * storedViewScale), static_cast<int>(storedViewYCoor * storedViewScale));
view->DrawNew();
- pagePalette->Rebuild();
-// if (outlinePalette->isVisible())
-// outlinePalette->BuildTree();
-// slotDocCh();
}
void ScribusMainWindow::ApplyMasterPage()
@@ -8883,7 +8858,7 @@
pagePalette->rebuildMasters();
}
if (doc->masterPageMode() && !pageName.isEmpty())
- ActWin->masterPagesPalette()->updateMasterPageList();
+ pagePalette->updateMasterPageList();
pagePalette->rebuildPages();
}
@@ -9673,7 +9648,7 @@
return;
if(doc->masterPageMode())
{
- ActWin->masterPagesPalette()->close();
+ manageMasterPagesEnd();
qApp->processEvents();
}
}
Modified: trunk/Scribus/scribus/scribus.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17513&path=/trunk/Scribus/scribus/scribus.h
==============================================================================
--- trunk/Scribus/scribus/scribus.h (original)
+++ trunk/Scribus/scribus/scribus.h Sat May 19 11:40:38 2012
@@ -405,7 +405,6 @@
void ToggleRulers();
void ToggleRulerMode();
void togglePagePalette();
- void setPagePalette(bool visible);
void toggleUndoPalette();
void setUndoPalette(bool visible);
void toggleCheckPal();
Modified: trunk/Scribus/scribus/scribuswin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17513&path=/trunk/Scribus/scribus/scribuswin.cpp
==============================================================================
--- trunk/Scribus/scribus/scribuswin.cpp (original)
+++ trunk/Scribus/scribus/scribuswin.cpp Sat May 19 11:40:38 2012
@@ -25,7 +25,7 @@
#include "scribus.h"
#include "commonstrings.h"
#include "fileloader.h"
-#include "ui/masterpagepalette.h"
+#include "ui/pagepalette.h"
#include "ui/pageselector.h"
#include "ui/scrspinbox.h"
#include "ui/storyeditor.h"
@@ -44,7 +44,6 @@
setWindowIcon(loadIcon("AppIcon2.png"));
setAttribute(Qt::WA_DeleteOnClose);
m_Doc = doc;
- m_masterPagesPalette = NULL;
currentDir = QDir::currentPath();
}
@@ -159,12 +158,17 @@
void ScribusWin::setMasterPagesPaletteShown(bool isShown) const
{
- if (m_masterPagesPalette==NULL)
- return;
- if (isShown)
- m_masterPagesPalette->show();
- else
- m_masterPagesPalette->hide();
+ QString pageName;
+ PagePalette* pagePalette = m_MainWindow->pagePalette;
+ if (isShown && m_Doc->masterPageMode())
+ {
+ pageName = m_Doc->currentPage()->pageName();
+ pagePalette->startMasterPageMode(pageName);
+ }
+ else if (pagePalette->masterPageMode())
+ {
+ pagePalette->endMasterPageMode();
+ }
}
void ScribusWin::windowActivationChange ( bool oldActive )
@@ -175,13 +179,3 @@
currentDir = QDir::currentPath();
QMainWindow::windowActivationChange( oldActive );
}
-
-void ScribusWin::setMasterPagesPalette(MasterPagesPalette* newMPP)
-{
- m_masterPagesPalette=newMPP;
-}
-
-MasterPagesPalette* ScribusWin::masterPagesPalette() const
-{
- return m_masterPagesPalette;
-}
Modified: trunk/Scribus/scribus/scribuswin.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17513&path=/trunk/Scribus/scribus/scribuswin.h
==============================================================================
--- trunk/Scribus/scribus/scribuswin.h (original)
+++ trunk/Scribus/scribus/scribuswin.h Sat May 19 11:40:38 2012
@@ -56,8 +56,6 @@
ScribusDoc* doc() const { return m_Doc;}
QMdiSubWindow* getSubWin() { return subWindow; }
void setSubWin(QMdiSubWindow *win) { subWindow = win; }
- void setMasterPagesPalette(MasterPagesPalette* newMPP);
- MasterPagesPalette* masterPagesPalette() const;
void setMenuStatus(int index, bool value) { if (index>=0 && index <=6) MenuStat[index]=value;}
bool menuStatus(int index) const { if (index>=0 && index <=6) return MenuStat[index]; else return false; }
void setMasterPagesPaletteShown(bool isShown) const;
@@ -75,7 +73,6 @@
ScribusMainWindow* m_MainWindow;
ScribusView* m_View;
ScribusDoc* m_Doc;
- MasterPagesPalette* m_masterPagesPalette;
QFrame *statusFrame;
QMdiSubWindow* subWindow;
bool MenuStat[7];
Modified: trunk/Scribus/scribus/ui/newfile.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17513&path=/trunk/Scribus/scribus/ui/newfile.h
==============================================================================
--- trunk/Scribus/scribus/ui/newfile.h (original)
+++ trunk/Scribus/scribus/ui/newfile.h Sat May 19 11:40:38 2012
@@ -28,7 +28,6 @@
class PrefsManager;
class MarginWidget;
-class PageLayouts;
class ScrSpinBox;
class ScComboBox;
#if QT_VERSION >= 0x040300
Modified: trunk/Scribus/scribus/ui/pagelayout.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17513&path=/trunk/Scribus/scribus/ui/pagelayout.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/pagelayout.cpp (original)
+++ trunk/Scribus/scribus/ui/pagelayout.cpp Sat May 19 11:40:38 2012
@@ -59,7 +59,37 @@
}
}
-PageLayouts::PageLayouts( QWidget* parent, QList<PageSet> pSets, bool mode ) : QGroupBox( parent )
+PageLayouts::PageLayouts(QWidget* parent) : QGroupBox( parent )
+{
+ struct PageSet pageS;
+ pageS.Name = CommonStrings::trPageSet2;
+ pageS.FirstPage = 0;
+ pageS.Rows = 1;
+ pageS.Columns = 1;
+ pageS.pageNames.clear();
+ pageS.pageNames.append(CommonStrings::trPageLocMiddleRight);
+ pageSets.append(pageS);
+
+ modus = false;
+ layoutGroupLayout = new QVBoxLayout(this);
+ layoutGroupLayout->setSpacing( 5 );
+ layoutGroupLayout->setMargin( 10 );
+
+ layoutsCombo = new ScComboBox( this );
+ layoutGroupLayout->addWidget( layoutsCombo );
+
+ layoutLabel1 = new QLabel( this );
+ layoutGroupLayout->addWidget( layoutLabel1 );
+ firstPage = new ScComboBox( this );
+ layoutGroupLayout->addWidget( firstPage );
+
+ languageChange();
+
+ connect(layoutsCombo, SIGNAL(activated(int)), this, SLOT(itemSelected(int)));
+ connect(firstPage, SIGNAL(activated(int)), this, SIGNAL(selectedFirstPage(int)));
+}
+
+PageLayouts::PageLayouts(QWidget* parent, QList<PageSet> pSets, bool mode) : QGroupBox( parent )
{
pageSets = pSets;
modus = mode;
Modified: trunk/Scribus/scribus/ui/pagelayout.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17513&path=/trunk/Scribus/scribus/ui/pagelayout.h
==============================================================================
--- trunk/Scribus/scribus/ui/pagelayout.h (original)
+++ trunk/Scribus/scribus/ui/pagelayout.h Sat May 19 11:40:38 2012
@@ -39,8 +39,10 @@
Q_OBJECT
public:
- PageLayouts( QWidget* parent, QList<PageSet> pSets, bool mode = true );
+ PageLayouts(QWidget* parent);
+ PageLayouts(QWidget* parent, QList<PageSet> pSets, bool mode = true);
~PageLayouts() {};
+
void updateLayoutSelector(QList<PageSet> pSets);
void selectFirstP(int nr);
void selectItem(uint nr);
Modified: trunk/Scribus/scribus/ui/pagepalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17513&path=/trunk/Scribus/scribus/ui/pagepalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/pagepalette.cpp (original)
+++ trunk/Scribus/scribus/ui/pagepalette.cpp Sat May 19 11:40:38 2012
@@ -7,951 +7,200 @@
#include <QApplication>
-#include <QBitmap>
-#include <QCursor>
-#include <QDrag>
#include <QEvent>
-#include <QHeaderView>
-#include <QLabel>
#include <QList>
-#include <QMenu>
-#include <QMimeData>
-#include <QMessageBox>
#include <QPainter>
+#include <QStackedWidget>
#include "commonstrings.h"
#include "pagelayout.h"
#include "pagepalette.h"
+#include "pagepalette_masterpages.h"
+#include "pagepalette_pages.h"
+#include "pagepalette_widgets.h"
#include "sccombobox.h"
#include "scpage.h"
#include "scribus.h"
#include "scribusview.h"
#include "util_icon.h"
-/* IconItems Code */
-SeItem::SeItem(QString text, uint nr, const QPixmap& Pix) : QTableWidgetItem(QIcon(Pix), "", 1002)
-{
- pageNumber = nr;
- pageName = text;
- setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
-}
-
-const QString& SeItem::getPageName()
-{
- return pageName;
-}
-
-/* ListBox Subclass */
-SeList::SeList(QWidget* parent) : QListWidget(parent)
-{
- Mpressed = false;
- setAcceptDrops(true);
-}
-
-void SeList::mouseReleaseEvent(QMouseEvent *m)
-{
- Mpressed = false;
- if (m->button() == Qt::RightButton)
- {
- QMenu *pmen = new QMenu();
- qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
- QAction *px = pmen->addAction( tr("Show Page Previews"), this, SLOT(toggleThumbnail()));
- px->setCheckable(true);
- if (Thumb)
- px->setChecked(true);
- pmen->exec(QCursor::pos());
- delete pmen;
- }
- QListWidget::mouseReleaseEvent(m);
-}
-
-void SeList::toggleThumbnail()
-{
- Thumb = !Thumb;
- emit thumbnailChanged();
-}
-
-void SeList::mousePressEvent(QMouseEvent* e)
-{
- e->accept();
- CurItem = 0;
- QListWidgetItem *i = itemAt(e->pos());
- if (i)
- {
- CurItem = i;
- Mpos = e->pos();
- Mpressed = true;
- }
- QListWidget::mousePressEvent(e);
-}
-
-void SeList::mouseMoveEvent(QMouseEvent* e)
-{
- if ((Mpressed) && ((Mpos - e->pos()).manhattanLength() > 4))
- {
- Mpressed = false;
- QListWidgetItem *i = itemAt(Mpos);
- if (i)
- {
- QMimeData *mimeData = new QMimeData;
- mimeData->setData("page/magic", "1"+i->text().toLocal8Bit());
- mimeData->setText("1"+i->text());
- QDrag *dr = new QDrag(this);
- dr->setMimeData(mimeData);
- const QPixmap& pm = loadIcon("doc.png");
- dr->setPixmap(pm);
- // dr->setDragCursor(pm, Qt::CopyAction);
- // dr->setDragCursor(pm, Qt::MoveAction);
- dr->exec(Qt::CopyAction | Qt::MoveAction);
- QApplication::setOverrideCursor(Qt::ArrowCursor);
- }
- }
-}
-
-void SeList::keyPressEvent(QKeyEvent * e)
-{
- bool accepted = false;
- int k = e->key();
- if (k == Qt::Key_Delete)
- {
- if (currentItem())
- {
- e->accept();
- if (!QMessageBox::question(this, tr("Delete Master Page?"),
- "<qt>" + tr("Are you sure you want to delete this master page?") + "</qt>",
- CommonStrings::trYesKey, CommonStrings::trNoKey, QString::null, 0, 1 ))
- {
- emit DelMaster(currentItem()->text());
- }
- accepted = true;
- }
- }
- if (!accepted)
- QListWidget::keyPressEvent(e);
-}
-
-
-/* QTable Subclass */
-SeView::SeView(QWidget* parent) : QTableWidget(parent)
-{
- setDragEnabled(true);
- setAcceptDrops(true);
- setDropIndicatorShown(true);
-// viewport()->setAcceptDrops(true);
- setShowGrid(false);
- setWordWrap(true);
- Mpressed = false;
- Namen = true;
-// setFocusPolicy(Qt::NoFocus);
-}
-
-void SeView::mousePressEvent(QMouseEvent* e)
-{
- e->accept();
- Mpos = e->pos();
- Mpressed = true;
- QTableWidget::mousePressEvent(e);
-}
-
-void SeView::mouseReleaseEvent(QMouseEvent* e)
-{
- e->accept();
- Mpressed = false;
-/* if (e->button() == RightButton)
- {
- QPopupMenu *pmen = new QPopupMenu();
- qApp->setOverrideCursor(QCursor(Qt::ArrowCursor), true);
- int px = pmen->insertItem( tr("Show Master Page Names"), this, SLOT(ToggleNam()));
- if (Namen)
- pmen->setItemChecked(px, true);
- pmen->exec(QCursor::pos());
- delete pmen;
- } */
- emit Click(rowAt(e->pos().y()), columnAt(e->pos().x()), e->button());
- QTableWidget::mouseReleaseEvent(e);
-}
-
-void SeView::ToggleNam()
-{
-/* Namen = !Namen;
- int val = 35;
- if (Namen)
- val = 100;
- setColumnWidth(1, val);
- setColumnWidth(3, val);
- hide();
- show(); */
-}
-
-void SeView::mouseMoveEvent(QMouseEvent* e)
-{
- if ((Mpressed) && ((Mpos - e->pos()).manhattanLength() > 4))
- {
- Mpressed = false;
- int a = rowAt(e->pos().y());
- int b = columnAt(e->pos().x());
- if ((a != -1) && (b != -1))
- {
- QTableWidgetItem* ite = item(a, b);
- if (ite != 0)
- {
- if (ite->type() == 1002)
- {
- SeItem* it = (SeItem*)ite;
- QString str(it->pageName);
- bool dummy;
- int p = GetPage(a, b, &dummy);
- QString tmp;
- QMimeData *mimeData = new QMimeData;
- mimeData->setData("page/magic", "2 "+tmp.setNum(p).toLocal8Bit()+" "+str.toLocal8Bit());
- mimeData->setText("2 "+tmp.setNum(p)+" "+str);
- QDrag *dr = new QDrag(this);
- dr->setMimeData(mimeData);
- const QPixmap& pm = loadIcon("doc.png");
- dr->setPixmap(pm);
- // dr->setDragCursor(pm, Qt::CopyAction);
- // dr->setDragCursor(pm, Qt::MoveAction);
- dr->exec(Qt::CopyAction | Qt::MoveAction);
- QApplication::setOverrideCursor(Qt::ArrowCursor);
- }
- }
- }
- }
- QTableWidget::mouseMoveEvent(e);
-}
-
-void SeView::dropEvent(QDropEvent * e)
-{
- QString str, tmp;
- bool lastPage = false;
- if (e->mimeData()->hasFormat("page/magic"))
- {
- e->setDropAction(Qt::MoveAction);
- e->accept();
- // HACK to prevent strange Qt4 cursor behaviour after dropping. It's examined by Trolltech now - PV.
- // It's the one and only reason why to include QApplication here.
- // But sadly this destroys our normal Cursors
- // Fixed at least in Qt-4.4.2
-// QApplication::restoreOverrideCursor();
- str = e->mimeData()->text();
- ClearPix();
- if (str.startsWith("1"))
- {
- int a = rowAt(e->pos().y());
- int b = columnAt(e->pos().x());
- int p;
- tmp = str.remove(0,1);
- if ((a == -1) || (b == -1))
- return;
- if (a == rowCount()-1)
- {
- emit NewPage(MaxC+1, tmp);
- return;
- }
- p = GetPage(a, b, &lastPage);
- if (columnCount() == 1)
- {
- if ((a % 2) == 0)
- emit NewPage(p, tmp);
- else
- {
- emit UseTemp(tmp, p);
- QTableWidgetItem* ite = item(a, b);
- if (ite == 0)
- return;
- if (ite->type() == 1002)
- {
- SeItem* it = (SeItem*)ite;
- it->pageName = tmp;
- }
- }
- return;
- }
- else
- {
- if ((b % 2) == 0)
- {
- if (lastPage)
- emit NewPage(p+1, tmp);
- else
- emit NewPage(p, tmp);
- }
- else
- {
- emit UseTemp(tmp, p);
- QTableWidgetItem* ite = item(a, b);
- if (ite == 0)
- return;
- if (ite->type() == 1002)
- {
- SeItem* it = (SeItem*)ite;
- it->pageName = tmp;
- }
- }
- return;
- }
- }
- if (str.startsWith("2"))
- {
- int st = str.indexOf(" ");
- int en = str.indexOf(" ", st+1);
- tmp = str.mid(en+1);
- int dr = str.mid(st, en-st).toInt();
- int a = rowAt(e->pos().y());
- int b = columnAt(e->pos().x());
- int p;
- if ((a == -1) || (b == -1))
- return;
- QTableWidgetItem* ite = item(a, b);
- p = GetPage(a, b, &lastPage);
- if (a == rowCount()-1)
- {
- emit movePage(dr, p+1);
- return;
- }
- if (columnCount() == 1)
- {
- if ((a % 2) == 0)
- emit movePage(dr, p);
- else
- {
- emit UseTemp(tmp, p);
- if (ite == 0)
- return;
- SeItem* it = (SeItem*)ite;
- it->pageName = tmp;
- }
- return;
- }
- else
- {
- if ((b % 2) == 0)
- emit movePage(dr, lastPage ? p+1 : p);
- else
- {
- emit UseTemp(tmp, p);
- if (ite == 0)
- return;
- if (ite->type() == 1002)
- {
- SeItem* it = (SeItem*)ite;
- it->pageName = tmp;
- }
- }
- return;
- }
- }
- }
-}
-
-void SeView::dragEnterEvent(QDragEnterEvent *e)
-{
- if (e->mimeData()->hasFormat("page/magic"))
- e->acceptProposedAction();
-}
-
-void SeView::dragLeaveEvent(QDragLeaveEvent *)
-{
- ClearPix();
-}
-
-void SeView::dragMoveEvent(QDragMoveEvent *e)
-{
- QString str, tmp;
- if (e->mimeData()->hasFormat("page/magic"))
- {
- e->acceptProposedAction();
- str = e->mimeData()->text();
- int a = rowAt(e->pos().y());
- int b = columnAt(e->pos().x());
- ClearPix();
- if ((a == -1) || (b == -1))
- return;
- if (columnCount() == 1)
- {
- if ((a % 2) == 0)
- {
- item(a, 0)->setBackground(Qt::darkBlue);
- }
- }
- else
- {
- if (((b % 2) == 0) || (a == rowCount()-1))
- {
- item(a, b)->setBackground(Qt::darkBlue);
- }
- }
- }
-}
-
-void SeView::keyPressEvent(QKeyEvent * e)
-{
- bool accepted = false;
- int k = e->key();
- if (k == Qt::Key_Delete)
- {
- e->accept();
- if (!QMessageBox::question(this, tr("Delete Page?"),
- "<qt>" + tr("Are you sure you want to delete this page?") + "</qt>",
- CommonStrings::trYesKey, CommonStrings::trNoKey, QString::null, 0, 1 ))
- {
- bool dummy;
- int pageToDelete=GetPage(currentRow(), currentColumn(), &dummy);
- emit DelPage(pageToDelete);
- }
- accepted = true;
- }
- if (!accepted)
- QTableWidget::keyPressEvent(e);
-}
-
-void SeView::ClearPix()
-{
- int counter = 0;
- int rowcounter = 0;
- for (int a = 0; a < rowCount(); ++a)
- {
- counter = 0;
- if (columnCount() == 1)
- {
- if ((a % 2) == 0)
- {
- item(rowcounter, 0)->setBackground(Qt::white);
- rowcounter += 2;
- }
- }
- else
- {
- for (int b = 0; b < columnCount(); ++b)
- {
- if ((b % 2) == 0)
- {
- item(rowcounter, counter)->setBackground(Qt::white);
- counter += 2;
- }
- }
- rowcounter++;
- }
- }
- for (int c = 0; c < columnCount(); ++c)
- {
- item(rowCount()-1, c)->setBackground(Qt::white);
- }
-}
-
-int SeView::GetPage(int r, int c, bool *last)
-{
- int counter = firstP;
- int rowcounter = 0;
- int ret = MaxC;
- *last = false;
- if (r == rowCount()-1)
- {
- *last = true;
- return ret;
- }
- if ((r == 0) && (c < firstP*colmult+coladd))
- return 0;
- for (int a = 0; a < MaxC+1; ++a)
- {
- if ((rowcounter*rowmult+rowadd == r) && (counter*colmult+coladd == c))
- {
- ret = a;
- return ret;
- }
- else
- {
- if (columnCount() == 1)
- {
- if ((rowcounter*rowmult) == r)
- {
- ret = a;
- return ret;
- }
- }
- else
- {
- if ((counter*colmult == c) && (rowcounter*rowmult+rowadd == r))
- {
- ret = a;
- return ret;
- }
- }
- }
- counter++;
- if (counter > cols-1)
- {
- counter = 0;
- rowcounter++;
- }
- }
- *last = true;
- return ret;
-}
-
-/* Der Muelleimer */
-TrashBin::TrashBin(QWidget * parent) : QLabel(parent)
-{
- Normal = loadIcon("trashcan.png");
- Offen = loadIcon("trashcan2.png");
- setPixmap(Normal);
- setScaledContents(false);
- setAcceptDrops(true);
-}
-
-void TrashBin::dragEnterEvent(QDragEnterEvent *e)
-{
- if (e->mimeData()->hasFormat("page/magic"))
- {
- e->accept();
- setPixmap(Offen);
- }
-}
-
-void TrashBin::dragLeaveEvent(QDragLeaveEvent *)
-{
- setPixmap(Normal);
-}
-
-void TrashBin::dropEvent(QDropEvent * e)
-{
- setPixmap(Normal);
- QString str, tmp;
- if (e->mimeData()->hasFormat("page/magic"))
- {
- e->accept();
- str = e->mimeData()->text();
- if (str.startsWith("2"))
- {
- int st = str.indexOf(" ");
- int en = str.indexOf(" ", st+1);
- emit DelPage(str.mid(st, en-st).toInt());
- }
- if (str.startsWith("1"))
- {
- tmp = str.remove(0,1);
- emit DelMaster(tmp);
- }
- }
-}
-
-
-PagePalette::PagePalette(QWidget* parent) : ScDockPalette( parent, "Sp", 0)
-{
- m_scMW=(ScribusMainWindow*)parent;
- setObjectName(QString::fromLocal8Bit("Sp"));
- setSizePolicy( QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
- containerWidget = new QWidget(this);
- PagePaletteLayout = new QVBoxLayout( containerWidget );
- PagePaletteLayout->setSpacing( 5 );
- PagePaletteLayout->setMargin( 5 );
- Splitter1 = new QSplitter( this );
- Splitter1->setOrientation( Qt::Vertical );
- QWidget* privateLayoutWidget = new QWidget( Splitter1 );
- Layout2 = new QVBoxLayout( privateLayoutWidget );
- Layout2->setMargin(0);
- Layout2->setSpacing(5);
- TextLabel1 = new QLabel( privateLayoutWidget );
- Layout2->addWidget( TextLabel1 );
- masterPageList = new SeList(privateLayoutWidget);
- masterPageList->setMinimumSize(QSize(130,70));
- masterPageList->Thumb = false;
- masterPageList->setIconSize(QSize(60, 60));
- Layout2->addWidget( masterPageList );
- QWidget* privateLayoutWidget_2 = new QWidget( Splitter1 );
- Layout3 = new QVBoxLayout( privateLayoutWidget_2);
- Layout3->setMargin(0);
- Layout3->setSpacing(5);
- TextLabel2 = new QLabel( privateLayoutWidget_2 );
- Layout3->addWidget( TextLabel2 );
- pageView = new SeView(privateLayoutWidget_2);
- QHeaderView *Header = pageView->verticalHeader();
- Header->setMovable(false);
- Header->setResizeMode(QHeaderView::Fixed);
- Header->hide();
- Header = pageView->horizontalHeader();
- Header->setMovable(false);
- Header->setResizeMode(QHeaderView::Fixed);
- Header->hide();
- pageView->setSortingEnabled(false);
- pageView->setSelectionMode( QAbstractItemView::NoSelection );
- pageView->setRowCount(1);
- pageView->setColumnCount(1);
- pageView->setIconSize(QSize(60, 60));
- pageView->setMinimumSize(QSize(130,120));
- Layout3->addWidget( pageView );
- PagePaletteLayout->addWidget( Splitter1 );
-
- Layout1 = new QHBoxLayout;
- Layout1->setSpacing( 5 );
- Layout1->setMargin( 0 );
- QList<PageSet> dummy;
- dummy.clear();
- struct PageSet pageS;
- pageS.Name = CommonStrings::trPageSet2;
- pageS.FirstPage = 0;
- pageS.Rows = 1;
- pageS.Columns = 1;
-// pageS.GapHorizontal = 0.0;
-// pageS.GapVertical = 0.0;
-// pageS.GapBelow = 40.0;
- pageS.pageNames.clear();
- pageS.pageNames.append(CommonStrings::trPageLocMiddleRight);
- dummy.append(pageS);
- pageLayout = new PageLayouts(this, dummy, false);
- Layout1->addWidget( pageLayout );
-
-// QSpacerItem* spacer = new QSpacerItem( 15, 15, QSizePolicy::Expanding, QSizePolicy::Minimum );
-// Layout1->addItem( spacer );
-
- Trash = new TrashBin( this );
- Trash->setMinimumSize(QSize(32,32));
- Trash->setMaximumSize(QSize(32,32));
- Layout1->addWidget( Trash );
- PagePaletteLayout->addLayout( Layout1 );
- setWidget( containerWidget );
- pix = loadIcon("32/page-simple.png");
- currView = 0;
+PagePalette::PagePalette(QWidget* parent) : ScDockPalette(parent, "PagePalette", 0)
+{
+ m_scMW = (ScribusMainWindow*) parent;
+ m_view = 0;
+
+ setObjectName(QString::fromLocal8Bit("PagePalette"));
+
+ QStackedWidget* stackedWidget = new QStackedWidget(this);
+ stackedWidget->setObjectName(QString::fromLocal8Bit("stackedWidget"));
+
+ PagePalette_Pages* pageWidget = new PagePalette_Pages(stackedWidget);
+ pageWidget->setObjectName(QString::fromLocal8Bit("PagePalette_Pages"));
+ stackedWidget->addWidget(pageWidget);
+
+ setWidget(stackedWidget);
+
+ connect(pageWidget, SIGNAL(gotoMasterPage(QString)), m_scMW, SLOT(manageMasterPages(QString)));
+
Rebuild();
languageChange();
- connect(masterPageList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(selMasterPage()));
- connect(masterPageList, SIGNAL(thumbnailChanged()), this, SLOT(rebuildMasters()));
- connect(masterPageList, SIGNAL(DelMaster(QString)), this, SLOT(deleteMasterPage(QString)));
- connect(pageView, SIGNAL(Click(int, int, int)), this, SLOT(pageView_gotoPage(int, int, int)));
- connect(pageView, SIGNAL(movePage(int, int)), this, SLOT(pageView_movePage(int, int)));
- connect(Trash, SIGNAL(DelMaster(QString)), this, SLOT(deleteMasterPage(QString)));
- connect(pageLayout, SIGNAL(selectedLayout(int )), this, SLOT(handlePageLayout(int )));
- connect(pageLayout, SIGNAL(selectedFirstPage(int )), this, SLOT(handleFirstPage(int )));
- connect(this, SIGNAL(EditTemp(QString)), m_scMW, SLOT(manageMasterPages(QString)));
- connect(pageView, SIGNAL(UseTemp(QString, int)), m_scMW, SLOT(Apply_MasterPage(QString, int)));
- connect(pageView, SIGNAL(NewPage(int, QString)), m_scMW, SLOT(slotNewPageP(int, QString)));
- connect(Trash, SIGNAL(DelPage(int)), m_scMW, SLOT(deletePage2(int)));
- connect(pageView, SIGNAL(DelPage(int)), m_scMW, SLOT(deletePage2(int)));
- connect(this, SIGNAL(gotoPage(int)), m_scMW, SLOT(selectPagesFromOutlines(int)));
-}
-
-void PagePalette::deleteMasterPage(QString tmp)
-{
- if (tmp == CommonStrings::trMasterPageNormal)
- return;
- QString extraWarn = "";
- for (int i=0; i < currView->Doc->DocPages.count(); ++i )
- {
- if (currView->Doc->DocPages[i]->MPageNam == tmp)
- extraWarn = tr("This master page is used at least once in the document.");
- }
- int exit = QMessageBox::warning(this,
- CommonStrings::trWarning,
- tr("Do you really want to delete this master page?")+"\n"+extraWarn,
- QMessageBox::Yes | QMessageBox::No);
- if (exit == QMessageBox::Yes)
- {
- bool oldMPMode = currView->Doc->masterPageMode();
- int storedPageNum = currView->Doc->currentPageNumber();
- int storedViewXCoor = currView->horizontalScrollBar()->value();
- int storedViewYCoor = currView->verticalScrollBar()->value();
-
- currView->Doc->setMasterPageMode(true);
- currView->Doc->scMW()->deletePage2(currView->Doc->MasterNames[tmp]);
- //<<CB TODO Move back into ScribusDoc::deleteMasterPage();
- //This must happen after the pages have been reformed (view/doc)
- currView->Doc->rebuildMasterNames();
- // Fix up any pages that refer to the deleted master page
- currView->Doc->replaceMasterPage(tmp);
- currView->Doc->setMasterPageMode(oldMPMode);
- currView->Doc->setModified(true);
-
- currView->Doc->setCurrentPage(currView->Doc->DocPages.at(storedPageNum));
- currView->reformPages(false);
- currView->setContentsPos(storedViewXCoor, storedViewYCoor);
- currView->DrawNew();
- }
-}
-
-void PagePalette::pageView_movePage(int r, int c)
-{
- if (r == c)
- return;
- if (c > pageView->MaxC)
- currView->Doc->movePage(r, r + 1, c, 2);
- else
- currView->Doc->movePage(r, r + 1, c, 0);
- currView->reformPages();
- rebuildPages();
- currView->DrawNew();
-//CB done by doc::reformpages
-// currView->Doc->setModified(true);
-}
-
-void PagePalette::pageView_gotoPage(int r, int c, int b)
-{
- int p;
- bool dummy;
- if ((b == Qt::LeftButton) && (r != -1) && (c != -1))
- {
- p = pageView->GetPage(r, c, &dummy);
- emit gotoPage(p);
- }
+}
+
+QWidget* PagePalette::currentWidget()
+{
+ QStackedWidget* sw = dynamic_cast<QStackedWidget*>(this->widget());
+ if (sw)
+ return sw->currentWidget();
+ return 0;
+}
+
+PagePalette_MasterPages* PagePalette::masterpageWidget() const
+{
+ if (this->stackedWidget()->count() >= 2)
+ return dynamic_cast<PagePalette_MasterPages*>(this->stackedWidget()->widget(1));
+ return 0;
+}
+
+PagePalette_Pages* PagePalette::pageWidget() const
+{
+ if (this->stackedWidget()->count() >= 1)
+ return dynamic_cast<PagePalette_Pages*>(this->stackedWidget()->widget(0));
+ return 0;
+}
+
+QStackedWidget* PagePalette::stackedWidget() const
+{
+ QStackedWidget* sw = dynamic_cast<QStackedWidget*>(this->widget());
+ return sw;
}
void PagePalette::enablePalette(const bool enabled)
{
- pageView->setEnabled(enabled);
- masterPageList->setEnabled(enabled);
- pageLayout->setEnabled(enabled);
-}
-
-void PagePalette::handlePageLayout(int layout)
-{
- pageLayout->selectFirstP(currView->Doc->pageSets()[layout].FirstPage);
- currView->Doc->resetPage(layout);
- currView->reformPages();
- currView->DrawNew();
- currView->GotoPage(currView->Doc->currentPageNumber());
- rebuildPages();
-//CB done by doc::reformpages
-// currView->Doc->setModified(true);
-}
-
-void PagePalette::handleFirstPage(int fp)
-{
-// currView->Doc->pageSets()[currView->Doc->currentPageLayout].FirstPage = fp;
- currView->Doc->setPageSetFirstPage(currView->Doc->pagePositioning(), fp);
- currView->reformPages();
- currView->DrawNew();
- currView->GotoPage(currView->Doc->currentPageNumber());
- rebuildPages();
-//CB done by doc::reformpages
-// currView->Doc->setModified(true);
+ PagePalette_Pages* pageWidget = dynamic_cast<PagePalette_Pages*>(this->currentWidget());
+ if (pageWidget)
+ pageWidget->enablePalette(enabled);
}
void PagePalette::rebuildMasters()
{
if (m_scMW->scriptIsRunning())
return;
- masterPageList->clear();
- if (currView == 0)
- return;
- QPixmap pm;
- QMap<QString,int>::Iterator it;
- for (it = currView->Doc->MasterNames.begin(); it != currView->Doc->MasterNames.end(); ++it)
- {
- if (masterPageList->Thumb)
- {
- pm = QPixmap::fromImage(currView->MPageToPixmap(it.key(),60));
- new QListWidgetItem(QIcon(pm), it.key() == CommonStrings::masterPageNormal ? CommonStrings::trMasterPageNormal : it.key(), masterPageList);
- }
- else
- masterPageList->addItem(it.key() == CommonStrings::masterPageNormal ? CommonStrings::trMasterPageNormal : it.key());
- }
+
+ PagePalette_Pages* pageWidget = dynamic_cast<PagePalette_Pages*>(this->currentWidget());
+ if (pageWidget)
+ pageWidget->rebuildMasters();
}
void PagePalette::rebuildPages()
{
if (m_scMW->scriptIsRunning())
return;
- QString str;
- disconnect(pageLayout, SIGNAL(selectedLayout(int )), this, SLOT(handlePageLayout(int )));
- disconnect(pageLayout, SIGNAL(selectedFirstPage(int )), this, SLOT(handleFirstPage(int )));
- pageView->clearContents();
- pageView->setRowCount(1);
- pageView->setColumnCount(1);
- if (currView == 0)
- {
- connect(pageLayout, SIGNAL(selectedLayout(int )), this, SLOT(handlePageLayout(int )));
- connect(pageLayout, SIGNAL(selectedFirstPage(int )), this, SLOT(handleFirstPage(int )));
- return;
- }
- pageLayout->updateLayoutSelector(currView->Doc->pageSets());
- pageLayout->selectItem(currView->Doc->pagePositioning());
- pageLayout->firstPage->setCurrentIndex(currView->Doc->pageSets()[currView->Doc->pagePositioning()].FirstPage);
- pageView->MaxC = currView->Doc->DocPages.count()-1;
- int counter = currView->Doc->pageSets()[currView->Doc->pagePositioning()].FirstPage;
- int cols = currView->Doc->pageSets()[currView->Doc->pagePositioning()].Columns;
- int rows = (currView->Doc->DocPages.count()+counter) / currView->Doc->pageSets()[currView->Doc->pagePositioning()].Columns;
- if (((currView->Doc->DocPages.count()+counter) % currView->Doc->pageSets()[currView->Doc->pagePositioning()].Columns) != 0)
- rows++;
- int rowcounter = 0;
- int colmult, rowmult, coladd, rowadd;
- if (cols == 1)
- {
- pageView->setColumnCount(cols);
- pageView->setRowCount(rows*2+1);
- colmult = 1;
- coladd = 0;
- rowmult = 2;
- rowadd = 1;
- }
- else
- {
- pageView->setColumnCount(cols*2);
- pageView->setRowCount(rows+1);
- colmult = 2;
- coladd = 1;
- rowmult = 1;
- rowadd = 0;
- }
- for (int rr = 0; rr < pageView->rowCount(); rr++)
- {
- for (int cc = 0; cc < pageView->columnCount(); cc++)
- {
- QTableWidgetItem *tW = new QTableWidgetItem(1001);
- tW->setFlags(Qt::ItemIsEnabled);
- pageView->setItem(rr, cc, tW);
- }
- }
- pageView->coladd = coladd;
- pageView->colmult = colmult;
- pageView->rowadd = rowadd;
- pageView->rowmult = rowmult;
- pageView->firstP = counter;
- pageView->cols = currView->Doc->pageSets()[currView->Doc->pagePositioning()].Columns;
- pageList.clear();
- for (int a = 0; a < currView->Doc->DocPages.count(); ++a)
- {
- str = currView->Doc->DocPages.at(a)->MPageNam;
- SeItem *it = new SeItem(str, a, CreateIcon(a, pix));
- pageList.append(it);
- pageView->setItem(rowcounter*rowmult+rowadd, counter*colmult+coladd, (QTableWidgetItem *)it);
- pageView->setColumnWidth(counter*colmult+coladd, pix.width());
- if (cols == 1)
- {
- pageView->setRowHeight(rowcounter*rowmult, 10);
- pageView->setRowHeight(rowcounter*rowmult+rowadd, pix.height());
- }
- else
- pageView->setRowHeight(rowcounter*rowmult+rowadd, pix.height()+5);
- counter++;
- if (counter > currView->Doc->pageSets()[currView->Doc->pagePositioning()].Columns-1)
- {
- counter = 0;
- rowcounter++;
- }
- }
- pageView->setRowHeight(pageView->rowCount()-1, 10);
- counter = 0;
- if (cols != 1)
- {
- for (int c = 0; c < pageView->columnCount(); ++c)
- {
- if ((counter % 2) == 0)
- pageView->setColumnWidth(counter, 10);
- else
- pageView->setColumnWidth(counter, pix.width());
- counter++;
- }
- }
- pageView->repaint();
- if (currView != 0)
- markPage(currView->Doc->currentPageNumber());
- connect(pageLayout, SIGNAL(selectedLayout(int )), this, SLOT(handlePageLayout(int )));
- connect(pageLayout, SIGNAL(selectedFirstPage(int )), this, SLOT(handleFirstPage(int )));
+
+ PagePalette_Pages* pageWidget = dynamic_cast<PagePalette_Pages*>(this->currentWidget());
+ if (pageWidget)
+ pageWidget->rebuildPages();
}
void PagePalette::Rebuild()
{
rebuildMasters();
rebuildPages();
- enablePalette(currView != 0);
+ enablePalette(m_view != 0);
}
void PagePalette::markPage(uint nr)
{
- if (currView != 0)
- {
- SeItem *it;
- for (int a = 0; a < pageList.count(); a++)
- {
- it = pageList.at(a);
- if (it->pageNumber == nr)
- {
- pageView->clearSelection();
- pageView->item(it->row(), it->column())->setSelected(true);
- pageView->scrollToItem(pageView->item(it->row(), it->column()), QAbstractItemView::EnsureVisible);
- break;
- }
- }
- }
+ PagePalette_Pages* pageWidget = dynamic_cast<PagePalette_Pages*>(this->currentWidget());
+ if (pageWidget)
+ pageWidget->markPage(nr);
}
void PagePalette::setView(ScribusView *view)
{
- if (m_scMW->scriptIsRunning())
+ PagePalette_Pages* pageWidget = dynamic_cast<PagePalette_Pages*>(this->currentWidget());
+ if (pageWidget)
+ pageWidget->setView(view);
+ PagePalette_MasterPages* mpWidget = dynamic_cast<PagePalette_MasterPages*>(this->currentWidget());
+ if (mpWidget)
+ mpWidget->setView(view);
+ m_view = view;
+}
+
+void PagePalette::updateMasterPageList()
+{
+ PagePalette_Pages* pageWidget = dynamic_cast<PagePalette_Pages*>(this->currentWidget());
+ if (pageWidget)
+ pageWidget->rebuildMasters();
+ else
+ {
+ PagePalette_MasterPages* mpWidget = dynamic_cast<PagePalette_MasterPages*>(this->currentWidget());
+ if (mpWidget)
+ mpWidget->updateMasterPageList();
+ }
+}
+
+bool PagePalette::masterPageMode()
+{
+ PagePalette_MasterPages* mpWidget = dynamic_cast<PagePalette_MasterPages*>(this->currentWidget());
+ return (mpWidget != NULL);
+}
+
+void PagePalette::startMasterPageMode(QString masterPage)
+{
+ m_view->Deselect(true);
+
+ QStackedWidget* stackedWidget = this->stackedWidget();
+ if (stackedWidget->count() < 2)
+ {
+ PagePalette_MasterPages* mpWidget = new PagePalette_MasterPages(stackedWidget, m_view, masterPage);
+ mpWidget->setObjectName(QString::fromLocal8Bit("PagePalette_MasterPages"));
+ stackedWidget->addWidget(mpWidget);
+
+ connect(mpWidget, SIGNAL(removePage(int )), m_scMW, SLOT(deletePage2(int )));
+ connect(mpWidget, SIGNAL(finished()) , m_scMW, SLOT(manageMasterPagesEnd()));
+ }
+ else
+ {
+ ScribusDoc* doc = m_view->Doc;
+ PagePalette_MasterPages* mpWidget = this->masterpageWidget();
+ if (mpWidget->currentView != m_view)
+ mpWidget->setView(m_view, masterPage);
+ mpWidget->updateMasterPageList(masterPage);
+ if (doc->currentPage()->pageName() != masterPage)
+ mpWidget->selectMasterPage(masterPage);
+ }
+
+ // Set focus to page palette or focus may be set to wrong document window
+ this->setFocus();
+ stackedWidget->setCurrentIndex(1);
+}
+
+void PagePalette::endMasterPageMode()
+{
+ if (this->stackedWidget()->currentIndex() > 0)
+ {
+ // Set focus to page palette or focus may be set to wrong document window
+ this->setFocus();
+ this->stackedWidget()->setCurrentIndex(0);
+ }
+
+ PagePalette_Pages* pageWidget = dynamic_cast<PagePalette_Pages*>(this->currentWidget());
+ pageWidget->setView(m_view);
+ pageWidget->Rebuild();
+}
+
+void PagePalette::changeEvent(QEvent *e)
+{
+ if (e->type() == QEvent::LanguageChange)
+ {
+ languageChange();
return;
- currView = view;
-}
-
-void PagePalette::selMasterPage()
-{
- if (masterPageList->CurItem != 0)
- emit EditTemp(masterPageList->CurItem->text());
-}
-
-QPixmap PagePalette::CreateIcon(int nr, QPixmap pixin)
-{
- QPainter p;
- // Necessary on windows to ensure the pixmap is drawable
- QPixmap ret(pixin.width(), pixin.height()); // Qt4, pixin.depth());
- if (p.begin(&ret))
- {
- p.drawPixmap( 0, 0, pixin );
-// if( !pixin.mask().isNull() )
-// ret.setMask( pixin.mask() );
- p.setBrush(Qt::white);
- p.setBackground(Qt::white);
- p.setBackgroundMode(Qt::OpaqueMode);
- p.setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
- p.setFont(QFont("Helvetica", 12, QFont::Bold));
- //QString tmp = tmp.setNum(nr+1);
- QString tmp(currView->Doc->getSectionPageNumberForPageIndex(nr));
- if (tmp.isEmpty())
- tmp = tmp.setNum(nr+1);
- QRect b = p.fontMetrics().boundingRect(tmp);
- QRect c = QRect((ret.width() / 2 - b.width() / 2)-2, (ret.height() / 2 - b.height() / 2)-2, b.width()+4, b.height()+4);
- p.drawRect(c);
- QRect d = QRect((ret.width() / 2 - b.width() / 2), (ret.height() / 2 - b.height() / 2), b.width(), b.height());
- p.setFont(QFont("Helvetica", 10, QFont::Normal));
- p.drawText(d, Qt::AlignCenter, tmp);
- p.end();
- if( !pixin.mask().isNull() )
- ret.setMask( pixin.mask() );
- }
- return ret;
-}
-
-void PagePalette::changeEvent(QEvent *e)
-{
- if (e->type() == QEvent::LanguageChange)
- {
- languageChange();
- }
- else
- ScDockPalette::changeEvent(e);
+ }
+
+ ScDockPalette::changeEvent(e);
}
void PagePalette::languageChange()
{
setWindowTitle( tr( "Arrange Pages" ) );
- TextLabel1->setText( tr( "Available Master Pages:" ) );
- TextLabel2->setText( tr( "Document Pages:" ) );
-
- masterPageList->setToolTip( "<qt>" + tr( "List of master pages in the document. Master page names may be dragged onto the page view below to apply master pages, or onto the empty space between pages to create new pages." ) + "</qt>");
- pageView->setToolTip( "<qt>" + tr( "List of normal pages in the document, shown with the document layout. Pages may be dragged to rearrange or delete them.") + "</qt>");
- Trash->setToolTip( "<qt>" + tr("Drag pages or master pages onto the trash to delete them") + "</qt>");
-}
-
-//CB Whats this variable returned for.. its always true... ?
-//CB Clean up the interface and stick it behind this member for now
-const bool PagePalette::getNamen()
-{
- return pageView->Namen;
-}
-
-//CB Whats this variable returned for.. its always true... ?
-//CB Clean up the interface and stick it behind this member for now
-const bool PagePalette::getThumb()
-{
- return masterPageList->Thumb;
-}
-
-
+}
Modified: trunk/Scribus/scribus/ui/pagepalette.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17513&path=/trunk/Scribus/scribus/ui/pagepalette.h
==============================================================================
--- trunk/Scribus/scribus/ui/pagepalette.h (original)
+++ trunk/Scribus/scribus/ui/pagepalette.h Sat May 19 11:40:38 2012
@@ -7,152 +7,28 @@
#ifndef SEITENPAL_H
#define SEITENPAL_H
-#include <QCheckBox>
-#include <QDialog>
-#include <QDragEnterEvent>
-#include <QDragLeaveEvent>
-#include <QDragMoveEvent>
-#include <QDropEvent>
#include <QHBoxLayout>
-#include <QImage>
-#include <QKeyEvent>
#include <QLabel>
#include <QLayout>
-#include <QListWidget>
-#include <QMouseEvent>
#include <QPixmap>
-#include <QPushButton>
#include <QSplitter>
-#include <QTableWidget>
-#include <QTableWidgetItem>
#include <QToolTip>
#include <QVBoxLayout>
-
class QEvent;
-
+class QStackedWidget;
+class SeItem;
+class SeList;
+class SeView;
+class TrashBin;
#include "scribusapi.h"
#include "scdockpalette.h"
+class PagePalette_MasterPages;
+class PagePalette_Pages;
class ScribusView;
class ScribusMainWindow;
-class PageLayouts;
-
-class SCRIBUS_API SeItem : public QTableWidgetItem
-{
-
-friend class PagePalette;
-friend class SeView;
-
-
-public:
- SeItem(QString text, uint pgnr, const QPixmap& Pix);
- ~SeItem() {};
-
- const QString& getPageName();
- uint pageNumber;
-
-protected:
- QString pageName;
-};
-
-class SCRIBUS_API SeList : public QListWidget
-{
-friend class PagePalette;
-
- Q_OBJECT
-
-public:
- SeList(QWidget* parent);
- ~SeList() {};
-
-private slots:
- void toggleThumbnail();
-
-signals:
- //! Emitted when user requests/disables the thumbnais for master pages.
- void thumbnailChanged();
- void DelMaster(QString);
-
-protected:
- void mouseReleaseEvent(QMouseEvent *m);
- void mousePressEvent(QMouseEvent* e);
- void mouseMoveEvent(QMouseEvent* e);
- virtual void keyPressEvent(QKeyEvent* e);
-
- QPoint Mpos;
- QListWidgetItem *CurItem;
- bool Mpressed;
- bool Thumb;
-
-};
-
-class SCRIBUS_API SeView : public QTableWidget
-{
- Q_OBJECT
-
-friend class PagePalette;
-
-public:
- SeView(QWidget* parent);
- ~SeView() {};
- void ClearPix();
- int GetPage(int r, int c, bool *last);
-
-public slots:
- void ToggleNam();
-
-signals:
- void UseTemp(QString, int);
- void NewPage(int, QString);
- void movePage(int, int);
- void Click(int, int, int);
- void DelPage(int);
-
-protected:
- virtual void dropEvent(QDropEvent * e);
- virtual void dragEnterEvent(QDragEnterEvent *e);
- virtual void dragLeaveEvent(QDragLeaveEvent *e);
- virtual void dragMoveEvent(QDragMoveEvent *e);
- virtual void mouseReleaseEvent(QMouseEvent *m);
- virtual void mousePressEvent(QMouseEvent* e);
- virtual void mouseMoveEvent(QMouseEvent* e);
- virtual void keyPressEvent(QKeyEvent* e);
-
- QPoint Mpos;
- bool Mpressed;
- bool Doppel;
- bool Links;
- bool Namen;
- int MaxC;
- int colmult;
- int rowmult;
- int coladd;
- int rowadd;
- int cols;
- int firstP;
-};
-
-class SCRIBUS_API TrashBin : public QLabel
-{
- Q_OBJECT
-
-public:
- TrashBin( QWidget * parent );
- ~TrashBin() {};
- void dragEnterEvent( QDragEnterEvent *e );
- void dragLeaveEvent( QDragLeaveEvent * );
- void dropEvent( QDropEvent * e );
-
-protected:
- QPixmap Normal;
- QPixmap Offen;
-
-signals:
- void DelPage(int);
- void DelMaster(QString);
-};
class SCRIBUS_API PagePalette : public ScDockPalette
{
@@ -162,53 +38,38 @@
PagePalette(QWidget* parent);
~PagePalette() {};
+ QWidget* currentWidget();
+ QStackedWidget* stackedWidget() const;
+
+ PagePalette_MasterPages* masterpageWidget() const;
+ PagePalette_Pages* pageWidget() const;
+
+protected:
+ ScribusView *m_view;
+ ScribusMainWindow *m_scMW;
+
virtual void changeEvent(QEvent *e);
-
- //CB FIXME Put these in for now and hide the rest. What are these indicating?
- const bool getNamen();
- const bool getThumb();
public slots:
void setView(ScribusView *view);
- void deleteMasterPage(QString tmp);
- void pageView_movePage(int r, int c);
- void pageView_gotoPage(int r, int c, int b);
void enablePalette(const bool);
- void handlePageLayout(int layout);
- void handleFirstPage(int fp);
//! Recreate master pages thumbnails (if it's set on)
void rebuildMasters();
//! Recreate common pages arrangement
void rebuildPages();
+ //! Rebuild all lists
void Rebuild();
void markPage(uint nr);
- void selMasterPage();
- QPixmap CreateIcon(int nr, QPixmap pixin);
+ void updateMasterPageList();
+
void languageChange();
+ bool masterPageMode();
+ void startMasterPageMode(QString);
+ void endMasterPageMode();
+
signals:
- void EditTemp(QString);
void gotoPage(int);
-
-protected:
- QWidget* containerWidget;
- QVBoxLayout* PagePaletteLayout;
- QHBoxLayout* Layout1;
- QVBoxLayout* Layout2;
- QVBoxLayout* Layout3;
-
- PageLayouts* pageLayout;
- QSplitter* Splitter1;
- QLabel* TextLabel1;
- QLabel* TextLabel2;
- TrashBin* Trash;
- QList<SeItem*> pageList;
- SeList* masterPageList;
- SeView* pageView;
- ScribusView *currView;
- ScribusMainWindow *m_scMW;
- QPixmap pix;
-// DynamicTip* dynTip;
};
#endif // SEITENPAL_H
Modified: trunk/Scribus/win32/vc9/scribus-main/Scribus.vcproj
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17513&path=/trunk/Scribus/win32/vc9/scribus-main/Scribus.vcproj
==============================================================================
--- trunk/Scribus/win32/vc9/scribus-main/Scribus.vcproj (original)
+++ trunk/Scribus/win32/vc9/scribus-main/Scribus.vcproj Sat May 19 11:40:38 2012
@@ -1183,6 +1183,18 @@
>
</File>
<File
+ RelativePath="..\..\..\scribus\ui\pagepalette_masterpages.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\scribus\ui\pagepalette_pages.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\scribus\ui\pagepalette_widgets.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\..\scribus\ui\pageselector.cpp"
>
</File>
@@ -5084,6 +5096,60 @@
</FileConfiguration>
</File>
<File
+ RelativePath="..\..\..\scribus\ui\pagepalette_masterpages.h"
+ >
+ <FileConfiguration
+ Name="Debug-cairo|Win32"
+ >
+ <Tool
+ Name="moc.exe"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release-cairo|Win32"
+ >
+ <Tool
+ Name="moc.exe"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\..\scribus\ui\pagepalette_pages.h"
+ >
+ <FileConfiguration
+ Name="Debug-cairo|Win32"
+ >
+ <Tool
+ Name="moc.exe"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release-cairo|Win32"
+ >
+ <Tool
+ Name="moc.exe"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\..\scribus\ui\pagepalette_widgets.h"
+ >
+ <FileConfiguration
+ Name="Debug-cairo|Win32"
+ >
+ <Tool
+ Name="moc.exe"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release-cairo|Win32"
+ >
+ <Tool
+ Name="moc.exe"
+ />
+ </FileConfiguration>
+ </File>
+ <File
RelativePath="..\..\..\scribus\ui\pageselector.h"
>
<FileConfiguration
@@ -8477,6 +8543,10 @@
>
</File>
<File
+ RelativePath="..\..\..\scribus\ui\ui_pagepalette_masterpagesbase.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\scribus\ui\ui_paintmanagerbase.h"
>
</File>
@@ -9322,6 +9392,18 @@
>
</File>
<File
+ RelativePath="..\..\..\scribus\ui\moc_pagepalette_masterpages.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\scribus\ui\moc_pagepalette_pages.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\scribus\ui\moc_pagepalette_widgets.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\..\scribus\ui\moc_pageselector.cpp"
>
</File>
@@ -10055,6 +10137,14 @@
>
</File>
<File
+ RelativePath="..\..\..\scribus\ui\pagepalette_masterpagesbase.ui"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\scribus\ui\pagepalette_pagesbase.ui"
+ >
+ </File>
+ <File
RelativePath="..\..\..\scribus\ui\paintmanagerbase.ui"
>
</File>
More information about the scribus-commit
mailing list