Treat buddy as Buddy and Divemaster, sort the filter lists.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2014-10-31 17:13:09 -02:00 committed by Dirk Hohndel
parent 2827da5ecf
commit 03c22c3b18
2 changed files with 12 additions and 6 deletions

View file

@ -2282,6 +2282,7 @@ void TagFilterModel::repopulate()
list.append(QString(current_tag_entry->tag->name)); list.append(QString(current_tag_entry->tag->name));
current_tag_entry = current_tag_entry->next; current_tag_entry = current_tag_entry->next;
} }
qSort(list);
list << tr("Empty Tags"); list << tr("Empty Tags");
setStringList(list); setStringList(list);
delete[] checkState; delete[] checkState;
@ -2383,9 +2384,9 @@ bool BuddyFilterModel::filterRow(int source_row, const QModelIndex &source_paren
// Checked means 'Show', Unchecked means 'Hide'. // Checked means 'Show', Unchecked means 'Hide'.
QString diveBuddy(d->buddy); QString diveBuddy(d->buddy);
QString divemaster(d->divemaster);
// only show empty buddie dives if the user checked that. // only show empty buddie dives if the user checked that.
if (diveBuddy.isEmpty()) { if (diveBuddy.isEmpty() && divemaster.isEmpty()) {
if (rowCount() > 0) if (rowCount() > 0)
return checkState[rowCount() - 1]; return checkState[rowCount() - 1];
else else
@ -2397,7 +2398,7 @@ bool BuddyFilterModel::filterRow(int source_row, const QModelIndex &source_paren
if (!buddyList.isEmpty()) { if (!buddyList.isEmpty()) {
buddyList.removeLast(); // remove the "Show Empty Tags"; buddyList.removeLast(); // remove the "Show Empty Tags";
for(int i = 0; i < rowCount(); i++){ for(int i = 0; i < rowCount(); i++){
if(checkState[i] && diveBuddy.indexOf(stringList()[i]) != -1){ if(checkState[i] && (diveBuddy.indexOf(stringList()[i]) != -1 || divemaster.indexOf(stringList()[i]) != -1 )){
return true; return true;
} }
} }
@ -2418,11 +2419,15 @@ void BuddyFilterModel::repopulate()
for_each_dive (i, dive) for_each_dive (i, dive)
{ {
QString buddy(dive->buddy); QString buddy(dive->buddy);
if (!list.contains(buddy)) { QString divemaster(dive->divemaster);
if (!buddy.isEmpty() && !list.contains(buddy)) {
list.append(buddy); list.append(buddy);
} }
if(!divemaster.isEmpty() && !list.contains(divemaster)){
list.append(divemaster);
}
} }
setStringList(list); qSort(list);
list << tr("No Buddies"); list << tr("No Buddies");
setStringList(list); setStringList(list);
delete[] checkState; delete[] checkState;

View file

@ -484,7 +484,8 @@ void TagFilter::hideEvent(QHideEvent *event)
BuddyFilter::BuddyFilter(QWidget *parent) : QWidget(parent) BuddyFilter::BuddyFilter(QWidget *parent) : QWidget(parent)
{ {
ui.setupUi(this); ui.setupUi(this);
ui.label->setText(tr("Buddies: ")); ui.label->setText(tr("Person: "));
ui.label->setToolTip(tr("Searches for Buddies and Divemasters"));
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
ui.filterInternalList->setClearButtonEnabled(true); ui.filterInternalList->setClearButtonEnabled(true);
#endif #endif