There was refactored code

This commit is contained in:
master 2023-04-06 16:13:59 +03:00
parent 45edd82368
commit 95eb3eca16
2 changed files with 4 additions and 7 deletions

View File

@ -39,10 +39,10 @@ QHash<int, QByteArray> HistoryNotificationsModel::roleNames() const {
void HistoryNotificationsModel::setHistory(const QmlNotificationService::NotificationData &notificationData) { void HistoryNotificationsModel::setHistory(const QmlNotificationService::NotificationData &notificationData) {
beginResetModel(); const int index = notificationsList.count() > 0? notificationsList.count() - 1 : notificationsList.count();
notificationsList.push_back(notificationData); beginInsertRows(QModelIndex(), index, index);
endResetModel(); notificationsList.insert(index, notificationData);
emit dataInserted(); endInsertRows();
} }
void HistoryNotificationsModel::clearAllHistory() { void HistoryNotificationsModel::clearAllHistory() {

View File

@ -15,8 +15,6 @@ class HistoryNotificationsModel : public QAbstractListModel
Type Type
}; };
Q_PROPERTY(int notificationsCount READ getNotificationsCount WRITE setNotificationsCount NOTIFY notificationsCountChanged)
public: public:
explicit HistoryNotificationsModel(QObject *parent = nullptr); explicit HistoryNotificationsModel(QObject *parent = nullptr);
@ -34,7 +32,6 @@ signals:
private: private:
QList<QmlNotificationService::NotificationData> notificationsList; QList<QmlNotificationService::NotificationData> notificationsList;
int m_notificationsCount;
}; };
#endif // HISTORYNOTIFICATIONMODEL_H #endif // HISTORYNOTIFICATIONMODEL_H