Revision
14651
Author
jmesquita
Date
2009-08-27 15:02:35 -0500 (Thu, 27 Aug 2009)

Log Message

Improve performance of ConsoleModel::timerEvent so it emits the correct signals avoiding repaints.

Modified Paths

Diff

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoletabwidget.cpp (14650 => 14651)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoletabwidget.cpp	2009-08-27 16:43:55 UTC (rev 14650)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoletabwidget.cpp	2009-08-27 20:02:35 UTC (rev 14651)
@@ -20,9 +20,11 @@
     model->setFilterKeyColumn(0);
     m_ui->consoleListView->setModel(model);
 
-    QObject::connect(sourceModel, SIGNAL(layoutAboutToBeChanged()),
+    QObject::connect(sourceModel, SIGNAL(beforeInserting()),
                      this, SLOT(setConditionalScroll()));
-    QObject::connect(sourceModel, SIGNAL(layoutChanged()),
+    /*QObject::connect(sourceModel, SIGNAL(layoutChanged()),
+                     this, SLOT(conditionalScroll()));*/
+    QObject::connect(sourceModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
                      this, SLOT(conditionalScroll()));
 
     QObject::connect(m_ui->btnSend, SIGNAL(clicked()),

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/sortfilterproxymodel.cpp (14650 => 14651)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/sortfilterproxymodel.cpp	2009-08-27 16:43:55 UTC (rev 14650)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/sortfilterproxymodel.cpp	2009-08-27 20:02:35 UTC (rev 14651)
@@ -48,15 +48,21 @@
             } else {
                  toBeInserted = batchSize - 1;
             }
+            QModelIndex topLeft = QModelIndex();
+            if (!_listDisplayModel.isEmpty())
+            {
+                topLeft =  index(_listDisplayModel.size()-1,0,QModelIndex());
+            }
+            emit beforeInserting();
             beginInsertRows( QModelIndex(), _listDisplayModel.size(), _listDisplayModel.size() + toBeInserted );
-            emit layoutAboutToBeChanged();
             while( !_listInsertModel.isEmpty() && inserted_items < batchSize)
             {
                 _listDisplayModel.append(_listInsertModel.takeFirst());
                 inserted_items++;
             }
             endInsertRows();
-            emit layoutChanged();
+            QModelIndex bottomRight = index(_listDisplayModel.size()-1,0,QModelIndex());
+            emit dataChanged( topLeft, bottomRight );
         }
     }
 }

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/sortfilterproxymodel.h (14650 => 14651)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/sortfilterproxymodel.h	2009-08-27 16:43:55 UTC (rev 14650)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/sortfilterproxymodel.h	2009-08-27 20:02:35 UTC (rev 14651)
@@ -62,6 +62,8 @@
         LogLevelRole = Qt::UserRole,
         UUIDRole
     };
+signals:
+    void beforeInserting();
 protected:
     void timerEvent(QTimerEvent *);
 private: