diff options
author | Arno <am@disconnect.de> | 2013-07-28 08:16:47 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2013-07-28 08:16:47 +0200 |
commit | d2e774d2fbb4250bc65ff81b542854e211b59f4c (patch) | |
tree | 4bab1ecf65d06bf058c4e3144444c81e3eaf88fb /delegates.cpp | |
parent | d6b178b1fdcdac519ded25e3f253d9eeffa84053 (diff) | |
download | SheMov-d2e774d2fbb4250bc65ff81b542854e211b59f4c.tar.gz SheMov-d2e774d2fbb4250bc65ff81b542854e211b59f4c.tar.bz2 SheMov-d2e774d2fbb4250bc65ff81b542854e211b59f4c.zip |
Move filetype delegate to delegate.*
Missed this one the first time...
Diffstat (limited to 'delegates.cpp')
-rw-r--r-- | delegates.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/delegates.cpp b/delegates.cpp index ec1fe54..ae99241 100644 --- a/delegates.cpp +++ b/delegates.cpp @@ -7,8 +7,10 @@ #include <QVariant> #include <QSpinBox> +#include <QComboBox> #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{ |