diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index d7b48ce77..273517ffb 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -34,7 +34,7 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec setItemDelegate(new DiveListDelegate(this)); setUniformRowHeights(true); setItemDelegateForColumn(DiveTripModel::RATING, new StarWidgetsDelegate(this)); - QSortFilterProxyModel *model = new QSortFilterProxyModel(this); + TagFilterSortModel *model = new TagFilterSortModel(this); model->setSortRole(DiveTripModel::SORT_ROLE); model->setFilterKeyColumn(-1); // filter all columns model->setFilterCaseSensitivity(Qt::CaseInsensitive); @@ -57,8 +57,8 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec searchBox.installEventFilter(this); searchBox.hide(); - connect(showSearchBox, SIGNAL(triggered(bool)), this, SLOT(showSearchEdit())); - connect(&searchBox, SIGNAL(textChanged(QString)), model, SLOT(setFilterFixedString(QString))); +// connect(showSearchBox, SIGNAL(triggered(bool)), this, SLOT(showSearchEdit())); +// connect(&searchBox, SIGNAL(textChanged(QString)), model, SLOT(setFilterFixedString(QString))); } // # Date Rtg Dpth Dur Tmp Wght Suit Cyl Gas SAC OTU CNS Loc diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index def258a5f..f1f1f636c 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -2146,6 +2146,7 @@ bool TagFilterModel::setData(const QModelIndex &index, const QVariant &value, in { if(role == Qt::CheckStateRole){ checkState[index.row()] = value.toBool(); + dataChanged(index,index); return true; } return false; @@ -2153,7 +2154,7 @@ bool TagFilterModel::setData(const QModelIndex &index, const QVariant &value, in TagFilterSortModel::TagFilterSortModel(QObject *parent): QSortFilterProxyModel(parent) { - + connect(TagFilterModel::instance(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(invalidate())); } bool TagFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const @@ -2162,16 +2163,25 @@ bool TagFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &sou QVariant diveVariant = sourceModel()->data(index0, DiveTripModel::DIVE_ROLE); struct dive* d = (struct dive* ) diveVariant.value(); if(!d) - return false; // it's a trip. - + return false; // Checked means 'Show', Unchecked means 'Hide'. struct tag_entry *head = d->tag_list; + if (!head){ // doesn't have tags, only show if no tags are selected. + for(int i = 0; i < TagFilterModel::instance()->stringList().count(); i++){ + if (TagFilterModel::instance()->checkState[i]) + return false; + } + return true; + } + + // have at least one tag. while(head) { QString tagName(head->tag->name); int index = TagFilterModel::instance()->stringList().indexOf(tagName); - if (TagFilterModel::instance()->checkState[index] == false ) + if (TagFilterModel::instance()->checkState[index]) return true; + head = head->next; } return false; }