Changeset View
Changeset View
Standalone View
Standalone View
libs/pageapp/widgets/KoPageNavigator.cpp
Show First 20 Lines • Show All 117 Lines • ▼ Show 20 Line(s) | 83 | #endif | |||
---|---|---|---|---|---|
118 | layout->addWidget(d->pageNumberEdit); | 118 | layout->addWidget(d->pageNumberEdit); | ||
119 | layout->addWidget(d->gotoNextPageButton); | 119 | layout->addWidget(d->gotoNextPageButton); | ||
120 | layout->addWidget(d->gotoLastPageButton); | 120 | layout->addWidget(d->gotoLastPageButton); | ||
121 | 121 | | |||
122 | addWidget(controlWidget); | 122 | addWidget(controlWidget); | ||
123 | 123 | | |||
124 | KoPADocument *const kopaDocument = d->view->kopaDocument(); | 124 | KoPADocument *const kopaDocument = d->view->kopaDocument(); | ||
125 | connect(kopaDocument, SIGNAL(pageAdded(KoPAPageBase*)), SLOT(updateDisplayLabel())); | 125 | connect(kopaDocument, SIGNAL(pageAdded(KoPAPageBase*)), SLOT(updateDisplayLabel())); | ||
126 | connect(kopaDocument, SIGNAL(pageRemoved(KoPAPageBase*)), SLOT(updateDisplayLabel())); | 126 | connect(kopaDocument, SIGNAL(pageRemoved(KoPAPageBase*,int)), SLOT(slotPageRemoved(KoPAPageBase*,int))); | ||
127 | connect(d->view->proxyObject, SIGNAL(activePageChanged()), SLOT(updateDisplayLabel())); | 127 | connect(d->view->proxyObject, SIGNAL(activePageChanged()), SLOT(updateDisplayLabel())); | ||
128 | 128 | | |||
129 | // Fix width by the largest needed | 129 | // Fix width by the largest needed | ||
130 | QFontMetrics fontMetrics(font()); | 130 | QFontMetrics fontMetrics(font()); | ||
131 | d->pageNumberEdit->setMinimumWidth(fontMetrics.width(QString::number(maxPageCountPattern*10))); //one more | 131 | d->pageNumberEdit->setMinimumWidth(fontMetrics.width(QString::number(maxPageCountPattern*10))); //one more | ||
132 | const int editWidth = widget(Edit)->minimumWidth(); | 132 | const int editWidth = widget(Edit)->minimumWidth(); | ||
133 | const int normalWidth = fontMetrics.width(displayText(false, isSlideType, maxPageCountPattern, maxPageCountPattern)); | 133 | const int normalWidth = fontMetrics.width(displayText(false, isSlideType, maxPageCountPattern, maxPageCountPattern)); | ||
134 | const int masterWidth = fontMetrics.width(displayText(true, isSlideType, maxPageCountPattern, maxPageCountPattern)); | 134 | const int masterWidth = fontMetrics.width(displayText(true, isSlideType, maxPageCountPattern, maxPageCountPattern)); | ||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Line(s) | 243 | { | |||
250 | 250 | | |||
251 | const QList<KoPAPageBase*> pages = kopaDocument->pages(isMasterPage); | 251 | const QList<KoPAPageBase*> pages = kopaDocument->pages(isMasterPage); | ||
252 | 252 | | |||
253 | KoPAPageBase* newPage = pages.value(pageNumber-1); | 253 | KoPAPageBase* newPage = pages.value(pageNumber-1); | ||
254 | if (newPage) { | 254 | if (newPage) { | ||
255 | d->view->proxyObject->updateActivePage(newPage); | 255 | d->view->proxyObject->updateActivePage(newPage); | ||
256 | } | 256 | } | ||
257 | } | 257 | } | ||
258 | | ||||
259 | void KoPageNavigator::slotPageRemoved(KoPAPageBase *page, int index) | ||||
260 | { | ||||
261 | KoPAPageBase *const activePage = d->view->activePage(); | ||||
262 | if (page != activePage) { | ||||
263 | updateDisplayLabel(); | ||||
264 | } else { | ||||
265 | KoPADocument *const kopaDocument = d->view->kopaDocument(); | ||||
266 | const int pageNumber = index == 0 ? 0 : index - 1; | ||||
267 | KoPAPageBase* newPage = kopaDocument->pages().value(pageNumber); | ||||
268 | if (newPage && d->view->proxyObject) { | ||||
269 | d->view->proxyObject->updateActivePage(newPage); | ||||
270 | } else { | ||||
271 | updateDisplayLabel(); | ||||
272 | } | ||||
273 | } | ||||
274 | } |