Make the processview more appealing by expanding pid 1
parent
fce3ebedca
commit
31f2e0078d
|
@ -107,6 +107,7 @@ ApplicationWindow {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
TextField {
|
TextField {
|
||||||
id: processFilterInput
|
id: processFilterInput
|
||||||
|
focus: true
|
||||||
width: parent.width
|
width: parent.width
|
||||||
placeholderText: "Filter processes"
|
placeholderText: "Filter processes"
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
|
@ -122,14 +123,14 @@ ApplicationWindow {
|
||||||
model: processes
|
model: processes
|
||||||
sortIndicatorVisible: true
|
sortIndicatorVisible: true
|
||||||
alternatingRowColors: true
|
alternatingRowColors: true
|
||||||
TableViewColumn {
|
|
||||||
title: "pid"
|
|
||||||
role: "pid"
|
|
||||||
}
|
|
||||||
TableViewColumn {
|
TableViewColumn {
|
||||||
title: "name"
|
title: "name"
|
||||||
role: "name"
|
role: "name"
|
||||||
}
|
}
|
||||||
|
TableViewColumn {
|
||||||
|
title: "pid"
|
||||||
|
role: "pid"
|
||||||
|
}
|
||||||
TableViewColumn {
|
TableViewColumn {
|
||||||
title: "cpu"
|
title: "cpu"
|
||||||
role: "cpu"
|
role: "cpu"
|
||||||
|
@ -140,29 +141,19 @@ ApplicationWindow {
|
||||||
var role = getColumn(processView.sortIndicatorColumn).role;
|
var role = getColumn(processView.sortIndicatorColumn).role;
|
||||||
model.sortByRole(role, processView.sortIndicatorOrder);
|
model.sortByRole(role, processView.sortIndicatorOrder);
|
||||||
}
|
}
|
||||||
Component.onCompleted: {
|
Timer {
|
||||||
var r = processView.rootIndex;
|
interval: 100; running: true; repeat: true
|
||||||
var a = processes.index(0, 0, r);
|
onTriggered: {
|
||||||
var b = processes.index(1, 0, r);
|
var root = processView.rootIndex;
|
||||||
processView.expand(processView.rootIndex);
|
var systemd = processes.index(1, 0, root);
|
||||||
processView.expand(a);
|
if (processes.data(systemd) === "systemd") {
|
||||||
processView.expand(b);
|
processView.expand(systemd);
|
||||||
processes.rowsInserted.connect(function (index) {
|
running = false;
|
||||||
processView.expand(processView.rootIndex);
|
}
|
||||||
processView.expand(index);
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
view->connect(&models->sortedProcesses, &QAbstractItemModel::rowsInserted,
|
|
||||||
view, [view](const QModelIndex& index) {
|
|
||||||
if (!index.isValid()) {
|
|
||||||
view->expandAll();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
Tab {
|
Tab {
|
||||||
id: chartTab
|
id: chartTab
|
||||||
|
|
|
@ -1 +1,17 @@
|
||||||
|
#include "SortedModel.h"
|
||||||
|
|
||||||
|
bool SortedModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
|
||||||
|
{
|
||||||
|
if (QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QModelIndex source_index = sourceModel()->index(source_row, 0, source_parent);
|
||||||
|
for (int i = 0 ; i < sourceModel()->rowCount(source_index); ++i) {
|
||||||
|
if (filterAcceptsRow(i, source_index)) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#include "SortedModel.moc"
|
#include "SortedModel.moc"
|
||||||
|
|
|
@ -8,6 +8,10 @@ class SortedModel : public QSortFilterProxyModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
SortedModel() :QSortFilterProxyModel() {}
|
SortedModel() :QSortFilterProxyModel() {}
|
||||||
|
bool filterAcceptsRow ( int source_row, const QModelIndex & source_parent ) const;
|
||||||
|
Q_INVOKABLE QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const {
|
||||||
|
return QSortFilterProxyModel::data(index, role);
|
||||||
|
}
|
||||||
public slots:
|
public slots:
|
||||||
void sortByRole(const QString& role, Qt::SortOrder order) {
|
void sortByRole(const QString& role, Qt::SortOrder order) {
|
||||||
QHashIterator<int, QByteArray> i(roleNames());
|
QHashIterator<int, QByteArray> i(roleNames());
|
||||||
|
|
Loading…
Reference in New Issue