summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2018-11-03 07:55:02 +0100
committerArno <arno@disconnect.de>2018-11-03 07:55:02 +0100
commita896d928412bc8f02131c8c6ab0d8c1ad4e4753f (patch)
treebb2d50f4675c3100b1a1a578988c41c3f5c6275f
parent3bfc587c081df11a02fad65e9cf9a3174aba284a (diff)
downloadSheMov-a896d928412bc8f02131c8c6ab0d8c1ad4e4753f.tar.gz
SheMov-a896d928412bc8f02131c8c6ab0d8c1ad4e4753f.tar.bz2
SheMov-a896d928412bc8f02131c8c6ab0d8c1ad4e4753f.zip
Put WizardTreeModel in separate file
One class per file :) No functional changes, just code shuffle and reindention.
-rw-r--r--newmoviewizard.cpp68
-rw-r--r--newmoviewizard.h20
-rw-r--r--shemov.pro6
-rw-r--r--wizardtreemodel.cpp76
-rw-r--r--wizardtreemodel.h34
5 files changed, 115 insertions, 89 deletions
diff --git a/newmoviewizard.cpp b/newmoviewizard.cpp
index 79674dd..bab8e71 100644
--- a/newmoviewizard.cpp
+++ b/newmoviewizard.cpp
@@ -29,7 +29,7 @@
#include <QDirIterator>
#include "newmoviewizard.h"
-#include "smtreeitem.h"
+#include "wizardtreemodel.h"
#include "smglobals.h"
#include "mappingtablemodel.h"
#include "delegates.h"
@@ -652,69 +652,3 @@ void MovieMetadataPage::initializePage(){
mWidget->setMetadata(curMetadata);
}
}
-
-WizardTreeModel::WizardTreeModel(QStringList &headers, QObject *parent) : SmTreeModel(headers, parent){
- mFiletypeMap = SmGlobals::instance()->filetypeMap();
-}
-
-Qt::ItemFlags WizardTreeModel::flags(const QModelIndex &index) const{
- if(index.column() == FileType || index.column() == FilePart){
- return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
- }
- return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
-}
-
-QList<QVariant> WizardTreeModel::fileData(const QModelIndex &idx) const{
- SmTreeItem *item = itemAt(idx);
- QList<QVariant> retval;
- for(int i = 0; i < item->columnCount(); ++i){
- retval << item->data(i);
- }
- return retval;
-}
-
-void WizardTreeModel::clear(){
- SmTreeItem *rootItem = new SmTreeItem(NumFields);
- setRoot(rootItem);
-}
-
-QVariant WizardTreeModel::data(const QModelIndex &index, int role) const{
- SmTreeItem *item = static_cast<SmTreeItem*>(index.internalPointer());
- if(role == Qt::TextAlignmentRole){
- if(index.column() == FileSize){
- return Qt::AlignRight;
- }
- return Qt::AlignLeft;
- }
- if(role == FileNameRole){
- return item->data(FileName);
- }
- if(role == FileSizeRole){
- return item->data(FileSize);
- }
- if(role == FileTypeRole){
- return item->data(FileType);
- }
- if(role == FullPathRole){
- return item->data(FullPath);
- }
- if(role == FilePartRole){
- return item->data(FilePart);
- }
- return SmTreeModel::data(index, role);
-}
-
-bool WizardTreeModel::setData(const QModelIndex &index, const QVariant &value, int role){
- if(role == Qt::EditRole){
- SmTreeItem *item = itemAt(index);
- if(index.column() == FileType){
- QVariant realVal = mFiletypeMap.key(value.toString());
- item->setData(index.column(), realVal);
- }else{
- item->setData(index.column(), value);
- }
- emit dataChanged(index, index);
- return true;
- }
- return false;
-}
diff --git a/newmoviewizard.h b/newmoviewizard.h
index 132ae4e..ee3b20d 100644
--- a/newmoviewizard.h
+++ b/newmoviewizard.h
@@ -121,25 +121,5 @@ class MovieMetadataPage : public QWizardPage {
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 = nullptr);
-
- //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
diff --git a/shemov.pro b/shemov.pro
index b5dfce6..da69ea8 100644
--- a/shemov.pro
+++ b/shemov.pro
@@ -58,7 +58,8 @@ SOURCES = main.cpp \
mappingtreeproxy.cpp \
mappingtreeresultmodel.cpp \
mappingdata.cpp \
- videoviewer.cpp
+ videoviewer.cpp \
+ wizardtreemodel.cpp
HEADERS = \
shemov.h \
helper.h \
@@ -111,7 +112,8 @@ HEADERS = \
mappingtreeproxy.h \
mappingtreeresultmodel.h \
mappingdata.h \
- videoviewer.h
+ videoviewer.h \
+ wizardtreemodel.h
LIBS += -lmagic -lXfixes -lX11 -lMagick++-6.Q16HDRI
INCLUDEPATH += /usr/include/ImageMagick-6/
RESOURCES = shemov.qrc
diff --git a/wizardtreemodel.cpp b/wizardtreemodel.cpp
new file mode 100644
index 0000000..783fc4a
--- /dev/null
+++ b/wizardtreemodel.cpp
@@ -0,0 +1,76 @@
+/*
+ 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.
+*/
+
+#include "wizardtreemodel.h"
+#include "smglobals.h"
+#include "smtreeitem.h"
+
+WizardTreeModel::WizardTreeModel(QStringList &headers, QObject *parent) : SmTreeModel(headers, parent){
+ mFiletypeMap = SmGlobals::instance()->filetypeMap();
+}
+
+Qt::ItemFlags WizardTreeModel::flags(const QModelIndex &index) const{
+ if(index.column() == FileType || index.column() == FilePart){
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
+ }
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+}
+
+QList<QVariant> WizardTreeModel::fileData(const QModelIndex &idx) const{
+ SmTreeItem *item = itemAt(idx);
+ QList<QVariant> retval;
+ for(int i = 0; i < item->columnCount(); ++i){
+ retval << item->data(i);
+ }
+ return retval;
+}
+
+void WizardTreeModel::clear(){
+ SmTreeItem *rootItem = new SmTreeItem(NumFields);
+ setRoot(rootItem);
+}
+
+QVariant WizardTreeModel::data(const QModelIndex &index, int role) const{
+ SmTreeItem *item = static_cast<SmTreeItem*>(index.internalPointer());
+ if(role == Qt::TextAlignmentRole){
+ if(index.column() == FileSize){
+ return Qt::AlignRight;
+ }
+ return Qt::AlignLeft;
+ }
+ if(role == FileNameRole){
+ return item->data(FileName);
+ }
+ if(role == FileSizeRole){
+ return item->data(FileSize);
+ }
+ if(role == FileTypeRole){
+ return item->data(FileType);
+ }
+ if(role == FullPathRole){
+ return item->data(FullPath);
+ }
+ if(role == FilePartRole){
+ return item->data(FilePart);
+ }
+ return SmTreeModel::data(index, role);
+}
+
+bool WizardTreeModel::setData(const QModelIndex &index, const QVariant &value, int role){
+ if(role == Qt::EditRole){
+ SmTreeItem *item = itemAt(index);
+ if(index.column() == FileType){
+ QVariant realVal = mFiletypeMap.key(value.toString());
+ item->setData(index.column(), realVal);
+ }else{
+ item->setData(index.column(), value);
+ }
+ emit dataChanged(index, index);
+ return true;
+ }
+ return false;
+}
diff --git a/wizardtreemodel.h b/wizardtreemodel.h
new file mode 100644
index 0000000..8053f5b
--- /dev/null
+++ b/wizardtreemodel.h
@@ -0,0 +1,34 @@
+/*
+ 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 WIZARDTREEMODEL_H
+#define WIZARDTREEMODEL_H
+
+#include "smtreemodel.h"
+
+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 = nullptr);
+
+ //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 // WIZARDTREEMODEL_H