Go to the documentation of this file.00001 #ifndef MODELFILTER_HPP
00002 #define MODELFILTER_HPP
00003
00004 #include <chrono>
00005 #include <QSortFilterProxyModel>
00006 #include <QDateTime>
00007 #include <QString>
00008 #include <QRegExpValidator>
00009
00010 typedef std::chrono::high_resolution_clock::time_point TimePoint;
00011
00012 class ModelFilter : public QSortFilterProxyModel
00013 {
00014 Q_OBJECT
00015 public:
00016 explicit ModelFilter(QObject *parent = 0);
00017
00018 typedef enum{
00019 CONTAINS_ONE = 0,
00020 WILDCARDS = 1,
00021 REGEX = 2
00022 }FilterMode;
00023
00024 signals:
00025
00026 public slots:
00027
00028 void setMessageFilterEnabled(bool enabled);
00029 void setNodeFilterEnabled(bool enabled);
00030 void setSourceFilterEnabled(bool enabled);
00031 void setTimeFilterEnabled(bool enabled);
00032
00033 void messageFilterUpdated(FilterMode mode, const QString& text );
00034 void nodeFilterUpdated(FilterMode mode, const QString& text );
00035 void sourceFilterUpdated(FilterMode mode, const QString& text );
00036 void timeMinMaxUpdated(TimePoint min, TimePoint max);
00037
00038 void setSeverityInfoEnabled(bool enabled);
00039 void setSeverityDebugEnabled(bool enabled);
00040 void setSeverityErrorEnabled(bool enabled);
00041 void setSeverityWarningsEnabled(bool enabled);
00042
00043 private:
00044 bool applyFilter(const QString &filter, ModelFilter::FilterMode mode,
00045 const QString& text_to_parse, const QRegExpValidator *validator) const;
00046
00047 protected:
00048 virtual bool filterAcceptsRow(int sourceRow,
00049 const QModelIndex &sourceParent) const override;
00050
00051 TimePoint _min;
00052 TimePoint _max;
00053
00054 bool _node_filter_enabled;
00055 bool _source_filter_enabled;
00056 bool _msg_filter_enabled;
00057 bool _time_filter_enabled;
00058
00059 bool _debug_filter_enabled;
00060 bool _info_filter_enabled;
00061 bool _error_filter_enabled;
00062 bool _warn_filter_enabled;
00063
00064 FilterMode _node_mode;
00065 FilterMode _msg_mode;
00066 FilterMode _source_mode;
00067
00068 QString _node_text;
00069 QString _msg_text;
00070 QString _source_text;
00071
00072 QRegExpValidator _node_validator;
00073 QRegExpValidator _msg_validator;
00074 QRegExpValidator _source_validator;
00075 };
00076
00077 #endif // MODELFILTER_HPP