18 #include <unity/shell/application/ApplicationManagerInterface.h> 19 #include <unity/shell/application/ApplicationInfoInterface.h> 21 #include "applicationsfiltermodel.h" 25 ApplicationsFilterModel::ApplicationsFilterModel(QObject *parent):
26 QSortFilterProxyModel(parent),
28 m_filterTouchApps(false),
29 m_filterLegacyApps(false)
33 ApplicationManagerInterface *ApplicationsFilterModel::applicationsModel()
const 38 void ApplicationsFilterModel::setApplicationsModel(ApplicationManagerInterface *applicationsModel)
40 if (m_appModel != applicationsModel) {
42 disconnect(m_appModel, &ApplicationManagerInterface::countChanged,
this, &ApplicationsFilterModel::countChanged);
44 m_appModel = applicationsModel;
45 setSourceModel(m_appModel);
46 Q_EMIT applicationsModelChanged();
47 connect(m_appModel, &ApplicationManagerInterface::countChanged,
this, &ApplicationsFilterModel::countChanged);
51 bool ApplicationsFilterModel::filterTouchApps()
const 53 return m_filterTouchApps;
56 void ApplicationsFilterModel::setFilterTouchApps(
bool filterTouchApps)
58 if (m_filterTouchApps != filterTouchApps) {
59 m_filterTouchApps = filterTouchApps;
60 Q_EMIT filterTouchAppsChanged();
63 Q_EMIT countChanged();
67 bool ApplicationsFilterModel::filterLegacyApps()
const 69 return m_filterLegacyApps;
72 void ApplicationsFilterModel::setFilterLegacyApps(
bool filterLegacyApps)
74 if (m_filterLegacyApps != filterLegacyApps) {
75 m_filterLegacyApps = filterLegacyApps;
76 Q_EMIT filterLegacyAppsChanged();
79 Q_EMIT countChanged();
83 bool ApplicationsFilterModel::filterAcceptsRow(
int source_row,
const QModelIndex &source_parent)
const 85 Q_UNUSED(source_parent);
87 ApplicationInfoInterface *app = m_appModel->get(source_row);
89 if (m_filterLegacyApps && !app->isTouchApp()) {
92 if (m_filterTouchApps && app->isTouchApp()) {
98 ApplicationInfoInterface *ApplicationsFilterModel::get(
int index)
const 100 return m_appModel->get(mapToSource(this->index(index, 0)).row());