[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:51 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-accounts-kcm.git;a=commitdiff;h=65f7f02
The following commit has been merged in the master branch:
commit 65f7f026de31db2f4e66d90be6adb6df3f77f031
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Wed Jan 12 01:04:34 2011 +0000
Update model with checkbox state changes.
---
src/accounts-list-delegate.cpp | 12 ++++++++++--
src/accounts-list-delegate.h | 4 ++++
src/accounts-list-model.cpp | 6 ++++--
src/kcm-telepathy-accounts.cpp | 9 ++++++++-
src/kcm-telepathy-accounts.h | 2 ++
5 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/src/accounts-list-delegate.cpp b/src/accounts-list-delegate.cpp
index 0779561..2d03e48 100644
--- a/src/accounts-list-delegate.cpp
+++ b/src/accounts-list-delegate.cpp
@@ -26,22 +26,30 @@ QSize AccountsListDelegate::sizeHint(const QStyleOptionViewItem &option, const Q
QList<QWidget*> AccountsListDelegate::createItemWidgets() const
{
QCheckBox *checkbox = new QCheckBox();
+ connect(checkbox, SIGNAL(clicked(bool)), SLOT(onCheckBoxToggled(bool)));
return QList<QWidget*>() << checkbox;
}
void AccountsListDelegate::updateItemWidgets(const QList<QWidget *> widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const
{
- QWidget* checkbox = widgets.at(0);
+ QCheckBox* checkbox = qobject_cast<QCheckBox*>(widgets.at(0));
if (checkbox) {
int topMargin = (option.rect.height() - checkbox->height()) / 2;
checkbox->move(m_paddingSize, topMargin);
+ checkbox->setChecked(index.data(Qt::CheckStateRole).toBool());
}
else {
kDebug() << "checkbox widget pointer is null..";
}
}
+void AccountsListDelegate::onCheckBoxToggled(bool checked)
+{
+ QModelIndex index = focusedIndex();
+ emit dataChanged(index, QVariant((checked ? Qt::Checked : Qt::Unchecked)), Qt::CheckStateRole);
+}
+
void AccountsListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
@@ -69,7 +77,7 @@ void AccountsListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
QRect checkBoxRect(0, innerRect.top(), checkBoxSize.width(), innerRect.height());
QRect decorationRect(checkBoxRect.right(), innerRect.top(), decorationSize.width(), innerRect.height());
- QRect statusTextRect(option.rect.right() - statusTextSize.width(), innerRect.top(), statusTextSize.width(), innerRect.height());
+ QRect statusTextRect(innerRect.right() - statusTextSize.width(), innerRect.top(), statusTextSize.width(), innerRect.height());
QRect statusIconRect(statusTextRect.left() - statusIconSize.width() -2, innerRect.top(), statusIconSize.width(), innerRect.height());
QRect mainTextRect(decorationRect.topRight() + QPoint(m_paddingSize,0), statusIconRect.bottomLeft());
diff --git a/src/accounts-list-delegate.h b/src/accounts-list-delegate.h
index 20a7b04..be06118 100644
--- a/src/accounts-list-delegate.h
+++ b/src/accounts-list-delegate.h
@@ -17,11 +17,15 @@ public:
void updateItemWidgets(const QList<QWidget *> widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const;
signals:
+ void dataChanged(const QModelIndex &index, const QVariant &value, int role);
public slots:
private:
static const int m_paddingSize = 7;
+
+private slots:
+ void onCheckBoxToggled(bool checked);
};
#endif // ACCOUNTLISTDELEGATE_H
diff --git a/src/accounts-list-model.cpp b/src/accounts-list-model.cpp
index 4db4f5a..165a329 100644
--- a/src/accounts-list-model.cpp
+++ b/src/accounts-list-model.cpp
@@ -100,8 +100,10 @@ bool AccountsListModel::setData(const QModelIndex &index, const QVariant &value,
{
kDebug();
if(role == Qt::CheckStateRole) {
- m_accounts.at(index.row())->account()->setEnabled(value.toInt() == Qt::Checked);
- return true;
+ if(m_accounts.at(index.row())->account()) {
+ m_accounts.at(index.row())->account()->setEnabled(value.toInt() == Qt::Checked);
+ return true;
+ }
}
return false;
}
diff --git a/src/kcm-telepathy-accounts.cpp b/src/kcm-telepathy-accounts.cpp
index fe85387..bdbb356 100644
--- a/src/kcm-telepathy-accounts.cpp
+++ b/src/kcm-telepathy-accounts.cpp
@@ -81,7 +81,9 @@ KCMTelepathyAccounts::KCMTelepathyAccounts(QWidget *parent, const QVariantList&
m_ui->accountsListView->setItemDelegate(delegate);
- // Connect to useful signals from the UI elements.
+ connect(delegate,
+ SIGNAL(dataChanged(QModelIndex,QVariant,int)),
+ SLOT(onAccountModelChange(QModelIndex,QVariant,int)));
connect(m_ui->addAccountButton,
SIGNAL(clicked()),
SLOT(onAddAccountClicked()));
@@ -115,6 +117,11 @@ void KCMTelepathyAccounts::load()
return;
}
+void KCMTelepathyAccounts::onAccountModelChange(const QModelIndex &index, const QVariant &value, int role)
+{
+ m_accountsListModel->setData(index, value, role);
+}
+
void KCMTelepathyAccounts::onAccountManagerReady(Tp::PendingOperation *op)
{
kDebug();
diff --git a/src/kcm-telepathy-accounts.h b/src/kcm-telepathy-accounts.h
index a8961f7..16ab70c 100644
--- a/src/kcm-telepathy-accounts.h
+++ b/src/kcm-telepathy-accounts.h
@@ -54,6 +54,8 @@ private Q_SLOTS:
void onAccountManagerReady(Tp::PendingOperation *op);
void onAccountCreated(const Tp::AccountPtr &account);
+ void onAccountModelChange(const QModelIndex &index, const QVariant &value, int role);
+
void onSelectedItemChanged();
void onAddAccountClicked();
void onEditAccountClicked();
--
ktp-accounts-kcm packaging
More information about the pkg-kde-commits
mailing list