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
90
91
92
93
94
95
96
97
98
99
100
101
|
/*
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 "smtreemodel.h"
class QTabWidget;
class QMoveEvent;
class QLabel;
class QMenu;
class SmTreeView;
class NewPicFilesModel;
class PictureViewer2;
class QSortFilterProxyModel;
class MappingTreeWidget;
class MappingEditWidget;
struct FileData;
class NewPicsDialog : public QDialog {
Q_OBJECT
public:
explicit NewPicsDialog(QWidget *parent = nullptr, Qt::WindowFlags f = nullptr);
public slots:
void selectFiles();
void removeFiles();
void addFiles(const QStringList &files);
void setFile(const QString &file);
void setDir(const QString &dir);
void clearFiles();
void setFocusToMappings();
void setNextPic();
void accept();
private slots:
void archive();
void writeSettings();
void readSettings();
private:
void setupDlg();
QTabWidget *mTab;
QWidget *mFilesWidget;
MappingEditWidget *mMappingEditWidget;
SmTreeView *mFilesV;
NewPicFilesModel *mFilesModel;
QSortFilterProxyModel *mFilesProxy;
QPushButton *mOk;
QPushButton *mCancel;
QSqlDatabase mDb;
QPoint mPos;
QStringList mFiles;
int mFilesCtr;
};
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, PicSizeRole = Qt::UserRole + 7 };
enum Fields { FileName = 0, Size = 1, Valid = 2, Md5Sum = 3, MimeType = 4, FullPath = 5, PicSize = 6 };
enum { NumFields = 7 };
explicit NewPicFilesModel(const QStringList &header, QObject *parent = nullptr);
//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;
public slots:
void clear();
private:
bool haveMd5(const QString &md5) const;
QSqlDatabase mDb;
};
struct FileData {
QString fileName;
int size;
bool valid;
QString md5sum;
QString mimeType;
QString fullPath;
QString picSize;
};
#endif // NEWPICSDIALOG_H
|