From e07de4e0a1bd56aab8f4ee81d6db252e442c3d7a Mon Sep 17 00:00:00 2001 From: Arno Date: Sun, 13 Oct 2013 07:25:50 +0200 Subject: Add filter bar to MappingTreeWidget Move matchRecursive from ArchiveModel to SmTreeModel so we can use it here, too. --- archivemodel.cpp | 43 ------------------------------------------- 1 file changed, 43 deletions(-) (limited to 'archivemodel.cpp') diff --git a/archivemodel.cpp b/archivemodel.cpp index 0f266ca..212c60d 100644 --- a/archivemodel.cpp +++ b/archivemodel.cpp @@ -163,38 +163,6 @@ bool ArchiveModel::setData(const QModelIndex &idx, const QVariant &value, int ro return false; } -bool ArchiveModel::matchRecursive(const QModelIndex &parent, const QRegExp ®ex, int column) const { - if(!parent.isValid()){ - return false; - } - // first try the parent itself - QString value = parent.data().toString(); - if(value.isEmpty()){ - return false; - } - if(value.contains(regex)){ - return true; - } - - // no match, check for children - SmTreeItem *item = static_cast(parent.internalPointer()); - if(!item->childCount()){ - //leaf, chech parents - return checkParents(item, regex, column); - } - - // we have children, traverse them - bool retval = false; - for(int i = 0; i < item->childCount(); ++i){ - QModelIndex newIdx = createIndex(i, column, item->child(i)); - retval = matchRecursive(newIdx, regex, column); - if(retval){ - break; - } - } - return retval; -} - bool ArchiveModel::removeNode(const QModelIndex &idx){ if(!idx.isValid()){ return false; @@ -619,17 +587,6 @@ void ArchiveModel::collectorFinished(QObject *thread){ emit message(msg); } -bool ArchiveModel::checkParents(const SmTreeItem *item, const QRegExp ®ex, int column) const { - while(item != root()){ - QString value = item->data(column).toString(); - if(value.contains(regex)){ - return true; - } - item = item->parent(); - } - return false; -} - void ArchiveModel::emitDatabaseError(const QSqlError &e){ QString databaseText = e.databaseText().isEmpty() ? tr("(none)") : e.databaseText(); QString driverText = e.driverText().isEmpty() ? tr("(none)") : e.driverText(); -- cgit v1.2.3-70-g09d2