Commit aa911d87 authored by Daniel Nicoletti's avatar Daniel Nicoletti
Browse files

Add a column to show the hostname which originated the print job

BUG: 56175
parent 096bbb46
......@@ -76,6 +76,7 @@
#define KCUPS_JOB_PRINTER_URI "job-printer-uri"
#define KCUPS_JOB_PRINTER_STATE_MESSAGE "job-printer-state-message"
#define KCUPS_JOB_ORIGINATING_USER_NAME "job-originating-user-name"
#define KCUPS_JOB_ORIGINATING_HOST_NAME "job-originating-host-name"
#define KCUPS_JOB_MEDIA_PROGRESS "job-media-progress"
#define KCUPS_JOB_MEDIA_SHEETS "job-media-sheets"
#define KCUPS_JOB_MEDIA_SHEETS_COMPLETED "job-media-sheets-completed"
......
......@@ -56,11 +56,16 @@ QString KCupsJob::name() const
return m_arguments[KCUPS_JOB_NAME].toString();
}
QString KCupsJob::ownerName() const
QString KCupsJob::originatingUserName() const
{
return m_arguments[KCUPS_JOB_ORIGINATING_USER_NAME].toString();
}
QString KCupsJob::originatingHostName() const
{
return m_arguments[KCUPS_JOB_ORIGINATING_HOST_NAME].toString();
}
QString KCupsJob::printer() const
{
return m_printer;
......
......@@ -36,8 +36,9 @@ public:
int id() const;
QString idStr() const;
QString name() const;
QString ownerName() const;
QString name() const;
QString originatingUserName() const;
QString originatingHostName() const;
QString printer() const;
QDateTime createdAt() const;
QDateTime completedAt() const;
......
......@@ -51,6 +51,7 @@ PrintQueueModel::PrintQueueModel(QObject *parent) :
setHorizontalHeaderItem(ColSize, new QStandardItem(i18n("Size")));
setHorizontalHeaderItem(ColStatusMessage, new QStandardItem(i18n("Status Message")));
setHorizontalHeaderItem(ColPrinter, new QStandardItem(i18n("Printer")));
setHorizontalHeaderItem(ColFromHost, new QStandardItem(i18n("From Hostname")));
// Setup the attributes we want from jobs
m_jobAttributes << KCUPS_JOB_ID;
......@@ -63,6 +64,7 @@ PrintQueueModel::PrintQueueModel(QObject *parent) :
m_jobAttributes << KCUPS_TIME_AT_PROCESSING;
m_jobAttributes << KCUPS_JOB_PRINTER_URI;
m_jobAttributes << KCUPS_JOB_ORIGINATING_USER_NAME;
m_jobAttributes << KCUPS_JOB_ORIGINATING_HOST_NAME;
m_jobAttributes << KCUPS_JOB_MEDIA_PROGRESS;
m_jobAttributes << KCUPS_JOB_MEDIA_SHEETS;
m_jobAttributes << KCUPS_JOB_MEDIA_SHEETS_COMPLETED;
......@@ -83,6 +85,7 @@ PrintQueueModel::PrintQueueModel(QObject *parent) :
roles[RoleJobReleaseEnabled] = "jobReleaseEnabled";
roles[RoleJobRestartEnabled] = "jobRestartEnabled";
roles[RoleJobPrinter] = "jobPrinter";
roles[RoleJobOriginatingHostName] = "jobFrom";
setRoleNames(roles);
// This is emitted when a job change it's state
......@@ -305,7 +308,8 @@ void PrintQueueModel::insertJob(int pos, const KCupsJob &job)
statusItem->setData(jobState, RoleJobState);
statusItem->setData(job.id(), RoleJobId);
statusItem->setData(job.name(), RoleJobName);
statusItem->setData(job.ownerName(), RoleJobOwner);
statusItem->setData(job.originatingUserName(), RoleJobOwner);
statusItem->setData(job.originatingHostName(), RoleJobOriginatingHostName);
QString size = KGlobal::locale()->formatByteSize(job.size());
statusItem->setData(size, RoleJobSize);
QString createdAt = KGlobal::locale()->formatDateTime(job.createdAt());
......@@ -379,7 +383,7 @@ void PrintQueueModel::updateJob(int pos, const KCupsJob &job)
// owner of the job
// try to get the full user name
QString userString = job.ownerName();
QString userString = job.originatingUserName();
KUser user(userString);
if (user.isValid() && !user.property(KUser::FullName).toString().isEmpty()) {
userString = user.property(KUser::FullName).toString();
......@@ -437,6 +441,13 @@ void PrintQueueModel::updateJob(int pos, const KCupsJob &job)
if (item(pos, ColStatusMessage)->text() != stateMessage) {
item(pos, ColStatusMessage)->setText(stateMessage);
}
// owner of the job
// try to get the full user name
QString originatingHostName = job.originatingHostName();
if (item(pos, ColFromHost)->text() != originatingHostName) {
item(pos, ColFromHost)->setText(originatingHostName);
}
}
QStringList PrintQueueModel::mimeTypes() const
......
......@@ -48,7 +48,8 @@ public:
RoleJobHoldEnabled,
RoleJobReleaseEnabled,
RoleJobRestartEnabled,
RoleJobPrinter
RoleJobPrinter,
RoleJobOriginatingHostName
};
enum JobAction {
......@@ -69,6 +70,7 @@ public:
ColSize,
ColStatusMessage,
ColPrinter,
ColFromHost,
LastColumn
};
......
......@@ -143,6 +143,7 @@ PrintQueueUi::PrintQueueUi(const KCupsPrinter &printer, QWidget *parent) :
header->hideSection(PrintQueueModel::ColUser);
header->hideSection(PrintQueueModel::ColCompleted);
header->hideSection(PrintQueueModel::ColSize);
header->hideSection(PrintQueueModel::ColFromHost);
}
// This is emitted when a printer is modified
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment