From kde-commits Wed Oct 31 23:34:18 2012 From: Jaroslaw Staniek Date: Wed, 31 Oct 2012 23:34:18 +0000 To: kde-commits Subject: [calligra/calligra/2.6] kexi/plugins/forms/widgets: Kexi Forms: Fix "data source tag" for text box Message-Id: <20121031233418.B7D19A6078 () git ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=135172647232230 Git commit 633d83082159f6cf4b7de5386b36a91ce19a20cc by Jaroslaw Staniek. Committed on 31/10/2012 at 18:17. Pushed by staniek into branch 'calligra/2.6'. Kexi Forms: Fix "data source tag" for text box (regression because of changes in KDE libraries' line editor) M +27 -5 kexi/plugins/forms/widgets/kexidblineedit.cpp M +3 -0 kexi/plugins/forms/widgets/kexidblineedit.h http://commits.kde.org/calligra/633d83082159f6cf4b7de5386b36a91ce19a20cc diff --git a/kexi/plugins/forms/widgets/kexidblineedit.cpp b/kexi/plugins/f= orms/widgets/kexidblineedit.cpp index e1e3f77..f023937 100644 --- a/kexi/plugins/forms/widgets/kexidblineedit.cpp +++ b/kexi/plugins/forms/widgets/kexidblineedit.cpp @@ -62,12 +62,14 @@ public: KexiDBLineEditStyle(QStyle* parentStyle) : KexiUtils::StyleProxy(paren= tStyle), indent(0) { } + virtual ~KexiDBLineEditStyle() { + } = void setIndent(int indent) { this->indent =3D indent; } = - QRect subElementRect(SubElement element, const QStyleOption *option, c= onst QWidget *widget) const + QRect subElementRect(SubElement element, const QStyleOption *option, c= onst QWidget *widget =3D 0) const { const KFormDesigner::FormWidgetInterface *formWidget =3D dynamic_c= ast(widget); if (formWidget->designMode()) { @@ -98,6 +100,7 @@ KexiDBLineEdit::KexiDBLineEdit(QWidget *parent) , m_internalReadOnly(false) , m_slotTextChanged_enabled(true) , m_paletteChangeEvent_enabled(true) + , m_inStyleChangeEvent(false) { QFont tmpFont; tmpFont.setPointSize(KGlobalSettings::smallestReadableFont().pointSize= ()); @@ -108,10 +111,12 @@ KexiDBLineEdit::KexiDBLineEdit(QWidget *parent) connect(this, SIGNAL(cursorPositionChanged(int,int)), this, SLOT(slotCursorPositionChanged(int,int))); = - KexiDBLineEditStyle *ks =3D new KexiDBLineEditStyle(style()); - ks->setParent(this); - ks->setIndent(KexiFormUtils::dataSourceTagIcon().width()); - setStyle( ks ); + m_internalStyle =3D new KexiDBLineEditStyle(style()); + m_internalStyle->setParent(this); + m_internalStyle->setIndent(KexiFormUtils::dataSourceTagIcon().width()); + m_inStyleChangeEvent =3D true; // do not allow KLineEdit::event() to t= ouch the style + setStyle(m_internalStyle); + m_inStyleChangeEvent =3D false; } = KexiDBLineEdit::~KexiDBLineEdit() @@ -342,8 +347,25 @@ void KexiDBLineEdit::paintEvent(QPaintEvent *pe) = bool KexiDBLineEdit::event(QEvent * e) { + if (e->type() =3D=3D QEvent::StyleChange) { + if (m_inStyleChangeEvent) { + return true; + } + // let the KLineEdit set its KLineEditStyle + if (!KLineEdit::event(e)) { + return false; + } + // move the KLineEditStyle inside our internal style as parent + m_internalStyle->setParent(style()); + m_inStyleChangeEvent =3D true; // avoid recursion + setStyle(m_internalStyle); + m_inStyleChangeEvent =3D false; + return true; + } + const bool ret =3D KLineEdit::event(e); KexiDBTextWidgetInterface::event(e, this, text().isEmpty()); + if (e->type() =3D=3D QEvent::FocusOut) { QFocusEvent *fe =3D static_cast(e); if (fe->reason() =3D=3D Qt::TabFocusReason || fe->reason() =3D=3D = Qt::BacktabFocusReason) { diff --git a/kexi/plugins/forms/widgets/kexidblineedit.h b/kexi/plugins/for= ms/widgets/kexidblineedit.h index fbf686a..faf954b 100644 --- a/kexi/plugins/forms/widgets/kexidblineedit.h +++ b/kexi/plugins/forms/widgets/kexidblineedit.h @@ -35,6 +35,7 @@ #include = class KexiDBWidgetContextMenuExtender; +class KexiDBLineEditStyle; = //! @short Line edit widget for Kexi forms /*! Handles many data types. User input is validated by using validators @@ -177,6 +178,8 @@ protected: int m_cursorPosition; QPalette m_originalPalette; //!< Used for read-only case bool m_paletteChangeEvent_enabled; + bool m_inStyleChangeEvent; + QPointer m_internalStyle; }; = #endif