Fork me on GitHub
2.15.20
FGx
A cross-platform launcher for FlightGear
aircraftproxymodel.cpp
Go to the documentation of this file.
1 
2 #include <QtDebug>
3 #include <QStandardItemModel>
4 #include "aircraftproxymodel.h"
5 
8 {
9 }
10 
11 // This adds or removed entries to the filter
12 void AircraftProxyModel::show_dir(QString dir, bool show){
13 
14  int idx = this->dirs.indexOf(dir);
15 
16  if(show == false){
17  if( idx != -1){
18  this->dirs.removeAt(idx);
19  }
20  } else {
21  if( idx == -1){
22  this->dirs.append(dir);
23  }
24  }
25  this->invalidateFilter();
26 }
27 
28 bool AircraftProxyModel::filterAcceptsRow(int source_row, const QModelIndex & source_parent ) const {
29 
30  QModelIndex dirIdx = this->sourceModel()->index(source_row, 7);
31  QString dir = this->sourceModel()->data(dirIdx, Qt::DisplayRole).toString();
32  int idx = this->dirs.indexOf(dir);
33  if(idx == -1){
34  return false;
35  }
36  return QSortFilterProxyModel::filterAcceptsRow( source_row, source_parent);
37 }
AircraftProxyModel(QObject *parent=0)
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
void show_dir(QString dir, bool show)