File indexing completed on 2024-11-10 05:02:45
0001 /* 0002 SPDX-FileCopyrightText: 2022 Fushan Wen <qydwhotmail@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "maximizedwindowmonitor.h" 0008 0009 #include "abstracttasksmodel.h" // For enums 0010 #include "activityinfo.h" 0011 #include "virtualdesktopinfo.h" 0012 0013 MaximizedWindowMonitor::MaximizedWindowMonitor(QObject *parent) 0014 : TaskManager::TasksModel(parent) 0015 , m_activityInfo(activityInfo()) 0016 , m_virtualDesktopInfo(virtualDesktopInfo()) 0017 { 0018 setSortMode(SortMode::SortActivity); 0019 setGroupMode(GroupMode::GroupDisabled); 0020 0021 auto currentActivity = std::bind(&TaskManager::ActivityInfo::currentActivity, m_activityInfo); 0022 auto setCurrentActivity = std::bind(&TaskManager::TasksModel::setActivity, this, currentActivity); 0023 setCurrentActivity(); 0024 connect(m_activityInfo.get(), &TaskManager::ActivityInfo::currentActivityChanged, this, setCurrentActivity); 0025 0026 auto currentDesktop = std::bind(&TaskManager::VirtualDesktopInfo::currentDesktop, m_virtualDesktopInfo); 0027 auto setCurrentDesktop = std::bind(&TaskManager::TasksModel::setVirtualDesktop, this, currentDesktop); 0028 setCurrentDesktop(); 0029 connect(m_virtualDesktopInfo.get(), &TaskManager::VirtualDesktopInfo::currentDesktopChanged, this, setCurrentDesktop); 0030 0031 setFilterMinimized(true); 0032 setFilterByActivity(true); 0033 setFilterByVirtualDesktop(true); 0034 setFilterByRegion(RegionFilterMode::Mode::Intersect); 0035 } 0036 0037 MaximizedWindowMonitor::~MaximizedWindowMonitor() 0038 { 0039 } 0040 0041 bool MaximizedWindowMonitor::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const 0042 { 0043 const QModelIndex sourceIndex = sourceModel()->index(sourceRow, 0); 0044 0045 if (!TaskManager::TasksModel::filterAcceptsRow(sourceRow, sourceParent)) { 0046 return false; 0047 } 0048 0049 if (sourceIndex.data(TaskManager::AbstractTasksModel::IsMaximized).toBool() || sourceIndex.data(TaskManager::AbstractTasksModel::IsFullScreen).toBool()) { 0050 return true; 0051 } 0052 0053 return false; 0054 }