<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][14574] </title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=14574">14574</a></dd>
<dt>Author</dt> <dd>jmesquita</dd>
<dt>Date</dt> <dd>2009-08-19 20:59:48 -0500 (Wed, 19 Aug 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fix problem with autoscrolling on console. Should be tested with a high traffic server.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunkcontribjmesquitafsguisrcpluginsconsoleplugincentralWidgetui">freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/centralWidget.ui</a></li>
<li><a href="#freeswitchtrunkcontribjmesquitafsguisrcpluginsconsolepluginconsoleplugincpp">freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoleplugin.cpp</a></li>
<li><a href="#freeswitchtrunkcontribjmesquitafsguisrcpluginsconsolepluginconsolepluginh">freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoleplugin.h</a></li>
<li><a href="#freeswitchtrunkcontribjmesquitafsguisrcpluginsconsolepluginconsoletabwidgetcpp">freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoletabwidget.cpp</a></li>
<li><a href="#freeswitchtrunkcontribjmesquitafsguisrcpluginsconsolepluginconsoletabwidgeth">freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoletabwidget.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunkcontribjmesquitafsguisrcpluginsconsoleplugincentralWidgetui"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/centralWidget.ui (14573 => 14574)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/centralWidget.ui        2009-08-19 23:28:41 UTC (rev 14573)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/centralWidget.ui        2009-08-20 01:59:48 UTC (rev 14574)
</span><span class="lines">@@ -76,8 +76,6 @@
</span><span class="cx">     &lt;property name=&quot;title&quot;&gt;
</span><span class="cx">      &lt;string&gt;&amp;amp;Console&lt;/string&gt;
</span><span class="cx">     &lt;/property&gt;
</span><del>-    &lt;addaction name=&quot;actionAutomatic_Scroll&quot;/&gt;
-    &lt;addaction name=&quot;separator&quot;/&gt;
</del><span class="cx">     &lt;addaction name=&quot;actionRealtime_Statistics&quot;/&gt;
</span><span class="cx">    &lt;/widget&gt;
</span><span class="cx">    &lt;addaction name=&quot;menu_File&quot;/&gt;
</span></span></pre></div>
<a id="freeswitchtrunkcontribjmesquitafsguisrcpluginsconsolepluginconsoleplugincpp"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoleplugin.cpp (14573 => 14574)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoleplugin.cpp        2009-08-19 23:28:41 UTC (rev 14573)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoleplugin.cpp        2009-08-20 01:59:48 UTC (rev 14574)
</span><span class="lines">@@ -29,8 +29,6 @@
</span><span class="cx">                      this, SLOT(clearLogContents()));
</span><span class="cx">     QObject::connect(consoleWindow-&gt;actionRealtime_Statistics, SIGNAL(triggered()),
</span><span class="cx">                      this, SLOT(showRealtimeStats()));
</span><del>-    QObject::connect(consoleWindow-&gt;actionAutomatic_Scroll, SIGNAL(toggled(bool)),
-                     this, SLOT(setAutoScroll(bool)));
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ConsolePlugin::~ConsolePlugin(){}
</span><span class="lines">@@ -409,44 +407,29 @@
</span><span class="cx"> void ConsolePlugin::tabChanged(int index)
</span><span class="cx"> {
</span><span class="cx">     ESLconnection *esl = hashESL.value(consoleWindow-&gt;tabConsole-&gt;tabText(index), NULL);
</span><del>-    ConsoleTabWidget *tab = qobject_cast&lt;ConsoleTabWidget *&gt;(consoleWindow-&gt;tabConsole-&gt;currentWidget());
</del><span class="cx">     if (esl)
</span><span class="cx">     {
</span><span class="cx">         consoleWindow-&gt;action_Connect-&gt;setDisabled(esl-&gt;isConnected());
</span><span class="cx">         consoleWindow-&gt;action_Disconnect-&gt;setEnabled(esl-&gt;isConnected());
</span><del>-        consoleWindow-&gt;actionAutomatic_Scroll-&gt;setChecked(tab-&gt;getAutomaticScroll());
-        consoleWindow-&gt;actionAutomatic_Scroll-&gt;setEnabled(esl-&gt;isConnected());
-        tab-&gt;flipScrollTimer();
</del><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ConsolePlugin::connect()
</span><span class="cx"> {
</span><span class="cx">     ESLconnection *esl = hashESL.value(consoleWindow-&gt;tabConsole-&gt;tabText(consoleWindow-&gt;tabConsole-&gt;currentIndex()), NULL);
</span><del>-    ConsoleTabWidget *tab = qobject_cast&lt;ConsoleTabWidget *&gt;(consoleWindow-&gt;tabConsole-&gt;currentWidget());
</del><span class="cx">     if (esl)
</span><span class="cx">     {
</span><span class="cx">         esl-&gt;connect();
</span><del>-        tab-&gt;flipScrollTimer();
</del><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ConsolePlugin::disconnect()
</span><span class="cx"> {
</span><span class="cx">     ESLconnection *esl = hashESL.value(consoleWindow-&gt;tabConsole-&gt;tabText(consoleWindow-&gt;tabConsole-&gt;currentIndex()), NULL);
</span><del>-    ConsoleTabWidget *tab = qobject_cast&lt;ConsoleTabWidget *&gt;(consoleWindow-&gt;tabConsole-&gt;currentWidget());
</del><span class="cx">     if (esl)
</span><span class="cx">     {
</span><span class="cx">         esl-&gt;disconnect();
</span><del>-        tab-&gt;flipScrollTimer();
</del><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ConsolePlugin::setAutoScroll(bool checked)
-{
-    ConsoleTabWidget *tab = qobject_cast&lt;ConsoleTabWidget *&gt;(consoleWindow-&gt;tabConsole-&gt;currentWidget());
-    tab-&gt;setAutomaticScroll(checked);
-    tab-&gt;flipScrollTimer();
-}
-
</del><span class="cx"> Q_EXPORT_PLUGIN2(consoleplugin, ConsolePlugin)
</span></span></pre></div>
<a id="freeswitchtrunkcontribjmesquitafsguisrcpluginsconsolepluginconsolepluginh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoleplugin.h (14573 => 14574)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoleplugin.h        2009-08-19 23:28:41 UTC (rev 14573)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoleplugin.h        2009-08-20 01:59:48 UTC (rev 14574)
</span><span class="lines">@@ -53,7 +53,6 @@
</span><span class="cx">     void changeDebugForegroundColor();
</span><span class="cx">     void tabClose(int index);
</span><span class="cx">     void tabChanged(int index);
</span><del>-    void setAutoScroll(bool checked);
</del><span class="cx">     void readSettings();
</span><span class="cx">     void writeSettings();
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunkcontribjmesquitafsguisrcpluginsconsolepluginconsoletabwidgetcpp"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoletabwidget.cpp (14573 => 14574)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoletabwidget.cpp        2009-08-19 23:28:41 UTC (rev 14573)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoletabwidget.cpp        2009-08-20 01:59:48 UTC (rev 14574)
</span><span class="lines">@@ -8,10 +8,8 @@
</span><span class="cx">     QWidget(parent),
</span><span class="cx">     m_ui(new Ui::ConsoleTabWidget),
</span><span class="cx">     esl(eslconnection),
</span><del>-    scrollTimer(new QTimer),
</del><span class="cx">     _rtStatsDlg(NULL),
</span><del>-    findNext(false),
-    autoScroll(true)
</del><ins>+    findNext(false)
</ins><span class="cx"> {
</span><span class="cx">     m_ui-&gt;setupUi(this);
</span><span class="cx">     sourceModel = new QStandardItemModel(this);
</span><span class="lines">@@ -57,13 +55,16 @@
</span><span class="cx">     QObject::connect(esl, SIGNAL(receivedLogMessage(ESLevent)),
</span><span class="cx">                      this, SLOT(gotEvent(ESLevent)));
</span><span class="cx"> 
</span><del>-    QObject::connect(scrollTimer, SIGNAL(timeout()),
-                     this, SLOT(conditionalScroll()));
</del><span class="cx"> 
</span><span class="cx">     esl-&gt;connect();
</span><span class="cx"> 
</span><span class="cx">     msm = new MonitorStateMachine();
</span><span class="cx">     msm-&gt;addESLconnection(esl);
</span><ins>+
+    scrollTimer = new QBasicTimer;
+    scrollTimer-&gt;start(0, this);
+    /* Number of items to be inserted */
+    batch = 40;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ConsoleTabWidget::~ConsoleTabWidget()
</span><span class="lines">@@ -88,36 +89,25 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ConsoleTabWidget::flipScrollTimer()
</del><ins>+void ConsoleTabWidget::timerEvent(QTimerEvent *e)
</ins><span class="cx"> {
</span><del>-    if (!esl-&gt;isConnected())
</del><ins>+    bool scroll = false;
+    if (e-&gt;timerId() == scrollTimer-&gt;timerId())
</ins><span class="cx">     {
</span><del>-        scrollTimer-&gt;stop();
-        return;
-    }
</del><ins>+        if (m_ui-&gt;consoleListView-&gt;verticalScrollBar()-&gt;value() == m_ui-&gt;consoleListView-&gt;verticalScrollBar()-&gt;maximum())
+            scroll = true;
</ins><span class="cx"> 
</span><del>-    if (scrollTimer-&gt;isActive())
-        scrollTimer-&gt;stop();
-    else if (autoScroll)
-        scrollTimer-&gt;start(500);
</del><ins>+        int inserted_items = 0;
+        while( !_list_items.isEmpty() &amp;&amp; inserted_items &lt; batch)
+        {
+            sourceModel-&gt;appendRow(_list_items.takeFirst());
+            inserted_items++;
+        }
+        if (scroll)
+            m_ui-&gt;consoleListView-&gt;scrollToBottom();
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ConsoleTabWidget::setAutomaticScroll(bool enabled)
-{
-    autoScroll = enabled;
-}
-
-bool ConsoleTabWidget::getAutomaticScroll()
-{
-    return autoScroll;
-}
-
-void ConsoleTabWidget::conditionalScroll()
-{
-    if (autoScroll)
-        m_ui-&gt;consoleListView-&gt;scrollToBottom();
-}
-
</del><span class="cx"> void ConsoleTabWidget::filterClear()
</span><span class="cx"> {
</span><span class="cx">     m_ui-&gt;lineFilter-&gt;clear();
</span><span class="lines">@@ -195,7 +185,8 @@
</span><span class="cx">     QPalette palette = settings.value(QString(&quot;log-level-%1-palette&quot;).arg(item-&gt;data(Qt::UserRole).toInt())).value&lt;QPalette&gt;();
</span><span class="cx">     item-&gt;setBackground(palette.base());
</span><span class="cx">     item-&gt;setForeground(palette.text());
</span><del>-    sourceModel-&gt;appendRow(item);
</del><ins>+    //sourceModel-&gt;appendRow(item);
+    _list_items.append(item);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ConsoleTabWidget::cmdSendClicked()
</span></span></pre></div>
<a id="freeswitchtrunkcontribjmesquitafsguisrcpluginsconsolepluginconsoletabwidgeth"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoletabwidget.h (14573 => 14574)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoletabwidget.h        2009-08-19 23:28:41 UTC (rev 14573)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoletabwidget.h        2009-08-20 01:59:48 UTC (rev 14574)
</span><span class="lines">@@ -25,12 +25,10 @@
</span><span class="cx"> public slots:
</span><span class="cx">     void clearConsoleContents();
</span><span class="cx">     void showRealtimeStats();
</span><del>-    void flipScrollTimer();
-    void setAutomaticScroll(bool enabled);
-    bool getAutomaticScroll();
</del><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     void changeEvent(QEvent *e);
</span><ins>+    void timerEvent(QTimerEvent *);
</ins><span class="cx"> 
</span><span class="cx"> private slots:
</span><span class="cx">     void conditionalScroll();
</span><span class="lines">@@ -56,12 +54,13 @@
</span><span class="cx">     QStandardItemModel *sourceModel;
</span><span class="cx">     QModelIndexList foundItems;
</span><span class="cx">     SortFilterProxyModel *model;
</span><ins>+    QBasicTimer *scrollTimer;
</ins><span class="cx">     ESLconnection *esl;
</span><del>-    QTimer *scrollTimer;
</del><span class="cx">     MonitorStateMachine *msm;
</span><span class="cx">     RealtimeStatisticsDialog *_rtStatsDlg;
</span><span class="cx">     bool findNext;
</span><del>-    bool autoScroll;
</del><ins>+    QList&lt;QStandardItem *&gt; _list_items;
+    int batch;
</ins><span class="cx"> 
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>