[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:22:58 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=b91c3d0

The following commit has been merged in the master branch:
commit b91c3d03c42e6df2af743ecd9f07d1433d9705c5
Author: Dan Vrátil <dvratil at redhat.com>
Date:   Wed Nov 14 11:23:28 2012 +0100

    Add dialog for initial Kopete logs import
    
    On start up logviewer will check for existing Kopete logs
    and offer a dialog to import the logs. This will happen
    only once.
    
    REVIEW: 107263
---
 logviewer/CMakeLists.txt         |   2 +
 logviewer/log-viewer.cpp         |  39 +++++++++++-
 logviewer/log-viewer.h           |   2 +
 logviewer/logs-import-dialog.cpp | 133 +++++++++++++++++++++++++++++++++++++++
 logviewer/logs-import-dialog.h   |  59 +++++++++++++++++
 5 files changed, 234 insertions(+), 1 deletion(-)

diff --git a/logviewer/CMakeLists.txt b/logviewer/CMakeLists.txt
index a975fa0..3953dc1 100644
--- a/logviewer/CMakeLists.txt
+++ b/logviewer/CMakeLists.txt
@@ -3,6 +3,7 @@ include_directories(${CMAKE_SOURCE_DIR}/lib)
 set(ktp-log-viewer_SRCS
         main.cpp
         log-viewer.cpp
+        logs-import-dialog.cpp
         entity-model.cpp
         entity-model-item.cpp
         message-view.cpp
@@ -24,6 +25,7 @@ target_link_libraries(ktp-log-viewer
             ${KDE4_KCMUTILS_LIBS}
             ${TELEPATHY_LOGGER_QT4_LIBRARIES}
             ${QT_QTWEBKIT_LIBRARY}
+            ${KTP_LIBRARIES}
             ktpchat)
 
 install(TARGETS ktp-log-viewer DESTINATION ${BIN_INSTALL_DIR})
diff --git a/logviewer/log-viewer.cpp b/logviewer/log-viewer.cpp
index ce39775..9d20a35 100644
--- a/logviewer/log-viewer.cpp
+++ b/logviewer/log-viewer.cpp
@@ -24,13 +24,14 @@
 #include <TelepathyQt/PendingReady>
 #include <TelepathyQt/ContactManager>
 
-
 #include <TelepathyLoggerQt4/Init>
 #include <TelepathyLoggerQt4/Entity>
 #include <TelepathyLoggerQt4/LogManager>
 #include <TelepathyLoggerQt4/SearchHit>
 #include <TelepathyLoggerQt4/PendingSearch>
 
+#include <KTp/logs-importer.h>
+
 #include <QSortFilterProxyModel>
 #include <QMenu>
 #include <QWebFrame>
@@ -38,9 +39,12 @@
 #include <KPixmapSequence>
 #include <KMessageBox>
 
+#include <KDebug>
+
 #include "entity-model.h"
 #include "entity-proxy-model.h"
 #include "entity-model-item.h"
+#include "logs-import-dialog.h"
 
 Q_DECLARE_METATYPE(QModelIndex)
 
@@ -114,6 +118,8 @@ void LogViewer::onAccountManagerReady()
     Tpl::LogManagerPtr logManager = Tpl::LogManager::instance();
     logManager->setAccountManagerPtr(m_accountManager);
     m_entityModel->setAccountManager(m_accountManager);
+
+    runKopeteLogsImport();
 }
 
 void LogViewer::onEntitySelected(const QModelIndex &current, const QModelIndex &previous)
@@ -304,3 +310,34 @@ void LogViewer::logClearingFinished(Tpl::PendingOperation *operation)
 
     m_entityListContextMenu->setProperty("index", QVariant());
 }
+
+void LogViewer::runKopeteLogsImport()
+{
+    KSharedConfigPtr config = KSharedConfig::openConfig(QLatin1String("ktelepathyrc"));
+    KConfigGroup logsConfig = config->group("logs");
+
+    bool importDone = logsConfig.readEntry(QLatin1String("InitialKopeteImportDone"), QVariant(false)).toBool();
+    if (importDone) {
+	kDebug() << "Skipping initial Kopete logs import, already done.";
+	return;
+    }
+
+    QList<Tp::AccountPtr> accounts = m_accountManager->allAccounts();
+    QList<Tp::AccountPtr> matchingAccounts;
+    KTp::LogsImporter importer;
+
+    Q_FOREACH (const Tp::AccountPtr &account, accounts) {
+	if (importer.hasKopeteLogs(account)) {
+	    matchingAccounts << account;
+	}
+    }
+
+    kDebug() << "Initial Kopete logs import: found" << matchingAccounts.count() << "accounts to import";
+
+    if (!matchingAccounts.isEmpty()) {
+	LogsImportDialog *dialog = new LogsImportDialog(this);
+	dialog->importLogs(matchingAccounts);
+    }
+
+    logsConfig.writeEntry(QLatin1String("InitialKopeteImportDone"), true);
+}
diff --git a/logviewer/log-viewer.h b/logviewer/log-viewer.h
index b69753a..8829e7b 100644
--- a/logviewer/log-viewer.h
+++ b/logviewer/log-viewer.h
@@ -61,6 +61,8 @@ private Q_SLOTS:
     void clearContactHistory();
     void logClearingFinished(Tpl::PendingOperation *);
 private:
+    void runKopeteLogsImport();
+
     Ui::LogViewer *ui;
     Tp::AccountManagerPtr m_accountManager;
     EntityModel *m_entityModel;
diff --git a/logviewer/logs-import-dialog.cpp b/logviewer/logs-import-dialog.cpp
new file mode 100644
index 0000000..200f943
--- /dev/null
+++ b/logviewer/logs-import-dialog.cpp
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2012  Dan Vratil <dvratil at redhat.com>
+ *
+ * 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 Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include "logs-import-dialog.h"
+
+#include <QVBoxLayout>
+#include <QLabel>
+#include <QProgressBar>
+#include <KListWidget>
+#include <KLocalizedString>
+#include <KDebug>
+#include <KTp/Logs/logs-importer.h>
+#include <TelepathyQt/Account>
+
+Q_DECLARE_METATYPE(Tp::AccountPtr);
+
+LogsImportDialog::LogsImportDialog(QObject *parent)
+    : KDialog()
+{
+    Q_UNUSED(parent);
+
+    setWindowTitle(i18n("Import Kopete Logs"));
+    setWindowIcon(KIcon::fromTheme(QLatin1String("telepathy-kde")));
+
+    QWidget *mainWidget = new QWidget(this);
+    setMainWidget(mainWidget);
+
+    QVBoxLayout *layout = new QVBoxLayout();
+    mainWidget->setLayout(layout);
+
+    QLabel *label = new QLabel(mainWidget);
+    label->setText(i18n("We have found Kopete logs that seem to match some of your KDE Telepathy accounts.

"
+			"Do you want to import these logs from Kopete to KDE Telepathy?"));
+    label->setWordWrap(true);
+    layout->addWidget(label);
+
+    m_accountsList = new KListWidget(mainWidget);
+    m_accountsList->setIconSize(QSize(24,24));
+    layout->addWidget(m_accountsList, 1);
+
+    m_progressBar = new QProgressBar(mainWidget);
+    m_progressBar->setVisible(false);
+    m_progressBar->setMinimum(0);
+    m_progressBar->setMaximum(0);
+    m_progressBar->setTextVisible(false);
+    layout->addWidget(m_progressBar);
+
+    setButtons(Ok | Close);
+    setButtonText(Ok, i18n("Import Logs"));
+
+    setMinimumWidth(300);
+
+    m_importer = new KTp::LogsImporter(this);
+    connect(m_importer, SIGNAL(logsImported()), SLOT(importFinished()));
+}
+
+LogsImportDialog::~LogsImportDialog()
+{
+
+}
+
+void LogsImportDialog::importLogs(const QList< Tp::AccountPtr >& accounts)
+{
+    Q_FOREACH(const Tp::AccountPtr &account, accounts) {
+	QListWidgetItem *item = new QListWidgetItem();
+	item->setText(account->displayName());
+	item->setIcon(KIcon(account->iconName()));
+	item->setCheckState(Qt::Checked);
+	item->setData(Qt::UserRole + 1, QVariant::fromValue(account));
+
+	m_accountsList->addItem(item);
+    }
+
+    exec();
+}
+
+void LogsImportDialog::slotButtonClicked(int button)
+{
+    if (button == Ok) {
+	m_accountsList->setEnabled(false);
+	m_progressBar->setVisible(true);
+	enableButton(Ok, false);
+	enableButton(Close, false);
+
+	m_row = 0;
+	importFinished();
+	return;
+    }
+
+    KDialog::slotButtonClicked(button);
+}
+
+void LogsImportDialog::importFinished()
+{
+    if (m_row < m_accountsList->count()) {
+
+	/* If the account is not checked, skip to next one */
+	if (m_accountsList->item(m_row)->checkState() != Qt::Checked) {
+	    m_row++;
+	    importFinished();
+	    return;
+	}
+
+	if (m_row > 0) {
+	    m_accountsList->item(m_row - 1)->setCheckState(Qt::Unchecked);
+	}
+
+	Tp::AccountPtr account = m_accountsList->item(m_row)->data(Qt::UserRole + 1).value<Tp::AccountPtr>();
+	m_importer->startLogImport(account);
+	m_row++;
+    } else {
+	m_accountsList->item(m_row - 1)->setCheckState(Qt::Unchecked);
+	m_progressBar->setVisible(false);
+	enableButton(Close, true);
+	setButtonText(Close, i18n("Done"));
+    }
+}
diff --git a/logviewer/logs-import-dialog.h b/logviewer/logs-import-dialog.h
new file mode 100644
index 0000000..05f813e
--- /dev/null
+++ b/logviewer/logs-import-dialog.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2012  Dan Vratil <dvratil at redhat.com>
+ *
+ * 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 Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifndef LOGSIMPORTDIALOG_H
+#define LOGSIMPORTDIALOG_H
+
+#include <KDialog>
+#include <TelepathyQt/Types>
+
+namespace KTp {
+class LogsImporter;
+}
+
+class QProgressBar;
+class KListWidget;
+class LogsImportDialogPrivate;
+
+class LogsImportDialog : public KDialog
+{
+    Q_OBJECT
+
+  public:
+    LogsImportDialog(QObject* parent);
+    virtual ~LogsImportDialog();
+
+    void importLogs(const QList<Tp::AccountPtr> &accounts);
+
+  protected Q_SLOTS:
+    virtual void slotButtonClicked(int button);
+
+  private Q_SLOTS:
+    void importFinished();
+
+  private:
+    KListWidget *m_accountsList;
+    QProgressBar *m_progressBar;
+    KTp::LogsImporter *m_importer;
+    int m_row;
+
+
+};
+
+#endif // LOGSIMPORTDIALOG_H

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list