mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-10-11 17:13:47 +02:00
2020-12-27 Fred Gleason <fredg@paravelsystems.com>
* Refactored 'RDListLogs' dialog to use 'RDLogListModel'. * Added a 'caption' argument to the constructor of the 'RDListLogs' dialog. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Select a Rivendell Log
|
||||
//
|
||||
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2002-2020 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "rdlist_logs.h"
|
||||
|
||||
RDListLogs::RDListLogs(QString *logname,RDLogFilter::FilterMode mode,
|
||||
QWidget *parent)
|
||||
const QString &caption,QWidget *parent)
|
||||
: RDDialog(parent)
|
||||
{
|
||||
list_logname=logname;
|
||||
@@ -34,32 +34,32 @@ RDListLogs::RDListLogs(QString *logname,RDLogFilter::FilterMode mode,
|
||||
//
|
||||
setMinimumSize(sizeHint());
|
||||
|
||||
setWindowTitle(tr("Select Log"));
|
||||
setWindowTitle(caption+" - "+tr("Select Log"));
|
||||
|
||||
//
|
||||
// Log Filter
|
||||
//
|
||||
list_filter_widget=new RDLogFilter(mode,this);
|
||||
connect(list_filter_widget,SIGNAL(filterChanged(const QString &)),
|
||||
this,SLOT(filterChangedData(const QString &)));
|
||||
|
||||
//
|
||||
// Log List
|
||||
//
|
||||
list_log_list=new Q3ListView(this);
|
||||
list_log_list->setAllColumnsShowFocus(true);
|
||||
list_log_list->setItemMargin(5);
|
||||
list_log_list->setSelectionMode(Q3ListView::Single);
|
||||
connect(list_log_list,
|
||||
SIGNAL(doubleClicked(Q3ListViewItem *,const QPoint &,int)),
|
||||
this,
|
||||
SLOT(doubleClickedData(Q3ListViewItem *,const QPoint &,int)));
|
||||
list_log_list->addColumn(tr("Name"));
|
||||
list_log_list->setColumnAlignment(0,Qt::AlignLeft);
|
||||
list_log_list->addColumn(tr("Description"));
|
||||
list_log_list->setColumnAlignment(1,Qt::AlignLeft);
|
||||
list_log_list->addColumn(tr("Service"));
|
||||
list_log_list->setColumnAlignment(2,Qt::AlignLeft);
|
||||
list_log_view=new QTableView(this);
|
||||
list_log_view->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
list_log_view->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
list_log_view->setShowGrid(false);
|
||||
list_log_view->setSortingEnabled(false);
|
||||
list_log_view->setWordWrap(false);
|
||||
list_log_model=new RDLogListModel(this);
|
||||
list_log_model->setFont(defaultFont());
|
||||
list_log_model->setPalette(palette());
|
||||
list_log_view->setModel(list_log_model);
|
||||
list_log_view->resizeColumnsToContents();
|
||||
connect(list_filter_widget,SIGNAL(filterChanged(const QString &)),
|
||||
list_log_model,SLOT(setFilterSql(const QString &)));
|
||||
connect(list_log_view,SIGNAL(doubleClicked(const QModelIndex &)),
|
||||
this,SLOT(doubleClickedData(const QModelIndex &)));
|
||||
connect(list_log_model,SIGNAL(modelReset()),this,SLOT(modelResetData()));
|
||||
|
||||
//
|
||||
// OK Button
|
||||
@@ -78,13 +78,13 @@ RDListLogs::RDListLogs(QString *logname,RDLogFilter::FilterMode mode,
|
||||
list_cancel_button->setDefault(true);
|
||||
connect(list_cancel_button,SIGNAL(clicked()),this,SLOT(cancelButtonData()));
|
||||
|
||||
RefreshList();
|
||||
list_log_model->setFilterSql(list_filter_widget->whereSql());
|
||||
}
|
||||
|
||||
|
||||
QSize RDListLogs::sizeHint() const
|
||||
{
|
||||
return QSize(500,300);
|
||||
return QSize(600,400);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,29 +96,29 @@ QSizePolicy RDListLogs::sizePolicy() const
|
||||
|
||||
void RDListLogs::closeEvent(QCloseEvent *e)
|
||||
{
|
||||
done(1);
|
||||
cancelButtonData();
|
||||
}
|
||||
|
||||
|
||||
void RDListLogs::filterChangedData(const QString &where_sql)
|
||||
{
|
||||
RefreshList();
|
||||
}
|
||||
|
||||
|
||||
void RDListLogs::doubleClickedData(Q3ListViewItem *,const QPoint &,int)
|
||||
void RDListLogs::doubleClickedData(const QModelIndex &index)
|
||||
{
|
||||
okButtonData();
|
||||
}
|
||||
|
||||
|
||||
void RDListLogs::modelResetData()
|
||||
{
|
||||
list_log_view->resizeColumnsToContents();
|
||||
}
|
||||
|
||||
|
||||
void RDListLogs::okButtonData()
|
||||
{
|
||||
Q3ListViewItem *item=list_log_list->selectedItem();
|
||||
if(item==NULL) {
|
||||
if(list_log_view->selectionModel()->selectedRows().size()!=1) {
|
||||
return;
|
||||
}
|
||||
*list_logname=item->text(0);
|
||||
*list_logname=list_log_model->logName(list_log_view->selectionModel()->selectedRows().at(0).row());
|
||||
|
||||
done(true);
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ void RDListLogs::resizeEvent(QResizeEvent *e)
|
||||
list_filter_widget->
|
||||
setGeometry(10,10,size().width()-10,
|
||||
list_filter_widget->sizeHint().height());
|
||||
list_log_list->
|
||||
list_log_view->
|
||||
setGeometry(10,list_filter_widget->sizeHint().height(),
|
||||
size().width()-20,
|
||||
size().height()-list_filter_widget->sizeHint().height()-70);
|
||||
@@ -143,40 +143,3 @@ void RDListLogs::resizeEvent(QResizeEvent *e)
|
||||
list_cancel_button->
|
||||
setGeometry(size().width()-90,size().height()-60,80,50);
|
||||
}
|
||||
|
||||
|
||||
void RDListLogs::RefreshList()
|
||||
{
|
||||
RDSqlQuery *q;
|
||||
QString sql;
|
||||
Q3ListViewItem *l;
|
||||
Q3ListViewItem *view_item=NULL;
|
||||
QDate current_date=QDate::currentDate();
|
||||
|
||||
list_log_list->clear();
|
||||
sql=QString("select NAME,DESCRIPTION,SERVICE from LOGS ")+
|
||||
"where (TYPE=0)&&(LOG_EXISTS=\"Y\")&&"+
|
||||
"((START_DATE<=\""+current_date.toString("yyyy-MM-dd")+"\")||"+
|
||||
"(START_DATE=\"0000-00-00\")||"+
|
||||
"(START_DATE is null))&&"+
|
||||
"((END_DATE>=\""+current_date.toString("yyyy-MM-dd")+"\")||"+
|
||||
"(END_DATE=\"0000-00-00\")||"+
|
||||
"(END_DATE is null))"+
|
||||
list_filter_widget->whereSql();
|
||||
|
||||
q=new RDSqlQuery(sql);
|
||||
while(q->next()) {
|
||||
l=new Q3ListViewItem(list_log_list);
|
||||
l->setText(0,q->value(0).toString());
|
||||
l->setText(1,q->value(1).toString());
|
||||
l->setText(2,q->value(2).toString());
|
||||
if(l->text(0)==*list_logname) {
|
||||
view_item=l;
|
||||
}
|
||||
}
|
||||
delete q;
|
||||
if(view_item!=NULL) {
|
||||
list_log_list->setCurrentItem(view_item);
|
||||
list_log_list->ensureItemVisible(view_item);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user