[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:58:21 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-accounts-kcm.git;a=commitdiff;h=bf527f6
The following commit has been merged in the master branch:
commit bf527f62f5d01c0fb725e9fc8a614ee1a4e922be
Author: Gustavo P. Boiko <gustavo.boiko at kdemail.net>
Date: Mon Oct 4 17:40:06 2010 +0000
Remove the custom integer editting widgets. They were replaced by standard
spinboxes
svn path=/trunk/playground/network/telepathy-accounts-kcm/; revision=1182474
---
src/KCMTelepathyAccounts/CMakeLists.txt | 6 --
src/KCMTelepathyAccounts/include/IntegerEdit | 7 --
.../include/UnsignedIntegerEdit | 7 --
src/KCMTelepathyAccounts/integer-edit.cpp | 89 ------------------
src/KCMTelepathyAccounts/integer-edit.h | 55 -----------
.../parameter-edit-delegate.cpp | 104 ++++++---------------
src/KCMTelepathyAccounts/parameter-edit-delegate.h | 3 +-
7 files changed, 28 insertions(+), 243 deletions(-)
diff --git a/src/KCMTelepathyAccounts/CMakeLists.txt b/src/KCMTelepathyAccounts/CMakeLists.txt
index 307a331..a74ae27 100644
--- a/src/KCMTelepathyAccounts/CMakeLists.txt
+++ b/src/KCMTelepathyAccounts/CMakeLists.txt
@@ -9,8 +9,6 @@ set (libkcmtelepathyaccounts_SRCS
abstract-account-ui.cpp
abstract-account-parameters-widget.cpp
account-edit-widget.cpp
- integer-edit.cpp
- unsigned-integer-edit.cpp
protocol-select-widget.cpp
protocol-list-model.cpp
connection-manager-item.cpp
@@ -29,8 +27,6 @@ set (libkcmtelepathyaccounts_HDRS
abstract-account-parameters-widget.h
account-edit-widget.h
plugin-macros.h
- integer-edit.h
- unsigned-integer-edit.h
connection-manager-item.h
plugin-manager.h
protocol-select-widget.h
@@ -44,8 +40,6 @@ set (libkcmtelepathyaccounts_PRETTY_HDRS
include/AbstractAccountParametersWidget
include/AccountEditWidget
include/PluginMacros
- include/IntegerEdit
- include/UnsignedIntegerEdit
include/ConnectionManagerItem
include/PluginManager
include/ProtocolSelectWidget
diff --git a/src/KCMTelepathyAccounts/include/IntegerEdit b/src/KCMTelepathyAccounts/include/IntegerEdit
deleted file mode 100644
index de11179..0000000
--- a/src/KCMTelepathyAccounts/include/IntegerEdit
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef LIB_KCM_TELEPATHY_ACCOUNTS_INTEGER_EDIT_PRETTY_H
-#define LIB_KCM_TELEPATHY_ACCOUNTS_INTEGER_EDIT_PRETTY_H
-
-#include <KCMTelepathyAccounts/integer-edit.h>
-
-#endif
-
diff --git a/src/KCMTelepathyAccounts/include/UnsignedIntegerEdit b/src/KCMTelepathyAccounts/include/UnsignedIntegerEdit
deleted file mode 100644
index 56ba91e..0000000
--- a/src/KCMTelepathyAccounts/include/UnsignedIntegerEdit
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef LIB_KCM_TELEPATHY_ACCOUNTS_UNSIGNED_INTEGER_EDIT_PRETTY_H
-#define LIB_KCM_TELEPATHY_ACCOUNTS_UNSIGNED_INTEGER_EDIT_PRETTY_H
-
-#include <KCMTelepathyAccounts/unsigned-integer-edit.h>
-
-#endif
-
diff --git a/src/KCMTelepathyAccounts/integer-edit.cpp b/src/KCMTelepathyAccounts/integer-edit.cpp
deleted file mode 100644
index c2b541a..0000000
--- a/src/KCMTelepathyAccounts/integer-edit.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * This file is part of telepathy-accounts-kcm
- *
- * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "integer-edit.h"
-
-#include <KDebug>
-
-#include <QtGui/QIntValidator>
-
-IntegerEdit::IntegerEdit(QWidget *parent)
- : QLineEdit(parent)
-{
- connect(this, SIGNAL(textChanged(QString)), SLOT(onTextChanged(QString)));
-
- // Set the validator range to the range of values in a 32 bit integer (dbus-type 'i').
- setValidator(new QIntValidator(-2147483648, 2147483647, this));
-}
-
-IntegerEdit::~IntegerEdit()
-{
-
-}
-
-qint32 IntegerEdit::value() const
-{
- return text().toInt();
-}
-
-void IntegerEdit::setValue(qint32 integer)
-{
- setText(QString::number(integer));
-}
-
-QValidator::State IntegerEdit::validity() const
-{
- int cursorPos = cursorPosition();
- QString txt = text();
- return validator()->validate(txt, cursorPos);
-}
-
-QPair<qint32, qint32> IntegerEdit::validRange() const
-{
- QPair<qint32, qint32> ret;
- ret.first = 0;
- ret.second = 0;
-
- const QIntValidator *intValidator = qobject_cast<const QIntValidator*>(validator());
-
- if (!intValidator) {
- kWarning() << "Somehow this is not an int validator :/";
- return ret;
- }
-
- ret.first = intValidator->bottom();
- ret.second = intValidator->top();
-
- return ret;
-}
-
-void IntegerEdit::setValidRange(qint32 minimum, qint32 maximum)
-{
- setValidator(new QIntValidator(static_cast<int>(minimum), static_cast<int>(maximum), this));
-}
-
-void IntegerEdit::onTextChanged(const QString &text)
-{
- Q_EMIT integerChanged(text.toInt());
-}
-
-
-#include "integer-edit.moc"
-
diff --git a/src/KCMTelepathyAccounts/integer-edit.h b/src/KCMTelepathyAccounts/integer-edit.h
deleted file mode 100644
index 7d4c0d9..0000000
--- a/src/KCMTelepathyAccounts/integer-edit.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * This file is part of telepathy-accounts-kcm
- *
- * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef LIB_KCM_TELEPATHY_ACCOUNTS_INTEGER_EDIT_H
-#define LIB_KCM_TELEPATHY_ACCOUNTS_INTEGER_EDIT_H
-
-#include <kdemacros.h>
-
-#include <QtCore/QPair>
-#include <QtGui/QLineEdit>
-#include <QtGui/QValidator>
-
-class KDE_EXPORT IntegerEdit : public QLineEdit
-{
- Q_OBJECT
-
-public:
- explicit IntegerEdit(QWidget *parent = 0);
- virtual ~IntegerEdit();
-
- qint32 value() const;
- void setValue(qint32 integer);
-
- QValidator::State validity() const;
-
- QPair<qint32, qint32> validRange() const;
- void setValidRange(qint32 minimum, qint32 maximum);
-
-Q_SIGNALS:
- void integerChanged(qint32 integer);
-
-private Q_SLOTS:
- void onTextChanged(const QString &text);
-};
-
-
-#endif // header guard
-
diff --git a/src/KCMTelepathyAccounts/parameter-edit-delegate.cpp b/src/KCMTelepathyAccounts/parameter-edit-delegate.cpp
index edbf14e..057a76d 100644
--- a/src/KCMTelepathyAccounts/parameter-edit-delegate.cpp
+++ b/src/KCMTelepathyAccounts/parameter-edit-delegate.cpp
@@ -21,8 +21,6 @@
#include "parameter-edit-delegate.h"
#include "parameter-edit-model.h"
-#include "integer-edit.h"
-#include "unsigned-integer-edit.h"
#include <KDebug>
@@ -30,6 +28,7 @@
#include <QtGui/QCheckBox>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
+#include <QtGui/QSpinBox>
#include <QtGui/QPainter>
ParameterEditDelegate::ParameterEditDelegate(QAbstractItemView *itemView, QObject *parent)
@@ -56,18 +55,17 @@ QList<QWidget*> ParameterEditDelegate::createItemWidgets() const
QLabel *nameLabel = new QLabel();
QLineEdit *lineEdit = new QLineEdit();
QCheckBox *checkBox = new QCheckBox();
- IntegerEdit *integerEdit = new IntegerEdit();
- UnsignedIntegerEdit *unsignedIntegerEdit = new UnsignedIntegerEdit();
+ QSpinBox *spinBox = new QSpinBox();
+
+ // sets the maximum value. the minimum will be set according to the item type
+ spinBox->setMaximum(2147483647);
// 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)));
+ connect(spinBox, SIGNAL(valueChanged(int)), SLOT(onSpinBoxValueChanged(int)));
- widgets << nameLabel << lineEdit << checkBox << integerEdit << unsignedIntegerEdit;
+ widgets << nameLabel << lineEdit << checkBox << spinBox;
return widgets;
}
@@ -89,12 +87,13 @@ void ParameterEditDelegate::updateItemWidgets(const QList<QWidget*> widgets,
// Get all the optional input 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));
+ QSpinBox *spinBox = qobject_cast<QSpinBox*>(widgets.at(3));
// See what type the parameter is, and draw the appropriate widget for it.
// FIXME: Support uint types with appropriate validation.
- if (index.model()->data(index, ParameterEditModel::TypeRole).type() == QVariant::Bool) {
+ QVariant::Type type = index.data(ParameterEditModel::TypeRole).type();
+
+ if (type == QVariant::Bool) {
// Bool type. Draw a checkbox.
checkBox->move((right / 2) + margin, (option.rect.height() - checkBox->size().height()) / 2);
@@ -107,56 +106,29 @@ void ParameterEditDelegate::updateItemWidgets(const QList<QWidget*> widgets,
// 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();
- integerEdit->hide();
- unsignedIntegerEdit->hide();
+ spinBox->hide();
- } else if (index.model()->data(index, ParameterEditModel::TypeRole).type() == QVariant::Int) {
- // Integer type. Draw a integer edit.
- integerEdit->move((right / 2) + margin, (option.rect.height() - integerEdit->size().height()) / 2);
- integerEdit->resize(QSize(((right - (4 * margin)) / 2), integerEdit->size().height()));
+ } else if (type == QVariant::Int || type == QVariant::UInt) {
+ // Integer type. Draw a spinBox
+ spinBox->move((right / 2) + margin, (option.rect.height() - spinBox->size().height()) / 2);
+ spinBox->resize(QSize(((right - (4 * margin)) / 2), spinBox->size().height()));
- // Save the cursor position within the widget so we can restore it after altering the data
- int cursorPosition = integerEdit->cursorPosition();
+ // set the minimum value of the spinbox depending on whether it is signed or not
+ if (type == QVariant::UInt)
+ spinBox->setMinimum(0);
+ else
+ spinBox->setMinimum(-2147483648);
- integerEdit->setFocus(Qt::OtherFocusReason);
+ spinBox->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.
- integerEdit->setText(index.model()->data(index, ParameterEditModel::ValueRole).toString());
-
- // Restore the cursor position now the data has been changed.
- integerEdit->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();
- 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);
+ spinBox->setValue(index.data(ParameterEditModel::ValueRole).toString().toInt());
// 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.
@@ -184,9 +156,7 @@ void ParameterEditDelegate::updateItemWidgets(const QList<QWidget*> widgets,
// 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.
checkBox->hide();
- integerEdit->hide();
- unsignedIntegerEdit->hide();
-
+ spinBox->hide();
}
}
@@ -243,28 +213,9 @@ void ParameterEditDelegate::onCheckBoxToggled(bool checked)
Q_EMIT dataChanged(index, QVariant(checked), ParameterEditModel::ValueRole);
}
-void ParameterEditDelegate::onIntegerEditTextChanged(const QString &text)
-{
- kDebug();
-
- IntegerEdit *widget = qobject_cast<IntegerEdit*>(sender());
-
- if (!widget) {
- kWarning() << "Slot called by object of the wrong type.";
- return;
- }
-
- QModelIndex index = focusedIndex();
-
- Q_EMIT dataChanged(index, QVariant(text), ParameterEditModel::ValueRole);
- Q_EMIT dataChanged(index, QVariant(widget->validity()), ParameterEditModel::ValidityRole);
-}
-
-void ParameterEditDelegate::onUnsignedIntegerEditTextChanged(const QString &text)
+void ParameterEditDelegate::onSpinBoxValueChanged(int value)
{
- kDebug();
-
- UnsignedIntegerEdit *widget = qobject_cast<UnsignedIntegerEdit*>(sender());
+ QSpinBox *widget = qobject_cast<QSpinBox*>(sender());
if (!widget) {
kWarning() << "Slot called by object of the wrong type.";
@@ -273,8 +224,7 @@ void ParameterEditDelegate::onUnsignedIntegerEditTextChanged(const QString &text
QModelIndex index = focusedIndex();
- Q_EMIT dataChanged(index, QVariant(text), ParameterEditModel::ValueRole);
- Q_EMIT dataChanged(index, QVariant(widget->validity()), ParameterEditModel::ValidityRole);
+ Q_EMIT dataChanged(index, QVariant(QString::number(value)), ParameterEditModel::ValueRole);
}
diff --git a/src/KCMTelepathyAccounts/parameter-edit-delegate.h b/src/KCMTelepathyAccounts/parameter-edit-delegate.h
index 2da60fb..1e58874 100644
--- a/src/KCMTelepathyAccounts/parameter-edit-delegate.h
+++ b/src/KCMTelepathyAccounts/parameter-edit-delegate.h
@@ -39,8 +39,7 @@ public:
private Q_SLOTS:
void onLineEditTextChanged(QString text);
void onCheckBoxToggled(bool checked);
- void onIntegerEditTextChanged(const QString &text);
- void onUnsignedIntegerEditTextChanged(const QString &text);
+ void onSpinBoxValueChanged(int value);
Q_SIGNALS:
void dataChanged(const QModelIndex &index, const QVariant &value, int role);
--
ktp-accounts-kcm packaging
More information about the pkg-kde-commits
mailing list