[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:20:44 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=71f1f79
The following commit has been merged in the master branch:
commit 71f1f797c4c09f68d0299aca2c0bb680c20de912
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Sat Jan 21 00:52:10 2012 +0000
Start of a log viewer
---
CMakeLists.txt | 1 +
logviewer/CMakeLists.txt | 41 ++++++++++++++++++++++
logviewer/entity-model.cpp | 85 ++++++++++++++++++++++++++++++++++++++++++++++
logviewer/entity-model.h | 68 +++++++++++++++++++++++++++++++++++++
logviewer/log-viewer.cpp | 64 ++++++++++++++++++++++++++++++++++
logviewer/log-viewer.h | 32 +++++++++++++++++
logviewer/main.cpp | 11 ++++++
logviewer/message-view.cpp | 82 ++++++++++++++++++++++++++++++++++++++++++++
logviewer/message-view.h | 31 +++++++++++++++++
9 files changed, 415 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d1cc185..42d3d8e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -32,3 +32,4 @@ add_subdirectory(app)
add_subdirectory(config)
add_subdirectory(data)
add_subdirectory(adiumxtra-protocol-handler)
+add_subdirectory(logviewer)
diff --git a/logviewer/CMakeLists.txt b/logviewer/CMakeLists.txt
new file mode 100644
index 0000000..fc76e9b
--- /dev/null
+++ b/logviewer/CMakeLists.txt
@@ -0,0 +1,41 @@
+macro_optional_find_package(TelepathyLoggerQt4)
+macro_log_feature(TELEPATHY_LOGGER_QT4_FOUND "TelepathyLoggerQt4" "Qt4 wrapper around telepathy-logger" FALSE "" "Needed for optional backlog support in the chat-window")
+macro_display_feature_log()
+
+#Only do anything with this app if the logger is available.
+if(TELEPATHY_LOGGER_QT4_FOUND)
+ add_definitions( -DTELEPATHY_LOGGER_QT4_FOUND )
+
+
+ set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TELEPATHY_LOGGER_QT4_DEFINITIONS}" )
+
+
+include_directories(${CMAKE_SOURCE_DIR}/lib
+ ${TELEPATHY_LOGGER_QT4_INCLUDE_DIRS}
+ )
+
+set(ktp-log-viewer_SRCS
+ main.cpp
+ log-viewer.cpp
+ entity-model.cpp
+ message-view.cpp
+)
+
+kde4_add_ui_files(ktp-log-viewer_SRCS log-viewer.ui)
+
+kde4_add_executable(ktp-log-viewer ${ktp-log-viewer_SRCS})
+
+target_link_libraries(ktp-log-viewer
+ ${KDE4_KDECORE_LIBS}
+ ${KDE4_KDEUI_LIBS}
+ ${KDE4_KIO_LIBS}
+ ${TELEPATHY_QT4_LIBRARIES}
+ ${KDE4_KEMOTICONS_LIBS}
+ ${KDE4_KCMUTILS_LIBS}
+ ${TELEPATHY_LOGGER_QT4_LIBRARIES}
+ ktpchat)
+
+
+# change to binary install dir
+# install(TARGETS ktp-log-viewer DESTINATION ${LIBEXEC_INSTALL_DIR})
+endif()
diff --git a/logviewer/entity-model.cpp b/logviewer/entity-model.cpp
new file mode 100644
index 0000000..419b376
--- /dev/null
+++ b/logviewer/entity-model.cpp
@@ -0,0 +1,85 @@
+#include "entity-model.h"
+
+#include <TelepathyLoggerQt4/LogManager>
+#include <TelepathyLoggerQt4/PendingEntities>
+#include <TelepathyLoggerQt4/PendingOperation>
+#include <TelepathyLoggerQt4/Entity>
+
+#include <TelepathyQt/AccountManager>
+#include <TelepathyQt/Account>
+
+#include <QPixmap>
+
+
+EntityModel::EntityModel(QObject *parent) :
+ QAbstractListModel(parent)
+{
+}
+
+void EntityModel::setAccountManager(const Tp::AccountManagerPtr &accountManager)
+{
+ Tpl::LogManagerPtr logManager = Tpl::LogManager::instance();
+ Q_FOREACH(const Tp::AccountPtr &account, accountManager->allAccounts()) {
+ connect(logManager->queryEntities(account),
+ SIGNAL(finished(Tpl::PendingOperation*)),
+ SLOT(onEntitiesSearchFinished(Tpl::PendingOperation*)));
+ }
+}
+
+int EntityModel::rowCount(const QModelIndex &parent) const
+{
+ if (parent == QModelIndex()) {
+ return m_entities.size();
+ }
+ else {
+ return 0;
+ }
+}
+
+QVariant EntityModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid()) {
+ return QVariant();
+ }
+
+ Tpl::EntityPtr entity = m_entities[index.row()].entity;
+
+ switch (role) {
+ case Qt::DisplayRole:
+ return entity->alias();
+ case Qt::DecorationRole:
+ return QPixmap(entity->avatarToken());
+ case EntityModel::IdRole:
+ return entity->identifier();
+ case EntityModel::TypeRole:
+ return entity->entityType();
+ case EntityModel::EntityRole:
+ return QVariant::fromValue(entity);
+ case EntityModel::AccountRole:
+ return QVariant::fromValue(m_entities[index.row()].account);
+ }
+ return QVariant();
+}
+
+void EntityModel::onEntitiesSearchFinished(Tpl::PendingOperation *operation)
+{
+ Tpl::PendingEntities *pendingEntities = qobject_cast<Tpl::PendingEntities*>(operation);
+
+ Tpl::EntityPtrList newEntries = pendingEntities->entities();
+
+ if (newEntries.size() > 0) {
+ beginInsertRows(QModelIndex(), m_entities.size(), m_entities.size() + newEntries.size()-1);
+ Q_FOREACH(const Tpl::EntityPtr entity, newEntries) {
+ EntityModelItem item;
+ item.account = pendingEntities->account();
+ item.entity = entity;
+
+ qDebug() << entity->alias();
+
+ m_entities.append(item);
+ }
+
+ endInsertRows();
+ }
+}
+
diff --git a/logviewer/entity-model.h b/logviewer/entity-model.h
new file mode 100644
index 0000000..adf9b88
--- /dev/null
+++ b/logviewer/entity-model.h
@@ -0,0 +1,68 @@
+#ifndef ENTITYMODEL_H
+#define ENTITYMODEL_H
+
+#include <QAbstractListModel>
+
+#include <TelepathyQt/Types>
+
+#include <TelepathyLoggerQt4/Entity>
+#include <TelepathyQt/Account>
+
+
+/**
+ Lists all avilable entities.
+
+ roles:
+ - Qt::DisplayRole - name
+ - Qt::DecorationRole - avatar
+ - EntityModel::IdRole
+ - EntityModel::TypeRole - EntityType (EntityTypeContact/Room/Self/Unknown)
+ - EntityModel::EntityRole - relevant Tpl::EntityPtr
+ */
+
+namespace Tpl{
+ class PendingOperation;
+}
+
+
+class EntityModelItem {
+public:
+ Tpl::EntityPtr entity;
+ Tp::AccountPtr account;
+};
+
+class EntityModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ enum Role {
+ IdRole = Qt::UserRole,
+ TypeRole,
+ EntityRole,
+ AccountRole
+ };
+
+
+ explicit EntityModel(QObject *parent = 0);
+ void setAccountManager(const Tp::AccountManagerPtr &accountManager);
+
+ int rowCount(const QModelIndex &parent) const;
+ QVariant data(const QModelIndex &index, int role) const;
+
+Q_SIGNALS:
+
+public Q_SLOTS:
+
+private Q_SLOTS:
+ void onEntitiesSearchFinished(Tpl::PendingOperation*);
+
+private:
+ QList<EntityModelItem> m_entities;
+
+};
+
+Q_DECLARE_METATYPE(Tpl::EntityPtr);
+Q_DECLARE_METATYPE(Tp::AccountPtr);
+
+
+#endif // ENTITYMODEL_H
diff --git a/logviewer/log-viewer.cpp b/logviewer/log-viewer.cpp
new file mode 100644
index 0000000..8f973c5
--- /dev/null
+++ b/logviewer/log-viewer.cpp
@@ -0,0 +1,64 @@
+#include "log-viewer.h"
+#include "ui_log-viewer.h"
+
+#include <TelepathyQt/AccountManager>
+#include <TelepathyQt/PendingReady>
+
+
+#include <TelepathyLoggerQt4/Init>
+#include <TelepathyLoggerQt4/Entity>
+#include <TelepathyLoggerQt4/LogManager>
+
+#include <glib-object.h>
+#include <QGlib/Init>
+
+#include "entity-model.h"
+
+LogViewer::LogViewer(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::LogViewer)
+{
+ ui->setupUi(this);
+ Tp::registerTypes();
+ g_type_init();
+ QGlib::init(); //are these 4 really needed?
+ Tpl::init();
+
+ m_accountManager = Tp::AccountManager::create();
+
+ m_entityModel = new EntityModel(this);
+
+ ui->entityList->setModel(m_entityModel);
+
+ //TODO parse args and update all views as appropriate
+
+ connect(m_accountManager->becomeReady(), SIGNAL(finished(Tp::PendingOperation*)), SLOT(onAccountManagerReady()));
+ connect(ui->entityList, SIGNAL(activated(QModelIndex)), SLOT(onEntitySelected(QModelIndex)));
+}
+
+LogViewer::~LogViewer()
+{
+ delete ui;
+}
+
+void LogViewer::onAccountManagerReady()
+{
+ Tpl::LogManagerPtr logManager = Tpl::LogManager::instance();
+ logManager->setAccountManagerPtr(m_accountManager);
+ m_entityModel->setAccountManager(m_accountManager);
+}
+
+void LogViewer::onEntitySelected(const QModelIndex &index)
+{
+ //calendar needs to get pendingDates
+ Tpl::EntityPtr entity = index.data(EntityModel::EntityRole).value<Tpl::EntityPtr>();
+ Tp::AccountPtr account = index.data(EntityModel::AccountRole).value<Tp::AccountPtr>();
+ ui->messageView->loadLog(account, entity, QDate::currentDate());
+
+ //main view needs to show pendingEvents
+}
+
+void LogViewer::onDateSelected()
+{
+ //update main view
+}
diff --git a/logviewer/log-viewer.h b/logviewer/log-viewer.h
new file mode 100644
index 0000000..06d39af
--- /dev/null
+++ b/logviewer/log-viewer.h
@@ -0,0 +1,32 @@
+#ifndef LOGVIEWER_H
+#define LOGVIEWER_H
+
+#include <QWidget>
+#include <TelepathyQt/AccountManager>
+
+namespace Ui {
+ class LogViewer;
+}
+
+class EntityModel;
+
+class LogViewer : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit LogViewer(QWidget *parent = 0);
+ ~LogViewer();
+private Q_SLOTS:
+ void onAccountManagerReady();
+
+ void onEntitySelected(const QModelIndex &index);
+ void onDateSelected();
+
+private:
+ Ui::LogViewer *ui;
+ Tp::AccountManagerPtr m_accountManager;
+ EntityModel *m_entityModel;
+};
+
+#endif // LOGVIEWER_H
diff --git a/logviewer/main.cpp b/logviewer/main.cpp
new file mode 100644
index 0000000..d62f6c4
--- /dev/null
+++ b/logviewer/main.cpp
@@ -0,0 +1,11 @@
+#include <QtGui/QApplication>
+#include "log-viewer.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ LogViewer w;
+ w.show();
+
+ return a.exec();
+}
diff --git a/logviewer/message-view.cpp b/logviewer/message-view.cpp
new file mode 100644
index 0000000..9a5eae8
--- /dev/null
+++ b/logviewer/message-view.cpp
@@ -0,0 +1,82 @@
+#include "message-view.h"
+
+#include "adium-theme-view.h"
+
+#include <KDebug>
+
+#include <TelepathyLoggerQt4/LogManager>
+#include <TelepathyLoggerQt4/PendingEvents>
+#include <TelepathyLoggerQt4/TextEvent>
+
+#include <TelepathyQt/Account>
+
+MessageView::MessageView(QWidget *parent) :
+ AdiumThemeView(parent)
+{
+ connect(this, SIGNAL(loadFinished(bool)), SLOT(onLoadFinished()));
+}
+
+void MessageView::loadLog(const Tp::AccountPtr &account, const Tpl::EntityPtr &entity, const QDate &date)
+{
+ m_account = account;
+ m_entity = entity;
+ m_date = date;
+
+ //FIXME check entity type
+ load(AdiumThemeView::SingleUserChat);
+
+
+ AdiumThemeHeaderInfo headerInfo;
+ headerInfo.setDestinationDisplayName(m_entity->alias());
+ headerInfo.setChatName(m_entity->alias());
+// other headerInfo here.
+ initialise(headerInfo);
+}
+
+void MessageView::onLoadFinished()
+{
+ //load stuff here.
+ qDebug() << "load stuff";
+ Tpl::LogManagerPtr logManager = Tpl::LogManager::instance();
+ Tpl::PendingEvents *pendingEvents = logManager->queryEvents(m_account, m_entity, Tpl::EventTypeMaskText, m_date);
+ connect(pendingEvents, SIGNAL(finished(Tpl::PendingOperation*)), SLOT(onEventsLoaded(Tpl::PendingOperation*)));
+}
+
+void MessageView::onEventsLoaded(Tpl::PendingOperation *po)
+{
+ Tpl::PendingEvents *pe = qobject_cast<Tpl::PendingEvents*>(po);
+
+ QList<AdiumThemeContentInfo> messages;
+
+ qDebug() << "showing " << pe->events().size() << "messages";
+
+ Q_FOREACH(const Tpl::EventPtr &event, pe->events()) {
+ const Tpl::TextEventPtr textEvent(event.staticCast<Tpl::TextEvent>());
+
+ AdiumThemeMessageInfo::MessageType type;
+ QString iconPath;
+
+ if(event->sender()->identifier() == m_account->normalizedName()) {
+ type = AdiumThemeMessageInfo::HistoryLocalToRemote;
+ } else {
+ type = AdiumThemeMessageInfo::HistoryRemoteToLocal;
+ }
+
+
+ AdiumThemeContentInfo message(type);
+ message.setMessage(textEvent->message());
+ message.setService(m_account->serviceName());
+ message.setSenderDisplayName(textEvent->sender()->alias());
+ message.setSenderScreenName(textEvent->sender()->alias());
+ message.setTime(textEvent->timestamp());
+ message.setUserIconPath(iconPath);
+ kDebug() << textEvent->timestamp()
+ << "from" << textEvent->sender()->identifier()
+ << "to" << textEvent->receiver()->identifier()
+ << textEvent->message();
+
+ messages.append(message);
+
+ addContentMessage(message);
+ }
+}
diff --git a/logviewer/message-view.h b/logviewer/message-view.h
new file mode 100644
index 0000000..46f70f7
--- /dev/null
+++ b/logviewer/message-view.h
@@ -0,0 +1,31 @@
+#ifndef MESSAGEVIEW_H
+#define MESSAGEVIEW_H
+
+#include "adium-theme-view.h"
+
+#include <QDate>
+
+#include <TelepathyLoggerQt4/Entity>
+#include <TelepathyLoggerQt4/PendingOperation>
+
+
+class MessageView : public AdiumThemeView
+{
+ Q_OBJECT
+public:
+ explicit MessageView(QWidget *parent = 0);
+
+ void loadLog(const Tp::AccountPtr &account, const Tpl::EntityPtr &entity, const QDate &date);
+
+private Q_SLOTS:
+ void onLoadFinished();
+ void onEventsLoaded(Tpl::PendingOperation* po);
+
+private:
+ Tpl::EntityPtr m_entity;
+ Tp::AccountPtr m_account;
+ QDate m_date;
+
+};
+
+#endif // MESSAGEVIEW_H
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list