diff --git a/libnotificationmanager/notificationsortproxymodel.cpp b/libnotificationmanager/notificationsortproxymodel.cpp index 666ecabb6..fe66bbe41 100644 --- a/libnotificationmanager/notificationsortproxymodel.cpp +++ b/libnotificationmanager/notificationsortproxymodel.cpp @@ -1,134 +1,127 @@ /* * Copyright 2018-2019 Kai Uwe Broulik * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include "notificationsortproxymodel_p.h" #include #include "notifications.h" using namespace NotificationManager; NotificationSortProxyModel::NotificationSortProxyModel(QObject *parent) : QSortFilterProxyModel(parent) { setRecursiveFilteringEnabled(true); sort(0); } NotificationSortProxyModel::~NotificationSortProxyModel() = default; Notifications::SortMode NotificationSortProxyModel::sortMode() const { return m_sortMode; } void NotificationSortProxyModel::setSortMode(Notifications::SortMode sortMode) { if (m_sortMode != sortMode) { m_sortMode = sortMode; invalidate(); emit sortModeChanged(); } } Qt::SortOrder NotificationSortProxyModel::sortOrder() const { return m_sortOrder; } void NotificationSortProxyModel::setSortOrder(Qt::SortOrder sortOrder) { if (m_sortOrder != sortOrder) { m_sortOrder = sortOrder; invalidate(); emit sortOrderChanged(); } } int sortScore(const QModelIndex &idx) { const auto urgency = idx.data(Notifications::UrgencyRole).toInt(); if (urgency == Notifications::CriticalUrgency) { return 3; } const int type = idx.data(Notifications::TypeRole).toInt(); if (type == Notifications::JobType) { const int jobState = idx.data(Notifications::JobStateRole).toInt(); // Treat finished jobs as normal notifications but running jobs more important if (jobState == Notifications::JobStateStopped) { return 1; } else { return 2; } } if (urgency == Notifications::NormalUrgency) { return 1; } if (urgency == Notifications::LowUrgency) { return 0; } return -1; } bool NotificationSortProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const { // Sort order is (descending): // - Critical notifications // - Jobs // - Normal notifications // - Low urgency notifications // Within each group it's descending by created or last modified int scoreLeft = 0; int scoreRight = 0; if (m_sortMode == Notifications::SortByTypeAndUrgency) { scoreLeft = sortScore(source_left); Q_ASSERT(scoreLeft >= 0); scoreRight = sortScore(source_right); Q_ASSERT(scoreRight >= 0); } if (scoreLeft == scoreRight) { - QDateTime timeLeft = source_left.data(Notifications::UpdatedRole).toDateTime(); - if (!timeLeft.isValid()) { - timeLeft = source_left.data(Notifications::CreatedRole).toDateTime(); - } - - QDateTime timeRight = source_right.data(Notifications::UpdatedRole).toDateTime(); - if (!timeRight.isValid()) { - timeRight = source_right.data(Notifications::CreatedRole).toDateTime(); - } + const QDateTime timeLeft = source_left.data(Notifications::CreatedRole).toDateTime(); + const QDateTime timeRight = source_right.data(Notifications::CreatedRole).toDateTime(); if (m_sortOrder == Qt::DescendingOrder) { return timeLeft > timeRight; } else { return timeLeft < timeRight; } } return scoreLeft > scoreRight; } diff --git a/templates/ion-dataengine/src/ion-%{APPNAMELC}.desktop b/templates/ion-dataengine/src/ion-%{APPNAMELC}.desktop index 43df40ee5..405e98673 100644 --- a/templates/ion-dataengine/src/ion-%{APPNAMELC}.desktop +++ b/templates/ion-dataengine/src/ion-%{APPNAMELC}.desktop @@ -1,74 +1,58 @@ [Desktop Entry] Name=%{APPNAME} Weather Data Provider -Name[ca]=Proveïdor de dades meteorològiques de %{APPNAME} -Name[ca@valencia]=Proveïdor de dades meteorològiques de %{APPNAME} Name[da]=%{APPNAME} vejrdata-udbyder Name[de]=%{APPNAME}-Wetterdatenanbieter Name[el]=%{APPNAME} Πάροχος δεδομένων καιρού Name[en_GB]=%{APPNAME} Weather Data Provider Name[es]=Proveedor de datos meteorológicos %{APPNAME} Name[et]=%{APPNAME} ilmaandmete pakkuja Name[eu]=%{APPNAME} eguraldi datuen hornitzailea Name[fi]=%{APPNAME} -säätietojen tarjoaja Name[fr]=%{APPNAME} Fournisseur de données météorologiques Name[gl]=Fornecedor de datos meteorolóxicos %{APPNAME} Name[he]=ספק מזג האוויר %{APPNAME} Name[hu]=%{APPNAME} időjárásadat-szolgáltató -Name[id]=Penyedia Data Cuaca %{APPNAME} Name[is]=%{APPNAME} veðurgagnaþjónusta Name[it]=Fornitore di dati meteo di %{APPNAME} Name[ko]=%{APPNAME} 날씨 데이터 공급자 Name[lt]=Orų informacija iš %{APPNAME} Name[nl]=%{APPNAME} Leverancier van weergegevens -Name[nn]=%{APPNAME} vêrdataleverandør Name[pa]=%{APPNAME} ਮੌਸਮ ਡਾਟਾ ਦੇਣ ਵਾਲਾ Name[pl]=%{APPNAME} - dostawca danych pogodowych -Name[pt]=Fornecedor de Dados Meteorológicos do %{APPNAME} -Name[pt_BR]=Fornecedor de dados meteorológicos do %{APPNAME} Name[ru]=Источник данных о погоде %{APPNAME} Name[sk]=%{APPNAME} poskytovateľ údajov počasia Name[sl]=Ponudnik podatkov za vreme %{APPNAME} Name[sv]=%{APPNAME} väderdataleverantör Name[tr]=%{APPNAME} Hava Durumu Veri Sağlayıcısı Name[uk]=Засіб надання даних щодо погоди %{APPNAME} -Name[x-test]=xx%{APPNAME} Weather Data Providerxx -Name[zh_TW]=%{APPNAME} 天氣資料提供者 Comment=Access to the weather data provider %{APPNAME} -Comment[ca]=Accés al proveïdor de dades meteorològiques de %{APPNAME} -Comment[ca@valencia]=Accés al proveïdor de dades meteorològiques de %{APPNAME} Comment[da]=Adgang til vejrdata-udbyderen %{APPNAME} Comment[de]=Zugriff auf den Wetterdatenanbieter %{APPNAME} Comment[el]=Πρόσβαση στον πάροχο δεδομένων καιρού %{APPNAME} Comment[en_GB]=Access to the weather data provider %{APPNAME} Comment[es]=Acceso al proveedor de datos meteorológicos %{APPNAME} Comment[et]=Ilmaandmete pakkuja %{APPNAME} andmete kasutamine Comment[eu]=Sarbidea eguraldi datuen hornitzaile honetara: %{APPNAME} Comment[fi]=Pääsy säätietojen tarjoajaan %{APPNAME} Comment[fr]=Accès au fournisseur de données météorologiques %{APPNAME} Comment[gl]=Acceder ao fornecedor de datos meteorolóxicos %{APPNAME}. Comment[he]=גישה למספק מזג האוויר %{APPNAME} Comment[hu]=Hpzzáférés a(z) %{APPNAME} időjárási adataihoz -Comment[id]=Akses ke penyedia data cuaca %{APPNAME} Comment[is]=Aðgangur að veðurgagnaþjónustunni %{APPNAME} -Comment[it]=Accesso al fornitore di dati meteo di %{APPNAME} +Comment[it]=Accedi al fornitore di dati meteo di %{APPNAME} Comment[ko]=날씨 데이터 공급자 %{APPNAME}에 접근 Comment[lt]=Apsilankyti pas orų informacijos teikėją %{APPNAME} Comment[nl]=Toegang tot de leverancier van weergegevens %{APPNAME} -Comment[nn]=Tilgang til vêrdataleverandøren %{APPNAME} Comment[pl]=Połącz się z dostawcą danych pogodowych %{APPNAME} -Comment[pt]=Acesso ao fornecedor de dados meteorológicos do %{APPNAME} -Comment[pt_BR]=Acesso ao fornecedor de dados meteorológicos do %{APPNAME} Comment[ru]=Доступ к поставщику данных о погоде %{APPNAME} Comment[sk]=Prístup k poskytovateľovi údajov počasia %{APPNAME} Comment[sl]=Dostop do ponudnika podatkov za vreme %{APPNAME} Comment[sv]=Åtkomst till väderdataleverantören %{APPNAME} Comment[tr]=Hava durumu verileri sağlayıcısı %{APPNAME} erişimi Comment[uk]=Доступ до засобу надання даних щодо погоди %{APPNAME} -Comment[x-test]=xxAccess to the weather data provider %{APPNAME}xx -Comment[zh_TW]=存取天氣資料提供者 %{APPNAME} X-KDE-ServiceTypes=Plasma/DataEngine X-KDE-ParentApp=weatherengine Type=Service Icon=noneyet X-KDE-Library=ion_%{APPNAMELC} X-KDE-PluginInfo-Name=%{APPNAMELC}