[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: 2009-10-30 20:58:25
Message-ID: 1256936305.204836.8930.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1042842 by staniek:
Forms
*restore focus to the recently focused widget after clicking on the record navigator
*select widget contents (usually text) after moving to other record or moving to \
other field using tab/backtab
*set focus policy to "no" for forms themselves and the record navigator widget
M +7 -1 plugins/forms/kexiformdataiteminterface.cpp
M +6 -1 plugins/forms/kexiformdataiteminterface.h
M +10 -0 plugins/forms/kexiformscrollview.cpp
M +10 -3 plugins/forms/widgets/kexidbform.cpp
M +1 -0 widget/utils/kexirecordnavigator.cpp
--- trunk/koffice/kexi/plugins/forms/kexiformdataiteminterface.cpp #1042841:1042842
@@ -1,5 +1,5 @@
/* This file is part of the KDE project
- Copyright (C) 2005-2006 Jarosław Staniek <staniek@kde.org>
+ Copyright (C) 2005-2009 Jarosław Staniek <staniek@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -66,3 +66,9 @@
if (view)
view->cancelEditor();
}
+
+void KexiFormDataItemInterface::selectAllOnFocusIfNeeded()
+{
+ moveCursorToEnd();
+ selectAll();
+}
--- trunk/koffice/kexi/plugins/forms/kexiformdataiteminterface.h #1042841:1042842
@@ -1,5 +1,5 @@
/* This file is part of the KDE project
- Copyright (C) 2005-2006 Jarosław Staniek <staniek@kde.org>
+ Copyright (C) 2005-2009 Jarosław Staniek <staniek@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -155,6 +155,11 @@
Q_UNUSED(ke); return false;
}
+ //! Selects contents of the widget if there is such behaviour set (it is by \
default). +//! @todo add option for not selecting the field
+
+ void selectAllOnFocusIfNeeded();
+
protected:
QString m_dataSource;
QString m_dataSourcePartClass;
--- trunk/koffice/kexi/plugins/forms/kexiformscrollview.cpp #1042841:1042842
@@ -103,6 +103,16 @@
if (m_currentItem != m_previousRecord) {
fillDataItems(*m_currentItem, cursorAtNewRow());
m_previousRecord = m_currentItem;
+ QWidget *w = dbFormWidget()->orderedDataAwareWidgets()->at(m_curCol);
+ if (w) {
+ w->setFocus(); // re-focus, as we could have lost focus, e.g. when \
navigator button was clicked + // select all
+ KexiFormDataItemInterface *iface = \
dynamic_cast<KexiFormDataItemInterface*>(w); +//! @todo add option for not selecting \
the field + if (iface) {
+ iface->selectAllOnFocusIfNeeded();
+ }
+ }
}
} else {
m_previousRecord = 0;
--- trunk/koffice/kexi/plugins/forms/widgets/kexidbform.cpp #1042841:1042842
@@ -127,6 +127,7 @@
setCursor(QCursor(Qt::ArrowCursor)); //to avoid keeping Size cursor when moving \
from form's boundaries setAcceptDrops(true);
setAutoFillBackground(true);
+ setFocusPolicy(Qt::NoFocus);
}
KexiDBForm::~KexiDBForm()
@@ -492,6 +493,8 @@
if (widgetToFocus) {
widgetToFocus->setFocus();
+ if (dynamic_cast<KexiFormDataItemInterface*>(widgetToFocus))
+ \
dynamic_cast<KexiFormDataItemInterface*>(widgetToFocus)->selectAllOnFocusIfNeeded(); \
} else {
kWarning() << "widgetToFocus not found!";
@@ -556,7 +559,7 @@
} else {//backtab
if (d->orderedFocusWidgets.last() && realWidget == \
d->orderedFocusWidgets.first()) { d->orderedFocusWidgetsIterator
- = d->orderedFocusWidgets.begin() + \
(d->orderedFocusWidgets.count() - 1); + = \
d->orderedFocusWidgets.begin() + (d->orderedFocusWidgets.count() - \
1);
} else if (realWidget == *d->orderedFocusWidgetsIterator) {
--d->orderedFocusWidgetsIterator; //prev
} else {
@@ -573,8 +576,8 @@
"KFormDesigner::TabWidget",
pageFor_widgetToFocus
);
- if (tabWidgetFor_widgetToFocus
- && tabWidgetFor_widgetToFocus->currentWidget() != \
pageFor_widgetToFocus) + if ( tabWidgetFor_widgetToFocus
+ && tabWidgetFor_widgetToFocus->currentWidget() != \
pageFor_widgetToFocus) {
realWidget = widgetToFocus;
continue; // the new widget to focus is placed on invisible \
tab page: @@ -583,6 +586,8 @@
break;
}//while
+ QWidget *widgetToSelectAll = widgetToFocus;
+
//set focus, but don't use just setFocus() because certain widgets
//behaves differently (e.g. QLineEdit calls selectAll()) when
//focus event's reason is Qt::TabFocusReason
@@ -605,6 +610,8 @@
kDebug() << "focusing "
<< (*d->orderedFocusWidgetsIterator)->objectName();
}
+ if (dynamic_cast<KexiFormDataItemInterface*>(widgetToSelectAll))
+ \
dynamic_cast<KexiFormDataItemInterface*>(widgetToSelectAll)->selectAllOnFocusIfNeeded();
}
return true;
}
--- trunk/koffice/kexi/widget/utils/kexirecordnavigator.cpp #1042841:1042842
@@ -91,6 +91,7 @@
, d(new Private)
{
setAutoFillBackground(true);
+ setFocusPolicy(Qt::NoFocus);
if (parentView)
setParentView(parentView);
d->lyr = new QHBoxLayout(this);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic