/* 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 #include "smtreemodel.h" class QTabWidget; class QSqlDatabase; class QSqlQuery; class QTreeView; class NewPicFilesModel; class QSortFilterProxyModel; class QPushButton; class MappingTreeWidget; class MappingEditWidget; struct FileData; class NewPicsDialog : public QDialog { Q_OBJECT public: explicit NewPicsDialog(QWidget *parent = 0, Qt::WindowFlags f = 0); public slots: void addFiles(); void removeFiles(); void accept(); private: QTabWidget *mTab; QWidget *mFilesWidget; MappingEditWidget *mMappingEditWidget; QTreeView *mFilesV; NewPicFilesModel *mFilesModel; QSortFilterProxyModel *mFilesProxy; QPushButton *mAddFiles; QPushButton *mRemoveFiles; MappingTreeWidget *mMappingTreeWidget; QPushButton *mOk; QPushButton *mCancel; QSqlDatabase mDb; QSqlQuery *mAddFileQ; QSqlQuery *mAddMappingQ; }; class NewPicFilesModel : public SmTreeModel { Q_OBJECT public: enum Roles { FileNameRole = Qt::UserRole + 1, SizeRole = Qt::UserRole + 2, ValidRole = Qt::UserRole + 3, Md5SumRole = Qt::UserRole + 4, MimeTypeRole = Qt::UserRole + 5, FullPathRole = Qt::UserRole + 6 }; enum Fields { FileName = 0, Size = 1, Valid = 2, Md5Sum = 3, MimeType = 4, FullPath = 5 }; enum { NumFields = 6 }; 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; int size; bool valid; QString md5sum; QString mimeType; QString fullPath; }; #endif // NEWPICSDIALOG_H