[SCM] ktp-contact-list packaging branch, master, updated. debian/15.12.1-2-1070-g6c56f91
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:11:15 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=acdf50f
The following commit has been merged in the master branch:
commit acdf50f47ba3f9afdcf18fdf64e834d80f94ec93
Author: Martin Klapetek <martin.klapetek at gmail.com>
Date: Wed Aug 15 11:24:25 2012 +0200
Groups expanding/collapsing improvements
Reviewed-by: David Edmundson
REVIEW: 106025
CCBUG: 304095
---
contact-list-widget.cpp | 37 ++++++++++++++++++++++++++++++++-----
contact-list-widget.h | 2 ++
contact-list-widget_p.h | 1 +
3 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/contact-list-widget.cpp b/contact-list-widget.cpp
index 3809c24..6414dab 100644
--- a/contact-list-widget.cpp
+++ b/contact-list-widget.cpp
@@ -82,6 +82,7 @@ ContactListWidget::ContactListWidget(QWidget *parent)
setModel(d->modelFilter);
setSortingEnabled(true);
sortByColumn(0, Qt::AscendingOrder);
+ loadGroupStatesFromConfig();
connect(d->modelFilter, SIGNAL(rowsInserted(QModelIndex,int,int)),
this, SLOT(onNewGroupModelItemsInserted(QModelIndex,int,int)));
@@ -176,6 +177,8 @@ void ContactListWidget::showSettingsKCM()
void ContactListWidget::onContactListClicked(const QModelIndex& index)
{
+ Q_D(ContactListWidget);
+
if (!index.isValid()) {
return;
}
@@ -186,15 +189,20 @@ void ContactListWidget::onContactListClicked(const QModelIndex& index)
KSharedConfigPtr config = KSharedConfig::openConfig(QLatin1String("ktelepathyrc"));
KConfigGroup groupsConfig = config->group("GroupsState");
+ QString groupId = index.data(AccountsModel::IdRole).toString();
+
if (isExpanded(index)) {
collapse(index);
- groupsConfig.writeEntry(index.data(AccountsModel::IdRole).toString(), false);
+ groupsConfig.writeEntry(groupId, false);
} else {
expand(index);
- groupsConfig.writeEntry(index.data(AccountsModel::IdRole).toString(), true);
+ groupsConfig.writeEntry(groupId, true);
}
groupsConfig.config()->sync();
+
+ //replace the old value or insert new value if it isn't there yet
+ d->groupStates.insert(groupId, isExpanded(index));
}
}
@@ -278,6 +286,10 @@ void ContactListWidget::toggleGroups(bool show)
} else {
d->modelFilter->setSourceModel(d->model);
}
+
+ for (int i = 0; i < d->modelFilter->rowCount(); i++) {
+ onNewGroupModelItemsInserted(d->modelFilter->index(i, 0, QModelIndex()), 0, 0);
+ }
}
void ContactListWidget::toggleOfflineContacts(bool show)
@@ -426,19 +438,20 @@ void ContactListWidget::onNewGroupModelItemsInserted(const QModelIndex& index, i
{
Q_UNUSED(start);
Q_UNUSED(end);
+ Q_D(ContactListWidget);
+
if (!index.isValid()) {
return;
}
//if there is no parent, we deal with top-level item that we want to expand/collapse, ie. group or account
if (!index.parent().isValid()) {
- KSharedConfigPtr config = KSharedConfig::openConfig(QLatin1String("ktelepathyrc"));
- KConfigGroup groupsConfig = config->group("GroupsState");
//we're probably dealing with group item, so let's check if it is expanded first
if (!isExpanded(index)) {
//if it's not expanded, check the config if we should expand it or not
- if (groupsConfig.readEntry(index.data(AccountsModel::IdRole).toString(), false)) {
+ QString groupId = index.data(AccountsModel::IdRole).toString();
+ if (d->groupStates.value(groupId)) {
expand(index);
}
}
@@ -774,3 +787,17 @@ void ContactListWidget::drawBranches(QPainter *painter, const QRect &rect, const
// which looks like an artifact.
//See https://bugreports.qt-project.org/browse/QTBUG-26305
}
+
+void ContactListWidget::loadGroupStatesFromConfig()
+{
+ Q_D(ContactListWidget);
+ d->groupStates.clear();
+
+ KConfig config(QLatin1String("ktelepathyrc"));
+ KConfigGroup groupsConfig = config.group("GroupsState");
+
+ Q_FOREACH(const QString &key, groupsConfig.keyList()) {
+ bool expanded = groupsConfig.readEntry(key, false);
+ d->groupStates.insert(key, expanded);
+ }
+}
diff --git a/contact-list-widget.h b/contact-list-widget.h
index fd933df..b3b4f7c 100644
--- a/contact-list-widget.h
+++ b/contact-list-widget.h
@@ -97,6 +97,8 @@ private:
const QStringList& filenames,
const QDateTime& userActionTime);
+ void loadGroupStatesFromConfig();
+
friend class ContextMenu;
ContactListWidgetPrivate * const d_ptr;
};
diff --git a/contact-list-widget_p.h b/contact-list-widget_p.h
index 750eaf0..5868c88 100644
--- a/contact-list-widget_p.h
+++ b/contact-list-widget_p.h
@@ -48,6 +48,7 @@ public:
QPoint dragStartPosition;
bool shouldDrag;
bool showOffline;
+ QHash<QString, bool> groupStates;
};
#endif //CONTACT_LIST_WIDGET_P_H
--
ktp-contact-list packaging
More information about the pkg-kde-commits
mailing list