[Kst] branches/work/kst/portto4/kst/src

Mike Fenton mike at staikos.net
Wed May 7 20:47:15 CEST 2008


SVN commit 805156 by fenton:

Add setting to control update manager maximum update frequency.


 M  +1 -0      datasources/ascii/ascii.cpp  
 M  +6 -2      libkst/updatemanager.cpp  
 M  +3 -0      libkst/updatemanager.h  
 M  +16 -0     libkstapp/applicationsettings.cpp  
 M  +4 -0      libkstapp/applicationsettings.h  
 M  +2 -0      libkstapp/applicationsettingsdialog.cpp  
 M  +11 -0     libkstapp/generaltab.cpp  
 M  +3 -0      libkstapp/generaltab.h  
 M  +40 -17    libkstapp/generaltab.ui  
 M  +4 -0      libkstapp/mainwindow.cpp  


--- branches/work/kst/portto4/kst/src/datasources/ascii/ascii.cpp #805155:805156
@@ -33,6 +33,7 @@
 #include <qtextdocument.h>
 #include <QXmlStreamWriter>
 #include <QXmlStreamAttributes>
+#include <QFileSystemWatcher>
 
 #include <math_kst.h>
 #include "ascii.h"
--- branches/work/kst/portto4/kst/src/libkst/updatemanager.cpp #805155:805156
@@ -36,7 +36,8 @@
 
 
 UpdateManager::UpdateManager() {
-  QTimer::singleShot(MAX_UPDATES, this, SLOT(allowUpdates()));
+  _maxUpdate = MAX_UPDATES;
+  QTimer::singleShot(_maxUpdate, this, SLOT(allowUpdates()));
 }
 
 
@@ -107,7 +108,10 @@
       }
     }
   }
-  QTimer::singleShot(MAX_UPDATES, this, SLOT(allowUpdates()));
+#if DEBUG_UPDATE_CYCLE > 0
+  qDebug() << "UM - Delaying for " << _maxUpdate << "ms before allowing next update";
+#endif
+  QTimer::singleShot(_maxUpdate, this, SLOT(allowUpdates()));
 }
 
 
--- branches/work/kst/portto4/kst/src/libkst/updatemanager.h #805155:805156
@@ -38,6 +38,8 @@
     void updateStarted(ObjectPtr updateObject, ObjectPtr reportingObject);
     void updateFinished(ObjectPtr updateObject, ObjectPtr reportingObject);
 
+    void setMaximumUpdateFrequency(const int frequency) { _maxUpdate = frequency; }
+
   private Q_SLOTS:
     void allowUpdates();
 
@@ -53,6 +55,7 @@
     QMap<ObjectPtr, QList<QGraphicsRectItem*> > _displayUpdateRequests;
 
     bool _delayedUpdate;
+    int _maxUpdate;
 };
 
 }
--- branches/work/kst/portto4/kst/src/libkstapp/applicationsettings.cpp #805155:805156
@@ -11,6 +11,8 @@
 
 #include "applicationsettings.h"
 
+#include "updatemanager.h"
+
 #include <QCoreApplication>
 #include <QGLPixelBuffer>
 #include <QSettings>
@@ -52,6 +54,7 @@
   _refFontSize = _settings->value("general/referencefontsize", QVariant(12)).toInt();
   _minFontSize = _settings->value("general/minimumfontsize", QVariant(5)).toInt();
   _defaultFontFamily = _settings->value("general/defaultfontfamily", "Albany AMT").toString();
+  _maxUpdate = _settings->value("general/maximumupdatefrequency", QVariant(2000)).toInt();
 
   _showGrid = _settings->value("grid/showgrid", QVariant(true)).toBool();
   _snapToGrid = _settings->value("grid/snaptogrid", QVariant(false)).toBool();
@@ -155,6 +158,19 @@
 }
 
 
+int ApplicationSettings::maximumUpdateFrequency() const {
+  return _maxUpdate;
+}
+
+
+void ApplicationSettings::setMaximumUpdateFrequency(const int frequency) {
+  _maxUpdate = frequency;
+  _settings->setValue("general/maximumupdatefrequency", frequency);
+
+  UpdateManager::self()->setMaximumUpdateFrequency(frequency);
+}
+
+
 bool ApplicationSettings::showGrid() const {
   return _showGrid;
 }
--- branches/work/kst/portto4/kst/src/libkstapp/applicationsettings.h #805155:805156
@@ -47,6 +47,9 @@
     QString defaultFontFamily() const;
     void setDefaultFontFamily(const QString &fontFamily);
 
+    int maximumUpdateFrequency() const;
+    void setMaximumUpdateFrequency(const int frequency);
+
     bool showGrid() const;
     void setShowGrid(bool showGrid);
 
@@ -75,6 +78,7 @@
     int _refFontSize;
     int _minFontSize;
     QString _defaultFontFamily;
+    int _maxUpdate;
     bool _showGrid;
     bool _snapToGrid;
     qreal _gridHorSpacing;
--- branches/work/kst/portto4/kst/src/libkstapp/applicationsettingsdialog.cpp #805155:805156
@@ -56,6 +56,7 @@
   _generalTab->setReferenceFontSize(ApplicationSettings::self()->referenceFontSize());
   _generalTab->setMinimumFontSize(ApplicationSettings::self()->minimumFontSize());
   _generalTab->setDefaultFontFamily(ApplicationSettings::self()->defaultFontFamily());
+  _generalTab->setMaximumUpdateFrequency(ApplicationSettings::self()->maximumUpdateFrequency());
 }
 
 
@@ -76,6 +77,7 @@
   ApplicationSettings::self()->setReferenceFontSize(_generalTab->referenceFontSize());
   ApplicationSettings::self()->setMinimumFontSize(_generalTab->minimumFontSize());
   ApplicationSettings::self()->setDefaultFontFamily(_generalTab->defaultFontFamily());
+  ApplicationSettings::self()->setMaximumUpdateFrequency(_generalTab->maximumUpdateFrequency());
   ApplicationSettings::self()->blockSignals(false);
 
   emit ApplicationSettings::self()->modified();
--- branches/work/kst/portto4/kst/src/libkstapp/generaltab.cpp #805155:805156
@@ -25,6 +25,7 @@
   connect(_refFontSize, SIGNAL(valueChanged(int)), this, SIGNAL(modified()));
   connect(_minFontSize, SIGNAL(valueChanged(int)), this, SIGNAL(modified()));
   connect(_defaultFontFamily, SIGNAL(currentFontChanged(const QFont &)), this, SIGNAL(modified()));
+  connect(_maxUpdate, SIGNAL(valueChanged(int)), this, SIGNAL(modified()));
 }
 
 
@@ -91,6 +92,16 @@
   _defaultFontFamily->setCurrentFont(QFont(fontFamily));
 }
 
+
+int GeneralTab::maximumUpdateFrequency() const {
+  return _maxUpdate->value();
 }
 
+
+void GeneralTab::setMaximumUpdateFrequency(const int frequency) {
+  _maxUpdate->setValue(frequency);
+}
+
+}
+
 // vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/generaltab.h #805155:805156
@@ -42,6 +42,9 @@
 
     QString defaultFontFamily() const;
     void setDefaultFontFamily(const QString &fontFamily);
+
+    int maximumUpdateFrequency() const;
+    void setMaximumUpdateFrequency(const int frequency);
 };
 
 }
--- branches/work/kst/portto4/kst/src/libkstapp/generaltab.ui #805155:805156
@@ -13,80 +13,103 @@
    <string>Form</string>
   </property>
   <layout class="QGridLayout" >
-   <item row="0" column="0" colspan="3" >
+   <item row="0" column="0" colspan="2" >
     <widget class="QCheckBox" name="_useOpenGL" >
      <property name="text" >
       <string>Use OpenGL</string>
      </property>
     </widget>
    </item>
-   <item row="1" column="0" colspan="3" >
+   <item row="1" column="0" colspan="2" >
     <widget class="QLabel" name="label" >
      <property name="text" >
       <string>Reference View Width (cm):</string>
      </property>
     </widget>
    </item>
-   <item row="1" column="3" >
+   <item row="1" column="2" >
     <widget class="QDoubleSpinBox" name="_refViewWidth" >
      <property name="maximum" >
-      <number>2000</number>
+      <double>2000.000000000000000</double>
      </property>
     </widget>
    </item>
-   <item row="2" column="0" colspan="3" >
+   <item row="2" column="0" colspan="2" >
     <widget class="QLabel" name="label_2" >
      <property name="text" >
       <string>Reference View Height (cm):</string>
      </property>
     </widget>
    </item>
-   <item row="2" column="3" >
-     <widget class="QDoubleSpinBox" name="_refViewHeight" >
+   <item row="2" column="2" >
+    <widget class="QDoubleSpinBox" name="_refViewHeight" >
      <property name="maximum" >
-      <number>2000</number>
+      <double>2000.000000000000000</double>
      </property>
     </widget>
    </item>
-   <item row="3" column="0" colspan="3" >
+   <item row="3" column="0" colspan="2" >
     <widget class="QLabel" name="label_4" >
      <property name="text" >
       <string>Reference Font Size (points):</string>
      </property>
     </widget>
    </item>
-   <item row="3" column="3" >
+   <item row="3" column="2" >
     <widget class="QSpinBox" name="_refFontSize" />
    </item>
-   <item row="4" column="0" colspan="3" >
+   <item row="4" column="0" colspan="2" >
     <widget class="QLabel" name="label_3" >
      <property name="text" >
       <string>Minimum Font Size (points):</string>
      </property>
     </widget>
    </item>
-   <item row="4" column="3" >
+   <item row="4" column="2" >
     <widget class="QSpinBox" name="_minFontSize" />
    </item>
-   <item row="5" column="0" colspan="2" >
+   <item row="5" column="0" >
     <widget class="QLabel" name="_Label_12" >
      <property name="text" >
       <string>Default Font Family</string>
      </property>
     </widget>
    </item>
-   <item row="5" column="2" colspan="2" >
+   <item row="5" column="1" colspan="2" >
     <widget class="QFontComboBox" name="_defaultFontFamily" />
    </item>
-   <item row="6" column="1" >
+   <item row="6" column="0" colspan="2" >
+    <widget class="QLabel" name="label_5" >
+     <property name="text" >
+      <string>Maximum Update Frequency (ms)</string>
+     </property>
+    </widget>
+   </item>
+   <item row="6" column="2" >
+    <widget class="QSpinBox" name="_maxUpdate" >
+     <property name="minimum" >
+      <number>10</number>
+     </property>
+     <property name="maximum" >
+      <number>60000</number>
+     </property>
+     <property name="singleStep" >
+      <number>500</number>
+     </property>
+     <property name="value" >
+      <number>2000</number>
+     </property>
+    </widget>
+   </item>
+   <item row="7" column="0" >
     <spacer>
      <property name="orientation" >
       <enum>Qt::Vertical</enum>
      </property>
      <property name="sizeHint" >
       <size>
-       <width>20</width>
-       <height>41</height>
+       <width>44</width>
+       <height>16</height>
       </size>
      </property>
     </spacer>
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.cpp #805155:805156
@@ -36,6 +36,8 @@
 #include "viewprimitivedialog.h"
 #include "view.h"
 #include "viewmanager.h"
+#include "updatemanager.h"
+#include "applicationsettings.h"
 
 #include "applicationsettingsdialog.h"
 #include "differentiatecurvesdialog.h"
@@ -98,6 +100,8 @@
 
 
 void MainWindow::performHeavyStartupActions() {
+  // Set the timer for the UpdateManager.
+  UpdateManager::self()->setMaximumUpdateFrequency(ApplicationSettings::self()->maximumUpdateFrequency());
 }
 
 


More information about the Kst mailing list