From d2e774d2fbb4250bc65ff81b542854e211b59f4c Mon Sep 17 00:00:00 2001 From: Arno Date: Sun, 28 Jul 2013 08:16:47 +0200 Subject: Move filetype delegate to delegate.* Missed this one the first time... --- archiveview.cpp | 24 ------------------------ archiveview.h | 11 ----------- delegates.cpp | 26 ++++++++++++++++++++++++++ delegates.h | 11 +++++++++++ 4 files changed, 37 insertions(+), 35 deletions(-) diff --git a/archiveview.cpp b/archiveview.cpp index 9ca131d..27aacc9 100644 --- a/archiveview.cpp +++ b/archiveview.cpp @@ -406,30 +406,6 @@ bool ArchiveProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourcePare ArchiveFilesProxy::ArchiveFilesProxy(QObject *parent) : QSortFilterProxyModel(parent) {} -/* Delegate for file type */ - -FileTypeDelegate::FileTypeDelegate(QObject *parent) : QStyledItemDelegate(parent){ - mFiletypeMap = SmGlobals::instance()->filetypeMap(); -} - -QString FileTypeDelegate::displayText(const QVariant &value, const QLocale &locale) const{ - Q_UNUSED(locale); - int type = value.toInt(); - QString retval = mFiletypeMap.value(type); - if(!retval.isEmpty()){ - return retval; - } - return tr("n/a"); -} - -QWidget *FileTypeDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const{ - Q_UNUSED(option); - Q_UNUSED(index); - QComboBox *retval = new QComboBox(parent); - retval->addItems(mFiletypeMap.values()); - return retval; -} - /* Mapping Editor Widget */ MappingEditorWidget::MappingEditorWidget(const QString &caption, QWidget *parent) : QWidget(parent), mCaption(caption){ diff --git a/archiveview.h b/archiveview.h index 6abb86f..c786b33 100644 --- a/archiveview.h +++ b/archiveview.h @@ -124,17 +124,6 @@ class ArchiveFilesProxy : public QSortFilterProxyModel { explicit ArchiveFilesProxy(QObject *parent = 0); }; -class FileTypeDelegate : public QStyledItemDelegate { - Q_OBJECT - public: - explicit FileTypeDelegate(QObject *parent = 0); - virtual QString displayText(const QVariant &value, const QLocale &locale) const; - virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; - - private: - QHash mFiletypeMap; -}; - /* separate widget since we need it in NewMovieWizard * and editing genres, actors in the new ArchiveView */ diff --git a/delegates.cpp b/delegates.cpp index ec1fe54..ae99241 100644 --- a/delegates.cpp +++ b/delegates.cpp @@ -7,8 +7,10 @@ #include #include +#include #include "delegates.h" +#include "smglobals.h" #include "helper.h" /* Delegate for File no. */ @@ -30,6 +32,30 @@ QWidget *FileNoDelegate::createEditor(QWidget *parent, const QStyleOptionViewIte return retval; } +/* Delegate for file type */ + +FileTypeDelegate::FileTypeDelegate(QObject *parent) : QStyledItemDelegate(parent){ + mFiletypeMap = SmGlobals::instance()->filetypeMap(); +} + +QString FileTypeDelegate::displayText(const QVariant &value, const QLocale &locale) const{ + Q_UNUSED(locale); + int type = value.toInt(); + QString retval = mFiletypeMap.value(type); + if(!retval.isEmpty()){ + return retval; + } + return tr("n/a"); +} + +QWidget *FileTypeDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const{ + Q_UNUSED(option); + Q_UNUSED(index); + QComboBox *retval = new QComboBox(parent); + retval->addItems(mFiletypeMap.values()); + return retval; +} + /* Delegate for Dvd no. */ QString DvdNoDelegate::displayText(const QVariant &value, const QLocale &locale) const{ diff --git a/delegates.h b/delegates.h index 86ee94e..c08dfb0 100644 --- a/delegates.h +++ b/delegates.h @@ -21,6 +21,17 @@ class FileNoDelegate : public QStyledItemDelegate { virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; }; +class FileTypeDelegate : public QStyledItemDelegate { + Q_OBJECT + public: + explicit FileTypeDelegate(QObject *parent = 0); + virtual QString displayText(const QVariant &value, const QLocale &locale) const; + virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; + + private: + QHash mFiletypeMap; +}; + class DvdNoDelegate : public QStyledItemDelegate { Q_OBJECT public: -- cgit v1.2.3-70-g09d2