summaryrefslogtreecommitdiffstats
path: root/delegates.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'delegates.cpp')
-rw-r--r--delegates.cpp26
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{