[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Brekollect=5D_src=3A_Update_note_browser_and_windows?=
From: Jason Jackson <jacksonje () gmail ! com>
Date: 2011-03-07 15:58:49
Message-ID: 20110307155849.75D5EA60B0 () git ! kde ! org
[Download RAW message or body]
Git commit 3ed6688d2026d285a83c7f1ecf03fc8ea739e782 by Jason Jackson.
Committed on 07/03/2011 at 16:58.
Pushed by jackson into branch 'master'.
Update note browser and windows when the contents of the note directory change.
M +19 -0 src/notebrowserwindow.cpp
M +5 -0 src/notebrowserwindow.h
M +5 -0 src/notecollection.cpp
M +2 -0 src/notecollection.h
http://commits.kde.org/rekollect/3ed6688d2026d285a83c7f1ecf03fc8ea739e782
diff --git a/src/notebrowserwindow.cpp b/src/notebrowserwindow.cpp
index a2972fa..244d088 100644
--- a/src/notebrowserwindow.cpp
+++ b/src/notebrowserwindow.cpp
@@ -54,6 +54,7 @@
#include <kio/scheduler.h>
#include <KSaveFile>
#include <KConfigDialog>
+#include <KDirWatch>
NoteBrowserWindow::NoteBrowserWindow(QWidget *parent) : KXmlGuiWindow(parent)
{
@@ -61,9 +62,11 @@ NoteBrowserWindow::NoteBrowserWindow(QWidget *parent) : \
KXmlGuiWindow(parent) setWindowIcon(KIcon("rekollect"));
m_noteCollection = new NoteCollection(this);
m_windowCollection = new WindowCollection(this);
+ m_dirWatch = new KDirWatch(this);
setupWindow();
setupActions();
loadNoteDetails(m_noteCollection);
+ startDirWatch();
}
void NoteBrowserWindow::toggleBrowserWindow()
@@ -281,6 +284,13 @@ void NoteBrowserWindow::globalSettingsChanged(int category)
connectClickSignals();
}
+void NoteBrowserWindow::reloadNoteDetails()
+{
+ m_noteCollection->clear();
+ loadNoteDetails(m_noteCollection);
+ m_windowCollection->updateOpenWindows();
+}
+
void NoteBrowserWindow::loadNoteDetails(NoteCollection *collection)
{
QStringList noteList = KGlobal::dirs()->findAllResources("app_notes", \
QString()); @@ -292,6 +302,15 @@ void \
NoteBrowserWindow::loadNoteDetails(NoteCollection *collection) }
}
+void NoteBrowserWindow::startDirWatch()
+{
+ QStringList noteDirs = KGlobal::dirs()->findDirs("app_notes", QString());
+ foreach (const QString ¬eDir, noteDirs) {
+ m_dirWatch->addDir(noteDir);
+ }
+ connect(m_dirWatch, SIGNAL(dirty(QString)), this, SLOT(reloadNoteDetails()));
+}
+
void NoteBrowserWindow::connectWindowSignals(NoteWindow *window)
{
connect(window->editor()->document(), \
SIGNAL(documentNameChanged(QString,QString)), m_noteCollection, \
SLOT(documentNameChanged(QString,QString)));
diff --git a/src/notebrowserwindow.h b/src/notebrowserwindow.h
index 423c825..04fca4e 100644
--- a/src/notebrowserwindow.h
+++ b/src/notebrowserwindow.h
@@ -42,6 +42,7 @@ class QCloseEvent;
class KAction;
class KJob;
+class KDirWatch;
class NoteBrowserWindow : public KXmlGuiWindow
{
@@ -72,9 +73,11 @@ private slots:
void editLink(NoteEditor *editor);
void showPreferences();
void globalSettingsChanged(int category);
+ void reloadNoteDetails();
private:
void loadNoteDetails(NoteCollection *collection);
+ void startDirWatch();
void connectWindowSignals(NoteWindow *window);
void connectClickSignals();
@@ -91,6 +94,8 @@ private:
Ui::GeneralSettingsWidget *ui_generalSettings;
Ui::DisplaySettingsWidget *ui_displaySettings;
+ KDirWatch *m_dirWatch;
+
};
#endif // NOTEBROWSERWINDOW_H
diff --git a/src/notecollection.cpp b/src/notecollection.cpp
index 3a6d300..7806a41 100644
--- a/src/notecollection.cpp
+++ b/src/notecollection.cpp
@@ -69,6 +69,11 @@ QVariant NoteCollection::headerData(int section, Qt::Orientation \
orientation, in }
}
+void NoteCollection::clear()
+{
+ removeRows(0, rowCount());
+}
+
void NoteCollection::removeNote(const QString &fileName)
{
QStandardItem *item = itemFromFileName(fileName);
diff --git a/src/notecollection.h b/src/notecollection.h
index d36754a..926f655 100644
--- a/src/notecollection.h
+++ b/src/notecollection.h
@@ -42,6 +42,8 @@ public:
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = \
Qt::DisplayRole) const;
+ void clear();
+
public slots:
void removeNote(const QString &fileName);
void documentNameChanged(const QString &fileName, const QString &documentName);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic