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