mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 10:22:55 +00:00
implement font type editing for QItemEditorFactory
QTableWidgetItem is still somewhat QString bound because it forces Qt::DisplayRole as Qt::EditRole Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
facd387374
commit
c5e97acf49
2 changed files with 28 additions and 8 deletions
|
@ -476,7 +476,7 @@ QWidget *QItemDelegate::createEditor(QWidget *parent,
|
|||
Q_D(const QItemDelegate);
|
||||
if (!index.isValid())
|
||||
return 0;
|
||||
QVariant::Type t = static_cast<QVariant::Type>(index.data(Qt::EditRole).userType());
|
||||
QVariant::Type t = index.data(Qt::EditRole).type();
|
||||
const QItemEditorFactory *factory = d->f;
|
||||
if (factory == 0)
|
||||
factory = QItemEditorFactory::defaultFactory();
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "qcombobox.h"
|
||||
#include "qdatetimeedit.h"
|
||||
#include "qfontcombobox.h"
|
||||
#include "qlabel.h"
|
||||
#include "qlineedit.h"
|
||||
#include "qspinbox.h"
|
||||
|
@ -91,6 +92,7 @@ public:
|
|||
\row \o QPixmap \o QLabel
|
||||
\row \o QString \o QLineEdit
|
||||
\row \o QTime \o QTimeEdit
|
||||
\row \o QFont \o QFontComboBox
|
||||
\endtable
|
||||
|
||||
Additional editors can be registered with the registerEditor() function.
|
||||
|
@ -181,7 +183,8 @@ QWidget *QDefaultItemEditorFactory::createEditor(QVariant::Type type, QWidget *p
|
|||
case QVariant::Bool: {
|
||||
QBooleanComboBox *cb = new QBooleanComboBox(parent);
|
||||
cb->setFrame(false);
|
||||
return cb; }
|
||||
return cb;
|
||||
}
|
||||
#endif
|
||||
#ifndef QT_NO_SPINBOX
|
||||
case QVariant::UInt: {
|
||||
|
@ -194,18 +197,22 @@ QWidget *QDefaultItemEditorFactory::createEditor(QVariant::Type type, QWidget *p
|
|||
sb->setFrame(false);
|
||||
sb->setMinimum(INT_MIN);
|
||||
sb->setMaximum(INT_MAX);
|
||||
return sb; }
|
||||
return sb;
|
||||
}
|
||||
#endif
|
||||
#ifndef QT_NO_DATETIMEEDIT
|
||||
case QVariant::Date: {
|
||||
QDateTimeEdit *ed = new QDateEdit(parent);
|
||||
return ed; }
|
||||
return ed;
|
||||
}
|
||||
case QVariant::Time: {
|
||||
QDateTimeEdit *ed = new QTimeEdit(parent);
|
||||
return ed; }
|
||||
return ed;
|
||||
}
|
||||
case QVariant::DateTime: {
|
||||
QDateTimeEdit *ed = new QDateTimeEdit(parent);
|
||||
return ed; }
|
||||
return ed;
|
||||
}
|
||||
#endif
|
||||
case QVariant::Pixmap:
|
||||
return new QLabel(parent);
|
||||
|
@ -215,7 +222,15 @@ QWidget *QDefaultItemEditorFactory::createEditor(QVariant::Type type, QWidget *p
|
|||
sb->setFrame(false);
|
||||
sb->setMinimum(-DBL_MAX);
|
||||
sb->setMaximum(DBL_MAX);
|
||||
return sb; }
|
||||
return sb;
|
||||
}
|
||||
#endif
|
||||
#ifndef QT_NO_FONTCOMBOBOX
|
||||
case QVariant::Font: {
|
||||
QFontComboBox *fb = new QFontComboBox(parent);
|
||||
fb->setFrame(false);
|
||||
return fb;
|
||||
}
|
||||
#endif
|
||||
#ifndef QT_NO_LINEEDIT
|
||||
case QVariant::String:
|
||||
|
@ -225,7 +240,8 @@ QWidget *QDefaultItemEditorFactory::createEditor(QVariant::Type type, QWidget *p
|
|||
le->setFrame(le->style()->styleHint(QStyle::SH_ItemView_DrawDelegateFrame, 0, le));
|
||||
if (!le->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, le))
|
||||
le->setWidgetOwnsGeometry(true);
|
||||
return le; }
|
||||
return le;
|
||||
}
|
||||
#else
|
||||
default:
|
||||
break;
|
||||
|
@ -254,6 +270,10 @@ QByteArray QDefaultItemEditorFactory::valuePropertyName(QVariant::Type type) con
|
|||
return "time";
|
||||
case QVariant::DateTime:
|
||||
return "dateTime";
|
||||
#endif
|
||||
#ifndef QT_NO_FONTCOMBOBOX
|
||||
case QVariant::Font:
|
||||
return "currentFont";
|
||||
#endif
|
||||
case QVariant::String:
|
||||
default:
|
||||
|
|
Loading…
Add table
Reference in a new issue