1 /***************************************************************************
2  *   Copyright (C) 2012 by David Edmundson <kde@davidedmundson.co.uk>      *
3  *   Copyright (C) 2012,2013 by Daniel Vrátil <dvratil@redhat.com>         *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
19  ***************************************************************************/
20 
21 #ifndef LOGVIEWER_H
22 #define LOGVIEWER_H
23 
24 #include <KXmlGuiWindow>
25 #include <TelepathyQt/Types>
26 
27 #include "message-view.h"
28 
29 namespace KTp {
30     class PendingLoggerOperation;
31     class ContactsModel;
32 }
33 
34 namespace Ui {
35     class LogViewer;
36 }
37 
38 class DatesModel;
39 class EntityModel;
40 class EntityFilterModel;
41 class PersonEntityMergeModel;
42 class QMenu;
43 
44 class LogViewer : public KXmlGuiWindow
45 {
46     Q_OBJECT
47 
48 public:
49     explicit LogViewer(const Tp::AccountFactoryPtr &accountFactory, const Tp::ConnectionFactoryPtr &connectionFactory,
50                        const Tp::ChannelFactoryPtr &channelFactory, const Tp::ContactFactoryPtr &contactFactory,
51                        QWidget *parent = 0);
52     ~LogViewer();
53 
54 private Q_SLOTS:
55     void onAccountManagerReady();
56 
57     void slotMergeModelInitialized();
58 
59     void onEntityListClicked(const QModelIndex &index);
60     void onDatesReceived();
61 
62     void slotDateClicked(const QModelIndex &index);
63 
64     void slotUpdateMainWindow();
65     void slotSetConversationDate(const QDate &date);
66 
67     void slotShowEntityListContextMenu(const QPoint &coords);
68     void slotClearGlobalSearch();
69     void slotStartGlobalSearch();
70     void onGlobalSearchFinished(KTp::PendingLoggerOperation *);
71 
72     void slotClearContactHistory();
73     void slotClearAccountHistory();
74 
75     void slotImportKopeteLogs(bool force = true);
76 
77     void slotJumpToPrevConversation();
78     void slotJumpToNextConversation();
79 
80     void slotConfigure();
81     void slotNoLogsForContact();
82 
83 private:
84     void setupActions();
85 
86     Ui::LogViewer *ui;
87     Tp::AccountManagerPtr m_accountManager;
88     DatesModel *m_datesModel;
89     KTp::ContactsModel *m_contactsModel;
90     EntityModel *m_entityModel;
91     PersonEntityMergeModel *m_mergeModel;
92     EntityFilterModel *m_filterModel;
93 
94     QPersistentModelIndex m_expandedPersona;
95 
96     QMenu *m_entityListContextMenu;
97 
98     QDate m_prevConversationDate;
99     QDate m_nextConversationDate;
100 
101 };
102 
103 #endif // LOGVIEWER_H
104