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

Peter Kümmel syntheticpp at gmx.net
Thu Feb 10 23:25:49 CET 2011


SVN commit 1219771 by kuemmel:

Make it possible to remove non existent files.
Don't wanna call it on startup because kst maybe
hangs when files with non-local paths a checked.

 M  +26 -1     mainwindow.cpp  
 M  +1 -0      mainwindow.h  


--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.cpp #1219770:1219771
@@ -319,8 +319,15 @@
     recentFiles = recentFiles.mid(0, 30);
     settings.setValue(key, recentFiles);
   }
+  
+  submenu->clear();
+  QAction* check = new QAction(this);
+  check->setText("&Check Files On Existence");
+  check->setData(key);
+  check->setVisible(true);
+  connect(check, SIGNAL(triggered()), this, SLOT(checkRecentFilesOnExistence()));
+  submenu->addAction(check);
   int i = 0;
-  submenu->clear();
   foreach(const QString& it, recentFiles) {
     i++;
     if (i <= 5) {
@@ -343,8 +350,26 @@
 }
 
 
+void MainWindow::checkRecentFilesOnExistence()
+{
+  QAction *action = qobject_cast<QAction *>(sender());
+  if (action) {
+    QSettings settings("Kst2");
+    QStringList recentFiles = settings.value(action->data().toString()).toStringList();
+    recentFiles.removeDuplicates();
+    foreach(const QString& it, recentFiles) {
+      if (!QFileInfo(it).exists()) {
+        recentFiles.removeOne(it);
+      }
+    }
+    settings.setValue(action->data().toString(), recentFiles);
+    updateRecentKstFiles();
+    updateRecentDataFiles();
+  }
+}
 
 
+
 bool MainWindow::initFromCommandLine() {
   delete _doc;
   _doc = new Document(this);
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.h #1219770:1219771
@@ -149,6 +149,7 @@
     void openRecentDataFile();
     void updateRecentKstFiles(const QString& newfilename = QString());
     void updateRecentDataFiles(const QString& newfilename = QString());
+    void checkRecentFilesOnExistence();
 
   protected:
     void closeEvent(QCloseEvent *e);


More information about the Kst mailing list