[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdegraphics/kviewshell/shell
From: Wilfried Huss <Wilfried.Huss () gmx ! at>
Date: 2006-10-28 16:20:28
Message-ID: 1162052428.070869.16223.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 599796 by whuss:
port of commit 599795:
Don't rebuild all of the thumbnail widgets everytime their size has changed.
This makes rotation in large documents much faster.
M +43 -3 marklist.cpp
--- trunk/KDE/kdegraphics/kviewshell/shell/marklist.cpp #599795:599796
@@ -406,7 +406,8 @@
MarkList::MarkList(QWidget* parent, const char* name)
- : SmoothScrollView(parent, name), clickedThumbnail(0), showThumbnails(true), contextMenu(0)
+ : SmoothScrollView(parent, name, Qt::WStaticContents | Qt::WNoAutoErase),
+ clickedThumbnail(0), showThumbnails(true), contextMenu(0)
{
currentPage = PageNumber::invalidPage;
setFocusPolicy( Qt::StrongFocus );
@@ -439,6 +440,23 @@
// subtracted.
QRegion backgroundArea(e->rect());
+ for (unsigned int i = 0; i < widgetList.count(); i++) {
+ QWidget* item = widgetList.at(i);
+
+ QRect widgetGeometry = item->geometry();
+
+ // Draw the widget.
+ if (e->rect().intersects(widgetGeometry)) {
+ QRect widgetRect = e->rect().intersect(widgetGeometry);
+ widgetRect.moveBy(-widgetGeometry.left(), -widgetGeometry.top());
+
+ item->update(widgetRect);
+ }
+
+ // Substract the painted area.
+ backgroundArea -= widgetGeometry.intersect(e->rect());
+ }
+
// Paint the background.
QPainter p(viewport());
@@ -467,6 +485,29 @@
void MarkList::rebuildThumbnailWidgets(bool _showThumbnails)
{
+ int y = 0;
+
+ // If this function is called because the rotation or pagesizes have changed,
+ // only resize the MarkListWidgets as this is much faster than destroying and
+ // rebuilding all of them.
+ if (showThumbnails == _showThumbnails && widgetList.count() == dataModel->numberOfPages())
+ {
+ for (unsigned int i = 0; i < widgetList.count(); i++)
+ {
+ MarkListWidget* item = widgetList[i];
+ int height = item->setNewWidth(visibleWidth());
+ moveChild(item, 0, y);
+
+ y += height;
+ }
+
+ resizeContents(visibleWidth(), y);
+
+ setCurrentPage();
+
+ return;
+ }
+
showThumbnails = _showThumbnails;
// Empty the list
@@ -474,7 +515,7 @@
delete widgetList[i];
widgetList.clear();
- int y = 0;
+ y = 0;
for (unsigned int page = 1; page <= dataModel->numberOfPages(); page++) {
MarkListWidget* item = new MarkListWidget(viewport(), this, page, pageCache, showThumbnails);
@@ -737,7 +778,6 @@
bool show = showThumbnails;
// Rebuild thumbnail widgets.
- clear();
rebuildThumbnailWidgets(show);
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic