1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/*
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 <QDialog>
#include <QSqlDatabase>
#include <QTreeView>
#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<FileData> 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
|