summaryrefslogtreecommitdiff
path: root/src/dic-options/FieldsPreviewModel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dic-options/FieldsPreviewModel.cpp')
-rw-r--r--src/dic-options/FieldsPreviewModel.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/dic-options/FieldsPreviewModel.cpp b/src/dic-options/FieldsPreviewModel.cpp
new file mode 100644
index 0000000..e6ce1c6
--- /dev/null
+++ b/src/dic-options/FieldsPreviewModel.cpp
@@ -0,0 +1,34 @@
+#include "FieldsPreviewModel.h"
+#include "../dictionary/Field.h"
+#include "../field-styles/FieldStyle.h"
+#include "../field-styles/FieldStyleFactory.h"
+
+#include <QBrush>
+
+QVariant FieldsPreviewModel::data( const QModelIndex &index, int role ) const
+ {
+ if (!index.isValid())
+ return QVariant();
+ if (index.row() >= rowCount())
+ return QVariant();
+
+ Field* field = m_parent->m_dict.fields().value(index.row());
+ const FieldStyle fieldStyle = FieldStyleFactory::inst()->getStyle(field->style());
+ switch( role )
+ {
+ case Qt::DisplayRole:
+ return fieldStyle.prefix + field->name() + fieldStyle.suffix;
+ case Qt::FontRole:
+ return fieldStyle.font;
+ case Qt::BackgroundRole:
+ return QBrush( FieldStyleFactory::inst()->cardBgColor );
+ case Qt::ForegroundRole:
+ return fieldStyle.color;
+ case Qt::SizeHintRole:
+ return QSize(0, 50);
+ case Qt::TextAlignmentRole:
+ return Qt::AlignCenter;
+ default:
+ return QVariant();
+ }
+ }