+ auto pidSensor = new ProcessSensor<qlonglong>(this, QStringLiteral("process/pid"), i18n("PID"), &KSysGuard::Process::pid, KSysGuard::Process::Status);
+ pidSensor->setDescription(i18n("The unique Process ID that identifies this process."));
+ d->m_coreAttributes << pidSensor;
+
+ auto parentPidSensor = new ProcessSensor<qlonglong>(this, QStringLiteral("process/parentPid"), i18n("Parent PID"), &KSysGuard::Process::parentPid);
+ d->m_coreAttributes << parentPidSensor;
+
+ auto loginSensor = new ProcessSensor<QString>(this, QStringLiteral("process/login"), i18n("Login"), &KSysGuard::Process::login, KSysGuard::Process::Login);
+ loginSensor->setDescription(i18n("The user who owns this process."));
+ d->m_coreAttributes << loginSensor;
+
+ auto uidSensor = new ProcessSensor<qlonglong>(this, QStringLiteral("process/uid"), i18n("UID"), &KSysGuard::Process::uid, KSysGuard::Process::Uids);
+ d->m_coreAttributes << uidSensor;
+
+ auto userNameSensor = new ProcessSensor<QString>(this, QStringLiteral("process/username"), i18n("Username"), [](KSysGuard::Process *p) {
+ KUser user(p->uid());
+ QString username;
+ if (user.isValid()) {
+ username = user.loginName();
+ }
+ return username;
+ }, KSysGuard::Process::Uids);
+ d->m_coreAttributes << userNameSensor;
+
+ auto canUserLoginSensor = new ProcessSensor<bool>(this, QStringLiteral("process/canUserLogin"), i18n("Can Login"), [](KSysGuard::Process *p) {
+ K_UID uid = p->uid();
+ if (uid == 65534) {
+ return false;
+ }
+
+ KUser user(uid);
+ if (!user.isValid()) {
+ //for some reason the user isn't recognised. This might happen under certain security situations.
+ //Just return true to be safe
+ return true;
+ }
+ const QString shell = user.shell();
+ if (shell == QLatin1String("/bin/false")) { //FIXME - add in any other shells it could be for false
+ return false;
+ }
+ return true;
+ }, KSysGuard::Process::Uids);
+ d->m_coreAttributes << canUserLoginSensor;
+
+ auto euidSensor = new ProcessSensor<qlonglong>(this, QStringLiteral("process/euid"), i18n("EUID"), &KSysGuard::Process::euid, KSysGuard::Process::Uids);
+ d->m_coreAttributes << euidSensor;
+
+ auto suidSensor = new ProcessSensor<qlonglong>(this, QStringLiteral("process/suid"),
+ auto fsuidSensor = new ProcessSensor<qlonglong>(this, QStringLiteral("process/fsuid"), i18n("fsuid"), &KSysGuard::Process::fsuid, KSysGuard::Process::Uids);
+ d->m_coreAttributes << fsuidSensor;
+
+ auto gidSensor = new ProcessSensor<qlonglong>(this, QStringLiteral("process/gid"), i18n("gid"), &KSysGuard::Process::gid, KSysGuard::Process::Gids);
+ d->m_coreAttributes << gidSensor;
+
+ auto egidSensor = new ProcessSensor<qlonglong>(this, QStringLiteral("process/egid"), i18n("egid"), &KSysGuard::Process::egid, KSysGuard::Process::Gids);
+ d->m_coreAttributes << egidSensor;
+
+ auto sgidSensor = new ProcessSensor<qlonglong>(this, QStringLiteral("process/sgid"), i18n("sgid"), &KSysGuard::Process::sgid, KSysGuard::Process::Gids);
+ d->m_coreAttributes << sgidSensor;
+
+ auto fsgidSensor = new ProcessSensor<qlonglong>(this, QStringLiteral("process/fsgid"), i18n("fsgid"), &KSysGuard::Process::fsgid, KSysGuard::Process::Gids);
+ d->m_coreAttributes << fsgidSensor;
+
+ auto tracerpidSensor = new ProcessSensor<qlonglong>(this, QStringLiteral("process/tracerpid"), i18n("Tracer Pid"), &KSysGuard::Process::tracerpid);
+ d->m_coreAttributes << tracerpidSensor;
+
+
+ auto ttySensor = new ProcessSensor<QByteArray>(this, QStringLiteral("process/tty"), i18n("tty"), &KSysGuard::Process::tty, KSysGuard::Process::Tty);
+ ttySensor->setDescription(i18n("The controlling terminal on which this process is running."));
+ d->m_coreAttributes << ttySensor;
+
+ auto userTimeSensor = new ProcessSensor<qlonglong>(this, QStringLiteral("process/userTime"), i18n("User Time"), &KSysGuard::Process::userTime);
+ d->m_coreAttributes << userTimeSensor;
+
+ auto sysTimeSensor = new ProcessSensor<qlonglong>(this, QStringLiteral("process/sysTime"), i18n("System Time"), &KSysGuard::Process::sysTime);
+ timeSensor->setDescription(i18n("The total user and system time that this process has been running for"));
+ d->m_coreAttributes << timeSensor;
+
+ auto startTimeSensor = new ProcessSensor<qlonglong>(this, QStringLiteral("process/startTime"), i18n("Start Time"), &KSysGuard::Process::startTime);
+ startTimeSensor->setDescription(i18n("The elapsed time since the process was started."));
+ startTimeSensor->setUnit(KSysGuard::UnitTime);
+ d->m_coreAttributes << startTimeSensor;
+
+ auto userUsageSensor = new ProcessSensor<int>(this, QStringLiteral("process/userUsage"), i18n("User CPU Usage"), &KSysGuard::Process::userUsage, KSysGuard::Process::Usage);
+ auto sysUsageSensor = new ProcessSensor<int>(this, QStringLiteral("process/sysUsage"), i18n("System CPU Usage"), &KSysGuard::Process::sysUsage, KSysGuard::Process::Usage);
+ this, QStringLiteral("process/usage"), i18n("Total CPU Usage"), [](KSysGuard::Process *p) {
+ return p->userUsage() + p->sysUsage();
+ },
+ KSysGuard::Process::Usage);
+ usageSensor->setShortName(i18n("CPU"));
+ usageSensor->setMin(0);
+ usageSensor->setMax(100);
+ usageSensor->setUnit(KSysGuard::UnitPercent);
+ usageSensor->setDescription(i18n("The current total CPU usage of the process."));
+ d->m_coreAttributes << usageSensor;
+
+ auto totalUserUsageSensor = new ProcessSensor<int>(this, QStringLiteral("process/totalUserUsage"), i18n("Group User CPU Usage"), &KSysGuard::Process::totalUserUsage, KSysGuard::Process::TotalUsage);
+ totalUserUsageSensor->setDescription(i18n("The amount of userspace CPU used by this process and all its children."));
+ auto totalSysUsageSensor = new ProcessSensor<int>(this, QStringLiteral("process/totalSysUsage"), i18n("Group System CPU Usage"), &KSysGuard::Process::totalSysUsage, KSysGuard::Process::TotalUsage);
+ totalUserUsageSensor->setDescription(i18n("The amount of system CPU used by this process and all its children."));
+ auto niceLevelSensor = new ProcessSensor<int>(this, QStringLiteral("process/niceLevel"), i18n("Nice Level"), &KSysGuard::Process::niceLevel, KSysGuard::Process::NiceLevels);
+ niceLevelSensor->setDescription(i18n("The priority with which this process is being run. For the normal scheduler, this ranges from 19 (very nice, least priority) to -19 (top priority)."));
+ d->m_coreAttributes << niceLevelSensor;
+
+ auto schedulerSensor = new ProcessSensor<uint>(this, QStringLiteral("process/scheduler"), i18n("Scheduler"), &KSysGuard::Process::scheduler, KSysGuard::Process::NiceLevels);
+ d->m_coreAttributes << schedulerSensor;
+
+ auto ioPriorityClassSensor = new ProcessSensor<uint>(this, QStringLiteral("process/ioPriorityClass"), i18n("IO Priority Class"),
+ auto vmSizeSensor = new ProcessSensor<qlonglong>(this, QStringLiteral("process/vmSize"), i18n("VM Size"), &KSysGuard::Process::vmSize, KSysGuard::Process::VmSize);
+ vmSizeSensor->setUnit(KSysGuard::UnitKiloByte);
+ vmSizeSensor->setDescription(i18n("This is the amount of virtual memory space that the process is using, included shared libraries, graphics memory, files on disk, and so on. This number is almost meaningless."));
+ d->m_coreAttributes << vmSizeSensor;
+
+ auto vmRSSSensor = new ProcessSensor<qlonglong>(this, QStringLiteral("process/vmRSS"), i18n("RSS Memory Usage"), &KSysGuard::Process::vmRSS, KSysGuard::Process::VmRSS);
+ vmRSSSensor->setUnit(KSysGuard::UnitKiloByte);
+ vmRSSSensor->setDescription(i18n("This is the amount of physical memory that this process is using and includes the amount of memory used by shared libraries."));
+
+ auto vmURSSSensor = new ProcessSensor<qlonglong>(this, QStringLiteral("process/vmURSS"), i18n("Private Memory Usage"), &KSysGuard::Process::vmURSS, KSysGuard::Process::VmURSS);
+ vmURSSSensor->setUnit(KSysGuard::UnitKiloByte);
+ vmURSSSensor->setShortName(i18n("Private"));
+ vmURSSSensor->setDescription(i18n("This is the amount of physical memory that this process is using by itself, and approximates the Private memory usage of the process.<br>It does not include any swapped out memory, nor the code size of its shared libraries."));
+ d->m_coreAttributes << vmURSSSensor;
+
+ auto sharedMemorySensor = new ProcessSensor<qlonglong>(
+ sharedMemorySensor->setDescription(i18n("This is approximately the amount of real physical memory that this process's shared libraries are using.<br>This memory is shared among all processes that use this library."));
+ auto vmPSSSensor = new ProcessSensor<qlonglong>(this, QStringLiteral("process/vmPSS"), i18n("Memory Usage"), &KSysGuard::Process::vmPSS, KSysGuard::Process::VmPSS);
+ vmPSSSensor->setShortName(i18n("Memory"));
+ vmPSSSensor->setUnit(KSysGuard::UnitKiloByte);
+ vmPSSSensor->setDescription(i18n("This is an approximation of the real amount of physical memory that this process is using. It is calculated by dividing the process' shared memory usage by the amount of processes sharing that memory, then adding the process' private memory."));
+ d->m_coreAttributes << vmPSSSensor;
+
+ auto nameSensor = new ProcessSensor<QString>(this, QStringLiteral("process/name"), i18n("Name"), &KSysGuard::Process::name, KSysGuard::Process::Name);
+ nameSensor->setDescription(i18n("The process name."));
+ d->m_coreAttributes << nameSensor;
+
+ auto commandSensor = new ProcessSensor<QString>(this, QStringLiteral("process/command"), i18n("Command"), &KSysGuard::Process::command, KSysGuard::Process::Command);
+ commandSensor->setDescription(i18n("The command with which this process was launched."));
+ d->m_coreAttributes << commandSensor;
+
+ auto statusSensor = new ProcessSensor<uint>(this, QStringLiteral("process/status"), i18n("Status"), &KSysGuard::Process::status, KSysGuard::Process::Status);
+ d->m_coreAttributes << statusSensor;
+
+ auto ioCharactersReadSensor = new ProcessSensor<qlonglong>(this, QStringLiteral("process/ioCharactersRead"), i18n("IO Characters Read"), &KSysGuard::Process::ioCharactersRead, KSysGuard::Process::IO);
+ auto ioCharactersWrittenRateSensor = new ProcessSensor<qlonglong>(this, QStringLiteral("process/ioCharactersWrittenRate"), i18n("IO Characters Written Rate"), &KSysGuard::Process::ioCharactersWrittenRate, KSysGuard::Process::IO);
+ ioCharactersWrittenRateSensor->setDescription(i18n("The rate of bytes written"));
+ auto ioCharactersActuallyWrittenRateSensor = new ProcessSensor<qlonglong>(this, QStringLiteral("process/ioCharactersActuallyWrittenRate"), i18n("IO Characters Actually Written Rate"), &KSysGuard::Process::ioCharactersActuallyWrittenRate, KSysGuard::Process::IO);
+ auto numThreadsSensor = new ProcessSensor<int>(this, QStringLiteral("process/numThreads"), i18n("Threads"), &KSysGuard::Process::numThreads, KSysGuard::Process::NumThreads);
+QModelIndex ProcessDataModel::getQModelIndex( KSysGuard::Process *process, int column) const
+{
+ Q_ASSERT(process);
+ int pid = process->pid();
+ if (pid == -1) return QModelIndex(); //pid -1 is our fake process meaning the very root (never drawn). To represent that, we return QModelIndex() which also means the top element