Skip to content

Commit

Permalink
DEV: Merge from default
Browse files Browse the repository at this point in the history
--HG--
branch : stable
  • Loading branch information
emminizer committed Mar 15, 2022
2 parents 4095fe5 + f80248e commit 10b3173
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 34 deletions.
40 changes: 10 additions & 30 deletions SDK/simQt/SettingsProxyModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,70 +234,50 @@ bool SettingsNoEmptyFoldersFilter::isFolder_(int sourceRow, const QModelIndex& s
SettingsProxyModel::SettingsProxyModel(QAbstractItemModel* settingsModel, QWidget* parent)
: QSortFilterProxyModel(parent)
{
// Chain so that search>dataLevel>noempty
search_ = new SettingsSearchFilter(settingsModel, parent);
dataLevel_ = new SettingsDataLevelFilter(search_, parent);
noEmptyFolders_ = new SettingsNoEmptyFoldersFilter(dataLevel_, parent);
// Chain so that dataLevel>search>noempty
dataLevel_ = new SettingsDataLevelFilter(settingsModel, parent);
search_ = new SettingsSearchFilter(dataLevel_, parent);
noEmptyFolders_ = new SettingsNoEmptyFoldersFilter(search_, parent);
setSourceModel(noEmptyFolders_);

connect(settingsModel, SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(invalidateAll_()));
connect(settingsModel, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(invalidateAll_()));
connect(settingsModel, SIGNAL(modelReset()), this, SLOT(invalidateAll_()));
connect(settingsModel, SIGNAL(rowsInserted(QModelIndex, int, int)), dataLevel_, SLOT(invalidate()));
connect(settingsModel, SIGNAL(rowsRemoved(QModelIndex, int, int)), dataLevel_, SLOT(invalidate()));
connect(settingsModel, SIGNAL(modelReset()), dataLevel_, SLOT(invalidate()));
}

SettingsProxyModel::~SettingsProxyModel()
{
delete noEmptyFolders_;
delete dataLevel_;
delete search_;
delete dataLevel_;
}

void SettingsProxyModel::setFilterText(const QString& filterText)
{
if (filterText != search_->filterText())
{
search_->setFilterText(filterText);
noEmptyFolders_->invalidate();
invalidateFilter();
}
}

QModelIndexList SettingsProxyModel::match(const QModelIndex& start, int role, const QVariant& value, int hits, Qt::MatchFlags flags) const
{
auto searchList = search_->match(start, role, value, hits, flags);
auto searchList = search_->match(noEmptyFolders_->mapToSource(mapToSource(start)), role, value, hits, flags);
QModelIndexList rv;
for (auto index : searchList)
rv.push_back(mapFromSource(noEmptyFolders_->mapFromSource(dataLevel_->mapFromSource(index))));
rv.push_back(mapFromSource(noEmptyFolders_->mapFromSource(index)));

return rv;
}

void SettingsProxyModel::invalidateAll_()
{
search_->invalidate();
dataLevel_->invalidate();
noEmptyFolders_->invalidate();
invalidateFilter();
}

void SettingsProxyModel::setShowAdvanced(bool showAdvanced)
{
if (showAdvanced != dataLevel_->showAdvanced())
{
dataLevel_->setShowAdvanced(showAdvanced);
noEmptyFolders_->invalidate();
invalidateFilter();
}
}

void SettingsProxyModel::setShowUnknown(bool showUnknown)
{
if (showUnknown != dataLevel_->showUnknown())
{
dataLevel_->setShowUnknown(showUnknown);
noEmptyFolders_->invalidate();
invalidateFilter();
}
}

}
4 changes: 0 additions & 4 deletions SDK/simQt/SettingsProxyModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,6 @@ public slots:
/** Changes the filter text */
void setFilterText(const QString& filterText);

private slots:
/** Reacts to a change in the list of settings, such as when a new setting is registered */
void invalidateAll_();

private:
SettingsSearchFilter* search_;
SettingsDataLevelFilter* dataLevel_;
Expand Down

0 comments on commit 10b3173

Please sign in to comment.