[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/kviewshell-0.7/kviewshell/shell
From: Wilfried Huss <Wilfried.Huss () gmx ! at>
Date: 2006-10-28 16:15:12
Message-ID: 1162052112.051769.15785.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 599795 by whuss:
Don't rebuild all of the thumbnail widgets everytime their size has changed.
This makes rotation in large documents much faster.
M +44 -4 marklist.cpp
--- branches/work/kviewshell-0.7/kviewshell/shell/marklist.cpp #599794:599795
@@ -390,7 +390,8 @@
MarkList::MarkList(QWidget* parent, const char* name)
- : SmoothScrollView(parent, name), clickedThumbnail(0), showThumbnails(true), contextMenu(0)
+ : SmoothScrollView(parent, name, WStaticContents | WNoAutoErase),
+ clickedThumbnail(0), showThumbnails(true), contextMenu(0)
{
currentPage = PageNumber::invalidPage;
widgetList.setAutoDelete(true);
@@ -403,7 +404,7 @@
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
- viewport()->setBackgroundMode(Qt::PaletteBase);
+ viewport()->setBackgroundMode(Qt::NoBackground);
enableClipper(true);
}
@@ -429,6 +430,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());
@@ -448,11 +466,34 @@
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;
widgetList.resize(dataModel->numberOfPages());
- int y = 0;
+ y = 0;
for (unsigned int page = 1; page <= dataModel->numberOfPages(); page++)
{
@@ -724,7 +765,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