summaryrefslogtreecommitdiffstats
path: root/newmoviewizard.h
blob: e88be9fbfbb183d6f2f2d8a6d7bae85b7c0c2e2e (plain)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
  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 NEWMOVIEWIZARD_H
#define NEWMOVIEWIZARD_H

#include <QWizardPage>
#include <QStyledItemDelegate>

#include "smtreemodel.h"
#include "mappingtablewidget.h"

class QSpinBox;
class QComboBox;
class QCheckBox;
class QPlainTextEdit;
class QSortFilterProxyModel;
class WizardTreeModel;
class MovieInfoPage;
class MovieMappingPage;
class MovieMetadataPage;
class PictureViewer2;
class QCompleter;
class QStringListModel;
class MappingEditorWidget;
class MetadataEditorWidget;

class NewMovieWizard : public QWizard {
	Q_OBJECT
	public:
		explicit NewMovieWizard(QWidget *parent = 0);
        virtual void accept();
        virtual void reject();
		MovieInfoPage *infoPage() { return mInfoPage; }
		MovieMappingPage *actorPage() { return mActorPage; }
        MovieMappingPage *genrePage() { return mGenrePage; }

	private:
		MovieInfoPage *mInfoPage;
		MovieMappingPage *mActorPage;
		MovieMappingPage *mGenrePage;
		MovieMetadataPage *mMetadataPage;
};

class MovieInfoPage : public QWizardPage {
	Q_OBJECT
	public:
		explicit MovieInfoPage(QWidget *parent = 0);
		WizardTreeModel *model() { return mFileModel; }
		virtual void initializePage();
		void addFile(const QString &file);
        void setCurrentDir(const QString &dir) { mCurrentDir = dir; }
        void selectFirst();
        void saveData();
        void restoreData();

    public slots:
        void initCompleters();

	private slots:
        void extractTitle();
        void addOld();
		void addFiles();
		void removeFile();

	private:
		void setupGui();
        SmTreeView *mFileView;
		QLineEdit *mTitle;
		QLineEdit *mSubtitle;
		QSpinBox *mSeriesNo;
		QSpinBox *mQuality;
        QPushButton *mExtractTitle;
        QPushButton *mAddOld;
		QPushButton *mAddFile;
		QPushButton *mRemoveFile;
        WizardTreeModel *mFileModel;
        SmTreeItem *mMoviesItem;
        SmTreeItem *mCoversItem;
        QCompleter *mSeriesCompleter;
        QStringListModel *mSeriesCompleterModel;
        QSortFilterProxyModel *mProxy;
        QString mCurrentDir;
        QString mCurTitle;
        QString mCurSubtitle;
        int mCurSeriesno;
        int mCurQuality;
};

class MovieMappingPage : public QWizardPage {
	Q_OBJECT
	public:
		explicit MovieMappingPage(const QString &table, QWidget *parent = 0);
        MappingEditorWidget *widget() { return mWidget; }
		virtual void initializePage();

	private:
        /* defined in archiveview.h */
        MappingEditorWidget *mWidget;
        QString mTable;
};

class MovieMetadataPage : public QWizardPage {
	Q_OBJECT
	public:
		explicit MovieMetadataPage(QWidget *parent = 0);
        MetadataEditorWidget *widget() { return mWidget; }
		virtual void initializePage();

	private:
		void setupGui();
        /* defined in archiveview.h */
        MetadataEditorWidget *mWidget;
		QCheckBox *mMetadataEnabled;
};

class WizardTreeModel : public SmTreeModel {
	Q_OBJECT
	public:
		enum CustomRoles { FileNameRole = Qt::UserRole + 1, FileSizeRole = Qt::UserRole + 2, FileTypeRole = Qt::UserRole + 3, FilePartRole = Qt::UserRole + 4, FullPathRole = Qt::UserRole + 5 };
		enum Fields { FileName = 0, FileSize = 1, FileType = 2, FilePart = 3, FullPath = 4 };
        enum { NumFields = 5 };
        enum Types { Movie = 1, FrontCover = 2, BackCover = 3, GeneralCover = 4, Origin = 5 };
		explicit WizardTreeModel(QStringList &headers, QObject *parent = 0);

		//data + flags
		virtual QVariant data(const QModelIndex &index, int role) const;
        virtual bool setData(const QModelIndex &index, const QVariant &value, int role);
		virtual Qt::ItemFlags flags(const QModelIndex &index) const;
        QList<QVariant> fileData(const QModelIndex &idx) const;
        void clear();

	private:
        QHash<int, QString> mFiletypeMap;
		QHash<QString, int> mFilePartMap;
};

#endif