5.2.1 Add setup with no platforms and media types configured
------------------------------------------------------------
- Click Add button
->
+> An error message is shown that no platform and/or media types are configured.
5.2.2 Add setup with no platforms configured
--------------------------------------------
+- Click Add button
+> An error message is shown that no platform and/or media types are configured.
5.2.3 Add setup with no media types configured
----------------------------------------------
+- Click Add button
+> An error message is shown that no platform and/or media types are configured.
5.2.3 Add setup with a single media type and a single platform configured
-------------------------------------------------------------------------
*/
#include "stringlistdelegate.h"
#include "fileextensionwidget.h"
+#include <QPainter>
+#include <QDebug>
StringListDelegate::StringListDelegate(QString separator, QObject *parent) :
QStyledItemDelegate(parent), separator(separator)
QWidget* StringListDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
StringListWidget *editor = new StringListWidget(parent);
+ editor->setFixedSize(WIDTH, HEIGHT);
QString str = index.model()->data(index, Qt::DisplayRole).toString();
editor->setItems(str.split(separator, QString::SkipEmptyParts));
connect(editor, SIGNAL(stringListUpdated()), this, SLOT(commitAndCloseEditor()));
QSize StringListDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
- QSize sz(300,300);
+ QSize sz(WIDTH, HEIGHT);
return sz;
}
+
+void StringListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
+{
+ if (option.state & QStyle::State_Editing) {
+ QRect rc(option.rect.x(), option.rect.y(), WIDTH, HEIGHT);
+ painter->fillRect(rc, option.palette.highlight());
+ }
+ else {
+ painter->save();
+ QRect rc(option.rect.x(), option.rect.y(), WIDTH, HEIGHT);
+ painter->fillRect(rc, (option.state & QStyle::State_Selected) ? option.palette.highlight() : option.palette.light() );
+ QString str = index.model()->data(index, Qt::DisplayRole).toString();
+ painter->setBrush(option.palette.foreground());
+ painter->drawText(rc, str);
+ painter->restore();
+ }
+}
Q_OBJECT
public:
StringListDelegate(QString separator, QObject *parent = 0);
- //void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
+ void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
+ static const int WIDTH = 150;
+ static const int HEIGHT = 100;
private slots:
void commitAndCloseEditor();