[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:24:10 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=35a766c
The following commit has been merged in the master branch:
commit 35a766c5708f8e391b1ac7580f51d17da8402c59
Author: Dan Vrátil <dvratil at redhat.com>
Date: Sun Sep 15 22:49:33 2013 +0200
Fix opening logs for contact passed via command line
And add support for opening logs via Nepomuk URI
REVIEW: 112739
BUG: 324918
---
logviewer/dates-model.cpp | 4 ++++
logviewer/dates-model.h | 3 +++
logviewer/entity-filter-model.cpp | 4 ++++
logviewer/entity-view.cpp | 32 ++++++++++++++++++++++----------
logviewer/entity-view.h | 1 +
logviewer/log-viewer.cpp | 29 ++++++++++++++++++++++++++++-
logviewer/log-viewer.h | 4 ++++
logviewer/person-entity-merge-model.cpp | 27 ++++++++++++++++++++++-----
logviewer/person-entity-merge-model.h | 5 +++++
9 files changed, 93 insertions(+), 16 deletions(-)
diff --git a/logviewer/dates-model.cpp b/logviewer/dates-model.cpp
index 195765f..d887841 100644
--- a/logviewer/dates-model.cpp
+++ b/logviewer/dates-model.cpp
@@ -395,6 +395,10 @@ void DatesModel::onDatesReceived(KTp::PendingLoggerOperation *operation)
if (m_resetInProgress == 0) {
endResetModel();
}
+
+ if (m_pendingDates.isEmpty()) {
+ Q_EMIT datesReceived();
+ }
}
#include "dates-model.moc"
diff --git a/logviewer/dates-model.h b/logviewer/dates-model.h
index 14d2eae..773f3b0 100644
--- a/logviewer/dates-model.h
+++ b/logviewer/dates-model.h
@@ -75,6 +75,9 @@ class DatesModel : public QAbstractItemModel
virtual QModelIndex parent(const QModelIndex& child) const;
virtual QModelIndex index(int row, int column, const QModelIndex& parent) const;
+ Q_SIGNALS:
+ void datesReceived();
+
private Q_SLOTS:
void onDatesReceived(KTp::PendingLoggerOperation *operation);
diff --git a/logviewer/entity-filter-model.cpp b/logviewer/entity-filter-model.cpp
index 356e3d6..82c3304 100644
--- a/logviewer/entity-filter-model.cpp
+++ b/logviewer/entity-filter-model.cpp
@@ -97,6 +97,10 @@ bool EntityFilterModel::filterAcceptsRow(int source_row, const QModelIndex &sour
return false;
} else if (itemType == PersonEntityMergeModel::Persona) {
+ if (sourceModel()->rowCount(index) == 0) {
+ return true;
+ }
+
for (int i = 0; i < sourceModel()->rowCount(index); ++i) {
if (filterAcceptsRow(i, index)) {
return true;
diff --git a/logviewer/entity-view.cpp b/logviewer/entity-view.cpp
index 77fefc0..6d2ac9b 100644
--- a/logviewer/entity-view.cpp
+++ b/logviewer/entity-view.cpp
@@ -25,7 +25,7 @@
#include <TelepathyQt/Account>
-#include "entity-model.h"
+#include "person-entity-merge-model.h"
EntityView::EntityView(QWidget *parent) :
QTreeView(parent)
@@ -42,30 +42,42 @@ void EntityView::rowsInserted(const QModelIndex &parent, int start, int end)
return;
}
- if (KCmdLineArgs::parsedArgs()->count() == 2) {
+ QModelIndex selectedIndex;
+ if (KCmdLineArgs::parsedArgs()->count() == 1 && KTp::kpeopleEnabled()) {
+ const QString selectedPersonaId = KCmdLineArgs::parsedArgs()->arg(0);
+ for (int i = start; i <= end; i++) {
+ const QModelIndex index = model()->index(i, 0, parent);
+ if (index.data(KTp::NepomukUriRole).toUrl() == selectedPersonaId) {
+ selectedIndex = index;
+ break;
+ }
+ }
+ } else if (KCmdLineArgs::parsedArgs()->count() == 2) {
QString selectAccountId = KCmdLineArgs::parsedArgs()->arg(0);
QString selectContactId = KCmdLineArgs::parsedArgs()->arg(1);
for (int i = start; i <= end; i++) {
QModelIndex index = model()->index(i, 0, parent);
- Tp::AccountPtr account = index.data(EntityModel::AccountRole).value<Tp::AccountPtr>();
- KTp::LogEntity entity = index.data(EntityModel::EntityRole).value<KTp::LogEntity>();
-
+ Tp::AccountPtr account = index.data(PersonEntityMergeModel::AccountRole).value<Tp::AccountPtr>();
+ KTp::LogEntity entity = index.data(PersonEntityMergeModel::EntityRole).value<KTp::LogEntity>();
if (account.isNull() || !entity.isValid()) {
continue;
}
if (selectAccountId == account->uniqueIdentifier() && selectContactId == entity.id()) {
- setCurrentIndex(index);
- loadedCurrentContact = true;
+ selectedIndex = index;
break;
}
}
+ }
- if (!loadedCurrentContact) {
- Q_EMIT noSuchContact();
- }
+ if (selectedIndex.isValid()) {
+ loadedCurrentContact = true;
+ setCurrentIndex(selectedIndex);
+ } else {
+ Q_EMIT noSuchContact();
}
expandAll();
+
}
diff --git a/logviewer/entity-view.h b/logviewer/entity-view.h
index 18bf9d5..48b132d 100644
--- a/logviewer/entity-view.h
+++ b/logviewer/entity-view.h
@@ -36,6 +36,7 @@ Q_SIGNALS:
protected Q_SLOTS:
void rowsInserted(const QModelIndex &parent, int start, int end);
+
};
#endif // ENTITYVIEW_H
diff --git a/logviewer/log-viewer.cpp b/logviewer/log-viewer.cpp
index 8b2e779..5cdc956 100644
--- a/logviewer/log-viewer.cpp
+++ b/logviewer/log-viewer.cpp
@@ -83,6 +83,8 @@ LogViewer::LogViewer(const Tp::AccountFactoryPtr &accountFactory, const Tp::Conn
m_entityModel = new EntityModel(this);
m_mergeModel = new PersonEntityMergeModel(m_contactsModel, m_entityModel, this);
+ connect(m_mergeModel, SIGNAL(modelInitialized()),
+ this, SLOT(slotMergeModelInitialized()));
m_filterModel = new EntityFilterModel(this);
m_filterModel->setSourceModel(m_mergeModel);
@@ -104,6 +106,8 @@ LogViewer::LogViewer(const Tp::AccountFactoryPtr &accountFactory, const Tp::Conn
ui->datesView->setRootIsDecorated(false);
ui->datesView->setExpandsOnDoubleClick(false);
ui->datesView->setIndentation(0);
+ connect(m_datesModel, SIGNAL(datesReceived()),
+ this, SLOT(onDatesReceived()));
connect(ui->entityList, SIGNAL(clicked(QModelIndex)), SLOT(onEntityListClicked(QModelIndex)));
connect(ui->datesView, SIGNAL(clicked(QModelIndex)), SLOT(slotDateClicked(QModelIndex)));
@@ -178,7 +182,17 @@ void LogViewer::onAccountManagerReady()
slotImportKopeteLogs(false);
}
-void LogViewer::onEntityListClicked(const QModelIndex& index)
+void LogViewer::slotMergeModelInitialized()
+{
+ // Make sure we cal onEntityListClicked now - this ensures that if EntityView
+ // has selected a person or contact (because user has passed it via arguments
+ // on command line) it will correctly list all dates for all subcontacts
+ if (!ui->entityList->selectionModel()->selectedIndexes().isEmpty()) {
+ onEntityListClicked(ui->entityList->selectionModel()->selectedIndexes().first());
+ }
+}
+
+void LogViewer::onEntityListClicked(const QModelIndex &index)
{
const PersonEntityMergeModel::ItemType itemType =
static_cast<PersonEntityMergeModel::ItemType>(index.data(PersonEntityMergeModel::ItemTypeRole).toUInt());
@@ -220,6 +234,19 @@ void LogViewer::onEntityListClicked(const QModelIndex& index)
}
}
+void LogViewer::onDatesReceived()
+{
+ const QModelIndex groupIndex = m_datesModel->index(0, 0, QModelIndex());
+ if (groupIndex.isValid()) {
+ // expand group
+ slotDateClicked(groupIndex);
+
+ // call slotUpdateMainWindow
+ const QModelIndex dateIndex = m_datesModel->index(0, 0, groupIndex);
+ ui->datesView->selectionModel()->setCurrentIndex(dateIndex, QItemSelectionModel::Select);
+ }
+}
+
void LogViewer::slotDateClicked(const QModelIndex& index)
{
if (ui->datesView->isExpanded(index)) {
diff --git a/logviewer/log-viewer.h b/logviewer/log-viewer.h
index b3a53f0..51374c0 100644
--- a/logviewer/log-viewer.h
+++ b/logviewer/log-viewer.h
@@ -54,7 +54,11 @@ public:
private Q_SLOTS:
void onAccountManagerReady();
+ void slotMergeModelInitialized();
+
void onEntityListClicked(const QModelIndex &index);
+ void onDatesReceived();
+
void slotDateClicked(const QModelIndex &index);
void slotUpdateMainWindow();
diff --git a/logviewer/person-entity-merge-model.cpp b/logviewer/person-entity-merge-model.cpp
index 0fcff92..00381c0 100644
--- a/logviewer/person-entity-merge-model.cpp
+++ b/logviewer/person-entity-merge-model.cpp
@@ -92,6 +92,23 @@ class PersonEntityMergeModel::ContactItem: public Item
};
+void PersonEntityMergeModel::addItem(PersonEntityMergeModel::Item* item, PersonEntityMergeModel::Item* parent)
+{
+ const int pos = parent->children.count();
+ beginInsertRows(indexForItem(parent), pos, pos);
+ parent->addChild(item);
+ endInsertRows();
+}
+
+QModelIndex PersonEntityMergeModel::indexForItem(PersonEntityMergeModel::Item *item) const
+{
+ if (item == m_rootItem) {
+ return QModelIndex();
+ }
+
+ return index(item->parent->children.indexOf(item), 0, indexForItem(item->parent));
+}
+
PersonEntityMergeModel::ContactItem* PersonEntityMergeModel::itemForPersona(const QModelIndex &personsModel_personaIndex)
{
if (!personsModel_personaIndex.isValid()) {
@@ -116,7 +133,7 @@ PersonEntityMergeModel::ContactItem* PersonEntityMergeModel::itemForPersona(cons
const QStringList groupNames = personsModel_personaIndex.data(KTp::ContactGroupsRole).toStringList();
GroupItem *groupItem = groupForName(groupNames.size() ? groupNames.first() : QString());
- groupItem->addChild(item);
+ addItem(item, groupItem);
return item;
}
@@ -152,7 +169,7 @@ PersonEntityMergeModel::GroupItem* PersonEntityMergeModel::groupForName(const QV
kDebug() << " Creating a new group" << groupName;
GroupItem *group = new GroupItem;
group->label = groupName;
- m_rootItem->addChild(group);
+ addItem(group, m_rootItem);
return group;
}
@@ -382,6 +399,8 @@ void PersonEntityMergeModel::sourceModelInitialized()
// TODO: Listen to changes from KPeople too
connect(m_entityModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
this, SLOT(entityModelDataChanged(QModelIndex,QModelIndex)));
+
+ Q_EMIT modelInitialized();
}
}
@@ -389,7 +408,6 @@ void PersonEntityMergeModel::sourceModelInitialized()
void PersonEntityMergeModel::initializeModel()
{
kDebug();
- beginResetModel();
for (int i = 0; i < m_entityModel->rowCount(QModelIndex()); ++i) {
const QModelIndex entityIndex = m_entityModel->index(i, 0);
@@ -439,9 +457,8 @@ void PersonEntityMergeModel::initializeModel()
item->entityIndex = entityIndex;
item->contactIndex = contactIndex;
item->personaIndex = personaIndex;
- parentItem->addChild(item);
+ addItem(item, parentItem);
}
- endResetModel();
}
void PersonEntityMergeModel::entityModelDataChanged(const QModelIndex &topLeft,
diff --git a/logviewer/person-entity-merge-model.h b/logviewer/person-entity-merge-model.h
index c07e066..8b04997 100644
--- a/logviewer/person-entity-merge-model.h
+++ b/logviewer/person-entity-merge-model.h
@@ -62,6 +62,9 @@ class PersonEntityMergeModel : public QAbstractItemModel
virtual Qt::ItemFlags flags(const QModelIndex& index) const;
virtual bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
+ Q_SIGNALS:
+ void modelInitialized();
+
private Q_SLOTS:
void sourceModelInitialized();
void entityModelDataChanged(const QModelIndex &topLeft,
@@ -75,6 +78,8 @@ class PersonEntityMergeModel : public QAbstractItemModel
class ContactItem;
class GroupItem;
+ void addItem(Item *item, Item *parent);
+ QModelIndex indexForItem(Item *item) const;
GroupItem* groupForName(const QVariant &name);
ContactItem* itemForPersona(const QModelIndex &personsModel_personaIndex);
Item* itemForIndex(const QModelIndex &index) const;
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list