Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 17512 → Rev 17513

/trunk/Scribus/scribus/prefsmanager.cpp
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());
}
 
/trunk/Scribus/scribus/scribuswin.cpp
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;
}
/trunk/Scribus/scribus/prefsstructs.h
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
/trunk/Scribus/scribus/ui/pagepalette.cpp
7,21 → 7,17
 
 
#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"
28,930 → 24,183
#include "scribusview.h"
#include "util_icon.h"
 
/* IconItems Code */
SeItem::SeItem(QString text, uint nr, const QPixmap& Pix) : QTableWidgetItem(QIcon(Pix), "", 1002)
PagePalette::PagePalette(QWidget* parent) : ScDockPalette(parent, "PagePalette", 0)
{
pageNumber = nr;
pageName = text;
setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
}
m_scMW = (ScribusMainWindow*) parent;
m_view = 0;
 
const QString& SeItem::getPageName()
{
return pageName;
}
setObjectName(QString::fromLocal8Bit("PagePalette"));
 
/* ListBox Subclass */
SeList::SeList(QWidget* parent) : QListWidget(parent)
{
Mpressed = false;
setAcceptDrops(true);
}
QStackedWidget* stackedWidget = new QStackedWidget(this);
stackedWidget->setObjectName(QString::fromLocal8Bit("stackedWidget"));
 
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);
}
PagePalette_Pages* pageWidget = new PagePalette_Pages(stackedWidget);
pageWidget->setObjectName(QString::fromLocal8Bit("PagePalette_Pages"));
stackedWidget->addWidget(pageWidget);
 
void SeList::toggleThumbnail()
{
Thumb = !Thumb;
emit thumbnailChanged();
}
setWidget(stackedWidget);
 
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);
connect(pageWidget, SIGNAL(gotoMasterPage(QString)), m_scMW, SLOT(manageMasterPages(QString)));
Rebuild();
languageChange();
}
 
void SeList::mouseMoveEvent(QMouseEvent* e)
QWidget* PagePalette::currentWidget()
{
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);
}
}
QStackedWidget* sw = dynamic_cast<QStackedWidget*>(this->widget());
if (sw)
return sw->currentWidget();
return 0;
}
 
void SeList::keyPressEvent(QKeyEvent * e)
PagePalette_MasterPages* PagePalette::masterpageWidget() const
{
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);
if (this->stackedWidget()->count() >= 2)
return dynamic_cast<PagePalette_MasterPages*>(this->stackedWidget()->widget(1));
return 0;
}
 
 
/* QTable Subclass */
SeView::SeView(QWidget* parent) : QTableWidget(parent)
PagePalette_Pages* PagePalette::pageWidget() const
{
setDragEnabled(true);
setAcceptDrops(true);
setDropIndicatorShown(true);
// viewport()->setAcceptDrops(true);
setShowGrid(false);
setWordWrap(true);
Mpressed = false;
Namen = true;
// setFocusPolicy(Qt::NoFocus);
if (this->stackedWidget()->count() >= 1)
return dynamic_cast<PagePalette_Pages*>(this->stackedWidget()->widget(0));
return 0;
}
 
void SeView::mousePressEvent(QMouseEvent* e)
QStackedWidget* PagePalette::stackedWidget() const
{
e->accept();
Mpos = e->pos();
Mpressed = true;
QTableWidget::mousePressEvent(e);
QStackedWidget* sw = dynamic_cast<QStackedWidget*>(this->widget());
return sw;
}
 
void SeView::mouseReleaseEvent(QMouseEvent* e)
void PagePalette::enablePalette(const bool enabled)
{
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);
PagePalette_Pages* pageWidget = dynamic_cast<PagePalette_Pages*>(this->currentWidget());
if (pageWidget)
pageWidget->enablePalette(enabled);
}
 
void SeView::ToggleNam()
void PagePalette::rebuildMasters()
{
/* Namen = !Namen;
int val = 35;
if (Namen)
val = 100;
setColumnWidth(1, val);
setColumnWidth(3, val);
hide();
show(); */
}
if (m_scMW->scriptIsRunning())
return;
 
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);
PagePalette_Pages* pageWidget = dynamic_cast<PagePalette_Pages*>(this->currentWidget());
if (pageWidget)
pageWidget->rebuildMasters();
}
 
void SeView::dropEvent(QDropEvent * e)
void PagePalette::rebuildPages()
{
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;
}
}
}
if (m_scMW->scriptIsRunning())
return;
PagePalette_Pages* pageWidget = dynamic_cast<PagePalette_Pages*>(this->currentWidget());
if (pageWidget)
pageWidget->rebuildPages();
}
 
void SeView::dragEnterEvent(QDragEnterEvent *e)
void PagePalette::Rebuild()
{
if (e->mimeData()->hasFormat("page/magic"))
e->acceptProposedAction();
rebuildMasters();
rebuildPages();
enablePalette(m_view != 0);
}
 
void SeView::dragLeaveEvent(QDragLeaveEvent *)
void PagePalette::markPage(uint nr)
{
ClearPix();
PagePalette_Pages* pageWidget = dynamic_cast<PagePalette_Pages*>(this->currentWidget());
if (pageWidget)
pageWidget->markPage(nr);
}
 
void SeView::dragMoveEvent(QDragMoveEvent *e)
void PagePalette::setView(ScribusView *view)
{
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);
}
}
}
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 SeView::keyPressEvent(QKeyEvent * e)
void PagePalette::updateMasterPageList()
{
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;
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);
PagePalette_Pages* pageWidget = dynamic_cast<PagePalette_Pages*>(this->currentWidget());
if (pageWidget)
pageWidget->rebuildMasters();
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);
PagePalette_MasterPages* mpWidget = dynamic_cast<PagePalette_MasterPages*>(this->currentWidget());
if (mpWidget)
mpWidget->updateMasterPageList();
}
}
 
void PagePalette::enablePalette(const bool enabled)
bool PagePalette::masterPageMode()
{
pageView->setEnabled(enabled);
masterPageList->setEnabled(enabled);
pageLayout->setEnabled(enabled);
PagePalette_MasterPages* mpWidget = dynamic_cast<PagePalette_MasterPages*>(this->currentWidget());
return (mpWidget != NULL);
}
 
void PagePalette::handlePageLayout(int layout)
void PagePalette::startMasterPageMode(QString masterPage)
{
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);
}
m_view->Deselect(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);
}
 
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)
QStackedWidget* stackedWidget = this->stackedWidget();
if (stackedWidget->count() < 2)
{
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_MasterPages* mpWidget = new PagePalette_MasterPages(stackedWidget, m_view, masterPage);
mpWidget->setObjectName(QString::fromLocal8Bit("PagePalette_MasterPages"));
stackedWidget->addWidget(mpWidget);
 
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;
connect(mpWidget, SIGNAL(removePage(int )), m_scMW, SLOT(deletePage2(int )));
connect(mpWidget, SIGNAL(finished()) , m_scMW, SLOT(manageMasterPagesEnd()));
}
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;
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);
}
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 )));
}
 
void PagePalette::Rebuild()
{
rebuildMasters();
rebuildPages();
enablePalette(currView != 0);
// Set focus to page palette or focus may be set to wrong document window
this->setFocus();
stackedWidget->setCurrentIndex(1);
}
 
void PagePalette::markPage(uint nr)
void PagePalette::endMasterPageMode()
{
if (currView != 0)
if (this->stackedWidget()->currentIndex() > 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;
}
}
// Set focus to page palette or focus may be set to wrong document window
this->setFocus();
this->stackedWidget()->setCurrentIndex(0);
}
}
 
void PagePalette::setView(ScribusView *view)
{
if (m_scMW->scriptIsRunning())
return;
currView = view;
PagePalette_Pages* pageWidget = dynamic_cast<PagePalette_Pages*>(this->currentWidget());
pageWidget->setView(m_view);
pageWidget->Rebuild();
}
 
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();
return;
}
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;
}
 
 
/trunk/Scribus/scribus/ui/pagepalette_pagesbase.ui
0,0 → 1,143
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PagePalette_PagesBase</class>
<widget class="QWidget" name="PagePalette_PagesBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>440</width>
<height>286</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>5</number>
</property>
<property name="margin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="textLabel1">
<property name="text">
<string>Available Master Pages:</string>
</property>
</widget>
</item>
<item>
<widget class="SeList" name="masterPageList">
<property name="minimumSize">
<size>
<width>130</width>
<height>70</height>
</size>
</property>
<property name="iconSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="textLabel2">
<property name="text">
<string>Document Pages:</string>
</property>
</widget>
</item>
<item>
<widget class="SeView" name="pageView">
<property name="minimumSize">
<size>
<width>130</width>
<height>120</height>
</size>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="iconSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="rowCount">
<number>1</number>
</property>
<property name="columnCount">
<number>1</number>
</property>
<attribute name="horizontalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<row/>
<column/>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="PageLayouts" name="pageLayout">
<property name="title">
<string>Document Layout</string>
</property>
</widget>
</item>
<item>
<widget class="TrashBin" name="trash">
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>SeList</class>
<extends>QListWidget</extends>
<header>pagepalette_widgets.h</header>
</customwidget>
<customwidget>
<class>SeView</class>
<extends>QTableWidget</extends>
<header>pagepalette_widgets.h</header>
</customwidget>
<customwidget>
<class>PageLayouts</class>
<extends>QGroupBox</extends>
<header>pagelayout.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>TrashBin</class>
<extends>QLabel</extends>
<header>pagepalette_widgets.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
/trunk/Scribus/scribus/ui/pagepalette_widgets.cpp
0,0 → 1,535
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
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.
*/
 
#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 "commonstrings.h"
#include "pagelayout.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);
}
}
}
/trunk/Scribus/scribus/ui/pagepalette_pages.cpp
0,0 → 1,395
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
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.
*/
 
 
#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 "commonstrings.h"
#include "pagelayout.h"
#include "pagepalette_pages.h"
#include "pagepalette_widgets.h"
#include "sccombobox.h"
#include "scpage.h"
#include "scribus.h"
#include "scribuscore.h"
#include "scribusview.h"
#include "util_icon.h"
 
PagePalette_Pages::PagePalette_Pages(QWidget* parent) : QWidget(parent)
{
m_scMW = ScCore->primaryMainWindow();
setupUi(this);
setSizePolicy( QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
 
masterPageList->setMinimumSize(QSize(130,70));
masterPageList->Thumb = false;
masterPageList->setIconSize(QSize(60, 60));
 
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));
 
trash->setMinimumSize(QSize(32,32));
trash->setMaximumSize(QSize(32,32));
 
pix = loadIcon("32/page-simple.png");
 
currView = 0;
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(pageLayout, SIGNAL(selectedLayout(int )) , this, SLOT(handlePageLayout(int )));
connect(pageLayout, SIGNAL(selectedFirstPage(int )), this, SLOT(handleFirstPage(int )));
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(pageView , SIGNAL(DelPage(int)) , m_scMW, SLOT(deletePage2(int)));
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(trash , SIGNAL(DelMaster(QString)) , this, SLOT(deleteMasterPage(QString)));
connect(this, SIGNAL(gotoPage(int)) , m_scMW, SLOT(selectPagesFromOutlines(int)));
}
 
void PagePalette_Pages::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_Pages::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_Pages::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);
}
}
 
void PagePalette_Pages::enablePalette(const bool enabled)
{
pageView->setEnabled(enabled);
masterPageList->setEnabled(enabled);
pageLayout->setEnabled(enabled);
}
 
void PagePalette_Pages::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_Pages::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);
}
 
void PagePalette_Pages::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());
}
}
 
void PagePalette_Pages::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 )));
}
 
void PagePalette_Pages::Rebuild()
{
rebuildMasters();
rebuildPages();
enablePalette(currView != 0);
}
 
void PagePalette_Pages::markPage(uint nr)
{
if (currView == 0)
return;
 
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;
}
}
}
 
void PagePalette_Pages::setView(ScribusView *view)
{
if (m_scMW->scriptIsRunning())
return;
currView = view;
}
 
void PagePalette_Pages::selMasterPage()
{
if (masterPageList->CurItem != 0)
emit gotoMasterPage(masterPageList->CurItem->text());
}
 
QPixmap PagePalette_Pages::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_Pages::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange)
{
languageChange();
return;
}
QWidget::changeEvent(e);
}
 
void PagePalette_Pages::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>");
}
/trunk/Scribus/scribus/ui/pagepalette_widgets.h
0,0 → 1,157
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
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.
*/
#ifndef PAGEPALETTE_WIDGETS_H
#define PAGEPALETTE_WIDGETS_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;
 
#include "scribusapi.h"
#include "scdockpalette.h"
 
class ScribusView;
class ScribusMainWindow;
class PageLayouts;
 
class SCRIBUS_API SeItem : public QTableWidgetItem
{
friend class PagePalette;
friend class PagePalette_Pages;
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;
friend class PagePalette_Pages;
 
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;
friend class PagePalette_Pages;
 
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);
};
 
#endif
 
/trunk/Scribus/scribus/ui/pagelayout.h
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);
/trunk/Scribus/scribus/ui/pagepalette_masterpages.h
0,0 → 1,69
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
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.
*/
#ifndef PAGEPALETTE_MASTERPAGES_H
#define PAGEPALETTE_MASTERPAGES_H
 
class QCloseEvent;
class QHBoxLayout;
class QListWidget;
class QListWidgetItem;
class QToolButton;
class QVBoxLayout;
 
#include "scribusapi.h"
#include "ui_pagepalette_masterpagesbase.h"
class ScribusDoc;
class ScribusView;
 
 
/*! \brief A dialog to manage/edit Master Pages
*/
class SCRIBUS_API PagePalette_MasterPages : public QWidget, Ui::PagePalette_MasterPagesBase
{
Q_OBJECT
 
friend class PagePalette;
 
public:
PagePalette_MasterPages( QWidget* parent, ScribusView *pCurrentView, QString masterPageName);
~PagePalette_MasterPages() {};
 
void setView(ScribusView* view, QString masterPageName = "");
void updateMasterPageList(void);
void updateMasterPageList(QString MasterPageName);
 
public slots:
void languageChange();
void selectMasterPage(QString name);
 
private:
QString currentPage;
ScribusDoc *currentDoc;
ScribusView *currentView;
 
protected:
 
void connectSignals();
void disconnectSignals();
 
virtual void changeEvent(QEvent *e);
 
private slots:
void duplicateMasterPage();
void deleteMasterPage();
void newMasterPage();
void renameMasterPage(QListWidgetItem * item);
void importPage();
void selectMasterPage(QListWidgetItem *item);
 
signals:
void removePage(int);
void finished();
};
 
#endif // MUSTERPAGES_H
/trunk/Scribus/scribus/ui/pagepalette.h
7,208 → 7,69
#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
class SCRIBUS_API PagePalette : public ScDockPalette
{
 
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);
PagePalette(QWidget* parent);
~PagePalette() {};
QPoint Mpos;
QListWidgetItem *CurItem;
bool Mpressed;
bool Thumb;
QWidget* currentWidget();
QStackedWidget* stackedWidget() const;
 
};
PagePalette_MasterPages* masterpageWidget() const;
PagePalette_Pages* pageWidget() const;
 
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;
};
ScribusView *m_view;
ScribusMainWindow *m_scMW;
 
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
{
Q_OBJECT
 
public:
PagePalette(QWidget* parent);
~PagePalette() {};
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
/trunk/Scribus/scribus/ui/pagepalette_masterpagesbase.ui
0,0 → 1,82
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PagePalette_MasterPagesBase</class>
<widget class="QWidget" name="PagePalette_MasterPagesBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>316</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>5</number>
</property>
<property name="margin">
<number>5</number>
</property>
<item>
<layout class="QHBoxLayout" name="buttonLayout">
<item>
<widget class="QToolButton" name="newButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="importButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="duplicateButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="deleteButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="masterPageListBox"/>
</item>
<item>
<widget class="QPushButton" name="finishButton">
<property name="text">
<string>&lt;&lt;&lt; Return to pages edition</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
/trunk/Scribus/scribus/ui/newfile.h
28,7 → 28,6
 
class PrefsManager;
class MarginWidget;
class PageLayouts;
class ScrSpinBox;
class ScComboBox;
#if QT_VERSION >= 0x040300
/trunk/Scribus/scribus/ui/pagepalette_masterpages.cpp
0,0 → 1,509
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
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.
*/
#include "pagepalette_masterpages.h"
 
#include <QApplication>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QSpacerItem>
#include <QToolButton>
#include <QListWidget>
#include <QListWidgetItem>
#include <QToolTip>
#include <QCursor>
#include <QCloseEvent>
#include <QMessageBox>
#include <QInputDialog>
 
#include "canvasmode.h"
#include "commonstrings.h"
#include "mergedoc.h"
#include "newtemp.h"
#include "pagestructs.h"
#include "prefsmanager.h"
#include "scpage.h"
#include "scribus.h"
#include "scribusdoc.h"
#include "scribusview.h"
#include "scribusXml.h"
#include "selection.h"
#include "util_icon.h"
 
PagePalette_MasterPages::PagePalette_MasterPages( QWidget* parent, ScribusView *pCurrentView, QString masterPageName) : QWidget(parent)
{
currentDoc = pCurrentView->Doc;
currentView = pCurrentView;
 
setupUi(this);
 
importButton->setIcon(QIcon(loadIcon("16/document-open.png")));
newButton->setIcon(QIcon(loadIcon("16/document-new.png")));
duplicateButton->setIcon(QIcon(loadIcon("16/edit-copy.png")));
deleteButton->setIcon(QIcon(loadIcon("16/edit-delete.png")));
 
masterPageListBox->setSelectionMode(QAbstractItemView::ExtendedSelection);
 
languageChange();
 
if (masterPageName.isEmpty())
currentPage = currentDoc->MasterNames.begin().key();
else
currentPage = masterPageName;
updateMasterPageList(currentPage);
currentView->showMasterPage(currentDoc->MasterNames[currentPage]);
 
setMinimumSize(sizeHint());
 
// signals and slots connections
connectSignals();
}
 
void PagePalette_MasterPages::setView(ScribusView* view, QString masterPageName)
{
ScribusView* oldView = currentView;
QString oldPage = currentPage;
 
disconnectSignals();
currentView = view;
 
if (!view)
{
this->setEnabled(false);
return;
}
 
currentDoc = currentView->Doc;
 
if (masterPageName.isEmpty() && currentDoc->masterPageMode())
currentPage = currentDoc->currentPage()->pageName();
else if (masterPageName.isEmpty())
currentPage = currentDoc->MasterNames.begin().key();
else
currentPage = masterPageName;
 
QString currentPageName;
if (currentDoc->masterPageMode())
currentPageName = currentDoc->currentPage()->pageName();
if (!currentDoc->masterPageMode() || currentPage != currentPageName)
currentView->showMasterPage(currentDoc->MasterNames[currentPage]);
 
this->setEnabled(true);
connectSignals();
}
 
void PagePalette_MasterPages::connectSignals()
{
connect(duplicateButton, SIGNAL(clicked()), this, SLOT(duplicateMasterPage()));
connect(deleteButton , SIGNAL(clicked()), this, SLOT(deleteMasterPage()));
connect(newButton , SIGNAL(clicked()), this, SLOT(newMasterPage()));
connect(importButton , SIGNAL(clicked()), this, SLOT(importPage()));
connect(masterPageListBox, SIGNAL(itemClicked(QListWidgetItem*)),
this, SLOT(selectMasterPage(QListWidgetItem*)));
connect(masterPageListBox, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
this, SLOT(renameMasterPage( QListWidgetItem*)));
connect(finishButton , SIGNAL(released()), this, SIGNAL(finished()));
}
 
void PagePalette_MasterPages::disconnectSignals()
{
disconnect(duplicateButton, SIGNAL(clicked()), this, SLOT(duplicateMasterPage()));
disconnect(deleteButton , SIGNAL(clicked()), this, SLOT(deleteMasterPage()));
disconnect(newButton , SIGNAL(clicked()), this, SLOT(newMasterPage()));
disconnect(importButton , SIGNAL(clicked()), this, SLOT(importPage()));
disconnect(masterPageListBox, SIGNAL(itemClicked(QListWidgetItem*)),
this, SLOT(selectMasterPage(QListWidgetItem*)));
disconnect(masterPageListBox, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
this, SLOT(renameMasterPage( QListWidgetItem*)));
disconnect(finishButton , SIGNAL(released()), this, SIGNAL(finished()));
}
 
void PagePalette_MasterPages::languageChange()
{
setWindowTitle( tr( "Edit Master Pages" ) );
duplicateButton->setToolTip( tr( "Duplicate the selected master page" ) );
deleteButton->setToolTip( tr( "Delete the selected master page" ) );
newButton->setToolTip( tr( "Add a new master page" ) );
importButton->setToolTip( tr( "Import master pages from another document" ) );
}
 
void PagePalette_MasterPages::deleteMasterPage()
{
bool forceDelete = false;
 
// allow to delete multiple pages in one step
foreach (QListWidgetItem * delItem, masterPageListBox->selectedItems())
{
currentPage = delItem->text();
 
if ((currentPage == CommonStrings::masterPageNormal)
|| (currentPage == CommonStrings::trMasterPageNormal)
|| (currentPage == CommonStrings::trMasterPageNormalLeft)
|| (currentPage == CommonStrings::trMasterPageNormalMiddle)
|| (currentPage == CommonStrings::trMasterPageNormalRight))
continue;
 
QString extraWarn = "";
 
if (!forceDelete)
{
for (int i=0; i < currentDoc->DocPages.count(); ++i )
{
if (currentDoc->DocPages[i]->MPageNam == currentPage)
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 master page \"%1\"?").arg(currentPage)+"\n"+extraWarn,
QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::Cancel);
 
if (exit == QMessageBox::YesToAll)
forceDelete = true;
if (exit == QMessageBox::No)
continue;
if (exit == QMessageBox::Cancel)
break;
}
 
if (currentDoc->appMode == modeEditClip)
currentView->requestMode(submodeEndNodeEdit);
currentDoc->scMW()->deletePage2(currentDoc->MasterNames[currentPage]);
//<<CB TODO Move back into ScribusDoc::deleteMasterPage();
//This must happen after the pages have been reformed (view/doc)
currentDoc->rebuildMasterNames();
// Fix up any pages that refer to the deleted master page
currentDoc->replaceMasterPage(currentPage);
}
 
// set the 1st MP for the other slots
QMap<QString,int>::Iterator it = currentDoc->MasterNames.begin();
currentPage = it.key();
updateMasterPageList(currentPage);
}
 
void PagePalette_MasterPages::duplicateMasterPage()
{
int copyC = 1;
QString potentialMasterPageName(currentPage);
while (currentDoc->MasterNames.contains(potentialMasterPageName))
potentialMasterPageName = tr("Copy #%1 of %2").arg(copyC++).arg(currentPage);
 
NewTm *dia = new NewTm(this, tr("&Name:"), tr("New Master Page"), currentDoc, potentialMasterPageName);
if (dia->exec())
{
if (currentDoc->appMode == modeEditClip)
currentView->requestMode(submodeEndNodeEdit);
QString MasterPageName = dia->Answer->text();
bool MasterPageNameWrong = currentDoc->MasterNames.contains(MasterPageName);
MasterPageNameWrong |= (MasterPageName == CommonStrings::masterPageNormal);
MasterPageNameWrong |= (MasterPageName == CommonStrings::trMasterPageNormal);
MasterPageNameWrong |= (MasterPageName == CommonStrings::trMasterPageNormalLeft);
MasterPageNameWrong |= (MasterPageName == CommonStrings::trMasterPageNormalMiddle);
MasterPageNameWrong |= (MasterPageName == CommonStrings::trMasterPageNormalRight);
MasterPageNameWrong |= MasterPageName.isEmpty();
while (MasterPageNameWrong)
{
if (!dia->exec())
{
delete dia;
return;
}
MasterPageName = dia->Answer->text();
bool MasterPageNameWrong = currentDoc->MasterNames.contains(MasterPageName);
MasterPageNameWrong |= (MasterPageName == CommonStrings::masterPageNormal);
MasterPageNameWrong |= (MasterPageName == CommonStrings::trMasterPageNormal);
MasterPageNameWrong |= (MasterPageName == CommonStrings::trMasterPageNormalLeft);
MasterPageNameWrong |= (MasterPageName == CommonStrings::trMasterPageNormalMiddle);
MasterPageNameWrong |= (MasterPageName == CommonStrings::trMasterPageNormalRight);
MasterPageNameWrong |= MasterPageName.isEmpty();
}
PrefsManager* prefsManager = PrefsManager::instance();
int inde = currentDoc->MasterNames[currentPage];
int nr = currentDoc->Pages->count();
ScPage* from = currentDoc->Pages->at(inde);
ScPage* destination = currentDoc->addMasterPage(nr, MasterPageName);
if (currentDoc->pagePositioning() != singlePage)
{
int lp = dia->Links->currentIndex();
if (lp == 0)
lp = 1;
else if (lp == static_cast<int>(dia->Links->count()-1))
lp = 0;
else
lp++;
destination->LeftPg = lp;
}
destination->initialMargins.Top = from->initialMargins.Top;
destination->initialMargins.Bottom = from->initialMargins.Bottom;
if (currentDoc->pageSets()[currentDoc->pagePositioning()].Columns == 1)
{
destination->initialMargins.Left = from->initialMargins.Left;
destination->initialMargins.Right = from->initialMargins.Right;
}
else
{
if (destination->LeftPg != from->LeftPg)
{
if (destination->LeftPg > 1)
{
destination->initialMargins.Right = from->initialMargins.Left;
destination->initialMargins.Left = from->initialMargins.Left;
}
else
{
destination->initialMargins.Left = from->initialMargins.Left;
destination->initialMargins.Right = from->initialMargins.Right;
}
}
else
{
destination->initialMargins.Left = from->initialMargins.Left;
destination->initialMargins.Right = from->initialMargins.Right;
}
}
//#8321 : incorrect selection of master page on new mp creation/duplictation
//currentDoc->setCurrentPage(destination);
selectMasterPage(MasterPageName);
uint oldItems = currentDoc->Items->count();
uint end2 = currentDoc->MasterItems.count();
int GrMax = currentDoc->GroupCounter;
currentDoc->m_Selection->clear();
if (oldItems>0)
{
ScLayers::iterator it;
currentDoc->m_Selection->delaySignalsOn();
for (it = currentDoc->Layers.begin(); it != currentDoc->Layers.end(); ++it)
{
for (uint ite = 0; ite < oldItems; ++ite)
{
PageItem *itemToCopy = currentDoc->Items->at(ite);
if (itemToCopy->OwnPage == inde && (it->ID == itemToCopy->LayerID))
currentDoc->m_Selection->addItem(itemToCopy, true);
}
if (currentDoc->m_Selection->count() != 0)
{
ScriXmlDoc *ss = new ScriXmlDoc();
QString buffer = ss->WriteElem(currentDoc, currentDoc->m_Selection);
ss->ReadElemToLayer(buffer, prefsManager->appPrefs.fontPrefs.AvailFonts, currentDoc, destination->xOffset(), destination->yOffset(), false, true, prefsManager->appPrefs.fontPrefs.GFontSub, it->ID);
currentDoc->m_Selection->clear();
delete ss;
}
}
currentDoc->m_Selection->clear();
currentDoc->m_Selection->delaySignalsOff();
}
uint end3 = currentDoc->MasterItems.count();
for (uint a = end2; a < end3; ++a)
{
PageItem *newItem = currentDoc->MasterItems.at(a);
newItem->OnMasterPage = MasterPageName;
newItem->OwnPage = currentDoc->MasterNames[MasterPageName];
}
from->guides.copy(&destination->guides);
currentDoc->GroupCounter = GrMax + 1;
currentView->Deselect(true);
updateMasterPageList(MasterPageName);
currentDoc->setLoading(false);
currentView->reformPages();
currentView->DrawNew();
}
delete dia;
}
 
void PagePalette_MasterPages::newMasterPage()
{
QString MasterPageName;
int nr = currentDoc->Pages->count();
NewTm *dia = new NewTm(this, tr("Name:"), tr("New MasterPage"), currentDoc, tr("New Master Page %1").arg(nr));
if (dia->exec())
{
if (currentDoc->appMode == modeEditClip)
currentView->requestMode(submodeEndNodeEdit);
MasterPageName = dia->Answer->text();
bool MasterPageNameWrong = currentDoc->MasterNames.contains(MasterPageName);
MasterPageNameWrong |= (MasterPageName == CommonStrings::masterPageNormal);
MasterPageNameWrong |= (MasterPageName == CommonStrings::trMasterPageNormal);
MasterPageNameWrong |= (MasterPageName == CommonStrings::trMasterPageNormalLeft);
MasterPageNameWrong |= (MasterPageName == CommonStrings::trMasterPageNormalMiddle);
MasterPageNameWrong |= (MasterPageName == CommonStrings::trMasterPageNormalRight);
MasterPageNameWrong |= MasterPageName.isEmpty();
while (MasterPageNameWrong)
{
if (!dia->exec())
{
delete dia;
return;
}
MasterPageName = dia->Answer->text();
MasterPageNameWrong = currentDoc->MasterNames.contains(MasterPageName);
MasterPageNameWrong |= (MasterPageName == CommonStrings::masterPageNormal);
MasterPageNameWrong |= (MasterPageName == CommonStrings::trMasterPageNormal);
MasterPageNameWrong |= (MasterPageName == CommonStrings::trMasterPageNormalLeft);
MasterPageNameWrong |= (MasterPageName == CommonStrings::trMasterPageNormalMiddle);
MasterPageNameWrong |= (MasterPageName == CommonStrings::trMasterPageNormalRight);
MasterPageNameWrong |= MasterPageName.isEmpty();
}
currentDoc->setCurrentPage(currentDoc->addMasterPage(nr, MasterPageName));
if (currentDoc->pagePositioning() != singlePage)
{
int lp = dia->Links->currentIndex();
if (lp == 0)
lp = 1;
else if (lp == static_cast<int>(dia->Links->count()-1))
lp = 0;
else
lp++;
currentDoc->Pages->at(nr)->LeftPg = lp;
}
updateMasterPageList(MasterPageName);
//#8321 : incorrect selection of master page on new mp creation/duplictation
//currentView->showMasterPage(currentDoc->MasterNames[MasterPageName]);
selectMasterPage(MasterPageName);
currentView->reformPages();
}
delete dia;
}
 
void PagePalette_MasterPages::importPage()
{
//bool atf;
MergeDoc *dia = new MergeDoc(this, true);
if (dia->exec())
{
if (currentDoc->appMode == modeEditClip)
currentView->requestMode(submodeEndNodeEdit);
qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
int nr = currentDoc->Pages->count();
//currentDoc->pageCount = 0;
//atf = currentDoc->usesAutomaticTextFrames();
//currentDoc->setUsesAutomaticTextFrames(false);
//emit createNew(nr);
QString MasterPageName(dia->getMasterPageNameText());
QString MasterPageName2(MasterPageName);
int copyC = 1;
while (currentDoc->MasterNames.contains(MasterPageName2))
{
MasterPageName2 = tr("Copy #%1 of ").arg(copyC)+MasterPageName;
copyC++;
}
currentDoc->setCurrentPage(currentDoc->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 doesnt pass in the new destination page
currentDoc->scMW()->loadPage(dia->getFromDoc(), dia->getMasterPageNameItem(), true, MasterPageName2);
qApp->processEvents();
/*
MasterPageName = currentDoc->Pages->at(nr)->PageNam;
MasterPageName2 = MasterPageName;
int copyC = 1;
while (currentDoc->MasterNames.contains(MasterPageName2))
{
MasterPageName2 = tr("Copy #%1 of ").arg(copyC)+MasterPageName;
copyC++;
}
currentDoc->MasterNames.insert(MasterPageName2, nr);
currentDoc->Pages->at(nr)->setPageName(MasterPageName2);
currentDoc->Pages->at(nr)->MPageNam = "";
*/
updateMasterPageList(MasterPageName2);
//currentDoc->setUsesAutomaticTextFrames(atf);
currentView->showMasterPage(currentDoc->MasterNames[MasterPageName2]);
qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
//currentDoc->MasterPages = currentDoc->Pages;
}
delete dia;
}
 
void PagePalette_MasterPages::selectMasterPage(QListWidgetItem *item)
{
currentPage = item->text();
deleteButton->setEnabled(currentDoc->MasterNames.count() == 1 ? false : true);
if (currentPage == CommonStrings::trMasterPageNormal || currentPage == CommonStrings::masterPageNormal)
{
// currentPage = CommonStrings::masterPageNormal;
deleteButton->setEnabled(false);
}
else
deleteButton->setEnabled(true);
if (currentDoc->appMode == modeEditClip)
currentView->requestMode(submodeEndNodeEdit);
else if (currentDoc->appMode == modeEdit || currentDoc->appMode == modeEditGradientVectors)
currentView->requestMode(modeNormal);
currentView->showMasterPage(currentDoc->MasterNames[currentPage]);
}
 
void PagePalette_MasterPages::selectMasterPage(QString name)
{
if (!currentDoc || !currentView)
return;
 
currentPage = name;
deleteButton->setEnabled(currentDoc->MasterNames.count() == 1 ? false : true);
if (currentPage == CommonStrings::trMasterPageNormal)
{
currentPage = CommonStrings::masterPageNormal;
deleteButton->setEnabled(false);
}
else
deleteButton->setEnabled(true);
if (currentDoc->appMode == modeEditClip)
currentView->requestMode(submodeEndNodeEdit);
currentView->showMasterPage(currentDoc->MasterNames[currentPage]);
}
 
void PagePalette_MasterPages::updateMasterPageList(void)
{
QString masterPageName = (currentDoc->MasterNames.contains(currentPage)) ? currentPage : CommonStrings::masterPageNormal;
updateMasterPageList(masterPageName);
}
 
void PagePalette_MasterPages::updateMasterPageList(QString masterPageName)
{
if (!currentDoc || !currentView)
return;
 
masterPageListBox->clear();
for (QMap<QString,int>::Iterator it = currentDoc->MasterNames.begin(); it != currentDoc->MasterNames.end(); ++it)
masterPageListBox->addItem(it.key() == CommonStrings::masterPageNormal ? CommonStrings::trMasterPageNormal : it.key());
deleteButton->setEnabled(currentDoc->MasterNames.count() == 1 ? false : true);
if (masterPageName == CommonStrings::masterPageNormal)
{
masterPageName = CommonStrings::trMasterPageNormal;
deleteButton->setEnabled(false);
}
QList<QListWidgetItem *> itL = masterPageListBox->findItems(masterPageName, Qt::MatchExactly);
if (itL.count() != 0)
itL.at(0)->setSelected(true);
}
 
void PagePalette_MasterPages::renameMasterPage(QListWidgetItem * item)
{
QString oldName(item->text());
if ((oldName == CommonStrings::masterPageNormal) || (oldName == CommonStrings::trMasterPageNormal) || (oldName == CommonStrings::trMasterPageNormalLeft) || (oldName == CommonStrings::trMasterPageNormalMiddle) || (oldName == CommonStrings::trMasterPageNormalRight))
{
QMessageBox::information( this, tr("Unable to Rename Master Page"), tr("The Normal page is not allowed to be renamed."), QMessageBox::Ok );
return;
}
bool ok;
QString newName = QInputDialog::getText( this, tr("Rename Master Page"), tr("New Name:"), QLineEdit::Normal, oldName, &ok);
if (ok && !newName.isEmpty())
{
if (currentDoc->renameMasterPage( oldName, newName))
updateMasterPageList(newName);
}
}
 
 
void PagePalette_MasterPages::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange)
{
languageChange();
return;
}
 
QWidget::changeEvent(e);
}
/trunk/Scribus/scribus/ui/pagepalette_pages.h
0,0 → 1,69
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
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.
*/
#ifndef PAGEPALETTE_PAGES_H
#define PAGEPALETTE_PAGES_H
 
#include <QHBoxLayout>
#include <QLabel>
#include <QLayout>
#include <QPixmap>
#include <QSplitter>
#include <QVBoxLayout>
 
#include "ui_pagepalette_pagesbase.h"
 
#include "scribusapi.h"
#include "scdockpalette.h"
 
class PageLayouts;
class ScribusView;
class ScribusMainWindow;
class SeItem;
class SeList;
class SeView;
 
class SCRIBUS_API PagePalette_Pages : public QWidget, Ui::PagePalette_PagesBase
{
Q_OBJECT
 
public:
PagePalette_Pages(QWidget* parent);
~PagePalette_Pages() {};
virtual void changeEvent(QEvent *e);
 
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();
void Rebuild();
void markPage(uint nr);
void selMasterPage();
QPixmap CreateIcon(int nr, QPixmap pixin);
void languageChange();
 
signals:
void gotoMasterPage(QString);
void gotoPage(int);
 
protected:
ScribusView *currView;
ScribusMainWindow *m_scMW;
 
QList<SeItem*> pageList;
QPixmap pix;
};
 
#endif // SEITENPAL_H
/trunk/Scribus/scribus/ui/pagelayout.cpp
59,8 → 59,38
}
}
 
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;
layoutGroupLayout = new QVBoxLayout(this);
/trunk/Scribus/scribus/scribuswin.h
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];
/trunk/Scribus/scribus/scribus.cpp
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);
pagePalette->startMasterPageMode(temp);
return;
}
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);
 
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();
}
}
/trunk/Scribus/scribus/scribus.h
405,7 → 405,6
void ToggleRulers();
void ToggleRulerMode();
void togglePagePalette();
void setPagePalette(bool visible);
void toggleUndoPalette();
void setUndoPalette(bool visible);
void toggleCheckPal();
/trunk/Scribus/scribus/CMakeLists.txt
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
/trunk/Scribus/win32/vc9/scribus-main/Scribus.vcproj
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>