From f4a99fc9a5bac76c6bfd10212a80d5ece3b41aac Mon Sep 17 00:00:00 2001 From: Arno Date: Sun, 21 Nov 2010 11:04:42 +0100 Subject: Implemented mark as seen Added new action to mark files as seen. Marked files have the foreground color red. For this the database connection is needed quite early, so I had to call SmGlobals::instance() in the constructor of SheMov without using it. --- filesystemwidget.h | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'filesystemwidget.h') diff --git a/filesystemwidget.h b/filesystemwidget.h index b04feca..0cc3abc 100644 --- a/filesystemwidget.h +++ b/filesystemwidget.h @@ -10,8 +10,11 @@ #include #include +#include +#include +#include +#include -class QFileSystemModel; class QTreeView; class FilesystemDirProxy; class FileView; @@ -24,6 +27,8 @@ class QVariant; class MessageDialog; class PictureViewer; class QStringList; +class FileSystemModel; +class QSqlQuery; class FilesystemWidget : public QWidget { Q_OBJECT @@ -32,7 +37,7 @@ class FilesystemWidget : public QWidget { ~FilesystemWidget() {}; FileView *fileView() { return mFileView; }; FilesystemFileProxy *fileProxy() { return mFileProxy; }; - QFileSystemModel *dirModel() { return mModel; }; + FileSystemModel *dirModel() { return mModel; }; const QString windowTitle() const { return mWindowTitle; }; PictureViewer *pictureViewer() { return mPicViewer; }; bool isMounted(); @@ -59,6 +64,7 @@ class FilesystemWidget : public QWidget { void readSettings(); void writeSettings(); void dvdMount(); + void markSeen(); private slots: void doRenameFile(); @@ -72,7 +78,7 @@ class FilesystemWidget : public QWidget { QPair programData(const QString &prefix, const QString &preferred); QStringList selectedFiles(); QStringList mExpandedDirs; - QFileSystemModel *mModel; + FileSystemModel *mModel; QTreeView *mDirView; FileView *mFileView; FilesystemDirProxy *mDirProxy; @@ -86,5 +92,23 @@ class FilesystemWidget : public QWidget { QString mLastDir; }; -#endif +class FileSystemModel : public QFileSystemModel { + Q_OBJECT + public: + FileSystemModel(QObject *parent = 0); + ~FileSystemModel(); + virtual QVariant data(const QModelIndex &index, int role) const; + bool isSeen(const QString &path) const; + + public slots: + void markAsSeen(const QString &path, bool seen); + private: + void cleanup(); + QHash mSeen; + QSqlDatabase mDb; + QSqlQuery *mDeleteFromSeenQuery; + QSqlQuery *mMarkAsSeenQuery; +}; + +#endif -- cgit v1.2.3-70-g09d2