]>
vaikene.ee Git - evaf/blob - src/plugins/LogView/logview.h
2 * @file LogView/logview.h
3 * @brief Implementation of the LogView module
6 * Copyright (c) 2011 Enar Vaikene
8 * This file is part of the eVaf C++ cross-platform application development framework.
10 * This file can be used under the terms of the GNU General Public License
11 * version 3.0 as published by the Free Software Foundation and appearing in
12 * the file LICENSE included in the packaging of this file. Please review the
13 * the following information to ensure the GNU General Public License version
14 * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
16 * Alternatively, this file may be used in accordance with the Commercial License
17 * Agreement provided with the Software.
20 #ifndef __LOGVIEW_LOGVIEW_H
21 # define __LOGVIEW_LOGVIEW_H
23 #include <Plugins/iPlugin>
24 #include <Common/iLogger>
29 #include <QAbstractListModel>
37 * Module for showing messages output with the eVaf::Common::iLogger interface.
39 * The LogView module implements a widget that shows all the messages output with the
40 * eVaf::Common::iLogger interface.
45 * Internal implementation of the LogView module.
50 * Data model for the log view widget
52 class Model
: public QAbstractListModel
58 /// One logger message
61 Message(Common::iLogger::Severity s
, QString
const & t
, QString
const & w
)
62 : dt(QDateTime::currentDateTime())
69 Common::iLogger::Severity severity
;
74 Model(QObject
* parent
= 0);
76 Message
const & messageAt(int idx
) const { return mData
.at(idx
); }
78 virtual int rowCount(QModelIndex
const & parent
= QModelIndex()) const { return mData
.size(); }
80 virtual QVariant
data(QModelIndex
const & index
, int role
= Qt::DisplayRole
) const;
82 void addMessage(Common::iLogger::Severity severity
, QString
const & text
, QString
const & where
);
84 QString
details(QModelIndex
const & index
) const;
86 bool saveToFile(QString
const & fileName
);
88 bool copyToClipboard(QModelIndex
const & index
);
90 QString
errorString() const { return mErrorString
; }
95 void messageAdded(QModelIndex
const & index
);
100 /// Maximum number of lines in the queue
101 static int const MaxLines
;
103 /// Human-readable texts for message severity levels
104 static char const * const SeverityText
[Common::iLogger::Count
];
106 /// Currently shown messages
107 QQueue
<Message
> mData
;
109 /// Human-readable error string if the last operation failed
110 QString mErrorString
;
115 inline char const * const severityText(Common::iLogger::Severity s
) const;
120 * The log view widget
122 class Widget
: public QWidget
128 Widget(QWidget
* parent
= 0, Qt::WindowFlags flags
= 0);
137 void restoreSettings();
142 * LogView module's implementation
144 class Module
: public Plugins::iPlugin
147 Q_INTERFACES(eVaf::Plugins::iPlugin
)
155 virtual bool init(QString
const & args
);
159 virtual bool isReady() const { return wWidget
!= 0; }
167 } // namespace eVaf::LogView::Internal
168 } // namespace eVaf::LogView