From dce686c895fce27cce1d8bf0247c692bd790f93a Mon Sep 17 00:00:00 2001 From: Arno Date: Fri, 24 Feb 2012 23:32:10 +0100 Subject: Implemented NewPicsDialog Version 1 of NewPicsDialog. Just one single tab for adding files. Does nothing yet besides adding and removing files. --- newpicsdialog.h | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 newpicsdialog.h (limited to 'newpicsdialog.h') 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 +#include + +#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 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 -- cgit v1.2.3-70-g09d2