Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions panels/dock/taskmanager/abstractwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,6 @@ class AbstractWindow : public QObject
Q_PROPERTY(bool shouldSkip READ shouldSkip NOTIFY shouldSkipChanged FINAL)

public:
enum Roles {
winIdRole = Qt::UserRole + 1,
pidRole,
identityRole,
winIconRole,
winTitleRole,
activieRole,
shouldSkipRole
};
Q_ENUM(Roles)

virtual ~AbstractWindow() {};

virtual uint32_t id() = 0;
Expand Down
58 changes: 29 additions & 29 deletions panels/dock/taskmanager/abstractwindowmonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "abstractwindowmonitor.h"
#include "abstractwindow.h"
#include "globals.h"
#include "taskmanager.h"

namespace dock {
AbstractWindowMonitor::AbstractWindowMonitor(QObject* parent)
Expand All @@ -13,15 +15,13 @@ AbstractWindowMonitor::AbstractWindowMonitor(QObject* parent)

QHash<int, QByteArray> AbstractWindowMonitor::roleNames() const
{
return {
{AbstractWindow::winIdRole, "winId"},
{AbstractWindow::pidRole, "pid"},
{AbstractWindow::identityRole, "identity"},
{AbstractWindow::winIconRole, "icon"},
{AbstractWindow::winTitleRole, "title"},
{AbstractWindow::activieRole, "isActive"},
{AbstractWindow::shouldSkipRole, "shouldSkip"}
};
return {{TaskManager::WinIdRole, MODEL_WINID},
{TaskManager::PidRole, MODEL_PID},
{TaskManager::IdentityRole, MODEL_IDENTIFY},
{TaskManager::WinIconRole, MODEL_WINICON},
{TaskManager::WinTitleRole, MODEL_TITLE},
{TaskManager::ActiveRole, MODEL_ACTIVE},
{TaskManager::ShouldSkipRole, MODEL_SHOULDSKIP}};
}

int AbstractWindowMonitor::rowCount(const QModelIndex &parent) const
Expand All @@ -37,20 +37,20 @@ QVariant AbstractWindowMonitor::data(const QModelIndex &index, int role) const
auto window = m_trackedWindows[pos];

switch (role) {
case AbstractWindow::winIdRole:
return window->id();
case AbstractWindow::pidRole:
return window->pid();
case AbstractWindow::identityRole:
return window->identity();
case AbstractWindow::winIconRole:
return window->icon();
case AbstractWindow::winTitleRole:
return window->title();
case AbstractWindow::activieRole:
return window->isActive();
case AbstractWindow::shouldSkipRole:
return window->shouldSkip();
case TaskManager::WinIdRole:
return window->id();
case TaskManager::PidRole:
return window->pid();
case TaskManager::IdentityRole:
return window->identity();
case TaskManager::WinIconRole:
return window->icon();
case TaskManager::WinTitleRole:
return window->title();
case TaskManager::ActiveRole:
return window->isActive();
case TaskManager::ShouldSkipRole:
return window->shouldSkip();
}

return QVariant();
Expand All @@ -65,33 +65,33 @@ void AbstractWindowMonitor::trackWindow(AbstractWindow* window)
connect(window, &AbstractWindow::pidChanged, this, [this, window](){
auto pos = m_trackedWindows.indexOf(window);
auto modelIndex = index(pos);
Q_EMIT dataChanged(modelIndex, modelIndex, {AbstractWindow::pidRole});
Q_EMIT dataChanged(modelIndex, modelIndex, {TaskManager::PidRole});
});
connect(window, &AbstractWindow::identityChanged, this, [this, window](){
auto pos = m_trackedWindows.indexOf(window);
auto modelIndex = index(pos);
Q_EMIT dataChanged(modelIndex, modelIndex, {AbstractWindow::identityRole});
Q_EMIT dataChanged(modelIndex, modelIndex, {TaskManager::IdentityRole});
});
connect(window, &AbstractWindow::iconChanged, this, [this, window](){
auto pos = m_trackedWindows.indexOf(window);
auto modelIndex = index(pos);
Q_EMIT dataChanged(modelIndex, modelIndex, {AbstractWindow::winIconRole});
Q_EMIT dataChanged(modelIndex, modelIndex, {TaskManager::WinIconRole});
});
connect(window, &AbstractWindow::titleChanged, this, [this, window](){
auto pos = m_trackedWindows.indexOf(window);
auto modelIndex = index(pos);
Q_EMIT dataChanged(modelIndex, modelIndex, {AbstractWindow::winTitleRole});
Q_EMIT dataChanged(modelIndex, modelIndex, {TaskManager::WinTitleRole});
});

connect(window, &AbstractWindow::isActiveChanged, this, [this, window](){
auto pos = m_trackedWindows.indexOf(window);
auto modelIndex = index(pos);
Q_EMIT dataChanged(modelIndex, modelIndex, {AbstractWindow::activieRole});
Q_EMIT dataChanged(modelIndex, modelIndex, {TaskManager::ActiveRole});
});
connect(window, &AbstractWindow::shouldSkipChanged, this, [this, window](){
auto pos = m_trackedWindows.indexOf(window);
auto modelIndex = index(pos);
Q_EMIT dataChanged(modelIndex, modelIndex, {AbstractWindow::shouldSkipRole});
Q_EMIT dataChanged(modelIndex, modelIndex, {TaskManager::ShouldSkipRole});
});
}

Expand Down
3 changes: 2 additions & 1 deletion panels/dock/taskmanager/abstractwindowmonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
#pragma once

#include "abstractwindow.h"
#include "taskmanager.h"

#include <cstdint>

Check warning on line 10 in panels/dock/taskmanager/abstractwindowmonitor.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <cstdint> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <QObject>
#include <QAbstractListModel>
Expand All @@ -20,7 +21,7 @@
public:
QHash<int, QByteArray> roleNames() const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = AbstractWindow::winIdRole) const override;
QVariant data(const QModelIndex &index, int role = TaskManager::WinIdRole) const override;

void trackWindow(AbstractWindow* window);
void destroyWindow(AbstractWindow * window);
Expand Down
3 changes: 1 addition & 2 deletions panels/dock/taskmanager/taskmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

#include "abstracttaskmanagerinterface.h"
#include "abstractwindow.h"
#include "abstractwindowmonitor.h"
#include "containment.h"

Check warning on line 9 in panels/dock/taskmanager/taskmanager.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "containment.h" not found.
#include "dockcombinemodel.h"
#include "dockglobalelementmodel.h"
#include "dockitemmodel.h"
Expand All @@ -17,7 +16,7 @@

namespace dock {
class AppItem;

class AbstractWindowMonitor;
class TaskManager : public DS_NAMESPACE::DContainment, public AbstractTaskManagerInterface
{
Q_OBJECT
Expand Down