mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 02:42: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);
|
Q_D(const QItemDelegate);
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return 0;
|
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;
|
const QItemEditorFactory *factory = d->f;
|
||||||
if (factory == 0)
|
if (factory == 0)
|
||||||
factory = QItemEditorFactory::defaultFactory();
|
factory = QItemEditorFactory::defaultFactory();
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include "qcombobox.h"
|
#include "qcombobox.h"
|
||||||
#include "qdatetimeedit.h"
|
#include "qdatetimeedit.h"
|
||||||
|
#include "qfontcombobox.h"
|
||||||
#include "qlabel.h"
|
#include "qlabel.h"
|
||||||
#include "qlineedit.h"
|
#include "qlineedit.h"
|
||||||
#include "qspinbox.h"
|
#include "qspinbox.h"
|
||||||
|
@ -91,6 +92,7 @@ public:
|
||||||
\row \o QPixmap \o QLabel
|
\row \o QPixmap \o QLabel
|
||||||
\row \o QString \o QLineEdit
|
\row \o QString \o QLineEdit
|
||||||
\row \o QTime \o QTimeEdit
|
\row \o QTime \o QTimeEdit
|
||||||
|
\row \o QFont \o QFontComboBox
|
||||||
\endtable
|
\endtable
|
||||||
|
|
||||||
Additional editors can be registered with the registerEditor() function.
|
Additional editors can be registered with the registerEditor() function.
|
||||||
|
@ -181,7 +183,8 @@ QWidget *QDefaultItemEditorFactory::createEditor(QVariant::Type type, QWidget *p
|
||||||
case QVariant::Bool: {
|
case QVariant::Bool: {
|
||||||
QBooleanComboBox *cb = new QBooleanComboBox(parent);
|
QBooleanComboBox *cb = new QBooleanComboBox(parent);
|
||||||
cb->setFrame(false);
|
cb->setFrame(false);
|
||||||
return cb; }
|
return cb;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifndef QT_NO_SPINBOX
|
#ifndef QT_NO_SPINBOX
|
||||||
case QVariant::UInt: {
|
case QVariant::UInt: {
|
||||||
|
@ -194,18 +197,22 @@ QWidget *QDefaultItemEditorFactory::createEditor(QVariant::Type type, QWidget *p
|
||||||
sb->setFrame(false);
|
sb->setFrame(false);
|
||||||
sb->setMinimum(INT_MIN);
|
sb->setMinimum(INT_MIN);
|
||||||
sb->setMaximum(INT_MAX);
|
sb->setMaximum(INT_MAX);
|
||||||
return sb; }
|
return sb;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifndef QT_NO_DATETIMEEDIT
|
#ifndef QT_NO_DATETIMEEDIT
|
||||||
case QVariant::Date: {
|
case QVariant::Date: {
|
||||||
QDateTimeEdit *ed = new QDateEdit(parent);
|
QDateTimeEdit *ed = new QDateEdit(parent);
|
||||||
return ed; }
|
return ed;
|
||||||
|
}
|
||||||
case QVariant::Time: {
|
case QVariant::Time: {
|
||||||
QDateTimeEdit *ed = new QTimeEdit(parent);
|
QDateTimeEdit *ed = new QTimeEdit(parent);
|
||||||
return ed; }
|
return ed;
|
||||||
|
}
|
||||||
case QVariant::DateTime: {
|
case QVariant::DateTime: {
|
||||||
QDateTimeEdit *ed = new QDateTimeEdit(parent);
|
QDateTimeEdit *ed = new QDateTimeEdit(parent);
|
||||||
return ed; }
|
return ed;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
case QVariant::Pixmap:
|
case QVariant::Pixmap:
|
||||||
return new QLabel(parent);
|
return new QLabel(parent);
|
||||||
|
@ -215,7 +222,15 @@ QWidget *QDefaultItemEditorFactory::createEditor(QVariant::Type type, QWidget *p
|
||||||
sb->setFrame(false);
|
sb->setFrame(false);
|
||||||
sb->setMinimum(-DBL_MAX);
|
sb->setMinimum(-DBL_MAX);
|
||||||
sb->setMaximum(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
|
#endif
|
||||||
#ifndef QT_NO_LINEEDIT
|
#ifndef QT_NO_LINEEDIT
|
||||||
case QVariant::String:
|
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));
|
le->setFrame(le->style()->styleHint(QStyle::SH_ItemView_DrawDelegateFrame, 0, le));
|
||||||
if (!le->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, le))
|
if (!le->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, le))
|
||||||
le->setWidgetOwnsGeometry(true);
|
le->setWidgetOwnsGeometry(true);
|
||||||
return le; }
|
return le;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -254,6 +270,10 @@ QByteArray QDefaultItemEditorFactory::valuePropertyName(QVariant::Type type) con
|
||||||
return "time";
|
return "time";
|
||||||
case QVariant::DateTime:
|
case QVariant::DateTime:
|
||||||
return "dateTime";
|
return "dateTime";
|
||||||
|
#endif
|
||||||
|
#ifndef QT_NO_FONTCOMBOBOX
|
||||||
|
case QVariant::Font:
|
||||||
|
return "currentFont";
|
||||||
#endif
|
#endif
|
||||||
case QVariant::String:
|
case QVariant::String:
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Add table
Reference in a new issue