mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-05-19 14:43:30 +02:00
2022-12-02 Fred Gleason <fredg@paravelsystems.com>
* 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 <fredg@paravelsystems.com>
This commit is contained in:
parent
a157602e10
commit
86ba78fa3d
@ -23737,3 +23737,6 @@
|
||||
display is initially fully scrolled to the left.
|
||||
2022-12-01 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added notification support to the 'RDLibraryModel' class.
|
||||
2022-12-02 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Fixed bugs in the notification subsystem that cause multiple
|
||||
entries to appear in log listings when a new log was created.
|
||||
|
@ -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<QVariant> 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;i<d_texts.size();i++) {
|
||||
if(d_texts.at(i).at(0)==name) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
list.push_back(name);
|
||||
d_texts.push_back(list);
|
||||
//
|
||||
// Make sure we match the current filter
|
||||
//
|
||||
QString sql=QString("select ")+
|
||||
"`NAME` "+ // 00
|
||||
"from `LOGS` where "+
|
||||
"`NAME`='"+RDEscapeString(name)+"' "+
|
||||
d_filter_sql;
|
||||
RDSqlQuery *q=new RDSqlQuery(sql);
|
||||
if(q->first()) {
|
||||
QList<QVariant> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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<QList<QVariant> > d_texts;
|
||||
QList<QList<QVariant> > d_icons;
|
||||
QList<QVariant> d_alignments;
|
||||
QString d_filter_sql;
|
||||
};
|
||||
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user