filter.h 942 Bytes
Newer Older
Giacomo Strangolino's avatar
Giacomo Strangolino committed
1
2
3
4
5
6
#ifndef FILTER_H
#define FILTER_H

#include <QStringList>
#define ICON_PATH QString("/runtime/elettra/share/icons/")

7
8
9
10
11
12
#include <QAbstractItemModel>
#include <QModelIndex>
#include <QTreeView>

class QAbstractItemModel;

Giacomo Strangolino's avatar
Giacomo Strangolino committed
13
14
class AlarmFilter
{
15
16
17
18
19
20
public:
    AlarmFilter() { ack_enable = ack = lev = stat = grp = false; }
    bool ack_enable, ack, lev, stat, grp;

    QString level, status;
    QStringList groups;
Giacomo Strangolino's avatar
Giacomo Strangolino committed
21

22
    void filter(QTreeView *m, const QString &column, const QString& f);
Giacomo Strangolino's avatar
Giacomo Strangolino committed
23
24
};

25
26
27
28
29
30
31
32
33
34
35
36
inline void AlarmFilter::filter(QTreeView *v, const QString& column, const QString& f)
{
    QAbstractItemModel *m = v->model();
    int c;
    for(c = 0; c < m->columnCount(); c++)
        if(m->headerData(c, Qt::Horizontal).toString() == column)
            break;
    for(int i = 0; i < m->rowCount(); i++) {
        v->setRowHidden(i, QModelIndex(), !f.isEmpty() && !m->data(m->index(i, c), Qt::DisplayRole).toString().contains(f));
    }
}

Giacomo Strangolino's avatar
Giacomo Strangolino committed
37
38
39
40

#endif