summaryrefslogtreecommitdiffstats
path: root/newpicsdialog.h
diff options
context:
space:
mode:
Diffstat (limited to 'newpicsdialog.h')
-rw-r--r--newpicsdialog.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/newpicsdialog.h b/newpicsdialog.h
new file mode 100644
index 0000000..de4275a
--- /dev/null
+++ b/newpicsdialog.h
@@ -0,0 +1,77 @@
+/*
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version
+ 2 of the License, or (at your option) any later version.
+*/
+
+#ifndef NEWPICSDIALOG_H
+#define NEWPICSDIALOG_H
+
+#include <QWidget>
+#include <QSqlDatabase>
+
+#include "smtreemodel.h"
+
+class QTabWidget;
+class QSqlDatabase;
+class QSqlQuery;
+class QTreeView;
+class NewPicFilesModel;
+class QSortFilterProxyModel;
+class QPushButton;
+
+struct FileData;
+
+class NewPicsDialog : public QWidget {
+ Q_OBJECT
+ public:
+ explicit NewPicsDialog(QWidget *parent = 0);
+
+ public slots:
+ void addFiles();
+ void removeFiles();
+
+ private:
+ QTabWidget *mTab;
+ QWidget *mFilesWidget;
+ QTreeView *mFilesV;
+ NewPicFilesModel *mFilesModel;
+ QSortFilterProxyModel *mFilesProxy;
+ QPushButton *mAddFiles;
+ QPushButton *mRemoveFiles;
+};
+
+class NewPicFilesModel : public SmTreeModel {
+ Q_OBJECT
+ public:
+ enum Roles { FileNameRole = Qt::UserRole + 1, ValidRole = Qt::UserRole + 2, Md5SumRole = Qt::UserRole + 3, MimeTypeRole = Qt::UserRole + 4, FullPathRole = Qt::UserRole + 5 };
+ enum Fields { FileName = 0, Valid = 1, Md5Sum = 2, MimeType = 3, FullPath = 4 };
+ enum { NumFields = 5 };
+ explicit NewPicFilesModel(const QStringList &header, QObject *parent = 0);
+ ~NewPicFilesModel();
+
+ //data
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ bool setData(const QModelIndex &index, const QVariant &value, int role);
+ void setFiles(const QStringList &paths);
+ void addFile(const QString &path);
+ void removeFile(const QModelIndex &idx);
+ QList<FileData> validFiles() const;
+
+ private:
+ bool haveMd5(const QString &md5) const;
+ QSqlDatabase mDb;
+ QSqlQuery *mMd5Query;
+};
+
+struct FileData {
+ QString fileName;
+ bool valid;
+ QString md5sum;
+ QString mimeType;
+ QString fullPath;
+};
+
+#endif // NEWPICSDIALOG_H