[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [calligra] kexi/plugins/forms/widgets: Kexi Forms: Fix "data source tag" for text box
From:       Jaroslaw Staniek <staniek () kde ! org>
Date:       2012-10-31 23:33:38
Message-ID: 20121031233338.8D27CA6078 () git ! kde ! org
[Download RAW message or body]

Git commit 92c2bb7eca407bc2cfa62cb0576fc4bfe0784808 by Jaroslaw Staniek.
Committed on 31/10/2012 at 18:17.
Pushed by staniek into branch 'master'.

Kexi Forms: Fix "data source tag" for text box

(regression because of changes in KDE libraries' line editor)

REVIEW:107159

M  +27   -5    kexi/plugins/forms/widgets/kexidblineedit.cpp
M  +3    -0    kexi/plugins/forms/widgets/kexidblineedit.h

http://commits.kde.org/calligra/92c2bb7eca407bc2cfa62cb0576fc4bfe0784808

diff --git a/kexi/plugins/forms/widgets/kexidblineedit.cpp \
b/kexi/plugins/forms/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(parentStyle), \
indent(0)  {
     }
+    virtual ~KexiDBLineEditStyle() {
+    }
 
     void setIndent(int indent) {
         this->indent = indent;
     }
 
-    QRect subElementRect(SubElement element, const QStyleOption *option, const \
QWidget *widget) const +    QRect subElementRect(SubElement element, const \
QStyleOption *option, const QWidget *widget = 0) const  {
         const KFormDesigner::FormWidgetInterface *formWidget = dynamic_cast<const \
KFormDesigner::FormWidgetInterface*>(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 = new KexiDBLineEditStyle(style());
-    ks->setParent(this);
-    ks->setIndent(KexiFormUtils::dataSourceTagIcon().width());
-    setStyle( ks );
+    m_internalStyle = new KexiDBLineEditStyle(style());
+    m_internalStyle->setParent(this);
+    m_internalStyle->setIndent(KexiFormUtils::dataSourceTagIcon().width());
+    m_inStyleChangeEvent = true; // do not allow KLineEdit::event() to touch the \
style +    setStyle(m_internalStyle);
+    m_inStyleChangeEvent = false;
 }
 
 KexiDBLineEdit::~KexiDBLineEdit()
@@ -342,8 +347,25 @@ void KexiDBLineEdit::paintEvent(QPaintEvent *pe)
 
 bool KexiDBLineEdit::event(QEvent * e)
 {
+    if (e->type() == 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 = true; // avoid recursion
+        setStyle(m_internalStyle);
+        m_inStyleChangeEvent = false;
+        return true;
+    }
+
     const bool ret = KLineEdit::event(e);
     KexiDBTextWidgetInterface::event(e, this, text().isEmpty());
+
     if (e->type() == QEvent::FocusOut) {
         QFocusEvent *fe = static_cast<QFocusEvent *>(e);
         if (fe->reason() == Qt::TabFocusReason || fe->reason() == \
                Qt::BacktabFocusReason) {
diff --git a/kexi/plugins/forms/widgets/kexidblineedit.h \
b/kexi/plugins/forms/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 <formeditor/FormWidgetInterface.h>
 
 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<KexiDBLineEditStyle> m_internalStyle;
 };
 
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic