]> vaikene.ee Git - evaf/blobdiff - src/plugins/LogView/logview.h
Warning fixes and copyright update.
[evaf] / src / plugins / LogView / logview.h
index 383588de454272efb192c1c019531688143004c6..228a6895623b62e2a6791e3759abee7ca0b41092 100644 (file)
@@ -3,7 +3,7 @@
  * @brief Implementation of the LogView module
  * @author Enar Vaikene
  *
- * Copyright (c) 2011 Enar Vaikene
+ * Copyright (c) 2011-2019 Enar Vaikene
  *
  * This file is part of the eVaf C++ cross-platform application development framework.
  *
@@ -22,6 +22,7 @@
 
 #include <Plugins/iPlugin>
 #include <Common/iLogger>
+#include <Gui/Panel>
 
 #include <QObject>
 #include <QString>
 #include <QQueue>
 #include <QDateTime>
 
+class QListView;
+class QLabel;
+class QTabWidget;
+class QStatusBar;
+class QEvent;
 
 namespace eVaf {
 
@@ -62,20 +68,22 @@ public:
             : dt(QDateTime::currentDateTime())
             , severity(s)
             , text(t)
+            , simplified(t.simplified())
             , where(w)
         {}
 
         QDateTime dt;
         Common::iLogger::Severity severity;
         QString text;
+        QString simplified;
         QString where;
     };
 
-    Model(QObject * parent = 0);
+    Model(QObject * parent = nullptr);
 
     Message const & messageAt(int idx) const { return mData.at(idx); }
 
-    virtual int rowCount(QModelIndex const & parent = QModelIndex()) const { return mData.size(); }
+    virtual int rowCount(QModelIndex const & = QModelIndex()) const { return mData.size(); }
 
     virtual QVariant data(QModelIndex const & index, int role = Qt::DisplayRole) const;
 
@@ -112,12 +120,14 @@ private: // Members
 
 private: // Methods
 
-    inline char const * const severityText(Common::iLogger::Severity s) const;
+    inline char const * severityText(Common::iLogger::Severity s) const;
 
 };
 
 /**
  * The log view widget
+ *
+ * The Widget class implements a widget that shows messages from one logger source.
  */
 class Widget : public QWidget
 {
@@ -125,9 +135,59 @@ class Widget : public QWidget
 
 public:
 
-    Widget(QWidget * parent = 0, Qt::WindowFlags flags = 0);
+    Widget(QString const & source, QWidget * parent = nullptr);
+
+    QString const & source() const { return mSource; }
+
+    inline void addMessage(Common::iLogger::Severity severity, QString const & text, QString const & where)
+    {
+        mModel->addMessage(severity, text, where);
+    }
+
+
+private slots:
+
+    void messageAdded(QModelIndex const & index);
+
+    void currentChanged(QModelIndex const &, QModelIndex const &);
+
+    void copyToClipboard();
+
+    void saveToFile();
+
+
+private:
+
+    QString mSource;
+
+    Model * mModel;
+
+    bool mAutoScroll;
+
+    QListView * wList;
+    QLabel * wDetails;
+
+};
+
+/**
+ * The log view window
+ */
+class Window : public Gui::Panel
+{
+    Q_OBJECT
+
+public:
+
+    Window(QString const & args, QWidget * parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
 
-    virtual ~Widget();
+    virtual ~Window();
+
+    virtual bool event(QEvent * e);
+
+
+public slots:
+
+    void loggerEvent(Common::iLogger::Severity severity, QString const & text, QString const & source, QString const & where);
 
 
 private: // Methods
@@ -136,6 +196,16 @@ private: // Methods
 
     void restoreSettings();
 
+    QString getPanelName(QString const & args) const;
+
+
+private: // Members
+
+    QString mDefSource;
+    QTabWidget * wTabs;
+    QHash<QString, Widget *> mLogViews;
+    QStatusBar * wStatusBar;
+
 };
 
 /**
@@ -156,11 +226,11 @@ public:
 
     virtual void done();
 
-    virtual bool isReady() const { return wWidget != 0; }
+    virtual bool isReady() const { return wWindow != nullptr; }
 
 private: // Members
 
-    Widget * wWidget;
+    Window * wWindow;
 
 };