7 struct KLsofWidgetPrivate
{
12 KLsofWidget::KLsofWidget(QWidget
*parent
) : QTreeWidget(parent
), d(new KLsofWidgetPrivate
)
16 setUniformRowHeights(true);
17 setRootIsDecorated(false);
18 setItemsExpandable(false);
19 setSortingEnabled(true);
20 setAllColumnsShowFocus(true);
21 setHeaderLabels(QStringList() << i18nc("Short for File Descriptor", "FD") << i18n("Type") << i18n("Object"));
22 d
->process
= new QProcess(this);
23 connect(d
->process
, SIGNAL(finished ( int, QProcess::ExitStatus
)), this, SLOT(finished(int, QProcess::ExitStatus
)));
26 KLsofWidget::~KLsofWidget()
31 qlonglong
KLsofWidget::pid() const
36 void KLsofWidget::setPid(qlonglong pid
) {
41 bool KLsofWidget::update()
45 d
->process
->waitForFinished();
48 args
<< ("-p" + QString::number(d
->pid
));
49 d
->process
->start("lsof", args
);
53 void KLsofWidget::finished ( int exitCode
, QProcess::ExitStatus exitStatus
)
56 QTreeWidgetItem
*process
= NULL
;
58 qint64 lineLength
= d
->process
->readLine(buf
, sizeof(buf
));
62 if(buf
[lineLength
-1] == '\n')
66 /* Process related stuff */
68 process
= new QTreeWidgetItem(this);
69 process
->setText(0,QString::fromUtf8(buf
+1, lineLength
- 1));
73 process
->setText(1,QString::fromUtf8(buf
+1, lineLength
- 1));
78 process
->setText(2,QString::fromUtf8(buf
+1, lineLength
- 1));