[SCM] ktp-accounts-kcm packaging branch, master, updated. debian/15.12.1-1-1157-gc4589c5
Maximiliano Curia
maxy at moszumanska.debian.org
Fri May 27 23:57:29 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-accounts-kcm.git;a=commitdiff;h=4ae5af7
The following commit has been merged in the master branch:
commit 4ae5af710f0ca25894f6305878eaa3f270f9f209
Author: George Goldberg <grundleborg at googlemail.com>
Date: Fri Jul 24 17:09:38 2009 +0000
Add a UnsignedIntegerEdit for editing parameters of type uint.
svn path=/trunk/playground/network/telepathy-accounts-kcm/; revision=1001973
---
src/CMakeLists.txt | 1 +
src/parameter-edit-delegate.cpp | 45 +++++++++++++++++++++-
src/parameter-edit-delegate.h | 1 +
...{integer-edit.cpp => unsigned-integer-edit.cpp} | 31 +++++----------
src/{integer-edit.h => unsigned-integer-edit.h} | 14 +++----
5 files changed, 62 insertions(+), 30 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6ecb496..5a1f29e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -18,6 +18,7 @@ set (telepathy_accounts_kcm_SRCS
parameter-edit-model.cpp
parameter-item.cpp
integer-edit.cpp
+ unsigned-integer-edit.cpp
)
kde4_add_ui_files (telepathy_accounts_kcm_SRCS
diff --git a/src/parameter-edit-delegate.cpp b/src/parameter-edit-delegate.cpp
index d88170a..10aaee4 100644
--- a/src/parameter-edit-delegate.cpp
+++ b/src/parameter-edit-delegate.cpp
@@ -22,6 +22,7 @@
#include "integer-edit.h"
#include "parameter-edit-model.h"
+#include "unsigned-integer-edit.h"
#include <KDebug>
@@ -56,13 +57,17 @@ QList<QWidget*> ParameterEditDelegate::createItemWidgets() const
QLineEdit *lineEdit = new QLineEdit();
QCheckBox *checkBox = new QCheckBox();
IntegerEdit *integerEdit = new IntegerEdit();
+ UnsignedIntegerEdit *unsignedIntegerEdit = new UnsignedIntegerEdit();
// Connect to the slots from the widgets that we are interested in.
connect(lineEdit, SIGNAL(textChanged(QString)), SLOT(onLineEditTextChanged(QString)));
connect(checkBox, SIGNAL(toggled(bool)), SLOT(onCheckBoxToggled(bool)));
connect(integerEdit, SIGNAL(textChanged(QString)), SLOT(onIntegerEditTextChanged(QString)));
+ connect(unsignedIntegerEdit,
+ SIGNAL(textChanged(QString)),
+ SLOT(onUnsignedIntegerEditTextChanged(QString)));
- widgets << nameLabel << lineEdit << checkBox << integerEdit;
+ widgets << nameLabel << lineEdit << checkBox << integerEdit << unsignedIntegerEdit;
return widgets;
}
@@ -85,6 +90,7 @@ void ParameterEditDelegate::updateItemWidgets(const QList<QWidget*> widgets,
QLineEdit *lineEdit = qobject_cast<QLineEdit*>(widgets.at(1));
QCheckBox *checkBox = qobject_cast<QCheckBox*>(widgets.at(2));
IntegerEdit *integerEdit = qobject_cast<IntegerEdit*>(widgets.at(3));
+ UnsignedIntegerEdit *unsignedIntegerEdit = qobject_cast<UnsignedIntegerEdit*>(widgets.at(4));
// See what type the parameter is, and draw the appropriate widget for it.
// FIXME: Support uint types with appropriate validation.
@@ -102,6 +108,7 @@ void ParameterEditDelegate::updateItemWidgets(const QList<QWidget*> widgets,
// to avoid them losing focus (and cursor position) when updating the content of them.
lineEdit->hide();
integerEdit->hide();
+ unsignedIntegerEdit->hide();
} else if (index.model()->data(index, ParameterEditModel::TypeRole).type() == QVariant::Int) {
// Integer type. Draw a integer edit.
@@ -124,6 +131,32 @@ void ParameterEditDelegate::updateItemWidgets(const QList<QWidget*> widgets,
// to avoid them losing focus (and cursor position) when updating the content of them.
lineEdit->hide();
checkBox->hide();
+ unsignedIntegerEdit->hide();
+
+ } else if (index.model()->data(index, ParameterEditModel::TypeRole).type() == QVariant::UInt) {
+ // Integer type. Draw a integer edit.
+ unsignedIntegerEdit->move((right / 2) + margin,
+ (option.rect.height() - unsignedIntegerEdit->size().height()) / 2);
+ unsignedIntegerEdit->resize(QSize(((right - (4 * margin)) / 2),
+ unsignedIntegerEdit->size().height()));
+
+ // Save the cursor position within the widget so we can restore it after altering the data
+ int cursorPosition = unsignedIntegerEdit->cursorPosition();
+
+ // integerEdit->setFocus(Qt::OtherFocusReason);
+ // NB: We must update the value of the widget AFTER setting it as focused, otherwise
+ // focusedItem() returns the wrong value and we end up setting the data of the wrong item
+ // in the model.
+ unsignedIntegerEdit->setText(index.model()->data(index, ParameterEditModel::ValueRole).toString());
+
+ // Restore the cursor position now the data has been changed.
+ unsignedIntegerEdit->setCursorPosition(cursorPosition);
+
+ // Hide all the other input widgets for this item. This must be done in each condition
+ // to avoid them losing focus (and cursor position) when updating the content of them.
+ lineEdit->hide();
+ checkBox->hide();
+ integerEdit->hide();
} else {
// For any other type, treat it as a string type.
@@ -147,6 +180,7 @@ void ParameterEditDelegate::updateItemWidgets(const QList<QWidget*> widgets,
// to avoid them losing focus (and cursor position) when updating the content of them.
checkBox->hide();
integerEdit->hide();
+ unsignedIntegerEdit->hide();
}
}
@@ -213,6 +247,15 @@ void ParameterEditDelegate::onIntegerEditTextChanged(const QString &text)
Q_EMIT dataChanged(index, QVariant(text), ParameterEditModel::ValueRole);
}
+void ParameterEditDelegate::onUnsignedIntegerEditTextChanged(const QString &text)
+{
+ kDebug();
+
+ QModelIndex index = focusedIndex();
+
+ Q_EMIT dataChanged(index, QVariant(text), ParameterEditModel::ValueRole);
+}
+
#include "parameter-edit-delegate.moc"
diff --git a/src/parameter-edit-delegate.h b/src/parameter-edit-delegate.h
index fe1f5bc..2da60fb 100644
--- a/src/parameter-edit-delegate.h
+++ b/src/parameter-edit-delegate.h
@@ -40,6 +40,7 @@ private Q_SLOTS:
void onLineEditTextChanged(QString text);
void onCheckBoxToggled(bool checked);
void onIntegerEditTextChanged(const QString &text);
+ void onUnsignedIntegerEditTextChanged(const QString &text);
Q_SIGNALS:
void dataChanged(const QModelIndex &index, const QVariant &value, int role);
diff --git a/src/integer-edit.cpp b/src/unsigned-integer-edit.cpp
similarity index 71%
copy from src/integer-edit.cpp
copy to src/unsigned-integer-edit.cpp
index 7b5bf08..68c2c90 100644
--- a/src/integer-edit.cpp
+++ b/src/unsigned-integer-edit.cpp
@@ -18,29 +18,29 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "integer-edit.h"
+#include "unsigned-integer-edit.h"
#include <KDebug>
#include <QtGui/QKeyEvent>
-IntegerEdit::IntegerEdit(QWidget *parent)
+UnsignedIntegerEdit::UnsignedIntegerEdit(QWidget *parent)
: QLineEdit(parent)
{
connect(this, SIGNAL(textChanged(QString)), SLOT(onTextChanged(QString)));
}
-IntegerEdit::~IntegerEdit()
+UnsignedIntegerEdit::~UnsignedIntegerEdit()
{
}
-void IntegerEdit::setValue(int integer)
+void UnsignedIntegerEdit::setValue(uint unsignedInteger)
{
- setText(QString::number(integer));
+ setText(QString::number(unsignedInteger));
}
-void IntegerEdit::keyPressEvent(QKeyEvent *event)
+void UnsignedIntegerEdit::keyPressEvent(QKeyEvent *event)
{
kDebug() << "Key:" << event->key() << "Text:" << event->text();
@@ -62,8 +62,7 @@ void IntegerEdit::keyPressEvent(QKeyEvent *event)
// FIXME: Have a better check to make sure the user doesn't enter a number too large.
QString validKeys("0123456789");
if (validKeys.contains(event->text())) {
- if (((text().contains(QString("-"))) && ((text().length() + 1) <= 5)) ||
- ((text().length() + 1) <= 4))
+ if ((text().length() + 1) <= 4)
{
kDebug() << "Key is a number.";
event->ignore();
@@ -72,24 +71,12 @@ void IntegerEdit::keyPressEvent(QKeyEvent *event)
}
}
- // Check for minus sign as the first character
- if (event->text() == QString("-")) {
- if (cursorPosition() == 0) {
- if (!text().contains(QString("-"))) {
- kDebug() << "Key is a minus-sign at the start.";
- event->ignore();
- QLineEdit::keyPressEvent(event);
- return;
- }
- }
- }
-
// Anything else, reject the keypress.
event->accept();
}
-void IntegerEdit::onTextChanged(const QString &text)
+void UnsignedIntegerEdit::onTextChanged(const QString &text)
{
- Q_EMIT integerChanged(text.toInt());
+ Q_EMIT unsignedIntegerChanged(text.toUInt());
}
diff --git a/src/integer-edit.h b/src/unsigned-integer-edit.h
similarity index 75%
copy from src/integer-edit.h
copy to src/unsigned-integer-edit.h
index 85f5cac..8f238fd 100644
--- a/src/integer-edit.h
+++ b/src/unsigned-integer-edit.h
@@ -18,26 +18,26 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef TELEPATHY_ACCOUNTS_KCM_INTEGER_EDIT_H
-#define TELEPATHY_ACCOUNTS_KCM_INTEGER_EDIT_H
+#ifndef TELEPATHY_ACCOUNTS_KCM_UNSIGNED_INTEGER_EDIT_H
+#define TELEPATHY_ACCOUNTS_KCM_UNSIGNED_INTEGER_EDIT_H
#include <QtGui/QLineEdit>
-class IntegerEdit : public QLineEdit
+class UnsignedIntegerEdit : public QLineEdit
{
Q_OBJECT
public:
- explicit IntegerEdit(QWidget *parent = 0);
- virtual ~IntegerEdit();
+ explicit UnsignedIntegerEdit(QWidget *parent = 0);
+ virtual ~UnsignedIntegerEdit();
- void setValue(int integer);
+ void setValue(uint unsignedInteger);
protected:
void keyPressEvent(QKeyEvent *event);
Q_SIGNALS:
- void integerChanged(int integer);
+ void unsignedIntegerChanged(uint unsignedInteger);
private Q_SLOTS:
void onTextChanged(const QString &text);
--
ktp-accounts-kcm packaging
More information about the pkg-kde-commits
mailing list