File ktrafficanalyzer-writetodisc.diff of Package KTrafficAnalyzer
--- settings/KTASettings.kcfg.orig 2007-04-12 02:10:51.000000000 +0700
+++ settings/KTASettings.kcfg 2007-04-14 21:08:44.000000000 +0700
@@ -96,4 +96,10 @@
<default code="true">KGlobalSettings::menuFont()</default>
</entry>
</group>
+ <group name="stats">
+ <entry name="sbWriteOnClose" type="Bool">
+ <label>Write stats to disc only on application close</label>
+ <default>true</default>
+ </entry>
+ </group>
</kcfg>
\ No newline at end of file
--- settings/Makefile.orig 2007-04-12 02:10:51.000000000 +0700
+++ settings/Makefile 2007-04-14 21:58:59.000000000 +0700
@@ -1,4 +1,4 @@
-do-it-all: KTASettings.o ColorWidget.o InterfaceWidget.o FontWidget.o WindowWidget.o
+do-it-all: KTASettings.o ColorWidget.o InterfaceWidget.o FontWidget.o WindowWidget.o StatsWidget.o
KTASettings.cpp: KTASettings.kcfg KTASettings.kcfgc
kconfig_compiler KTASettings.kcfg KTASettings.kcfgc
@@ -22,6 +22,10 @@
$(MOC) -o WindowWidget.moc WindowWidget.h
gcc -c WindowWidget.cpp $(CFLAGS)
+StatsWidget.o: StatsWidget.h StatsWidget.cpp
+ $(MOC) -o StatsWidget.moc StatsWidget.h
+ gcc -c StatsWidget.cpp $(CFLAGS)
+
clean:
rm -f KTASettings.h
rm -f KTASettings.cpp
--- settings/StatsWidget.cpp.orig 2007-04-14 22:59:09.000000000 +0700
+++ settings/StatsWidget.cpp 2007-04-14 22:46:05.000000000 +0700
@@ -0,0 +1,59 @@
+/****************************************************************************
+** Form implementation generated from reading ui file 'settings_stats.ui'
+**
+** Created: Do Nov 16 13:13:03 2006
+** by: The User Interface Compiler ($Id: qt/main.cpp 3.3.4 edited Nov 24 2003 $)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+
+#include "StatsWidget.h"
+#include "StatsWidget.moc"
+
+#include <qvariant.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qcheckbox.h>
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+
+/*
+ * Constructs a StatsWidget as a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'.
+ */
+StatsWidget::StatsWidget( QWidget* parent, const char* name, WFlags fl )
+ : QWidget( parent, name, fl )
+{
+ if ( !name )
+ setName( "StatsWidget" );
+
+ statsOptionsGroup = new QGroupBox( this, "statsOptionsGroup" );
+ statsOptionsGroup->setGeometry( QRect( 10, 10, 290, 50 ) );
+
+ kcfg_sbWriteOnClose = new QCheckBox( statsOptionsGroup, "kcfg_sbWriteOnClose" );
+ kcfg_sbWriteOnClose->setGeometry( QRect( 10, 20, 270, 20 ) );
+ languageChange();
+ resize( QSize(280, 216).expandedTo(minimumSizeHint()) );
+ clearWState( WState_Polished );
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+StatsWidget::~StatsWidget()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+/*
+ * Sets the strings of the subwidgets using the current
+ * language.
+ */
+void StatsWidget::languageChange()
+{
+ setCaption( tr( "Statistic settings" ) );
+ statsOptionsGroup->setTitle( tr( "Options" ) );
+ kcfg_sbWriteOnClose->setText( tr( "Write stats to disc only on application close" ) );
+}
+
--- settings/StatsWidget.h.orig 2007-04-14 22:59:20.000000000 +0700
+++ settings/StatsWidget.h 2007-04-14 22:26:57.000000000 +0700
@@ -0,0 +1,42 @@
+/****************************************************************************
+** Form interface generated from reading ui file 'settings_stats.ui'
+**
+** Created: Do Nov 16 13:12:37 2006
+** by: The User Interface Compiler ($Id: qt/main.cpp 3.3.4 edited Nov 24 2003 $)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+
+#ifndef STATSWIDGET_H
+#define STATSWIDGET_H
+
+#include <qvariant.h>
+#include <qwidget.h>
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QSpacerItem;
+class QGroupBox;
+class QLabel;
+class QCheckBox;
+
+class StatsWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ StatsWidget( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
+ ~StatsWidget();
+
+ QGroupBox* statsOptionsGroup;
+ QCheckBox* kcfg_sbWriteOnClose;
+
+protected:
+
+protected slots:
+ virtual void languageChange();
+
+};
+
+#endif // STATSWIDGET_H
--- lib/TrafficWindow.cpp.orig 2007-04-12 02:10:51.000000000 +0700
+++ lib/TrafficWindow.cpp 2007-04-14 22:48:02.000000000 +0700
@@ -68,6 +68,9 @@
//Create font entry
FontWidget *fontWidget = new FontWidget( 0, "KTAFontWidget" );
dialog->addPage( fontWidget, "Fonts", "fonts" );
+ //Create stats entry
+ StatsWidget *statsWidget = new StatsWidget( 0, "KTAStatsWidget" );
+ dialog->addPage( statsWidget, "Stats", "cache" );
//Create stats dialog
stats = new KConfigDialog( this, "KTAStats", KTAStats::self( this->trafficInterface->getInterfaceName().prepend( "ktastats" ) ), KDialogBase::IconList, KDialogBase::Ok );
@@ -193,7 +196,9 @@
KTAStats::setDates( dates );
KTAStats::setUploads( uploads );
KTAStats::setDownloads( downloads );
-
+ if( !KTASettings::sbWriteOnClose() ) {
+ KTAStats::writeConfig();
+ }
//Update dialog (if traffic was changed)
if( trafficDownloadDiff != 0.0 || trafficUploadDiff != 0.0 ) {
emit updateStatsDialog( dateIndex );
@@ -395,7 +400,9 @@
KTASettings::setSizeY( this->height() );
KTASettings::writeConfig();
- KTAStats::writeConfig();
+ if( KTASettings::sbWriteOnClose() ) {
+ KTAStats::writeConfig();
+ }
closeEvent->accept();
}
--- lib/TrafficWindow.h.orig 2007-04-12 02:12:11.000000000 +0700
+++ lib/TrafficWindow.h 2007-04-14 22:21:13.000000000 +0700
@@ -52,6 +52,7 @@
#include "settings/InterfaceWidget.h"
#include "settings/FontWidget.h"
#include "settings/WindowWidget.h"
+#include "settings/StatsWidget.h"
#include "stats/KTAStats.h"
#include "stats/TrafficStatsWidget.h"