[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/kexi
From: Jarosław Staniek <staniek () kde ! org>
Date: 2010-05-01 22:12:42
Message-ID: 20100501221242.3B784AC8AA () svn ! kde ! org
[Download RAW message or body]
SVN commit 1121616 by staniek:
Fix display comboboxes, remove related crashes.
M +15 -7 plugins/forms/widgets/kexidbautofield.cpp
M +4 -4 plugins/forms/widgets/kexidbautofield.h
M +38 -20 plugins/forms/widgets/kexidbcombobox.cpp
M +1 -1 plugins/forms/widgets/kexidbcombobox.h
M +12 -2 widget/tableview/kexicomboboxbase.cpp
M +3 -1 widget/tableview/kexicomboboxpopup.cpp
M +2 -2 widget/tableview/kexitableview.cpp
--- trunk/koffice/kexi/plugins/forms/widgets/kexidbautofield.cpp #1121615:1121616
@@ -145,15 +145,19 @@
}
QWidget *newSubwidget;
+ kDebug() << "widgetType:" << d->widgetType;
switch (d->widgetType) {
case Text:
case Double: //! @todo setup validator
case Integer: //! @todo setup validator
case Date:
case Time:
- case DateTime:
- newSubwidget = new KexiDBLineEdit(this);
+ case DateTime: {
+ KexiDBLineEdit *le = new KexiDBLineEdit(this);
+ newSubwidget = le;
+ le->setFrame(false);
break;
+ }
case MultiLineText:
newSubwidget = new KexiDBTextEdit(this);
break;
@@ -176,6 +180,7 @@
break;
}
+ kDebug() << newSubwidget;
setSubwidget(newSubwidget); //this will also allow to declare subproperties, \
see KFormDesigner::WidgetWithSubpropertiesInterface if (newSubwidget) {
newSubwidget->setObjectName(
@@ -199,6 +204,7 @@
newSubwidget->setPalette(qApp->palette());
copyPropertiesToEditor();
// KFormDesigner::installRecursiveEventFilter(newSubwidget, this);
+// newSubwidget->hide();
}
setLabelPosition(labelPosition());
@@ -206,6 +212,7 @@
void KexiDBAutoField::copyPropertiesToEditor()
{
+ kDebug() << m_subwidget;
if (m_subwidget) {
// kDebug() << "base col: " << d->baseColor.name() <<
// "; text col: " << d->textColor.name();
@@ -710,7 +717,7 @@
// ===== methods below are just proxies for the internal editor or label =====
-const QColor & KexiDBAutoField::paletteForegroundColor() const
+QColor KexiDBAutoField::paletteForegroundColor() const
{
//! @todo how about brush?
return d->textBrush.color();
@@ -723,7 +730,7 @@
copyPropertiesToEditor();
}
-const QColor & KexiDBAutoField::paletteBackgroundColor() const
+QColor KexiDBAutoField::paletteBackgroundColor() const
{
//! @todo how about brush?
return d->baseBrush.color();
@@ -731,12 +738,13 @@
void KexiDBAutoField::setPaletteBackgroundColor(const QColor & color)
{
+ kDebug();
//! @todo how about brush?
d->baseBrush.setColor(color);
copyPropertiesToEditor();
}
-const QColor & KexiDBAutoField::foregroundLabelColor() const
+QColor KexiDBAutoField::foregroundLabelColor() const
{
if (d->widgetType == Boolean)
return paletteForegroundColor();
@@ -761,12 +769,12 @@
}
}
-const QColor & KexiDBAutoField::backgroundLabelColor() const
+QColor KexiDBAutoField::backgroundLabelColor() const
{
if (d->widgetType == Boolean)
return paletteBackgroundColor();
- return d->label->paletteBackgroundColor();
+ return d->label->palette().color(d->label->backgroundRole());
}
void KexiDBAutoField::setBackgroundLabelColor(const QColor & color)
--- trunk/koffice/kexi/plugins/forms/widgets/kexidbautofield.h #1121615:1121616
@@ -144,25 +144,25 @@
virtual void setFocusPolicy(Qt::FocusPolicy policy);
//! Reimplemented to return internal editor's color.
- const QColor & paletteForegroundColor() const;
+ QColor paletteForegroundColor() const;
//! Reimplemented to set internal editor's color.
void setPaletteForegroundColor(const QColor & color);
//! Reimplemented to return internal editor's color.
- const QColor & paletteBackgroundColor() const;
+ QColor paletteBackgroundColor() const;
//! Reimplemented to set internal editor's color.
virtual void setPaletteBackgroundColor(const QColor & color);
//! \return label's foreground color
- const QColor & foregroundLabelColor() const;
+ QColor foregroundLabelColor() const;
//! Sets label's foreground color
virtual void setForegroundLabelColor(const QColor & color);
//! \return label's background color
- const QColor & backgroundLabelColor() const;
+ QColor backgroundLabelColor() const;
//! Sets label's background color
virtual void setBackgroundLabelColor(const QColor & color);
--- trunk/koffice/kexi/plugins/forms/widgets/kexidbcombobox.cpp #1121615:1121616
@@ -120,14 +120,28 @@
void KexiDBComboBox::paintEvent(QPaintEvent *)
{
QPainter p(this);
- QColorGroup cg(palette().active());
+ p.setPen(palette().color(QPalette::Text));
+// QColorGroup cg(palette().active());
// if ( hasFocus() )
// cg.setColor(QColorGroup::Base, cg.highlight());
// else
- cg.setColor(QColorGroup::Base, paletteBackgroundColor()); //update base color \
using (reimplemented) bg color
- p.setPen(cg.text());
+ QPalette pal(palette());
+ pal.setColor(QColorGroup::Base, paletteBackgroundColor()); //update base color \
using (reimplemented) bg color
+ if (width() < 5 || height() < 5) {
+ qDrawShadePanel(&p, rect(), pal, false /* !sunken */,
+ 2 /*line width*/, &pal.brush(QPalette::Button)/*fill*/);
+ return;
+ }
+
+#ifdef __GNUC__
+#warning TODO KexiDBComboBox::paintEvent()
+#else
+#pragma WARNING( TODO KexiDBComboBox::paintEvent() )
+#endif
+
QStyleOptionComboBox option;
+ option.palette = pal;
option.initFrom(d->paintedCombo);
if (isEnabled())
@@ -137,16 +151,8 @@
if (d->mouseOver)
option.state |= QStyle::State_MouseOver;
- if (width() < 5 || height() < 5) {
- qDrawShadePanel(&p, rect(), cg, false, 2, &cg.brush(QColorGroup::Button));
- return;
- }
+ style()->drawComplexControl(QStyle::CC_ComboBox, &option, &p, d->paintedCombo);
-#ifdef __GNUC__
-#warning TODO KexiDBComboBox::paintEvent()
-#else
-#pragma WARNING( TODO KexiDBComboBox::paintEvent() )
-#endif
#if 0 //TODO
//! @todo support reverse layout
//bool reverse = QApplication::reverseLayout();
@@ -200,11 +206,21 @@
if (m_subwidget) {
m_subwidget->setGeometry(editorGeometry());
if (!d->isEditable) {
+ QStyleOptionComboBox option;
+ option.initFrom(m_subwidget);
+ const QRect comboRect = m_subwidget->style()->subControlRect(
+ QStyle::CC_ComboBox, &option, QStyle::SC_ComboBoxEditField, \
m_subwidget); + kDebug() << "comboRect:" << comboRect;
+ m_subwidget->setContentsMargins(comboRect.left(), comboRect.top(),
+ width() - comboRect.right(), height() - comboRect.bottom());
+ int l, t, r, b;
+ m_subwidget->getContentsMargins(&l, &t, &r, &b);
+ kDebug() << "altered margins:" << l << t << r << b;
+
+ m_subwidget->setFocusPolicy(Qt::NoFocus);
m_subwidget->setCursor(QCursor(Qt::ArrowCursor)); // widgets like \
listedit have IbeamCursor, we don't want that
-//! @todo Qt4: set transparent background, for now we're setting button color
QPalette subwidgetPalette(m_subwidget->palette());
- subwidgetPalette.setColor(QPalette::Active, QColorGroup::Base,
- subwidgetPalette.color(QPalette::Active, \
QColorGroup::Button)); + subwidgetPalette.setColor(QColorGroup::Base, \
Qt::transparent); m_subwidget->setPalette(subwidgetPalette);
d->subWidgetsWithDisabledEvents.clear();
d->subWidgetsWithDisabledEvents << m_subwidget;
@@ -379,11 +395,12 @@
return true;
} else if (e->type() == QEvent::FocusOut) {
if (popup() && popup()->isVisible()) {
- popup()->hide();
- undoChanges();
+// popup()->hide();
+// undoChanges();
}
}
} else if (!d->isEditable && \
d->subWidgetsWithDisabledEvents.contains(dynamic_cast<QWidget*>(o))) { + \
kDebug() << "**********************####" << e->type() << o; if (e->type() == \
QEvent::MouseButtonPress) {
// clicking the subwidget should mean the same as clicking the combo box \
(i.e. show the popup) if (handleMousePressEvent(static_cast<QMouseEvent*>(e)))
@@ -392,7 +409,8 @@
if (handleKeyPressEvent(static_cast<QKeyEvent*>(e)))
return true;
}
- return e->type() != QEvent::Paint;
+ if (e->type() != QEvent::Paint)
+ return true;
}
return KexiDBAutoField::eventFilter(o, e);
}
@@ -406,10 +424,10 @@
void KexiDBComboBox::setPaletteBackgroundColor(const QColor & color)
{
KexiDBAutoField::setPaletteBackgroundColor(color);
- QPalette pal(palette());
+/* QPalette pal(palette());
QColorGroup cg(pal.active());
pal.setActive(cg);
- QWidget::setPalette(pal);
+ QWidget::setPalette(pal);*/
update();
}
--- trunk/koffice/kexi/plugins/forms/widgets/kexidbcombobox.h #1121615:1121616
@@ -86,7 +86,7 @@
Reimplemented. */
virtual KexiDB::QueryColumnInfo* visibleColumnInfo() const;
- const QColor & paletteBackgroundColor() const {
+ QColor paletteBackgroundColor() const {
return KexiDBAutoField::paletteBackgroundColor();
}
--- trunk/koffice/kexi/widget/tableview/kexicomboboxbase.cpp #1121615:1121616
@@ -334,11 +334,13 @@
void KexiComboBoxBase::showPopup()
{
+ kDebug(44010);
createPopup(true);
}
void KexiComboBoxBase::createPopup(bool show)
{
+ kDebug() << show << field() << popup() << m_updatePopupSelectionOnShow;
if (!field())
return;
m_insideCreatePopup = true;
@@ -369,12 +371,16 @@
QPoint posMappedToGlobal = mapFromParentToGlobal(thisWidget->pos());
if (posMappedToGlobal != QPoint(-1, -1)) {
//! todo alter the position to fit the popup within screen boundaries
+ popup()->hide();
popup()->move(posMappedToGlobal + QPoint(0, thisWidget->height()));
+ kDebug() << "pos:" << posMappedToGlobal + QPoint(0, thisWidget->height());
//to avoid flickering: first resize to 0-height, then show and resize back \
to prev. height const int w = popupWidthHint();
popup()->resize(w, 0);
- if (show)
+ if (show) {
popup()->show();
+ kDebug(44010) << "SHOW!!!";
+ }
popup()->updateSize(w);
if (m_updatePopupSelectionOnShow) {
int rowToHighlight = -1;
@@ -409,7 +415,11 @@
moveCursorToEndInInternalEditor();
selectAllInInternalEditor();
widgetToFocus->setFocus();
+ popup()->show();
+ popup()->raise();
+ popup()->repaint();
}
+ kDebug(44010) << popup()->isVisible();
m_insideCreatePopup = false;
}
@@ -443,7 +453,7 @@
void KexiComboBoxBase::slotItemSelected(KexiDB::RecordData*)
{
- kDebug() << "m_visibleValue=" << m_visibleValue;
+ kDebug(44010) << "m_visibleValue=" << m_visibleValue;
QVariant valueToSet;
KexiTableViewData *relData = column() ? column()->relatedData() : 0;
--- trunk/koffice/kexi/widget/tableview/kexicomboboxpopup.cpp #1121615:1121616
@@ -350,10 +350,12 @@
bool KexiComboBoxPopup::eventFilter(QObject *o, QEvent *e)
{
if (o == this && e->type() == QEvent::Hide) {
+ kDebug(44010) << "HIDE!!!";
emit hidden();
} else if (e->type() == QEvent::MouseButtonPress) {
- kDebug() << "QEvent::MousePress";
+ kDebug(44010) << "QEvent::MousePress";
} else if (o == d->tv) {
+ kDebug(44010) << "QEvent::KeyPress TV";
if (e->type() == QEvent::KeyPress) {
QKeyEvent *ke = static_cast<QKeyEvent*>(e);
const int k = ke->key();
--- trunk/koffice/kexi/widget/tableview/kexitableview.cpp #1121615:1121616
@@ -665,11 +665,11 @@
void KexiTableView::drawContents(QPainter *p, int cx, int cy, int cw, int ch)
{
+ kDebug() << "disable" << d->disableDrawContents << "cx" << cx << "cy" << cy << \
"cw" << cw << "ch" << ch; +
if (d->disableDrawContents)
return;
-//kDebug() << "cx" << cx << "cy" << cy << "cw" << cw << "ch" << ch;
-
bool paintOnlyInsertRow = false;
bool inserting = isInsertingEnabled();
bool plus1row = false; //true if we should show 'inserting' row at the end
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic