r18976 by craig - Refactor PageSelector a little.. rename, tidy

scribus-commit scribus-commit at lists.scribus.net
Tue Apr 1 19:25:43 UTC 2014


Author: craig
Date: Tue Apr  1 19:25:42 2014
New Revision: 18976

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18976
Log:
Refactor PageSelector a little.. rename, tidy

Modified:
    trunk/Scribus/scribus/canvasmode_copyproperties.cpp
    trunk/Scribus/scribus/canvasmode_create.cpp
    trunk/Scribus/scribus/canvasmode_drawbezier.cpp
    trunk/Scribus/scribus/canvasmode_drawcalligraphic.cpp
    trunk/Scribus/scribus/canvasmode_drawfreehand.cpp
    trunk/Scribus/scribus/canvasmode_edit.cpp
    trunk/Scribus/scribus/canvasmode_framelinks.cpp
    trunk/Scribus/scribus/canvasmode_normal.cpp
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/scribus.h
    trunk/Scribus/scribus/scribusview.cpp
    trunk/Scribus/scribus/ui/pageselector.cpp
    trunk/Scribus/scribus/ui/pageselector.h
    trunk/Scribus/scribus/ui/preview.cpp

Modified: trunk/Scribus/scribus/canvasmode_copyproperties.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18976&path=/trunk/Scribus/scribus/canvasmode_copyproperties.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_copyproperties.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_copyproperties.cpp Tue Apr  1 19:25:42 2014
@@ -281,7 +281,7 @@
 			if (m_doc->currentPageNumber() != pgNum)
 			{
 				m_doc->setCurrentPage(m_doc->Pages->at(unsigned(pgNum)));
-				m_view->m_ScMW->setMenTxt(unsigned(pgNum));
+				m_view->m_ScMW->slotSetCurrentPage(unsigned(pgNum));
 				m_view->DrawNew();
 			}
 		}

Modified: trunk/Scribus/scribus/canvasmode_create.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18976&path=/trunk/Scribus/scribus/canvasmode_create.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_create.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_create.cpp Tue Apr  1 19:25:42 2014
@@ -461,7 +461,7 @@
 			if (docCurrPageNo != j)
 			{
 				m_doc->setCurrentPage(m_doc->Pages->at(j));
-				m_view->m_ScMW->setMenTxt(j);
+				m_view->m_ScMW->slotSetCurrentPage(j);
 				m_view->DrawNew();
 			}
 		}

Modified: trunk/Scribus/scribus/canvasmode_drawbezier.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18976&path=/trunk/Scribus/scribus/canvasmode_drawbezier.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_drawbezier.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_drawbezier.cpp Tue Apr  1 19:25:42 2014
@@ -463,7 +463,7 @@
 			if (docCurrPageNo != j)
 			{
 				m_doc->setCurrentPage(m_doc->Pages->at(j));
-				m_view->m_ScMW->setMenTxt(j);
+				m_view->m_ScMW->slotSetCurrentPage(j);
 				m_view->DrawNew();
 			}
 		}

Modified: trunk/Scribus/scribus/canvasmode_drawcalligraphic.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18976&path=/trunk/Scribus/scribus/canvasmode_drawcalligraphic.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_drawcalligraphic.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_drawcalligraphic.cpp Tue Apr  1 19:25:42 2014
@@ -350,7 +350,7 @@
 			if (docCurrPageNo != j)
 			{
 				m_doc->setCurrentPage(m_doc->Pages->at(j));
-				m_view->m_ScMW->setMenTxt(j);
+				m_view->m_ScMW->slotSetCurrentPage(j);
 				m_view->DrawNew();
 			}
 		}

Modified: trunk/Scribus/scribus/canvasmode_drawfreehand.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18976&path=/trunk/Scribus/scribus/canvasmode_drawfreehand.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_drawfreehand.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_drawfreehand.cpp Tue Apr  1 19:25:42 2014
@@ -336,7 +336,7 @@
 			if (docCurrPageNo != j)
 			{
 				m_doc->setCurrentPage(m_doc->Pages->at(j));
-				m_view->m_ScMW->setMenTxt(j);
+				m_view->m_ScMW->slotSetCurrentPage(j);
 				m_view->DrawNew();
 			}
 		}

Modified: trunk/Scribus/scribus/canvasmode_edit.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18976&path=/trunk/Scribus/scribus/canvasmode_edit.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_edit.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_edit.cpp Tue Apr  1 19:25:42 2014
@@ -819,7 +819,7 @@
 			if (currItem->OwnPage != -1)
 			{
 				m_doc->setCurrentPage(m_doc->Pages->at(currItem->OwnPage));
-				m_view->m_ScMW->setMenTxt(currItem->OwnPage);
+				m_view->m_ScMW->slotSetCurrentPage(currItem->OwnPage);
 			}
 			//CB done with emitAllToGUI
 			//emit HaveSel(currItem->itemType());
@@ -846,7 +846,7 @@
 					if (docCurrPageNo != i)
 					{
 						m_doc->setCurrentPage(m_doc->Pages->at(i));
-						m_view->m_ScMW->setMenTxt(i);
+						m_view->m_ScMW->slotSetCurrentPage(i);
 					}
 					break;
 				}
@@ -990,7 +990,7 @@
 			if (m_doc->currentPageNumber() != pgNum)
 			{
 				m_doc->setCurrentPage(m_doc->Pages->at(unsigned(pgNum)));
-				m_view->m_ScMW->setMenTxt(unsigned(pgNum));
+				m_view->m_ScMW->slotSetCurrentPage(unsigned(pgNum));
 				m_view->DrawNew();
 			}
 		}

Modified: trunk/Scribus/scribus/canvasmode_framelinks.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18976&path=/trunk/Scribus/scribus/canvasmode_framelinks.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_framelinks.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_framelinks.cpp Tue Apr  1 19:25:42 2014
@@ -331,7 +331,7 @@
 			if (docCurrPageNo != j)
 			{
 				m_doc->setCurrentPage(m_doc->Pages->at(j));
-				m_view->m_ScMW->setMenTxt(j);
+				m_view->m_ScMW->slotSetCurrentPage(j);
 				m_view->DrawNew();
 			}
 		}
@@ -396,7 +396,7 @@
 			if (m_doc->currentPageNumber() != pgNum)
 			{
 				m_doc->setCurrentPage(m_doc->Pages->at(unsigned(pgNum)));
-				m_view->m_ScMW->setMenTxt(unsigned(pgNum));
+				m_view->m_ScMW->slotSetCurrentPage(unsigned(pgNum));
 				m_view->DrawNew();
 			}
 		}

Modified: trunk/Scribus/scribus/canvasmode_normal.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18976&path=/trunk/Scribus/scribus/canvasmode_normal.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_normal.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_normal.cpp Tue Apr  1 19:25:42 2014
@@ -1158,7 +1158,7 @@
 			if (currItem->OwnPage != -1)
 			{
 				m_doc->setCurrentPage(m_doc->Pages->at(currItem->OwnPage));
-				m_view->m_ScMW->setMenTxt(currItem->OwnPage);
+				m_view->m_ScMW->slotSetCurrentPage(currItem->OwnPage);
 			}
 			//CB done with emitAllToGUI
 			//emit HaveSel(currItem->itemType());
@@ -1191,7 +1191,7 @@
 					if (docCurrPageNo != i)
 					{
 						m_doc->setCurrentPage(m_doc->Pages->at(i));
-						m_view->m_ScMW->setMenTxt(i);
+						m_view->m_ScMW->slotSetCurrentPage(i);
 					}
 					break;
 				}
@@ -1694,7 +1694,7 @@
 			if (m_doc->currentPageNumber() != pgNum)
 			{
 				m_doc->setCurrentPage(m_doc->Pages->at(unsigned(pgNum)));
-				m_view->m_ScMW->setMenTxt(unsigned(pgNum));
+				m_view->m_ScMW->slotSetCurrentPage(unsigned(pgNum));
 				pageChanged = true;
 			}
 		}

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18976&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Tue Apr  1 19:25:42 2014
@@ -2405,7 +2405,7 @@
 		visualMenu->setCurrentIndex(doc->previewVisual);
 		connect(visualMenu, SIGNAL(activated(int)), doc->view(), SLOT(switchPreviewVisual(int)));
 		pageSelector->setMaximum(doc->masterPageMode() ? 1 : doc->Pages->count());
-		setMenTxt(doc->currentPageNumber());
+		slotSetCurrentPage(doc->currentPageNumber());
 		connect(pageSelector, SIGNAL(GotoPage(int)), this, SLOT(setCurrentPage(int)));
 	}
 
@@ -5831,7 +5831,7 @@
 {
 	doc->addPage(w, masterPageName, true);
 	view->addPage(w, mov);
-	setMenTxt(w);
+	slotSetCurrentPage(w);
 }
 
 
@@ -8883,28 +8883,25 @@
 }
 
 //TODO: use this only from this class, or just from doc->setcurrentpage
-void ScribusMainWindow::setMenTxt(int Seite)
+void ScribusMainWindow::slotSetCurrentPage(int Seite)
 {
 	if (scriptIsRunning())
 		return;
-	//disconnect(pageSelector);
 	pageSelector->blockSignals(true);
 	pageSelector->setMaximum(doc->masterPageMode() ? 1 : doc->Pages->count());
 	if ((!doc->isLoading()) && (!doc->masterPageMode()))
-		pageSelector->GotoPg(Seite);
+		pageSelector->setGUIForPage(Seite);
 	pageSelector->blockSignals(false);
-	//connect(pageSelector, SIGNAL(GotoPage(int)), doc->view(), SLOT(GotoPa(int)));
 }
 
 void ScribusMainWindow::setCurrentPage(int p)
 {
-	qDebug()<<"Requested Page:"<<p;
 	doc->view()->Deselect();
-	int p0=p-1; //p is what the user see.. p0 is our count from 0
+	int p0=p-1; //p is what the user sees.. p0 is our count from 0
 	doc->setCurrentPage(doc->Pages->at(p0));
 	if (scriptIsRunning())
 		return;
-	setMenTxt(p0);
+	slotSetCurrentPage(p0);
 	doc->view()->SetCPo(doc->currentPage()->xOffset() - 10, doc->currentPage()->yOffset() - 10);
 	HaveNewSel(-1);
 	doc->view()->setFocus();

Modified: trunk/Scribus/scribus/scribus.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18976&path=/trunk/Scribus/scribus/scribus.h
==============================================================================
--- trunk/Scribus/scribus/scribus.h (original)
+++ trunk/Scribus/scribus/scribus.h Tue Apr  1 19:25:42 2014
@@ -312,7 +312,7 @@
 	void changeLayer(int);
 	void setLayerMenuText(const QString &);
 	void showLayer();
-	void setMenTxt(int Seite);
+	void slotSetCurrentPage(int Seite);
 	void setCurrentPage(int p);
 	void ManageJava();
 	void editSelectedSymbolStart();

Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18976&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp (original)
+++ trunk/Scribus/scribus/scribusview.cpp Tue Apr  1 19:25:42 2014
@@ -1139,7 +1139,7 @@
 					if (docCurrPageNo != i)
 					{
 						Doc->setCurrentPage(Doc->Pages->at(i));
-						m_ScMW->setMenTxt(i);
+						m_ScMW->slotSetCurrentPage(i);
 						DrawNew();
 					}
 					break;
@@ -2001,7 +2001,7 @@
 	//Note this picks up the new page or master page depending on the mode.
 //	reformPages(mov);
 	Doc->reformPages(mov);
-	m_ScMW->setMenTxt(nr);
+	m_ScMW->slotSetCurrentPage(nr);
 	m_canvas->m_viewMode.m_MouseButtonPressed = false;
 	Doc->DragP = false;
 	Doc->leaveDrag = false;
@@ -2032,7 +2032,7 @@
 	if (!Doc->isLoading())
 	{
 		setRulerPos(contentsX(), contentsY());
-		m_ScMW->setMenTxt(Doc->currentPage()->pageNr());
+		m_ScMW->slotSetCurrentPage(Doc->currentPage()->pageNr());
 	}
 }
 
@@ -2325,7 +2325,7 @@
 	m_canvas->resetRenderMode();
 	updateContents();
 	setRulerPos(contentsX(), contentsY());
-	m_ScMW->setMenTxt(Doc->currentPage()->pageNr());
+	m_ScMW->slotSetCurrentPage(Doc->currentPage()->pageNr());
 	disconnect(m_ScMW->zoomSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setZoom()));
 	m_ScMW->zoomSpinBox->setValue(m_canvas->scale()/Prefs->displayPrefs.displayScale*100);
 	connect(m_ScMW->zoomSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setZoom()));
@@ -2382,7 +2382,7 @@
 	Doc->setCurrentPage(Doc->Pages->at(Seite));
 	if (m_ScMW->scriptIsRunning())
 		return;
-	m_ScMW->setMenTxt(Seite);
+	m_ScMW->slotSetCurrentPage(Seite);
 	SetCPo(Doc->currentPage()->xOffset() - 10, Doc->currentPage()->yOffset() - 10);
 	m_ScMW->HaveNewSel(-1);
 }

Modified: trunk/Scribus/scribus/ui/pageselector.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18976&path=/trunk/Scribus/scribus/ui/pageselector.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/pageselector.cpp (original)
+++ trunk/Scribus/scribus/ui/pageselector.cpp Tue Apr  1 19:25:42 2014
@@ -23,58 +23,24 @@
 #include "util_icon.h"
 #include "util.h"
 
-// QIntValidator does it better for us... PV
-// class PageValidator : public QValidator
-// {
-// public:
-// 	PageValidator(int min, int max, QObject * parent);
-// 	void fixup(QString & input) const;
-// 	State validate(QString & input, int & pos) const;
-// private:
-// 	QRegExp rx;
-// 	QRegExp rx2;
-// 	PageSelector * pageSelector;
-// };
-// 
-// PageValidator::PageValidator(int /* min */, int /* max */, QObject * parent) : QValidator
-// (parent), rx("^([0-9]+).*"), rx2("^[0-9]+$") 
-// {
-// 	pageSelector = static_cast<PageSelector*>(parent);
-// }
-// 
-// QValidator::State PageValidator::validate(QString & input, int & /* pos */) const
-// {
-// 	if (rx2.indexIn(input) == 0 && pageSelector->PageCombo->itemText(input.toInt()-1) == input)
-// 		return Acceptable;
-// 	else
-// 		return Intermediate;
-// }
-// 
-// void PageValidator::fixup(QString & input) const
-// {
-// 	if (rx.indexIn(input) == 0)
-// 		input = const_cast<QRegExp &>(rx).cap(1);
-// }
-// 	
-
 PageSelector::PageSelector( QWidget* parent, int maxPg ) : QWidget( parent, 0 )
 {
 	PageCountString = "%1" ;
-	LastPG = maxPg;
-	APage = 1;
+	m_lastPage = maxPg;
+	m_currentPage = 1;
 	PageSelectorLayout = new QHBoxLayout( this );
 	PageSelectorLayout->setMargin(0);
 	PageSelectorLayout->setSpacing(1);
 
 #if OPTION_USE_QTOOLBUTTON
-	Start = new QToolButton( this );
-	Start->setAutoRaise(OPTION_FLAT_BUTTON);
-	Back = new QToolButton( this );
-	Back->setAutoRaise(OPTION_FLAT_BUTTON);
-	Forward = new QToolButton( this );
-	Forward->setAutoRaise(OPTION_FLAT_BUTTON);
-	Last = new QToolButton( this );
-	Last->setAutoRaise(OPTION_FLAT_BUTTON);
+	startButton = new QToolButton( this );
+	startButton->setAutoRaise(OPTION_FLAT_BUTTON);
+	backButton = new QToolButton( this );
+	backButton->setAutoRaise(OPTION_FLAT_BUTTON);
+	forwardButton = new QToolButton( this );
+	forwardButton->setAutoRaise(OPTION_FLAT_BUTTON);
+	lastButton = new QToolButton( this );
+	lastButton->setAutoRaise(OPTION_FLAT_BUTTON);
 #else
 	Start = new QPushButton( this );
 	Start->setDefault( false );
@@ -93,93 +59,90 @@
 	Last->setAutoDefault( false );
 	Last->setFlat(OPTION_FLAT_BUTTON);
 #endif
-	Start->setIcon(QIcon(loadIcon("16/go-first.png")));
-	Start->setFocusPolicy(Qt::NoFocus);
-	PageSelectorLayout->addWidget( Start );
-
-	Back->setIcon(QIcon(loadIcon("16/go-previous.png")));
-	Back->setFocusPolicy(Qt::NoFocus);
-	Back->setAutoRepeat(true);
-	PageSelectorLayout->addWidget( Back );
-
-// 	v = new PageValidator(1, LastPG, this);
-	m_validator = new QIntValidator(1, LastPG, this);
-	PageCombo = new ScComboBox( this );
-	PageCombo->setEditable(true);
-	PageCombo->setDuplicatesEnabled( false );
-	PageCombo->lineEdit()->setAlignment(Qt::AlignHCenter);
-	for (int a = 0; a < LastPG; ++a)
+	startButton->setIcon(QIcon(loadIcon("16/go-first.png")));
+	startButton->setFocusPolicy(Qt::NoFocus);
+	PageSelectorLayout->addWidget( startButton );
+
+	backButton->setIcon(QIcon(loadIcon("16/go-previous.png")));
+	backButton->setFocusPolicy(Qt::NoFocus);
+	backButton->setAutoRepeat(true);
+	PageSelectorLayout->addWidget( backButton );
+
+	m_validator = new QIntValidator(1, m_lastPage, this);
+	m_pageCombo = new ScComboBox( this );
+	m_pageCombo->setEditable(true);
+	m_pageCombo->setDuplicatesEnabled( false );
+	m_pageCombo->lineEdit()->setAlignment(Qt::AlignHCenter);
+	for (int i = 0; i < m_lastPage; ++i)
 	{
-		PageCombo->addItem(QString::number(a+1));
+		m_pageCombo->addItem(QString::number(i+1));
 	}
-	PageCombo->setValidator(m_validator);
-	PageCombo->setMinimumSize(fontMetrics().width( "999" )+20, 20);
-	PageCombo->setFocusPolicy(Qt::ClickFocus);
-	PageSelectorLayout->addWidget( PageCombo );
+	m_pageCombo->setValidator(m_validator);
+	m_pageCombo->setMinimumSize(fontMetrics().width( "999" )+20, 20);
+	m_pageCombo->setFocusPolicy(Qt::ClickFocus);
+	PageSelectorLayout->addWidget( m_pageCombo );
 	
-	PageCount = new QLabel(PageCountString.arg(LastPG), this);
-	PageSelectorLayout->addWidget(PageCount);
+	pageCountLabel = new QLabel(PageCountString.arg(m_lastPage), this);
+	PageSelectorLayout->addWidget(pageCountLabel);
 			
-	Forward->setIcon(QIcon(loadIcon("16/go-next.png")));
-	Forward->setFocusPolicy(Qt::NoFocus);
-	Forward->setAutoRepeat(true);
-	PageSelectorLayout->addWidget( Forward );
-
-	Last->setIcon(QIcon(loadIcon("16/go-last.png")));
-	Last->setFocusPolicy(Qt::NoFocus);
-	PageSelectorLayout->addWidget( Last );
-	Forward->setEnabled(true);
-	Last->setEnabled(true);
-	Back->setEnabled(false);
-	Start->setEnabled(false);
-	if (APage == LastPG)
+	forwardButton->setIcon(QIcon(loadIcon("16/go-next.png")));
+	forwardButton->setFocusPolicy(Qt::NoFocus);
+	forwardButton->setAutoRepeat(true);
+	PageSelectorLayout->addWidget( forwardButton );
+
+	lastButton->setIcon(QIcon(loadIcon("16/go-last.png")));
+	lastButton->setFocusPolicy(Qt::NoFocus);
+	PageSelectorLayout->addWidget( lastButton );
+	forwardButton->setEnabled(true);
+	lastButton->setEnabled(true);
+	backButton->setEnabled(false);
+	startButton->setEnabled(false);
+	if (m_currentPage == m_lastPage)
 	{
-		Forward->setEnabled(false);
-		Last->setEnabled(false);
+		forwardButton->setEnabled(false);
+		lastButton->setEnabled(false);
 	}
 
 	languageChange();
 	// signals and slots connections
-	connect( PageCombo, SIGNAL( activated(int) ), this, SLOT( GotoPgE(int) ) );
-	connect( Back, SIGNAL( clicked() ), this, SLOT( goBk() ) );
-	connect( Start, SIGNAL( clicked() ), this, SLOT( ToStart() ) );
-	connect( Forward, SIGNAL( clicked() ), this, SLOT( goFw() ) );
-	connect( Last, SIGNAL( clicked() ), this, SLOT( ToEnd() ) );
+	connect( m_pageCombo, SIGNAL( activated(int) ), this, SLOT( GotoPgE(int) ) );
+	connect( backButton, SIGNAL( clicked() ), this, SLOT( goBackward()) );
+	connect( startButton, SIGNAL( clicked() ), this, SLOT( goToStart() ) );
+	connect( forwardButton, SIGNAL( clicked() ), this, SLOT( goForward() ) );
+	connect( lastButton, SIGNAL( clicked() ), this, SLOT( goToEnd() ) );
 }
 
 bool PageSelector::hasFocus()
 {
-	return PageCombo->hasFocus();
-}
-
+	return m_pageCombo->hasFocus();
+}
+
+void PageSelector::clearFocus()
+{
+	m_pageCombo->clearFocus();
+}
 
 void PageSelector::focusPolicy(Qt::FocusPolicy policy)
 {
-	PageCombo->setFocusPolicy(policy);
+	m_pageCombo->setFocusPolicy(policy);
 }
 
 void PageSelector::setFont ( const QFont &fo )
 {
-	PageCount->setFont(fo);
+	pageCountLabel->setFont(fo);
 	QWidget::setFont(fo);
 }
 
 int PageSelector::getCurrentPage()
 {
-	return APage;
-}
-
-void PageSelector::setCurrentPage(int i)
-{
-//	int j=qMax(LastPG, i);
-//	APage
-}
-
-void PageSelector::GotoPgE(int a)
+	return m_currentPage;
+}
+
+void PageSelector::GotoPgE(int i)
 {
 	clearFocus();
-	GotoPg(a);
-	emit GotoPage(a+1);
+	setGUIForPage(i);
+	emit GotoPage(i+1);
 }
 
 void PageSelector::GotoPage()
@@ -188,81 +151,68 @@
 	int p = rx.cap(1).toInt();
 	if (p < 1)
 		p=1;
-	if (p > LastPG)
-		p = LastPG;
-	GotoPg(p-1);
+	if (p > m_lastPage)
+		p = m_lastPage;
+	setGUIForPage(p-1);
 	emit GotoPage(p);
 }
 
-void PageSelector::GotoPg(int a)
-{
-	//disconnect( PageCombo, SIGNAL( activated(int) ), this, SLOT( GotoPgE(int) ) );
-	PageCombo->blockSignals(true);
-	PageCombo->setCurrentIndex(a);
-	setCurrentComboItem(PageCombo, QString::number(a+1));
-	APage = a+1;
-	Back->setEnabled(true);
-	Start->setEnabled(true);
-	Forward->setEnabled(true);
-	Last->setEnabled(true);
-	if (a == 0)
+void PageSelector::setGUIForPage(int i)
+{
+	m_pageCombo->blockSignals(true);
+	m_pageCombo->setCurrentIndex(i);
+	setCurrentComboItem(m_pageCombo, QString::number(i+1));
+	m_currentPage = i+1;
+	backButton->setEnabled(i != 0);
+	startButton->setEnabled(i != 0);
+	forwardButton->setEnabled(i != m_lastPage-1);
+	lastButton->setEnabled(i != m_lastPage-1);
+	m_pageCombo->blockSignals(false);
+}
+
+void PageSelector::setMaximum(int i)
+{
+	m_pageCombo->blockSignals(true);
+	m_pageCombo->clear();
+	m_lastPage = i;
+	m_validator->setRange(1, m_lastPage);
+	for (int b = 0; b < m_lastPage; ++b)
 	{
-		Back->setEnabled(false);
-		Start->setEnabled(false);
+		m_pageCombo->addItem(QString::number(b+1));
 	}
-	if (a == LastPG-1)
-	{
-		Forward->setEnabled(false);
-		Last->setEnabled(false);
-	}
-	PageCombo->blockSignals(false);
-	//connect( PageCombo, SIGNAL( activated(int) ), this, SLOT( GotoPgE(int) ) );
-}
-
-void PageSelector::setMaximum(int a)
-{
-	disconnect( PageCombo, SIGNAL( activated(int) ), this, SLOT( GotoPgE(int) ) );
-	PageCombo->clear();
-	LastPG = a;
-//	v->setTop(LastPG);
-	m_validator->setRange(1, LastPG);
-	for (int b = 0; b < LastPG; ++b)
-	{
-		PageCombo->addItem(QString::number(b+1));
-	}
-	setCurrentComboItem(PageCombo, QString::number(APage));
-	PageCount->setText(PageCountString.arg(LastPG));
-	connect( PageCombo, SIGNAL( activated(int) ), this, SLOT( GotoPgE(int) ) );
-}
-
-void PageSelector::ToStart()
-{
-	if (APage == 1)
+	setCurrentComboItem(m_pageCombo, QString::number(m_currentPage));
+	pageCountLabel->setText(PageCountString.arg(m_lastPage));
+	m_pageCombo->blockSignals(false);
+}
+
+void PageSelector::goToStart()
+{
+	if (m_currentPage == 1)
 		return;
 	GotoPgE(0);
 }
 
-void PageSelector::ToEnd()
-{
-	if (APage == LastPG)
+void PageSelector::goToEnd()
+{
+	if (m_currentPage == m_lastPage)
 		return;
-	GotoPgE(LastPG-1);
-}
-
-void PageSelector::goBk()
-{
-	APage--;
-	if (APage < 1)
-		APage = 1;
-	GotoPgE(APage-1);
-}
-
-void PageSelector::goFw()
-{
-	APage++;
-	if (APage > LastPG)
-		APage = LastPG;
-	GotoPgE(APage-1);
+	GotoPgE(m_lastPage-1);
+}
+
+void PageSelector::goBackward()
+{
+	m_currentPage--;
+	if (m_currentPage < 1)
+		m_currentPage = 1;
+	GotoPgE(m_currentPage-1);
+}
+
+void PageSelector::goForward()
+{
+	m_currentPage++;
+	if (m_currentPage > m_lastPage)
+		m_currentPage = m_lastPage;
+	GotoPgE(m_currentPage-1);
 }
 
 void PageSelector::changeEvent(QEvent *e)
@@ -275,19 +225,15 @@
 
 void PageSelector::languageChange()
 {
-	Start->setToolTip( tr("Go to the first page") );
-	Back->setToolTip( tr("Go to the previous page") );
-	Forward->setToolTip( tr("Go to the next page") );
-	Last->setToolTip( tr("Go to the last page") );
-	PageCombo->setToolTip( tr("Select the current page") );
+	startButton->setToolTip( tr("Go to the first page") );
+	backButton->setToolTip( tr("Go to the previous page") );
+	forwardButton->setToolTip( tr("Go to the next page") );
+	lastButton->setToolTip( tr("Go to the last page") );
+	m_pageCombo->setToolTip( tr("Select the current page") );
 	PageCountString =  tr(" of %1", "number of pages in document");
-	PageCount->setText(PageCountString.arg(LastPG));
-	disconnect( PageCombo, SIGNAL( activated(int) ), this, SLOT( GotoPgE(int) ) );
-	setCurrentComboItem(PageCombo, QString::number(APage));
-	connect( PageCombo, SIGNAL( activated(int) ), this, SLOT( GotoPgE(int) ) );
-}
-
-void PageSelector::clearFocus()
-{
-	PageCombo->clearFocus();	
-}
+	pageCountLabel->setText(PageCountString.arg(m_lastPage));
+	disconnect( m_pageCombo, SIGNAL( activated(int) ), this, SLOT( GotoPgE(int) ) );
+	setCurrentComboItem(m_pageCombo, QString::number(m_currentPage));
+	connect( m_pageCombo, SIGNAL( activated(int) ), this, SLOT( GotoPgE(int) ) );
+}
+

Modified: trunk/Scribus/scribus/ui/pageselector.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18976&path=/trunk/Scribus/scribus/ui/pageselector.h
==============================================================================
--- trunk/Scribus/scribus/ui/pageselector.h (original)
+++ trunk/Scribus/scribus/ui/pageselector.h Tue Apr  1 19:25:42 2014
@@ -36,43 +36,44 @@
 	void focusPolicy(Qt::FocusPolicy policy);
 	void setFont ( const QFont & );
 	int getCurrentPage();
-	void setCurrentPage(int i);
 
 #if OPTION_USE_QTOOLBUTTON
-	QToolButton* Start;
-	QToolButton* Back;
-	QToolButton* Forward;
-	QToolButton* Last;
+	QToolButton* startButton;
+	QToolButton* backButton;
+	QToolButton* forwardButton;
+	QToolButton* lastButton;
 #else
-	QPushButton* Start;
-	QPushButton* Back;
-	QPushButton* Forward;
-	QPushButton* Last;
+	QPushButton* startButton;
+	QPushButton* backButton;
+	QPushButton* forwardButton;
+	QPushButton* lastButton;
 #endif
-	
-	ScComboBox* PageCombo;
-	QIntValidator *m_validator;
-	int LastPG;
-	int APage;
+
+
 
 public slots:
-	virtual void GotoPg(int);
-	virtual void setMaximum(int);
+	virtual void setGUIForPage(int i);
+	virtual void setMaximum(int i);
 	void languageChange();
 	void clearFocus();
 
 private slots:
 	virtual void GotoPgE(int);
 	virtual void GotoPage();
-	virtual void ToStart();
-	virtual void ToEnd();
-	virtual void goBk();
-	virtual void goFw();
+	virtual void goToStart();
+	virtual void goToEnd();
+	virtual void goBackward();
+	virtual void goForward();
 
 protected:
-	QHBoxLayout* PageSelectorLayout;
-	QLabel *PageCount;
+	QHBoxLayout *PageSelectorLayout;
+	QLabel *pageCountLabel;
 	QString PageCountString;
+	int m_lastPage;
+	int m_currentPage;
+
+	ScComboBox *m_pageCombo;
+	QIntValidator *m_validator;
 
 signals:
 	void GotoPage(int);

Modified: trunk/Scribus/scribus/ui/preview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18976&path=/trunk/Scribus/scribus/ui/preview.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/preview.cpp (original)
+++ trunk/Scribus/scribus/ui/preview.cpp Tue Apr  1 19:25:42 2014
@@ -352,7 +352,7 @@
 			EnableCMYK_K->setEnabled(false);
 		}
 	}
-	PGSel->GotoPg(doc->currentPage()->pageNr());
+	PGSel->setGUIForPage(doc->currentPage()->pageNr());
 	// tooltips
 	AntiAlias->setToolTip( "<qt>" + tr( "Provides a more pleasant view of Type 1 fonts, TrueType Fonts, OpenType Fonts, EPS, PDF and vector graphics in the preview, at the expense of a slight slowdown in previewing" ) + "</qt>" );
 	AliasTr->setToolTip( "<qt>" + tr( "Shows transparency and transparent items in your document. Requires Ghostscript 7.07 or later" ) + "</qt>");




More information about the scribus-commit mailing list