SVN_SILENT made messages (.desktop file) - always resolve ours
[trojita.git] / src / Gui / ProtocolLoggerWidget.h
blob1028a5411f6cc962f583a42fa4e6f010fe01de7d
2 /* Copyright (C) 2006 - 2014 Jan Kundrát <jkt@flaska.net>
4 This file is part of the Trojita Qt IMAP e-mail client,
5 http://trojita.flaska.net/
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of
10 the License or (at your option) version 3 or any later version
11 accepted by the membership of KDE e.V. (or its successor approved
12 by the membership of KDE e.V.), which shall act as a proxy
13 defined in Section 14 of version 3 of the license.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #ifndef GUI_PROTOCOLLOGGERWIDGET_H
25 #define GUI_PROTOCOLLOGGERWIDGET_H
27 #include <QMap>
28 #include <QWidget>
29 #include "Common/FileLogger.h"
30 #include "Common/RingBuffer.h"
31 #include "Imap/ConnectionState.h"
33 class QPushButton;
34 class QTabWidget;
35 class QPlainTextEdit;
36 class QTimer;
38 namespace Common {
39 class FileLogger;
42 namespace Gui {
44 /** @short Widget (etc) for a single connection */
45 struct ConnectionLog {
46 ConnectionLog();
47 QPlainTextEdit *widget;
48 Common::RingBuffer<Common::LogMessage> buffer;
49 qint64 closedTime;
52 /** @short Protocol chat logger
54 A widget used for displaying a log of textual communication between
55 the client and the IMAP mail server.
57 class ProtocolLoggerWidget : public QWidget
59 Q_OBJECT
60 public:
61 explicit ProtocolLoggerWidget(QWidget *parent = 0);
62 virtual ~ProtocolLoggerWidget();
64 public slots:
65 /** @short An IMAP model wants to log something */
66 void slotImapLogged(uint parserId, Common::LogMessage message);
68 void onConnectionClosed(uint parserId, Imap::ConnectionState state);
70 /** @short Enable/disable persistent logging */
71 void slotSetPersistentLogging(const bool enabled);
73 private slots:
74 /** @short A tab is requested to close */
75 void closeTab(int index);
76 /** @short Clear all logs */
77 void clearLogDisplay();
79 /** @short Copy contents of all buffers into the GUI widgets */
80 void slotShowLogs();
82 signals:
83 void persistentLoggingChanged(const bool active);
85 private:
86 QTabWidget *tabs;
87 QMap<uint, ConnectionLog> logs;
88 QPushButton *clearAll;
89 bool loggingActive;
90 QTimer *delayedDisplay;
91 Common::FileLogger *m_fileLogger;
93 /** @short Return (possibly newly created) logger widget for a given parser */
94 QPlainTextEdit *getLogger(const uint parserId);
96 /** @short Dump the log bufer contents to the GUI widget */
97 void flushToWidget(const uint parserId, Common::RingBuffer<Common::LogMessage> &buf);
99 virtual void showEvent(QShowEvent *e);
100 virtual void hideEvent(QHideEvent *e);
105 #endif // GUI_PROTOCOLLOGGERWIDGET_H