[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/office/zippl
From:       Klaas Freitag <freitag () suse ! de>
Date:       2010-06-09 10:55:37
Message-ID: 20100609105537.0B954AC8A8 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1136263 by freitag:

added input file watching

 U             zippl.xml  
 M  +10 -2     zipplcontroler.cpp  
 M  +4 -0      zipplcontroler.h  


--- trunk/playground/office/zippl/zipplcontroler.cpp #1136262:1136263
@@ -7,11 +7,13 @@
   :QObject(),
   mGraphWidget( graphWidget ),
   mCurrSpotNo(0),
-  mCurrStationNo(0)
+  mCurrStationNo(0),
+  mWatcher( new QFileSystemWatcher(this))
 {
 
   connect( mGraphWidget, SIGNAL( moveToNextSpot()), SLOT( slotNextSpot() ) );
   connect( mGraphWidget, SIGNAL( moveToNextStation()), SLOT( slotNextStation() ) );
+  connect( mWatcher, SIGNAL(fileChanged( const QString&)), SLOT( slotFileChanged( const QString& )));
 
 }
 
@@ -30,13 +32,19 @@
   if( res ) {
     qDebug() << "Successfully read zippl in file!";
     mSpotList = xmlReader.spotItems();
-
+    mWatcher->addPath( filePath );
   } else {
     qDebug() << "Failed to read zippl in file!";
   }
   qDebug() << "Result: " << res;
 }
 
+void ZipplControler::slotFileChanged( const QString& file )
+{
+  qDebug() << "File changed - reload!";
+  loadFile( file );
+}
+
 void ZipplControler::slotNextSpot()
 {
   qDebug() << "Move to next spot, current spot no is " << mCurrSpotNo;
--- trunk/playground/office/zippl/zipplcontroler.h #1136262:1136263
@@ -2,6 +2,7 @@
 #define ZIPPLCONTROLER_H
 
 #include "graphwidget.h"
+class QFileSystemWatcher;
 
 class ZipplControler:public QObject
 {
@@ -14,11 +15,14 @@
   void slotNextSpot();
   void slotNextStation();
   void centerOnItem( QGraphicsItem* );
+  void slotFileChanged( const QString& );
+
 private:
   GraphWidget *mGraphWidget;
   QList<QGraphicsItem*> mSpotList;
   int          mCurrSpotNo;
   int          mCurrStationNo;
+  QFileSystemWatcher *mWatcher;
 };
 
 #endif // ZIPPLCONTROLER_H
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic