From 86ba78fa3d4289e909a4111d4d0ce8c86e7cb142 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Sat, 3 Dec 2022 11:25:24 -0500 Subject: [PATCH] 2022-12-02 Fred Gleason * Fixed bugs in the notification subsystem that cause multiple entries to appear in log listings when a new log was created. Signed-off-by: Fred Gleason --- ChangeLog | 3 ++ lib/rdloglistmodel.cpp | 67 +++++++++++++++++++++++++++++++++++------ lib/rdloglistmodel.h | 3 ++ rdlogedit/rdlogedit.cpp | 3 -- 4 files changed, 64 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8bc09e27..a0684b51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23737,3 +23737,6 @@ display is initially fully scrolled to the left. 2022-12-01 Fred Gleason * Added notification support to the 'RDLibraryModel' class. +2022-12-02 Fred Gleason + * Fixed bugs in the notification subsystem that cause multiple + entries to appear in log listings when a new log was created. diff --git a/lib/rdloglistmodel.cpp b/lib/rdloglistmodel.cpp index ce106d56..63eae876 100644 --- a/lib/rdloglistmodel.cpp +++ b/lib/rdloglistmodel.cpp @@ -69,6 +69,9 @@ RDLogListModel::RDLogListModel(QObject *parent) d_headers.push_back(tr("Last Modified")); d_alignments.push_back(left); + + connect(rda->ripc(),SIGNAL(notificationReceived(RDNotification *)), + this,SLOT(processNotification(RDNotification *))); } @@ -163,18 +166,42 @@ QString RDLogListModel::logName(const QModelIndex &row) const QModelIndex RDLogListModel::addLog(const QString &name) { - QList list; + QModelIndex ret; - beginInsertRows(QModelIndex(),d_texts.size(),d_texts.size()); - d_icons.push_back(list); + // + // Ensure we haven't already been added + // + for(int i=0;ifirst()) { + QList list; - updateRowLine(d_texts.size()-1); - endInsertRows(); + beginInsertRows(QModelIndex(),d_texts.size(),d_texts.size()); + d_icons.push_back(list); - return createIndex(d_texts.size()-1,0); + list.push_back(name); + d_texts.push_back(list); + + updateRowLine(d_texts.size()-1); + endInsertRows(); + ret=createIndex(d_texts.size()-1,0); + } + delete q; + + return ret; } @@ -230,12 +257,34 @@ void RDLogListModel::refresh(const QString &logname) void RDLogListModel::setFilterSql(const QString &sql) { - updateModel(sql); + if(d_filter_sql!=sql) { + updateModel(sql); + d_filter_sql=sql; + } } void RDLogListModel::processNotification(RDNotification *notify) { + if(notify->type()==RDNotification::LogType) { + switch(notify->action()) { + case RDNotification::AddAction: + addLog(notify->id().toString()); + break; + + case RDNotification::ModifyAction: + refresh(notify->id().toString()); + break; + + case RDNotification::DeleteAction: + removeLog(notify->id().toString()); + break; + + case RDNotification::NoAction: + case RDNotification::LastAction: + break; + } + } } diff --git a/lib/rdloglistmodel.h b/lib/rdloglistmodel.h index 44c405cf..1e1a8dbd 100644 --- a/lib/rdloglistmodel.h +++ b/lib/rdloglistmodel.h @@ -53,6 +53,8 @@ class RDLogListModel : public QAbstractTableModel public slots: void setFilterSql(const QString &sql); + + private slots: void processNotification(RDNotification *notify); protected: @@ -69,6 +71,7 @@ class RDLogListModel : public QAbstractTableModel QList > d_texts; QList > d_icons; QList d_alignments; + QString d_filter_sql; }; diff --git a/rdlogedit/rdlogedit.cpp b/rdlogedit/rdlogedit.cpp index bc451841..748f5f80 100644 --- a/rdlogedit/rdlogedit.cpp +++ b/rdlogedit/rdlogedit.cpp @@ -208,7 +208,6 @@ QSizePolicy MainWidget::sizePolicy() const void MainWidget::loadLocalSettings(RDProfile *p) { - printf("RDLogEdit loadLocalSettings()\n"); global_start_time_style= p->intValue("rdlogedit","StartTimeStyle",(int)RDLogModel::Estimated); } @@ -216,7 +215,6 @@ void MainWidget::loadLocalSettings(RDProfile *p) void MainWidget::saveLocalSettings(FILE *f) const { - printf("RDLogEdit saveLocalSettings()\n"); fprintf(f,"StartTimeStyle=%d\n",global_start_time_style); } @@ -287,7 +285,6 @@ void MainWidget::addData() LockList(); SendNotification(RDNotification::AddAction,logname); log_edit_dialog->exec(logname,&newlogs); - row=log_log_model->addLog(logname); log_log_view->selectRow(row.row()); UnlockList(); }