------------------------------------------------------------
revno: 110
committer: Aurelien Gateau <[email protected]>
branch nick: plasma-widget-message-indicator
timestamp: Thu 2010-02-11 18:01:25 +0100
message:
  Avoid emitting sizeChanged() multiple times
modified:
  src/view.cpp
  src/view.h


--
lp:plasma-widget-message-indicator
https://code.launchpad.net/~agateau/plasma-widget-message-indicator/trunk

Your team ayatana-commits is subscribed to branch 
lp:plasma-widget-message-indicator.
To unsubscribe from this branch go to 
https://code.launchpad.net/~agateau/plasma-widget-message-indicator/trunk/+edit-subscription.
=== modified file 'src/view.cpp'
--- src/view.cpp	2009-10-08 14:12:08 +0000
+++ src/view.cpp	2010-02-11 17:01:25 +0000
@@ -19,7 +19,11 @@
 
 ExpandedTreeView::ExpandedTreeView(QWidget* parent)
 : QTreeView(parent)
+, mAdjustSizeTimer(new QTimer(this))
 {
+    connect(mAdjustSizeTimer, SIGNAL(timeout()), SLOT(adjustSizeTightly()));
+    mAdjustSizeTimer->setSingleShot(true);
+    mAdjustSizeTimer->setInterval(0);
 }
 
 /**
@@ -68,19 +72,19 @@
             setUpRootIndex(row);
         }
     }
-    QTimer::singleShot(0, this, SLOT(adjustSizeTightly()));
+    mAdjustSizeTimer->start();
 }
 
 void ExpandedTreeView::rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end)
 {
     QTreeView::rowsAboutToBeRemoved(parent, start, end);
-    QTimer::singleShot(0, this, SLOT(adjustSizeTightly()));
+    mAdjustSizeTimer->start();
 }
 
 void ExpandedTreeView::dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
 {
     QTreeView::dataChanged(topLeft, bottomRight);
-    QTimer::singleShot(0, this, SLOT(adjustSizeTightly()));
+    mAdjustSizeTimer->start();
 }
 
 void ExpandedTreeView::reset()
@@ -89,7 +93,7 @@
     for (int row = 0; row < model()->rowCount(); ++row) {
         setUpRootIndex(row);
     }
-    QTimer::singleShot(0, this, SLOT(adjustSizeTightly()));
+    mAdjustSizeTimer->start();
 }
 
 void ExpandedTreeView::drawTree(QPainter*, const QRegion&) const

=== modified file 'src/view.h'
--- src/view.h	2009-10-08 14:12:08 +0000
+++ src/view.h	2010-02-11 17:01:25 +0000
@@ -14,6 +14,8 @@
 // Qt
 #include <QTreeView>
 
+class QTimer;
+
 /**
  * A tree view which is always fully expanded
  */
@@ -49,6 +51,8 @@
 private:
     void setUpRootIndex(int row);
     QSize sizeHintForIndexAndChildren(const QModelIndex& parent, int depth) const;
+
+    QTimer* mAdjustSizeTimer;
 };
 
 #endif /* VIEW_H */

_______________________________________________
Mailing list: https://launchpad.net/~ayatana-commits
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~ayatana-commits
More help   : https://help.launchpad.net/ListHelp

Reply via email to