mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-07-04 14:39:09 +02:00
2021-02-02 Fred Gleason <fredg@paravelsystems.com>
* Added 'RDSchedCodeListModel'. * Refactored the 'Rivendell Scheduler Codes List' dialog in rdadmin(1) to use the model-based API. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
6512148633
commit
b2f5bf72a5
@ -20986,3 +20986,7 @@
|
|||||||
2021-02-02 Fred Gleason <fredg@paravelsystems.com>
|
2021-02-02 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Commented out support for editing hotkeys in the 'Configure
|
* Commented out support for editing hotkeys in the 'Configure
|
||||||
RDAirPlay' dialog in rdadmin(1).
|
RDAirPlay' dialog in rdadmin(1).
|
||||||
|
2021-02-02 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Added 'RDSchedCodeListModel'.
|
||||||
|
* Refactored the 'Rivendell Scheduler Codes List' dialog in
|
||||||
|
rdadmin(1) to use the model-based API.
|
||||||
|
@ -228,6 +228,7 @@ dist_librd_la_SOURCES = dbversion.h\
|
|||||||
rdrsscategorybox.cpp rdrsscategorybox.h\
|
rdrsscategorybox.cpp rdrsscategorybox.h\
|
||||||
rdschedcartlist.cpp rdschedcartlist.h\
|
rdschedcartlist.cpp rdschedcartlist.h\
|
||||||
rdschedcode.cpp rdschedcode.h\
|
rdschedcode.cpp rdschedcode.h\
|
||||||
|
rdschedcodelistmodel.cpp rdschedcodelistmodel.h\
|
||||||
rdschedcodes_dialog.cpp rdschedcodes_dialog.h\
|
rdschedcodes_dialog.cpp rdschedcodes_dialog.h\
|
||||||
rdschedruleslist.cpp rdschedruleslist.h\
|
rdschedruleslist.cpp rdschedruleslist.h\
|
||||||
rdsegmeter.cpp rdsegmeter.h\
|
rdsegmeter.cpp rdsegmeter.h\
|
||||||
@ -379,6 +380,7 @@ nodist_librd_la_SOURCES = moc_rd3emptycart.cpp\
|
|||||||
moc_rdreplicatorlistmodel.cpp\
|
moc_rdreplicatorlistmodel.cpp\
|
||||||
moc_rdresourcelistmodel.cpp\
|
moc_rdresourcelistmodel.cpp\
|
||||||
moc_rdripc.cpp\
|
moc_rdripc.cpp\
|
||||||
|
moc_rdschedcodelistmodel.cpp\
|
||||||
moc_rdschedcodes_dialog.cpp\
|
moc_rdschedcodes_dialog.cpp\
|
||||||
moc_rdrsscategorybox.cpp\
|
moc_rdrsscategorybox.cpp\
|
||||||
moc_rdsegmeter.cpp\
|
moc_rdsegmeter.cpp\
|
||||||
|
@ -170,6 +170,7 @@ SOURCES += rdripc.cpp
|
|||||||
SOURCES += rdrssschemas.cpp
|
SOURCES += rdrssschemas.cpp
|
||||||
SOURCES += rdrsscategorybox.cpp
|
SOURCES += rdrsscategorybox.cpp
|
||||||
SOURCES += rdschedcode.cpp
|
SOURCES += rdschedcode.cpp
|
||||||
|
SOURCES += rdschedcodelistmodel.cpp
|
||||||
SOURCES += rdsegmeter.cpp
|
SOURCES += rdsegmeter.cpp
|
||||||
SOURCES += rdsendmail.cpp
|
SOURCES += rdsendmail.cpp
|
||||||
SOURCES += rdsettings.cpp
|
SOURCES += rdsettings.cpp
|
||||||
@ -343,6 +344,7 @@ HEADERS += rdripc.h
|
|||||||
HEADERS += rdrssschemas.h
|
HEADERS += rdrssschemas.h
|
||||||
HEADERS += rdrsscategorybox.h
|
HEADERS += rdrsscategorybox.h
|
||||||
HEADERS += rdschedcode.h
|
HEADERS += rdschedcode.h
|
||||||
|
HEADERS += rdschedcodelistmodel.h
|
||||||
HEADERS += rdsegmeter.h
|
HEADERS += rdsegmeter.h
|
||||||
HEADERS += rdsendmail.h
|
HEADERS += rdsendmail.h
|
||||||
HEADERS += rdservicelistmodel.h
|
HEADERS += rdservicelistmodel.h
|
||||||
|
@ -3985,6 +3985,17 @@ Zkuste to, prosím, znovu!</translation>
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>RDSchedCodeListModel</name>
|
||||||
|
<message>
|
||||||
|
<source>Code</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Description</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>RDServiceListModel</name>
|
<name>RDServiceListModel</name>
|
||||||
<message>
|
<message>
|
||||||
|
@ -3966,6 +3966,17 @@ bitte erneut versuchen!</translation>
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>RDSchedCodeListModel</name>
|
||||||
|
<message>
|
||||||
|
<source>Code</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Description</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>RDServiceListModel</name>
|
<name>RDServiceListModel</name>
|
||||||
<message>
|
<message>
|
||||||
|
@ -3945,6 +3945,17 @@ please try again!</source>
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>RDSchedCodeListModel</name>
|
||||||
|
<message>
|
||||||
|
<source>Code</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Description</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>RDServiceListModel</name>
|
<name>RDServiceListModel</name>
|
||||||
<message>
|
<message>
|
||||||
|
@ -3238,6 +3238,17 @@ please try again!</source>
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>RDSchedCodeListModel</name>
|
||||||
|
<message>
|
||||||
|
<source>Code</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Description</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>RDServiceListModel</name>
|
<name>RDServiceListModel</name>
|
||||||
<message>
|
<message>
|
||||||
|
@ -3848,6 +3848,17 @@ prøv ein gong til!</translation>
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>RDSchedCodeListModel</name>
|
||||||
|
<message>
|
||||||
|
<source>Code</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Description</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>RDServiceListModel</name>
|
<name>RDServiceListModel</name>
|
||||||
<message>
|
<message>
|
||||||
|
@ -3848,6 +3848,17 @@ prøv ein gong til!</translation>
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>RDSchedCodeListModel</name>
|
||||||
|
<message>
|
||||||
|
<source>Code</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Description</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>RDServiceListModel</name>
|
<name>RDServiceListModel</name>
|
||||||
<message>
|
<message>
|
||||||
|
@ -3899,6 +3899,17 @@ por favor, tente novamente!</translation>
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>RDSchedCodeListModel</name>
|
||||||
|
<message>
|
||||||
|
<source>Code</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Description</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>RDServiceListModel</name>
|
<name>RDServiceListModel</name>
|
||||||
<message>
|
<message>
|
||||||
|
270
lib/rdschedcodelistmodel.cpp
Normal file
270
lib/rdschedcodelistmodel.cpp
Normal file
@ -0,0 +1,270 @@
|
|||||||
|
// rdschedcodelistmodel.cpp
|
||||||
|
//
|
||||||
|
// Data model for Rivendell schedule codes
|
||||||
|
//
|
||||||
|
// (C) Copyright 2021 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
|
||||||
|
// published by the Free Software Foundation.
|
||||||
|
//
|
||||||
|
// This program 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 General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public
|
||||||
|
// License along with this program; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "rdapplication.h"
|
||||||
|
#include "rdescape_string.h"
|
||||||
|
#include "rdschedcodelistmodel.h"
|
||||||
|
|
||||||
|
RDSchedCodeListModel::RDSchedCodeListModel(QObject *parent)
|
||||||
|
: QAbstractTableModel(parent)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Column Attributes
|
||||||
|
//
|
||||||
|
unsigned left=Qt::AlignLeft|Qt::AlignVCenter;
|
||||||
|
// unsigned center=Qt::AlignCenter;
|
||||||
|
// unsigned right=Qt::AlignRight|Qt::AlignVCenter;
|
||||||
|
|
||||||
|
d_headers.push_back(tr("Code"));
|
||||||
|
d_alignments.push_back(left);
|
||||||
|
|
||||||
|
d_headers.push_back(tr("Description"));
|
||||||
|
d_alignments.push_back(left);
|
||||||
|
|
||||||
|
updateModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RDSchedCodeListModel::~RDSchedCodeListModel()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QPalette RDSchedCodeListModel::palette()
|
||||||
|
{
|
||||||
|
return d_palette;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RDSchedCodeListModel::setPalette(const QPalette &pal)
|
||||||
|
{
|
||||||
|
d_palette=pal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RDSchedCodeListModel::setFont(const QFont &font)
|
||||||
|
{
|
||||||
|
d_font=font;
|
||||||
|
d_bold_font=font;
|
||||||
|
d_bold_font.setWeight(QFont::Bold);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int RDSchedCodeListModel::columnCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
return d_headers.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int RDSchedCodeListModel::rowCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
return d_texts.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant RDSchedCodeListModel::headerData(int section,Qt::Orientation orient,
|
||||||
|
int role) const
|
||||||
|
{
|
||||||
|
if((orient==Qt::Horizontal)&&(role==Qt::DisplayRole)) {
|
||||||
|
return d_headers.at(section);
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant RDSchedCodeListModel::data(const QModelIndex &index,int role) const
|
||||||
|
{
|
||||||
|
QString str;
|
||||||
|
int col=index.column();
|
||||||
|
int row=index.row();
|
||||||
|
|
||||||
|
if(row<d_texts.size()) {
|
||||||
|
switch((Qt::ItemDataRole)role) {
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
return d_texts.at(row).at(col);
|
||||||
|
|
||||||
|
case Qt::DecorationRole:
|
||||||
|
// Nothing to do!
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Qt::TextAlignmentRole:
|
||||||
|
return d_alignments.at(col);
|
||||||
|
|
||||||
|
case Qt::FontRole:
|
||||||
|
if(col==0) {
|
||||||
|
return d_bold_font;
|
||||||
|
}
|
||||||
|
return d_font;
|
||||||
|
|
||||||
|
case Qt::TextColorRole:
|
||||||
|
// Nothing to do!
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Qt::BackgroundRole:
|
||||||
|
// Nothing to do!
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString RDSchedCodeListModel::schedCode(const QModelIndex &row) const
|
||||||
|
{
|
||||||
|
return d_texts.at(row.row()).at(0).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QModelIndex RDSchedCodeListModel::addSchedCode(const QString &scode)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Find the insertion offset
|
||||||
|
//
|
||||||
|
int offset=d_texts.size();
|
||||||
|
for(int i=0;i<d_texts.size();i++) {
|
||||||
|
if(scode.toLower()<d_texts.at(i).at(0).toString().toLower()) {
|
||||||
|
offset=i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
beginInsertRows(QModelIndex(),offset,offset);
|
||||||
|
QList<QVariant> list;
|
||||||
|
for(int i=0;i<columnCount();i++) {
|
||||||
|
list.push_back(QVariant());
|
||||||
|
}
|
||||||
|
list[0]=scode;
|
||||||
|
d_texts.insert(offset,list);
|
||||||
|
updateRowLine(offset);
|
||||||
|
endInsertRows();
|
||||||
|
|
||||||
|
return createIndex(offset,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RDSchedCodeListModel::removeSchedCode(const QModelIndex &row)
|
||||||
|
{
|
||||||
|
beginRemoveRows(QModelIndex(),row.row(),row.row());
|
||||||
|
|
||||||
|
d_texts.removeAt(row.row());
|
||||||
|
|
||||||
|
endRemoveRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RDSchedCodeListModel::removeSchedCode(const QString &scode)
|
||||||
|
{
|
||||||
|
for(int i=0;i<d_texts.size();i++) {
|
||||||
|
if(d_texts.at(i).at(0)==scode) {
|
||||||
|
removeSchedCode(createIndex(i,0));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RDSchedCodeListModel::refresh(const QModelIndex &row)
|
||||||
|
{
|
||||||
|
if(row.row()<d_texts.size()) {
|
||||||
|
QString sql=sqlFields()+
|
||||||
|
"where CODE=\""+
|
||||||
|
RDEscapeString(d_texts.at(row.row()).at(0).toString())+
|
||||||
|
"\"";
|
||||||
|
RDSqlQuery *q=new RDSqlQuery(sql);
|
||||||
|
if(q->first()) {
|
||||||
|
updateRow(row.row(),q);
|
||||||
|
emit dataChanged(createIndex(row.row(),0),
|
||||||
|
createIndex(row.row(),columnCount()));
|
||||||
|
}
|
||||||
|
delete q;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RDSchedCodeListModel::refresh(const QString &scode)
|
||||||
|
{
|
||||||
|
for(int i=0;i<d_texts.size();i++) {
|
||||||
|
if(d_texts.at(i).at(0)==scode) {
|
||||||
|
updateRowLine(i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RDSchedCodeListModel::updateModel()
|
||||||
|
{
|
||||||
|
QList<QVariant> texts;
|
||||||
|
|
||||||
|
RDSqlQuery *q=NULL;
|
||||||
|
QString sql=sqlFields();
|
||||||
|
sql+="order by CODE ";
|
||||||
|
beginResetModel();
|
||||||
|
d_texts.clear();
|
||||||
|
q=new RDSqlQuery(sql);
|
||||||
|
while(q->next()) {
|
||||||
|
d_texts.push_back(texts);
|
||||||
|
updateRow(d_texts.size()-1,q);
|
||||||
|
}
|
||||||
|
delete q;
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RDSchedCodeListModel::updateRowLine(int line)
|
||||||
|
{
|
||||||
|
if(line<d_texts.size()) {
|
||||||
|
QString sql=sqlFields()+
|
||||||
|
"where CODE=\""+RDEscapeString(d_texts.at(line).at(0).toString())+"\"";
|
||||||
|
RDSqlQuery *q=new RDSqlQuery(sql);
|
||||||
|
if(q->first()) {
|
||||||
|
updateRow(line,q);
|
||||||
|
}
|
||||||
|
delete q;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RDSchedCodeListModel::updateRow(int row,RDSqlQuery *q)
|
||||||
|
{
|
||||||
|
QList<QVariant> texts;
|
||||||
|
|
||||||
|
// Code
|
||||||
|
texts.push_back(q->value(0));
|
||||||
|
|
||||||
|
// Description
|
||||||
|
texts.push_back(q->value(1));
|
||||||
|
|
||||||
|
d_texts[row]=texts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString RDSchedCodeListModel::sqlFields() const
|
||||||
|
{
|
||||||
|
QString sql=QString("select ")+
|
||||||
|
"CODE,"+ // 00
|
||||||
|
"DESCRIPTION "+ // 01
|
||||||
|
"from SCHED_CODES ";
|
||||||
|
|
||||||
|
return sql;
|
||||||
|
}
|
70
lib/rdschedcodelistmodel.h
Normal file
70
lib/rdschedcodelistmodel.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
// rdschedcodelistmodel.h
|
||||||
|
//
|
||||||
|
// Data model for Rivendell schedule codes
|
||||||
|
//
|
||||||
|
// (C) Copyright 2021 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
|
||||||
|
// published by the Free Software Foundation.
|
||||||
|
//
|
||||||
|
// This program 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 General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public
|
||||||
|
// License along with this program; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef RDSCHEDCODELISTMODEL_H
|
||||||
|
#define RDSCHEDCODELISTMODEL_H
|
||||||
|
|
||||||
|
#include <QAbstractTableModel>
|
||||||
|
#include <QFont>
|
||||||
|
#include <QList>
|
||||||
|
#include <QPalette>
|
||||||
|
|
||||||
|
#include <rddb.h>
|
||||||
|
#include <rdnotification.h>
|
||||||
|
#include <rduser.h>
|
||||||
|
|
||||||
|
class RDSchedCodeListModel : public QAbstractTableModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
RDSchedCodeListModel(QObject *parent=0);
|
||||||
|
~RDSchedCodeListModel();
|
||||||
|
QPalette palette();
|
||||||
|
void setPalette(const QPalette &pal);
|
||||||
|
void setFont(const QFont &font);
|
||||||
|
int columnCount(const QModelIndex &parent=QModelIndex()) const;
|
||||||
|
int rowCount(const QModelIndex &parent=QModelIndex()) const;
|
||||||
|
QVariant headerData(int section,Qt::Orientation orient,
|
||||||
|
int role=Qt::DisplayRole) const;
|
||||||
|
QVariant data(const QModelIndex &index,int role=Qt::DisplayRole) const;
|
||||||
|
QString schedCode(const QModelIndex &row) const;
|
||||||
|
QModelIndex addSchedCode(const QString &scode);
|
||||||
|
void removeSchedCode(const QModelIndex &row);
|
||||||
|
void removeSchedCode(const QString &scode);
|
||||||
|
void refresh(const QModelIndex &row);
|
||||||
|
void refresh(const QString &scode);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void updateModel();
|
||||||
|
void updateRowLine(int line);
|
||||||
|
void updateRow(int row,RDSqlQuery *q);
|
||||||
|
QString sqlFields() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPalette d_palette;
|
||||||
|
QFont d_font;
|
||||||
|
QFont d_bold_font;
|
||||||
|
QList<QVariant> d_headers;
|
||||||
|
QList<QVariant> d_alignments;
|
||||||
|
QList<QList<QVariant> > d_texts;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // RDSCHEDCODELISTMODEL_H
|
@ -3,7 +3,7 @@
|
|||||||
// Add scheduler codes dialog
|
// Add scheduler codes dialog
|
||||||
//
|
//
|
||||||
// (C) Copyright 2005-2018 Stefan Gabriel <stg@st-gabriel.de>
|
// (C) Copyright 2005-2018 Stefan Gabriel <stg@st-gabriel.de>
|
||||||
// (C) Copyright 2018-2019 Fred Gleason <fredg@paravelsystems.com>
|
// (C) Copyright 2018-2021 Fred Gleason <fredg@paravelsystems.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
@ -19,56 +19,33 @@
|
|||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <qstring.h>
|
#include <QMessageBox>
|
||||||
#include <qpushbutton.h>
|
#include <QPushButton>
|
||||||
#include <q3listbox.h>
|
|
||||||
#include <q3textedit.h>
|
|
||||||
#include <qlabel.h>
|
|
||||||
#include <qpainter.h>
|
|
||||||
#include <qevent.h>
|
|
||||||
#include <qmessagebox.h>
|
|
||||||
#include <qcheckbox.h>
|
|
||||||
#include <q3buttongroup.h>
|
|
||||||
|
|
||||||
#include <rddb.h>
|
#include <rddb.h>
|
||||||
#include <rdescape_string.h>
|
#include <rdescape_string.h>
|
||||||
#include <rdpasswd.h>
|
|
||||||
#include <rdtextvalidator.h>
|
|
||||||
|
|
||||||
#include "edit_schedcodes.h"
|
#include "edit_schedcodes.h"
|
||||||
#include "add_schedcodes.h"
|
#include "add_schedcodes.h"
|
||||||
|
|
||||||
AddSchedCode::AddSchedCode(QString *schedCode,QWidget *parent)
|
AddSchedCode::AddSchedCode(QWidget *parent)
|
||||||
: RDDialog(parent)
|
: RDDialog(parent)
|
||||||
{
|
{
|
||||||
setModal(true);
|
|
||||||
|
|
||||||
schedcode_schedCode=schedCode;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Fix the Window Size
|
// Fix the Window Size
|
||||||
//
|
//
|
||||||
setMinimumWidth(sizeHint().width());
|
setMinimumSize(sizeHint());
|
||||||
setMaximumWidth(sizeHint().width());
|
setMaximumSize(sizeHint());
|
||||||
setMinimumHeight(sizeHint().height());
|
|
||||||
setMaximumHeight(sizeHint().height());
|
|
||||||
|
|
||||||
setWindowTitle("RDAdmin - "+tr("Add Scheduler Code"));
|
setWindowTitle("RDAdmin - "+tr("Add Scheduler Code"));
|
||||||
|
|
||||||
//
|
|
||||||
// Text Validator
|
|
||||||
//
|
|
||||||
RDTextValidator *validator=new RDTextValidator(this,"validator");
|
|
||||||
validator->addBannedChar(' ');
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Code Name
|
// Code Name
|
||||||
//
|
//
|
||||||
schedcode_name_edit=new QLineEdit(this);
|
d_code_edit=new QLineEdit(this);
|
||||||
schedcode_name_edit->setGeometry(105,11,sizeHint().width()-150,19);
|
d_code_edit->setGeometry(105,11,sizeHint().width()-150,19);
|
||||||
schedcode_name_edit->setMaxLength(10);
|
d_code_edit->setMaxLength(10);
|
||||||
schedcode_name_edit->setValidator(validator);
|
QLabel *label=new QLabel(d_code_edit,tr("&New Code:"),this);
|
||||||
QLabel *label=new QLabel(schedcode_name_edit,tr("&New Code:"),this);
|
|
||||||
label->setGeometry(10,11,90,19);
|
label->setGeometry(10,11,90,19);
|
||||||
label->setFont(labelFont());
|
label->setFont(labelFont());
|
||||||
label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||||
@ -97,7 +74,7 @@ AddSchedCode::AddSchedCode(QString *schedCode,QWidget *parent)
|
|||||||
|
|
||||||
AddSchedCode::~AddSchedCode()
|
AddSchedCode::~AddSchedCode()
|
||||||
{
|
{
|
||||||
delete schedcode_name_edit;
|
delete d_code_edit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -113,42 +90,38 @@ QSizePolicy AddSchedCode::sizePolicy() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int AddSchedCode::exec(QString *scode)
|
||||||
|
{
|
||||||
|
d_sched_code=scode;
|
||||||
|
|
||||||
|
d_code_edit->setText("");
|
||||||
|
|
||||||
|
return QDialog::exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void AddSchedCode::okData()
|
void AddSchedCode::okData()
|
||||||
{
|
{
|
||||||
RDSqlQuery *q;
|
if(d_code_edit->text().isEmpty()) {
|
||||||
QString sql;
|
QMessageBox::warning(this,"RDAdmin - "+tr("Error"),
|
||||||
|
tr("Invalid Schedule Code!"));
|
||||||
if(schedcode_name_edit->text().isEmpty()) {
|
|
||||||
QMessageBox::warning(this,tr("Invalid Name"),tr("Invalid Name!"));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sql=QString("insert into SCHED_CODES set ")+
|
QString sql=QString("insert into SCHED_CODES set ")+
|
||||||
"CODE=\""+RDEscapeString(schedcode_name_edit->text())+"\"";
|
"CODE=\""+RDEscapeString(d_code_edit->text())+"\"";
|
||||||
q=new RDSqlQuery(sql);
|
if(!RDSqlQuery::apply(sql)) {
|
||||||
if(!q->isActive()) {
|
QMessageBox::warning(this,"RDAdmin - "+tr("Error"),
|
||||||
QMessageBox::warning(this,tr("Code Exists"),tr("Code Already Exists!"),
|
tr("Schedule Code Already Exists!"));
|
||||||
1,0,0);
|
|
||||||
delete q;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
delete q;
|
*d_sched_code=d_code_edit->text();
|
||||||
|
|
||||||
EditSchedCode *schedCode=
|
done(true);
|
||||||
new EditSchedCode(schedcode_name_edit->text(),"",this);
|
|
||||||
if(schedCode->exec()<0) {
|
|
||||||
delete schedCode;
|
|
||||||
done(-1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
delete schedCode;
|
|
||||||
*schedcode_schedCode=schedcode_name_edit->text();
|
|
||||||
done(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AddSchedCode::cancelData()
|
void AddSchedCode::cancelData()
|
||||||
{
|
{
|
||||||
done(-1);
|
done(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// Add scheduler codes dialog
|
// Add scheduler codes dialog
|
||||||
//
|
//
|
||||||
// (C) Copyright Stefan Gabriel <stg@st-gabriel.de>
|
// (C) Copyright Stefan Gabriel <stg@st-gabriel.de>
|
||||||
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
|
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
@ -22,27 +22,29 @@
|
|||||||
#ifndef ADD_SCHEDCODES_H
|
#ifndef ADD_SCHEDCODES_H
|
||||||
#define ADD_SCHEDCODES_H
|
#define ADD_SCHEDCODES_H
|
||||||
|
|
||||||
#include <qcheckbox.h>
|
#include <QLineEdit>
|
||||||
#include <qlineedit.h>
|
|
||||||
|
|
||||||
#include <rddialog.h>
|
#include <rddialog.h>
|
||||||
|
|
||||||
class AddSchedCode : public RDDialog
|
class AddSchedCode : public RDDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
AddSchedCode(QString *schedCode,QWidget *parent=0);
|
AddSchedCode(QWidget *parent=0);
|
||||||
~AddSchedCode();
|
~AddSchedCode();
|
||||||
QSize sizeHint() const;
|
QSize sizeHint() const;
|
||||||
QSizePolicy sizePolicy() const;
|
QSizePolicy sizePolicy() const;
|
||||||
|
|
||||||
private slots:
|
public slots:
|
||||||
void okData();
|
int exec(QString *scode);
|
||||||
void cancelData();
|
|
||||||
|
|
||||||
private:
|
private slots:
|
||||||
QLineEdit *schedcode_name_edit;
|
void okData();
|
||||||
QString *schedcode_schedCode;
|
void cancelData();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QLineEdit *d_code_edit;
|
||||||
|
QString *d_sched_code;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ADD_SCHEDCODES_H
|
#endif // ADD_SCHEDCODES_H
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
//
|
//
|
||||||
// Edit scheduler codes dialog
|
// Edit scheduler codes dialog
|
||||||
//
|
//
|
||||||
// Stefan Gabriel <stg@st-gabriel.de>
|
// Based on original code by Stefan Gabriel <stg@st-gabriel.de>
|
||||||
// (C) Copyright 2005-2018
|
// (C) Copyright 2005-2018
|
||||||
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
|
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
@ -22,44 +22,28 @@
|
|||||||
|
|
||||||
#include <rddb.h>
|
#include <rddb.h>
|
||||||
#include <rdescape_string.h>
|
#include <rdescape_string.h>
|
||||||
#include <rdtextvalidator.h>
|
|
||||||
|
|
||||||
#include "edit_group.h"
|
#include "edit_group.h"
|
||||||
#include "edit_schedcodes.h"
|
#include "edit_schedcodes.h"
|
||||||
|
|
||||||
EditSchedCode::EditSchedCode(QString schedcode,QString description,
|
EditSchedCode::EditSchedCode(QWidget *parent)
|
||||||
QWidget *parent)
|
|
||||||
: RDDialog(parent)
|
: RDDialog(parent)
|
||||||
{
|
{
|
||||||
setModal(true);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Fix the Window Size
|
// Fix the Window Size
|
||||||
//
|
//
|
||||||
setMinimumWidth(sizeHint().width());
|
setMinimumSize(sizeHint());
|
||||||
setMaximumWidth(sizeHint().width());
|
setMaximumSize(sizeHint());
|
||||||
setMinimumHeight(sizeHint().height());
|
|
||||||
setMaximumHeight(sizeHint().height());
|
|
||||||
|
|
||||||
schedcode_code=new QString(schedcode);
|
|
||||||
schedcode_description=new QString(description);
|
|
||||||
|
|
||||||
setWindowTitle("RDAdmin - "+tr("Scheduler Code: ")+schedcode);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Text Validators
|
|
||||||
//
|
|
||||||
RDTextValidator *validator=new RDTextValidator(this);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Code Name
|
// Code Name
|
||||||
//
|
//
|
||||||
schedcode_name_edit=new QLineEdit(this);
|
d_code_edit=new QLineEdit(this);
|
||||||
schedcode_name_edit->setGeometry(125,11,100,19);
|
d_code_edit->setGeometry(125,11,100,19);
|
||||||
schedcode_name_edit->setMaxLength(10);
|
d_code_edit->setMaxLength(10);
|
||||||
schedcode_name_edit->setReadOnly(true);
|
d_code_edit->setReadOnly(true);
|
||||||
QLabel *schedcode_name_label=
|
QLabel *schedcode_name_label=
|
||||||
new QLabel(schedcode_name_edit,tr("Scheduler Code:"),this);
|
new QLabel(d_code_edit,tr("Scheduler Code:"),this);
|
||||||
schedcode_name_label->setGeometry(10,11,110,19);
|
schedcode_name_label->setGeometry(10,11,110,19);
|
||||||
schedcode_name_label->setFont(labelFont());
|
schedcode_name_label->setFont(labelFont());
|
||||||
schedcode_name_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
schedcode_name_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||||
@ -67,12 +51,11 @@ EditSchedCode::EditSchedCode(QString schedcode,QString description,
|
|||||||
//
|
//
|
||||||
// Code Description
|
// Code Description
|
||||||
//
|
//
|
||||||
schedcode_description_edit=new QLineEdit(this);
|
d_description_edit=new QLineEdit(this);
|
||||||
schedcode_description_edit->setGeometry(125,32,sizeHint().width()-135,19);
|
d_description_edit->setGeometry(125,32,sizeHint().width()-135,19);
|
||||||
schedcode_description_edit->setMaxLength(255);
|
d_description_edit->setMaxLength(255);
|
||||||
schedcode_description_edit->setValidator(validator);
|
|
||||||
QLabel *schedcode_description_label=
|
QLabel *schedcode_description_label=
|
||||||
new QLabel(schedcode_description_edit,tr("Code Description:"),this);
|
new QLabel(d_description_edit,tr("Code Description:"),this);
|
||||||
schedcode_description_label->setGeometry(10,32,110,19);
|
schedcode_description_label->setGeometry(10,32,110,19);
|
||||||
schedcode_description_label->setFont(labelFont());
|
schedcode_description_label->setFont(labelFont());
|
||||||
schedcode_description_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
schedcode_description_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||||
@ -96,19 +79,13 @@ EditSchedCode::EditSchedCode(QString schedcode,QString description,
|
|||||||
cancel_button->setFont(buttonFont());
|
cancel_button->setFont(buttonFont());
|
||||||
cancel_button->setText(tr("&Cancel"));
|
cancel_button->setText(tr("&Cancel"));
|
||||||
connect(cancel_button,SIGNAL(clicked()),this,SLOT(cancelData()));
|
connect(cancel_button,SIGNAL(clicked()),this,SLOT(cancelData()));
|
||||||
|
|
||||||
//
|
|
||||||
// Populate Fields
|
|
||||||
//
|
|
||||||
schedcode_name_edit->setText(*schedcode_code);
|
|
||||||
schedcode_description_edit->setText(*schedcode_description);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EditSchedCode::~EditSchedCode()
|
EditSchedCode::~EditSchedCode()
|
||||||
{
|
{
|
||||||
delete schedcode_name_edit;
|
delete d_code_edit;
|
||||||
delete schedcode_description_edit;
|
delete d_description_edit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -124,24 +101,43 @@ QSizePolicy EditSchedCode::sizePolicy() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int EditSchedCode::exec(const QString &scode)
|
||||||
|
{
|
||||||
|
setWindowTitle("RDAdmin - "+tr("Scheduler Code: ")+scode);
|
||||||
|
|
||||||
|
d_code_edit->setText(scode);
|
||||||
|
|
||||||
|
QString sql=QString("select ")+
|
||||||
|
"DESCRIPTION "+ // 00
|
||||||
|
"from SCHED_CODES where "+
|
||||||
|
"CODE=\""+RDEscapeString(scode)+"\"";
|
||||||
|
RDSqlQuery *q=new RDSqlQuery(sql);
|
||||||
|
if(q->first()) {
|
||||||
|
d_description_edit->setText(q->value(0).toString());
|
||||||
|
}
|
||||||
|
delete q;
|
||||||
|
|
||||||
|
return QDialog::exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void EditSchedCode::okData()
|
void EditSchedCode::okData()
|
||||||
{
|
{
|
||||||
RDSqlQuery *q;
|
RDSqlQuery *q;
|
||||||
QString sql;
|
QString sql;
|
||||||
|
|
||||||
sql=QString("update SCHED_CODES set ")+
|
sql=QString("update SCHED_CODES set ")+
|
||||||
"DESCRIPTION=\""+RDEscapeString(schedcode_description_edit->text())+"\" "+
|
"DESCRIPTION=\""+RDEscapeString(d_description_edit->text())+"\" "+
|
||||||
"where CODE=\""+RDEscapeString(schedcode_name_edit->text())+"\"";
|
"where CODE=\""+RDEscapeString(d_code_edit->text())+"\"";
|
||||||
q=new RDSqlQuery(sql);
|
q=new RDSqlQuery(sql);
|
||||||
delete q;
|
delete q;
|
||||||
|
|
||||||
*schedcode_description=schedcode_description_edit->text();
|
done(true);
|
||||||
done(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EditSchedCode::cancelData()
|
void EditSchedCode::cancelData()
|
||||||
{
|
{
|
||||||
done(-1);
|
done(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
//
|
//
|
||||||
// Edit scheduler codes dialog
|
// Edit scheduler codes dialog
|
||||||
//
|
//
|
||||||
// Stefan Gabriel <stg@st-gabriel.de>
|
// Based on original code by Stefan Gabriel <stg@st-gabriel.de>
|
||||||
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
|
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
@ -22,7 +22,7 @@
|
|||||||
#ifndef EDIT_SCHEDCODES_H
|
#ifndef EDIT_SCHEDCODES_H
|
||||||
#define EDIT_SCHEDCODES_H
|
#define EDIT_SCHEDCODES_H
|
||||||
|
|
||||||
#include <qlineedit.h>
|
#include <QLineEdit>
|
||||||
|
|
||||||
#include <rddialog.h>
|
#include <rddialog.h>
|
||||||
|
|
||||||
@ -30,20 +30,21 @@ class EditSchedCode : public RDDialog
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
EditSchedCode(QString schedcode,QString description,QWidget *parent=0);
|
EditSchedCode(QWidget *parent=0);
|
||||||
~EditSchedCode();
|
~EditSchedCode();
|
||||||
QSize sizeHint() const;
|
QSize sizeHint() const;
|
||||||
QSizePolicy sizePolicy() const;
|
QSizePolicy sizePolicy() const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
int exec(const QString &scode);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void okData();
|
void okData();
|
||||||
void cancelData();
|
void cancelData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString *schedcode_code;
|
QLineEdit *d_code_edit;
|
||||||
QString *schedcode_description;
|
QLineEdit *d_description_edit;
|
||||||
QLineEdit *schedcode_name_edit;
|
|
||||||
QLineEdit *schedcode_description_edit;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
//
|
//
|
||||||
// The scheduler codes dialog for rdadmin
|
// The scheduler codes dialog for rdadmin
|
||||||
//
|
//
|
||||||
// Stefan Gabriel <stg@st-gabriel.de>
|
// Based on original code by Stefan Gabriel <stg@st-gabriel.de>
|
||||||
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsyustems.com>
|
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsyustems.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
@ -19,7 +19,7 @@
|
|||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <qmessagebox.h>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include <rdcart.h>
|
#include <rdcart.h>
|
||||||
#include <rddb.h>
|
#include <rddb.h>
|
||||||
@ -33,8 +33,6 @@
|
|||||||
ListSchedCodes::ListSchedCodes(QWidget *parent)
|
ListSchedCodes::ListSchedCodes(QWidget *parent)
|
||||||
: RDDialog(parent)
|
: RDDialog(parent)
|
||||||
{
|
{
|
||||||
setModal(true);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Fix the Window Size
|
// Fix the Window Size
|
||||||
//
|
//
|
||||||
@ -42,6 +40,12 @@ ListSchedCodes::ListSchedCodes(QWidget *parent)
|
|||||||
|
|
||||||
setWindowTitle("RDAdmin - "+tr("Rivendell Scheduler Codes List"));
|
setWindowTitle("RDAdmin - "+tr("Rivendell Scheduler Codes List"));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Dialogs
|
||||||
|
//
|
||||||
|
list_add_schedcode_dialog=new AddSchedCode(this);
|
||||||
|
list_edit_schedcode_dialog=new EditSchedCode(this);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Add Button
|
// Add Button
|
||||||
//
|
//
|
||||||
@ -76,27 +80,28 @@ ListSchedCodes::ListSchedCodes(QWidget *parent)
|
|||||||
connect(list_close_button,SIGNAL(clicked()),this,SLOT(closeData()));
|
connect(list_close_button,SIGNAL(clicked()),this,SLOT(closeData()));
|
||||||
|
|
||||||
//
|
//
|
||||||
// Group List
|
// Schedule Codes List
|
||||||
//
|
//
|
||||||
list_schedCodes_view=new Q3ListView(this);
|
list_schedcodes_view=new RDTableView(this);
|
||||||
list_schedCodes_view->setAllColumnsShowFocus(true);
|
list_schedcodes_model=new RDSchedCodeListModel(this);
|
||||||
list_schedCodes_view->addColumn(tr("CODE"));
|
list_schedcodes_model->setFont(defaultFont());
|
||||||
list_schedCodes_view->addColumn(tr("DESCRIPTION"));
|
list_schedcodes_model->setPalette(palette());
|
||||||
QLabel *list_box_label=
|
list_schedcodes_view->setModel(list_schedcodes_model);
|
||||||
new QLabel(list_schedCodes_view,tr("Scheduler Codes:"),this);
|
list_schedcodes_label=
|
||||||
list_box_label->setFont(buttonFont());
|
new QLabel(list_schedcodes_view,tr("Replicators:"),this);
|
||||||
list_box_label->setGeometry(14,11,200,19);
|
list_schedcodes_label->setFont(labelFont());
|
||||||
connect(list_schedCodes_view,
|
connect(list_schedcodes_view,SIGNAL(doubleClicked(const QModelIndex &)),
|
||||||
SIGNAL(doubleClicked(Q3ListViewItem *,const QPoint &,int)),
|
this,SLOT(doubleClickedData(const QModelIndex &)));
|
||||||
this,
|
connect(list_schedcodes_model,SIGNAL(modelReset()),
|
||||||
SLOT(doubleClickedData(Q3ListViewItem *,const QPoint &,int)));
|
list_schedcodes_view,SLOT(resizeColumnsToContents()));
|
||||||
|
list_schedcodes_view->resizeColumnsToContents();
|
||||||
RefreshList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ListSchedCodes::~ListSchedCodes()
|
ListSchedCodes::~ListSchedCodes()
|
||||||
{
|
{
|
||||||
|
delete list_edit_schedcode_dialog;
|
||||||
|
delete list_add_schedcode_dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -114,55 +119,49 @@ QSizePolicy ListSchedCodes::sizePolicy() const
|
|||||||
|
|
||||||
void ListSchedCodes::addData()
|
void ListSchedCodes::addData()
|
||||||
{
|
{
|
||||||
QString schedCode;
|
QString scode;
|
||||||
|
|
||||||
AddSchedCode *add_schedCode=new AddSchedCode(&schedCode,this);
|
if(list_add_schedcode_dialog->exec(&scode)) {
|
||||||
if(add_schedCode->exec()<0) {
|
QModelIndex index=list_schedcodes_model->addSchedCode(scode);
|
||||||
delete add_schedCode;
|
if(index.isValid()) {
|
||||||
return;
|
list_schedcodes_view->selectRow(index.row());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QString sql=QString("delete from SCHED_CODES where ")+
|
||||||
|
"CODE=\""+RDEscapeString(scode)+"\"";
|
||||||
|
RDSqlQuery::apply(sql);
|
||||||
}
|
}
|
||||||
delete add_schedCode;
|
|
||||||
add_schedCode=NULL;
|
|
||||||
Q3ListViewItem *item=new Q3ListViewItem(list_schedCodes_view);
|
|
||||||
item->setText(0,schedCode);
|
|
||||||
RefreshItem(item);
|
|
||||||
item->setSelected(true);
|
|
||||||
list_schedCodes_view->setCurrentItem(item);
|
|
||||||
list_schedCodes_view->ensureItemVisible(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ListSchedCodes::editData()
|
void ListSchedCodes::editData()
|
||||||
{
|
{
|
||||||
Q3ListViewItem *item=list_schedCodes_view->selectedItem();
|
QModelIndexList rows=list_schedcodes_view->selectionModel()->selectedRows();
|
||||||
if(item==NULL) {
|
|
||||||
|
if(rows.size()!=1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EditSchedCode *edit_schedCode=
|
|
||||||
new EditSchedCode(item->text(0),item->text(1),this);
|
if(list_edit_schedcode_dialog->
|
||||||
edit_schedCode->exec();
|
exec(list_schedcodes_model->schedCode(rows.first()))) {
|
||||||
delete edit_schedCode;
|
list_schedcodes_model->refresh(rows.first());
|
||||||
edit_schedCode=NULL;
|
}
|
||||||
RefreshItem(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ListSchedCodes::deleteData()
|
void ListSchedCodes::deleteData()
|
||||||
{
|
{
|
||||||
Q3ListViewItem *item=list_schedCodes_view->selectedItem();
|
QModelIndexList rows=list_schedcodes_view->selectionModel()->selectedRows();
|
||||||
if(item==NULL) {
|
|
||||||
|
if(rows.size()!=1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString sql;
|
QString sql;
|
||||||
RDSqlQuery *q;
|
|
||||||
QString warning;
|
QString warning;
|
||||||
QString str;
|
QString str;
|
||||||
|
|
||||||
QString codename=item->text(0);
|
QString codename=list_schedcodes_model->schedCode(rows.first());
|
||||||
if(codename.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(QMessageBox::question(this,"RDAdmin - "+tr("Delete Scheduler Code"),
|
if(QMessageBox::question(this,"RDAdmin - "+tr("Delete Scheduler Code"),
|
||||||
tr("This operation will delete the selected scheduler code and")+
|
tr("This operation will delete the selected scheduler code and")+
|
||||||
"\n"+tr("all of its associated data.")+" "+
|
"\n"+tr("all of its associated data.")+" "+
|
||||||
@ -174,20 +173,16 @@ void ListSchedCodes::deleteData()
|
|||||||
|
|
||||||
sql=QString("delete from DROPBOX_SCHED_CODES where ")+
|
sql=QString("delete from DROPBOX_SCHED_CODES where ")+
|
||||||
"SCHED_CODE=\""+RDEscapeString(codename)+"\"";
|
"SCHED_CODE=\""+RDEscapeString(codename)+"\"";
|
||||||
q=new RDSqlQuery(sql);
|
RDSqlQuery::apply(sql);
|
||||||
delete q;
|
|
||||||
|
|
||||||
sql=QString("delete from SCHED_CODES where ")+
|
sql=QString("delete from SCHED_CODES where ")+
|
||||||
"CODE=\""+RDEscapeString(codename)+"\"";
|
"CODE=\""+RDEscapeString(codename)+"\"";
|
||||||
q=new RDSqlQuery(sql);
|
RDSqlQuery::apply(sql);
|
||||||
delete q;
|
list_schedcodes_model->removeSchedCode(rows.first());
|
||||||
item->setSelected(false);
|
|
||||||
delete item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ListSchedCodes::doubleClickedData(Q3ListViewItem *item,const QPoint &pt,
|
void ListSchedCodes::doubleClickedData(const QModelIndex &index)
|
||||||
int col)
|
|
||||||
{
|
{
|
||||||
editData();
|
editData();
|
||||||
}
|
}
|
||||||
@ -195,7 +190,7 @@ void ListSchedCodes::doubleClickedData(Q3ListViewItem *item,const QPoint &pt,
|
|||||||
|
|
||||||
void ListSchedCodes::closeData()
|
void ListSchedCodes::closeData()
|
||||||
{
|
{
|
||||||
done(0);
|
done(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -203,46 +198,8 @@ void ListSchedCodes::resizeEvent(QResizeEvent *e)
|
|||||||
{
|
{
|
||||||
list_add_button->setGeometry(size().width()-90,30,80,50);
|
list_add_button->setGeometry(size().width()-90,30,80,50);
|
||||||
list_edit_button->setGeometry(size().width()-90,90,80,50);
|
list_edit_button->setGeometry(size().width()-90,90,80,50);
|
||||||
list_delete_button->setGeometry(size().width()-90,210,80,50);
|
list_delete_button->setGeometry(size().width()-90,150,80,50);
|
||||||
list_close_button->setGeometry(size().width()-90,size().height()-60,80,50);
|
list_close_button->setGeometry(size().width()-90,size().height()-60,80,50);
|
||||||
list_schedCodes_view->setGeometry(10,30,size().width()-120,size().height()-40);
|
list_schedcodes_view->
|
||||||
|
setGeometry(10,30,size().width()-120,size().height()-40);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ListSchedCodes::RefreshList()
|
|
||||||
{
|
|
||||||
QString sql;
|
|
||||||
RDSqlQuery *q;
|
|
||||||
Q3ListViewItem *item;
|
|
||||||
|
|
||||||
list_schedCodes_view->clear();
|
|
||||||
q=new RDSqlQuery("select CODE,DESCRIPTION from SCHED_CODES");
|
|
||||||
while (q->next()) {
|
|
||||||
item=new Q3ListViewItem(list_schedCodes_view);
|
|
||||||
WriteItem(item,q);
|
|
||||||
}
|
|
||||||
delete q;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ListSchedCodes::RefreshItem(Q3ListViewItem *item)
|
|
||||||
{
|
|
||||||
QString sql;
|
|
||||||
RDSqlQuery *q;
|
|
||||||
|
|
||||||
sql=QString().sprintf("select CODE,DESCRIPTION from SCHED_CODES where CODE=\"%s\"",
|
|
||||||
(const char *)item->text(0));
|
|
||||||
q=new RDSqlQuery(sql);
|
|
||||||
if(q->next()) {
|
|
||||||
WriteItem(item,q);
|
|
||||||
}
|
|
||||||
delete q;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ListSchedCodes::WriteItem(Q3ListViewItem *item,RDSqlQuery *q)
|
|
||||||
{
|
|
||||||
item->setText(0,q->value(0).toString());
|
|
||||||
item->setText(1,q->value(1).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// The scheduler codes dialog for rdadmin
|
// The scheduler codes dialog for rdadmin
|
||||||
//
|
//
|
||||||
// Stefan Gabriel <stg@st-gabriel.de>
|
// Based on original code by Stefan Gabriel <stg@st-gabriel.de>
|
||||||
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
|
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// This program is free software; you can redistribute it and/or modify
|
||||||
@ -22,12 +22,16 @@
|
|||||||
#ifndef LIST_SCHEDCODES_H
|
#ifndef LIST_SCHEDCODES_H
|
||||||
#define LIST_SCHEDCODES_H
|
#define LIST_SCHEDCODES_H
|
||||||
|
|
||||||
#include <qpixmap.h>
|
#include <QLabel>
|
||||||
#include <qpushbutton.h>
|
#include <QPushButton>
|
||||||
|
|
||||||
#include <rddb.h>
|
#include <rddb.h>
|
||||||
#include <rddialog.h>
|
#include <rddialog.h>
|
||||||
#include <rdlistviewitem.h>
|
#include <rdschedcodelistmodel.h>
|
||||||
|
#include <rdtableview.h>
|
||||||
|
|
||||||
|
#include "add_schedcodes.h"
|
||||||
|
#include "edit_schedcodes.h"
|
||||||
|
|
||||||
class ListSchedCodes : public RDDialog
|
class ListSchedCodes : public RDDialog
|
||||||
{
|
{
|
||||||
@ -42,21 +46,22 @@ class ListSchedCodes : public RDDialog
|
|||||||
void addData();
|
void addData();
|
||||||
void editData();
|
void editData();
|
||||||
void deleteData();
|
void deleteData();
|
||||||
void doubleClickedData(Q3ListViewItem *item,const QPoint &pt,int col);
|
void doubleClickedData(const QModelIndex &index);
|
||||||
void closeData();
|
void closeData();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *e);
|
void resizeEvent(QResizeEvent *e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RefreshList();
|
RDTableView *list_schedcodes_view;
|
||||||
void RefreshItem(Q3ListViewItem *item);
|
QLabel *list_schedcodes_label;
|
||||||
void WriteItem(Q3ListViewItem *item,RDSqlQuery *q);
|
RDSchedCodeListModel *list_schedcodes_model;
|
||||||
Q3ListView *list_schedCodes_view;
|
|
||||||
QPushButton *list_add_button;
|
QPushButton *list_add_button;
|
||||||
QPushButton *list_edit_button;
|
QPushButton *list_edit_button;
|
||||||
QPushButton *list_delete_button;
|
QPushButton *list_delete_button;
|
||||||
QPushButton *list_close_button;
|
QPushButton *list_close_button;
|
||||||
|
AddSchedCode *list_add_schedcode_dialog;
|
||||||
|
EditSchedCode *list_edit_schedcode_dialog;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user