mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Create the sorting method.
This method should remove a row on the dive list model visualization if none of the tags that it have are marked as 'visible'. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
a6e9a1eab5
commit
4e3689370d
2 changed files with 34 additions and 2 deletions
|
@ -2150,3 +2150,28 @@ bool TagFilterModel::setData(const QModelIndex &index, const QVariant &value, in
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TagFilterSortModel::TagFilterSortModel(QObject *parent): QSortFilterProxyModel(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TagFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||||
|
{
|
||||||
|
QModelIndex index0 = sourceModel()->index(source_row, 0, source_parent);
|
||||||
|
QVariant diveVariant = sourceModel()->data(index0, DiveTripModel::DIVE_ROLE);
|
||||||
|
struct dive* d = (struct dive* ) diveVariant.value<void*>();
|
||||||
|
if(!d)
|
||||||
|
return false; // it's a trip.
|
||||||
|
|
||||||
|
// Checked means 'Show', Unchecked means 'Hide'.
|
||||||
|
struct tag_entry *head = d->tag_list;
|
||||||
|
|
||||||
|
while(head) {
|
||||||
|
QString tagName(head->tag->name);
|
||||||
|
int index = TagFilterModel::instance()->stringList().indexOf(tagName);
|
||||||
|
if (TagFilterModel::instance()->checkState[index] == false )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QStringListModel>
|
#include <QStringListModel>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
#include "../dive.h"
|
#include "../dive.h"
|
||||||
#include "../divelist.h"
|
#include "../divelist.h"
|
||||||
|
@ -217,7 +218,6 @@ struct TripItem;
|
||||||
|
|
||||||
class TreeModel : public QAbstractItemModel {
|
class TreeModel : public QAbstractItemModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TreeModel(QObject *parent = 0);
|
TreeModel(QObject *parent = 0);
|
||||||
virtual ~TreeModel();
|
virtual ~TreeModel();
|
||||||
|
@ -425,10 +425,17 @@ public:
|
||||||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||||
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
||||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
|
bool *checkState;
|
||||||
public slots:
|
public slots:
|
||||||
void repopulate();
|
void repopulate();
|
||||||
private:
|
private:
|
||||||
explicit TagFilterModel(QObject *parent = 0);
|
explicit TagFilterModel(QObject *parent = 0);
|
||||||
bool *checkState;
|
};
|
||||||
|
|
||||||
|
class TagFilterSortModel : public QSortFilterProxyModel {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
TagFilterSortModel(QObject *parent = 0);
|
||||||
|
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
|
||||||
};
|
};
|
||||||
#endif // MODELS_H
|
#endif // MODELS_H
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue