Commit dcaa4cfc authored by Ahmad Samir's avatar Ahmad Samir
Browse files

[libnotificationmanager] Integrate KJob::Unit::Items

This unit is neutral, it doesn't distinguish between e.g. file and dirs,
just counting items. Useful in e.g. notifications of batch rename jobs.

CCBUG: 422098
parent ebfc2b53
......@@ -104,7 +104,7 @@ GridLayout {
}
Repeater {
model: ["Bytes", "Files", "Directories"]
model: ["Bytes", "Files", "Directories", "Items"]
PlasmaExtras.DescriptiveLabel {
Layout.column: 1
......@@ -127,6 +127,9 @@ GridLayout {
case "Directories":
return i18ndcp("plasma_applet_org.kde.plasma.notifications", "How many dirs have been copied", "%2 of %1 folder", "%2 of %1 folders",
total, processed);
case "Items":
return i18ndcp("plasma_applet_org.kde.plasma.notifications", "How many items (that includes files and dirs) have been copied", "%2 of %1 item", "%2 of %1 items",
total, processed);
}
} else {
switch(modelData) {
......@@ -136,6 +139,8 @@ GridLayout {
return i18ndp("plasma_applet_org.kde.plasma.notifications", "%1 file", "%1 files", (processed || total));
case "Directories":
return i18ndp("plasma_applet_org.kde.plasma.notifications", "%1 folder", "%1 folders", (processed || total));
case "Items":
return i18ndp("plasma_applet_org.kde.plasma.notifications", "%1 item", "%1 items", (processed || total));
}
}
}
......
......@@ -202,6 +202,11 @@ qulonglong Job::processedDirectories() const
return d->m_processedDirectories;
}
qulonglong Job::processedItems() const
{
return d->m_processedItems;
}
qulonglong Job::totalBytes() const
{
return d->m_totalBytes;
......@@ -217,6 +222,11 @@ qulonglong Job::totalDirectories() const
return d->m_totalDirectories;
}
qulonglong Job::totalItems() const
{
return d->m_totalItems;
}
QString Job::descriptionLabel1() const
{
return d->m_descriptionLabel1;
......
......@@ -99,10 +99,12 @@ class NOTIFICATIONMANAGER_EXPORT Job : public QObject
Q_PROPERTY(qulonglong processedBytes READ processedBytes NOTIFY processedBytesChanged)
Q_PROPERTY(qulonglong processedFiles READ processedFiles NOTIFY processedFilesChanged)
Q_PROPERTY(qulonglong processedDirectories READ processedDirectories NOTIFY processedDirectoriesChanged)
Q_PROPERTY(qulonglong processedItems READ processedItems NOTIFY processedItemsChanged)
Q_PROPERTY(qulonglong totalBytes READ totalBytes NOTIFY totalBytesChanged)
Q_PROPERTY(qulonglong totalFiles READ totalFiles NOTIFY totalFilesChanged)
Q_PROPERTY(qulonglong totalDirectories READ totalDirectories NOTIFY totalDirectoriesChanged)
Q_PROPERTY(qulonglong totalItems READ totalItems NOTIFY totalItemsChanged)
Q_PROPERTY(QString descriptionLabel1 READ descriptionLabel1 NOTIFY descriptionLabel1Changed)
Q_PROPERTY(QString descriptionValue1 READ descriptionValue1 NOTIFY descriptionValue1Changed)
......@@ -179,10 +181,12 @@ public:
qulonglong processedBytes() const;
qulonglong processedFiles() const;
qulonglong processedDirectories() const;
qulonglong processedItems() const;
qulonglong totalBytes() const;
qulonglong totalFiles() const;
qulonglong totalDirectories() const;
qulonglong totalItems() const;
QString descriptionLabel1() const;
QString descriptionValue1() const;
......@@ -217,10 +221,12 @@ signals:
void processedBytesChanged();
void processedFilesChanged();
void processedDirectoriesChanged();
void processedItemsChanged();
void processedAmountChanged();
void totalBytesChanged();
void totalFilesChanged();
void totalDirectoriesChanged();
void totalItemsChanged();
void totalAmountChanged();
void descriptionLabel1Changed();
void descriptionValue1Changed();
......
......@@ -131,9 +131,11 @@ void JobPrivate::updateHasDetails()
const bool hasDetails = m_totalBytes > 0
|| m_totalFiles > 0
|| m_totalDirectories > 0
|| m_totalItems > 0
|| m_processedBytes > 0
|| m_processedFiles > 0
|| m_processedDirectories > 0
|| m_processedItems > 0
|| !m_descriptionLabel1.isEmpty()
|| !m_descriptionLabel2.isEmpty()
|| !m_descriptionValue1.isEmpty()
......@@ -278,6 +280,8 @@ void JobPrivate::setTotalAmount(quint64 amount, const QString &unit)
updateField(amount, m_totalFiles, &Job::totalFilesChanged);
} else if (unit == QLatin1String("dirs")) {
updateField(amount, m_totalDirectories, &Job::totalDirectoriesChanged);
} else if (unit == QLatin1String("items")) {
updateField(amount, m_totalItems, &Job::totalItemsChanged);
}
updateHasDetails();
}
......@@ -290,6 +294,8 @@ void JobPrivate::setProcessedAmount(quint64 amount, const QString &unit)
updateField(amount, m_processedFiles, &Job::processedFilesChanged);
} else if (unit == QLatin1String("dirs")) {
updateField(amount, m_processedDirectories, &Job::processedDirectoriesChanged);
} else if (unit == QLatin1String("items")) {
updateField(amount, m_processedItems, &Job::processedItemsChanged);
}
updateHasDetails();
}
......@@ -400,10 +406,12 @@ void JobPrivate::update(const QVariantMap &properties)
updateFieldFromProperties(properties, QStringLiteral("processedFiles"), m_processedFiles, &Job::processedFilesChanged);
updateFieldFromProperties(properties, QStringLiteral("processedBytes"), m_processedBytes, &Job::processedBytesChanged);
updateFieldFromProperties(properties, QStringLiteral("processedDirectories"), m_processedDirectories, &Job::processedDirectoriesChanged);
updateFieldFromProperties(properties, QStringLiteral("Items"), m_processedItems, &Job::processedItemsChanged);
updateFieldFromProperties(properties, QStringLiteral("totalFiles"), m_totalFiles, &Job::totalFilesChanged);
updateFieldFromProperties(properties, QStringLiteral("totalBytes"), m_totalBytes, &Job::totalBytesChanged);
updateFieldFromProperties(properties, QStringLiteral("totalDirectories"), m_totalDirectories, &Job::totalDirectoriesChanged);
updateFieldFromProperties(properties, QStringLiteral("totalItems"), m_totalItems, &Job::totalItemsChanged);
updateFieldFromProperties(properties, QStringLiteral("descriptionLabel1"), m_descriptionLabel1, &Job::descriptionLabel1Changed);
updateFieldFromProperties(properties, QStringLiteral("descriptionValue1"), m_descriptionValue1, &Job::descriptionValue1Changed);
......
......@@ -150,10 +150,12 @@ private:
qulonglong m_processedBytes = 0;
qulonglong m_processedFiles = 0;
qulonglong m_processedDirectories = 0;
qulonglong m_processedItems = 0;
qulonglong m_totalBytes = 0;
qulonglong m_totalFiles = 0;
qulonglong m_totalDirectories = 0;
qulonglong m_totalItems = 0;
QString m_descriptionLabel1;
QString m_descriptionValue1;
......
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