Commit 1d33ce06 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

Remove feature to delete seen apps

They shouldn't really pile up and only known non-hidden services are shown.
Also some minor cleanups
parent 004a6967
......@@ -65,10 +65,6 @@ KCMNotifications::KCMNotifications(QObject *parent, const QVariantList &args)
m_filteredModel->setSourceModel(m_sourcesModel);
connect(m_sourcesModel, &SourcesModel::pendingDeletionsChanged, this, [this] {
setNeedsSave(true);
});
QStringList stringArgs;
stringArgs.reserve(args.count() + 1);
// need to add a fake argv[0] for QCommandLineParser
......@@ -202,7 +198,6 @@ void KCMNotifications::load()
void KCMNotifications::save()
{
processPendingDeletions();
m_settings->save();
}
......@@ -211,15 +206,4 @@ void KCMNotifications::defaults()
m_settings->defaults();
}
void KCMNotifications::processPendingDeletions()
{
const QStringList pendingDeletions = m_sourcesModel->pendingDeletions();
for (const QString &desktopEntry : pendingDeletions) {
m_settings->forgetKnownApplication(desktopEntry);
}
m_sourcesModel->removeItemsPendingDeletion();
}
#include "kcm.moc"
......@@ -47,13 +47,6 @@ public:
KCMNotifications(QObject *parent, const QVariantList &args);
~KCMNotifications() override;
enum Roles {
SchemeNameRole = Qt::UserRole + 1,
PaletteRole,
RemovableRole,
PendingDeletionRole
};
SourcesModel *sourcesModel() const;
FilterProxyModel *filteredModel() const;
......
......@@ -91,10 +91,6 @@ Kirigami.Page {
ListView {
id: sourcesList
anchors {
fill: parent
margins: 2
}
clip: true
activeFocusOnTab: true
......@@ -153,7 +149,6 @@ Kirigami.Page {
width: sourcesList.width
text: model.display
highlighted: ListView.isCurrentItem
opacity: model.pendingDeletion ? 0.6 : 1
onClicked: {
var sourceIdx = kcm.filteredModel.mapToSource(kcm.filteredModel.index(index, 0));
appConfiguration.rootIndex = kcm.sourcesModel.makePersistentModelIndex(sourceIdx);
......@@ -165,7 +160,6 @@ Kirigami.Page {
Layout.preferredWidth: Kirigami.Units.iconSizes.small
Layout.preferredHeight: Kirigami.Units.iconSizes.small
source: model.decoration
enabled: !model.pendingDeletion
}
QtControls.Label {
......@@ -176,19 +170,6 @@ Kirigami.Page {
elide: Text.ElideRight
textFormat: Text.PlainText
}
// FIXME alignment
QtControls.ToolButton {
Layout.preferredWidth: Kirigami.Units.iconSizes.small + leftPadding + rightPadding
Layout.preferredHeight: Kirigami.Units.iconSizes.small + topPadding + bottomPadding
icon.name: model.pendingDeletion ? "edit-undo" : "edit-delete"
visible: model.removable
onClicked: model.pendingDeletion = !model.pendingDeletion
QtControls.ToolTip {
text: model.pendingDeletion ? i18n("Undo Remove") : i18n("Remove")
}
}
}
}
......
......@@ -119,8 +119,6 @@ QVariant SourcesModel::data(const QModelIndex &index, int role) const
case SourceTypeRole: return source.desktopEntry.isEmpty() ? ServiceType : ApplicationType;
case NotifyRcNameRole: return source.notifyRcName;
case DesktopEntryRole: return source.desktopEntry;
case RemovableRole: return source.removable;
case PendingDeletionRole: return source.pendingDeletion;
}
return QVariant();
......@@ -146,18 +144,6 @@ bool SourcesModel::setData(const QModelIndex &index, const QVariant &value, int
break;
}
}
} else { // source
auto &source = m_data[index.row()];
switch (role) {
case PendingDeletionRole: {
const bool newPending = value.toBool();
if (source.pendingDeletion != newPending) {
source.pendingDeletion = newPending;
dirty = true;
}
emit pendingDeletionsChanged();
}
}
}
if (dirty) {
......@@ -207,9 +193,7 @@ QHash<int, QByteArray> SourcesModel::roleNames() const
{NotifyRcNameRole, QByteArrayLiteral("notifyRcName")},
{DesktopEntryRole, QByteArrayLiteral("desktopEntry")},
{EventIdRole, QByteArrayLiteral("eventId")},
{ActionsRole, QByteArrayLiteral("actions")},
{RemovableRole, QByteArrayLiteral("removable")},
{PendingDeletionRole, QByteArrayLiteral("pendingDeletion")}
{ActionsRole, QByteArrayLiteral("actions")}
};
}
......@@ -269,10 +253,7 @@ void SourcesModel::load()
globalGroup.readEntry(QStringLiteral("IconName")),
notifyRcName,
desktopEntry,
{}, // events
config,
false, // removable
false // pendingDeletion
{} // events
};
QVector<EventData> events;
......@@ -325,10 +306,7 @@ void SourcesModel::load()
service->icon(),
QString(), //notifyRcFile
service->desktopEntryName(),
{},
nullptr,
false, // removable
false // pendingDeletion
{} // events
};
appsData.append(source);
desktopEntries.append(service->desktopEntryName());
......@@ -353,10 +331,7 @@ void SourcesModel::load()
service->icon(),
QString(), //notifyRcFile
service->desktopEntryName(),
{},
nullptr,
applicationsGroup.group(app).readEntry("Seen", false), // removable
false // pendingDeletion
{}
};
appsData.append(source);
desktopEntries.append(service->desktopEntryName());
......@@ -373,28 +348,3 @@ void SourcesModel::load()
endResetModel();
}
QStringList SourcesModel::pendingDeletions() const
{
QStringList pendingDeletions;
for (const auto &item : m_data) {
if (item.pendingDeletion) {
// Only apps can be deleted so we can assume it has a desktopEntry
pendingDeletions.append(item.desktopEntry);
}
}
return pendingDeletions;
}
void SourcesModel::removeItemsPendingDeletion()
{
for (int i = m_data.count() - 1; i >= 0; --i) {
if (m_data.at(i).pendingDeletion) {
beginRemoveRows(QModelIndex(), i, i);
m_data.remove(i);
endRemoveRows();
}
}
}
......@@ -25,8 +25,6 @@
#include <QString>
#include <QVector>
class KConfig;
struct EventData
{
QString name;
......@@ -48,11 +46,6 @@ struct SourceData
QVector<EventData> events;
KConfig *config; // KSharedConfig::Ptr?
bool removable; // for "observed" apps
bool pendingDeletion;
QString display() const
{
return !name.isEmpty() ? name : comment;
......@@ -73,9 +66,7 @@ public:
DesktopEntryRole,
EventIdRole,
ActionsRole,
RemovableRole, // for "observed" apps
PendingDeletionRole
ActionsRole
};
Q_ENUM(Roles)
......@@ -101,14 +92,8 @@ public:
QHash<int, QByteArray> roleNames() const override;
QStringList pendingDeletions() const;
void removeItemsPendingDeletion();
void load();
Q_SIGNALS:
void pendingDeletionsChanged();
private:
QVector<SourceData> m_data;
......
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