mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-07-30 07:29:33 +02:00
2021-01-27 Fred Gleason <fredg@paravelsystems.com>
* Added 'RDReplicatorListModel'. * Refactored the 'Rivendell Replicators' dialog in rdadmin(1) to use the model-based API. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
d8f526119e
commit
040711e1d8
@ -20922,3 +20922,7 @@
|
||||
model-based API.
|
||||
2021-01-26 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added 'RDTableView' and 'RDTreeView' base viewer classes.
|
||||
2021-01-27 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added 'RDReplicatorListModel'.
|
||||
* Refactored the 'Rivendell Replicators' dialog in rdadmin(1) to
|
||||
use the model-based API.
|
||||
|
@ -212,6 +212,7 @@ dist_librd_la_SOURCES = dbversion.h\
|
||||
rdrehash.cpp rdrehash.h\
|
||||
rdrenderer.cpp rdrenderer.h\
|
||||
rdreplicator.cpp rdreplicator.h\
|
||||
rdreplicatorlistmodel.cpp rdreplicatorlistmodel.h\
|
||||
rdreport.cpp rdreport.h\
|
||||
rdringbuffer.cpp rdringbuffer.h\
|
||||
rdripc.cpp rdripc.h\
|
||||
@ -360,6 +361,7 @@ nodist_librd_la_SOURCES = moc_rdadd_cart.cpp\
|
||||
moc_rdpypadlistmodel.cpp\
|
||||
moc_rdrehash.cpp\
|
||||
moc_rdrenderer.cpp\
|
||||
moc_rdreplicatorlistmodel.cpp\
|
||||
moc_rdripc.cpp\
|
||||
moc_rdschedcodes_dialog.cpp\
|
||||
moc_rdrsscategorybox.cpp\
|
||||
|
@ -156,6 +156,7 @@ SOURCES += rdpypadlistmodel.cpp
|
||||
SOURCES += rdrecording.cpp
|
||||
SOURCES += rdrehash.cpp
|
||||
SOURCES += rdrenderer.cpp
|
||||
SOURCES += rdreplicatorlistmodel.cpp
|
||||
SOURCES += rdreport.cpp
|
||||
SOURCES += rdripc.cpp
|
||||
SOURCES += rdrssschemas.cpp
|
||||
@ -320,6 +321,7 @@ HEADERS += rdpypadlistmodel.h
|
||||
HEADERS += rdrecording.h
|
||||
HEADERS += rdrehash.h
|
||||
HEADERS += rdrenderer.h
|
||||
HEADERS += rdreplicatorlistmodel.h
|
||||
HEADERS += rdreport.h
|
||||
HEADERS += rdripc.h
|
||||
HEADERS += rdrssschemas.h
|
||||
|
@ -3631,6 +3631,25 @@ Zkuste to, prosím, znovu!</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RDReplicatorListModel</name>
|
||||
<message>
|
||||
<source>Name</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Type</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Description</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Host</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RDReport</name>
|
||||
<message>
|
||||
|
@ -3612,6 +3612,25 @@ bitte erneut versuchen!</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RDReplicatorListModel</name>
|
||||
<message>
|
||||
<source>Name</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Type</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Description</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Host</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RDReport</name>
|
||||
<message>
|
||||
|
@ -3599,6 +3599,25 @@ please try again!</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RDReplicatorListModel</name>
|
||||
<message>
|
||||
<source>Name</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Type</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Description</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Host</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RDReport</name>
|
||||
<message>
|
||||
|
@ -2951,6 +2951,25 @@ please try again!</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RDReplicatorListModel</name>
|
||||
<message>
|
||||
<source>Name</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Type</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Description</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Host</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RDServiceListModel</name>
|
||||
<message>
|
||||
|
@ -3510,6 +3510,25 @@ prøv ein gong til!</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RDReplicatorListModel</name>
|
||||
<message>
|
||||
<source>Name</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Type</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Description</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Host</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RDReport</name>
|
||||
<message>
|
||||
|
@ -3510,6 +3510,25 @@ prøv ein gong til!</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RDReplicatorListModel</name>
|
||||
<message>
|
||||
<source>Name</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Type</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Description</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Host</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RDReport</name>
|
||||
<message>
|
||||
|
@ -3545,6 +3545,25 @@ por favor, tente novamente!</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RDReplicatorListModel</name>
|
||||
<message>
|
||||
<source>Name</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Type</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Description</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Host</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RDReport</name>
|
||||
<message>
|
||||
|
287
lib/rdreplicatorlistmodel.cpp
Normal file
287
lib/rdreplicatorlistmodel.cpp
Normal file
@ -0,0 +1,287 @@
|
||||
// rdreplicatorlistmodel.cpp
|
||||
//
|
||||
// Data model for Rivendell services
|
||||
//
|
||||
// (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 "rdreplicator.h"
|
||||
#include "rdreplicatorlistmodel.h"
|
||||
|
||||
RDReplicatorListModel::RDReplicatorListModel(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("Name"));
|
||||
d_alignments.push_back(left);
|
||||
|
||||
d_headers.push_back(tr("Type"));
|
||||
d_alignments.push_back(left);
|
||||
|
||||
d_headers.push_back(tr("Description"));
|
||||
d_alignments.push_back(left);
|
||||
|
||||
d_headers.push_back(tr("Host"));
|
||||
d_alignments.push_back(left);
|
||||
|
||||
updateModel();
|
||||
}
|
||||
|
||||
|
||||
RDReplicatorListModel::~RDReplicatorListModel()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QPalette RDReplicatorListModel::palette()
|
||||
{
|
||||
return d_palette;
|
||||
}
|
||||
|
||||
|
||||
void RDReplicatorListModel::setPalette(const QPalette &pal)
|
||||
{
|
||||
d_palette=pal;
|
||||
}
|
||||
|
||||
|
||||
void RDReplicatorListModel::setFont(const QFont &font)
|
||||
{
|
||||
d_font=font;
|
||||
d_bold_font=font;
|
||||
d_bold_font.setWeight(QFont::Bold);
|
||||
}
|
||||
|
||||
|
||||
int RDReplicatorListModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
return d_headers.size();
|
||||
}
|
||||
|
||||
|
||||
int RDReplicatorListModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return d_texts.size();
|
||||
}
|
||||
|
||||
|
||||
QVariant RDReplicatorListModel::headerData(int section,Qt::Orientation orient,
|
||||
int role) const
|
||||
{
|
||||
if((orient==Qt::Horizontal)&&(role==Qt::DisplayRole)) {
|
||||
return d_headers.at(section);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
QVariant RDReplicatorListModel::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 RDReplicatorListModel::replicatorName(const QModelIndex &row) const
|
||||
{
|
||||
return d_texts.at(row.row()).at(0).toString();
|
||||
}
|
||||
|
||||
|
||||
QModelIndex RDReplicatorListModel::addReplicator(const QString &replname)
|
||||
{
|
||||
//
|
||||
// Find the insertion offset
|
||||
//
|
||||
int offset=d_texts.size();
|
||||
for(int i=0;i<d_texts.size();i++) {
|
||||
if(replname.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]=replname;
|
||||
d_texts.insert(offset,list);
|
||||
updateRowLine(offset);
|
||||
endInsertRows();
|
||||
|
||||
return createIndex(offset,0);
|
||||
}
|
||||
|
||||
|
||||
void RDReplicatorListModel::removeReplicator(const QModelIndex &row)
|
||||
{
|
||||
beginRemoveRows(QModelIndex(),row.row(),row.row());
|
||||
|
||||
d_texts.removeAt(row.row());
|
||||
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
|
||||
void RDReplicatorListModel::removeReplicator(const QString &replname)
|
||||
{
|
||||
for(int i=0;i<d_texts.size();i++) {
|
||||
if(d_texts.at(i).at(0)==replname) {
|
||||
removeReplicator(createIndex(i,0));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RDReplicatorListModel::refresh(const QModelIndex &row)
|
||||
{
|
||||
if(row.row()<d_texts.size()) {
|
||||
QString sql=sqlFields()+
|
||||
"where REPLICATORS.NAME=\""+
|
||||
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 RDReplicatorListModel::refresh(const QString &replname)
|
||||
{
|
||||
for(int i=0;i<d_texts.size();i++) {
|
||||
if(d_texts.at(i).at(0)==replname) {
|
||||
updateRowLine(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RDReplicatorListModel::updateModel()
|
||||
{
|
||||
QList<QVariant> texts;
|
||||
|
||||
RDSqlQuery *q=NULL;
|
||||
QString sql=sqlFields();
|
||||
sql+="order by REPLICATORS.NAME ";
|
||||
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 RDReplicatorListModel::updateRowLine(int line)
|
||||
{
|
||||
if(line<d_texts.size()) {
|
||||
QString sql=sqlFields()+
|
||||
"where REPLICATORS.NAME=\""+
|
||||
RDEscapeString(d_texts.at(line).at(0).toString())+"\"";
|
||||
RDSqlQuery *q=new RDSqlQuery(sql);
|
||||
if(q->first()) {
|
||||
updateRow(line,q);
|
||||
}
|
||||
delete q;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RDReplicatorListModel::updateRow(int row,RDSqlQuery *q)
|
||||
{
|
||||
QList<QVariant> texts;
|
||||
|
||||
// Name
|
||||
texts.push_back(q->value(0));
|
||||
|
||||
// Type
|
||||
texts.push_back(RDReplicator::typeString((RDReplicator::Type)q->value(1).
|
||||
toUInt()));
|
||||
|
||||
// Description
|
||||
texts.push_back(q->value(2));
|
||||
|
||||
// Host
|
||||
texts.push_back(q->value(3));
|
||||
|
||||
d_texts[row]=texts;
|
||||
}
|
||||
|
||||
|
||||
QString RDReplicatorListModel::sqlFields() const
|
||||
{
|
||||
QString sql=QString("select ")+
|
||||
"REPLICATORS.NAME,"+ // 00
|
||||
"REPLICATORS.TYPE_ID,"+ // 01
|
||||
"REPLICATORS.DESCRIPTION,"+ // 02
|
||||
"REPLICATORS.STATION_NAME "+ // 03
|
||||
"from REPLICATORS ";
|
||||
|
||||
return sql;
|
||||
}
|
70
lib/rdreplicatorlistmodel.h
Normal file
70
lib/rdreplicatorlistmodel.h
Normal file
@ -0,0 +1,70 @@
|
||||
// rdreplicatorlistmodel.h
|
||||
//
|
||||
// Data model for Rivendell services
|
||||
//
|
||||
// (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 RDREPLICATORLISTMODEL_H
|
||||
#define RDREPLICATORLISTMODEL_H
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <QFont>
|
||||
#include <QList>
|
||||
#include <QPalette>
|
||||
|
||||
#include <rddb.h>
|
||||
#include <rdnotification.h>
|
||||
#include <rduser.h>
|
||||
|
||||
class RDReplicatorListModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RDReplicatorListModel(QObject *parent=0);
|
||||
~RDReplicatorListModel();
|
||||
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 replicatorName(const QModelIndex &row) const;
|
||||
QModelIndex addReplicator(const QString &replname);
|
||||
void removeReplicator(const QModelIndex &row);
|
||||
void removeReplicator(const QString &replname);
|
||||
void refresh(const QModelIndex &row);
|
||||
void refresh(const QString &replname);
|
||||
|
||||
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 // RDREPLICATORLISTMODEL_H
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Add a Rivendell Replicator Configuration
|
||||
//
|
||||
// (C) Copyright 2010-2019 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2010-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
|
||||
@ -20,18 +20,9 @@
|
||||
|
||||
#include <qstring.h>
|
||||
#include <qpushbutton.h>
|
||||
#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 <rdescape_string.h>
|
||||
#include <rdpasswd.h>
|
||||
#include <rdtextvalidator.h>
|
||||
|
||||
#include "edit_replicator.h"
|
||||
@ -47,10 +38,8 @@ AddReplicator::AddReplicator(QString *rname,QWidget *parent)
|
||||
//
|
||||
// Fix the Window Size
|
||||
//
|
||||
setMinimumWidth(sizeHint().width());
|
||||
setMaximumWidth(sizeHint().width());
|
||||
setMinimumHeight(sizeHint().height());
|
||||
setMaximumHeight(sizeHint().height());
|
||||
setMinimumSize(sizeHint());
|
||||
setMaximumSize(sizeHint());
|
||||
|
||||
setWindowTitle("RDAdmin - "+tr("Add Replicator"));
|
||||
|
||||
@ -138,16 +127,16 @@ void AddReplicator::okData()
|
||||
q=new RDSqlQuery(sql);
|
||||
delete q;
|
||||
delete replicator;
|
||||
done(-1);
|
||||
done(false);
|
||||
return;
|
||||
}
|
||||
delete replicator;
|
||||
*repl_name=repl_name_edit->text();
|
||||
done(0);
|
||||
done(true);
|
||||
}
|
||||
|
||||
|
||||
void AddReplicator::cancelData()
|
||||
{
|
||||
done(-1);
|
||||
done(false);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Edit a Rivendell Replicator
|
||||
//
|
||||
// (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
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
@ -342,11 +342,11 @@ void EditReplicator::okData()
|
||||
q=new RDSqlQuery(sql);
|
||||
delete q;
|
||||
|
||||
done(0);
|
||||
done(true);
|
||||
}
|
||||
|
||||
|
||||
void EditReplicator::cancelData()
|
||||
{
|
||||
done(-1);
|
||||
done(false);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// List Rivendell Replication Configurations
|
||||
//
|
||||
// (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
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
@ -18,13 +18,8 @@
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include <math.h>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <qmessagebox.h>
|
||||
|
||||
#include <rdcart.h>
|
||||
#include <rddb.h>
|
||||
#include <rdtextfile.h>
|
||||
#include <rdescape_string.h>
|
||||
#include <rdreplicator.h>
|
||||
|
||||
@ -36,13 +31,10 @@
|
||||
ListReplicators::ListReplicators(QWidget *parent)
|
||||
: RDDialog(parent)
|
||||
{
|
||||
setModal(true);
|
||||
|
||||
//
|
||||
// Fix the Window Size
|
||||
//
|
||||
setMinimumWidth(sizeHint().width());
|
||||
setMinimumHeight(sizeHint().height());
|
||||
setMinimumSize(sizeHint());
|
||||
|
||||
setWindowTitle("RDAdmin - "+tr("Rivendell Replicators"));
|
||||
|
||||
@ -90,23 +82,19 @@ ListReplicators::ListReplicators(QWidget *parent)
|
||||
//
|
||||
// Replicator List
|
||||
//
|
||||
list_replicators_view=new RDListView(this);
|
||||
list_replicators_view->setAllColumnsShowFocus(true);
|
||||
list_replicators_view->setItemMargin(5);
|
||||
list_replicators_view->addColumn(tr("NAME"));
|
||||
list_replicators_view->addColumn(tr("TYPE"));
|
||||
list_replicators_view->addColumn(tr("DESCRIPTION"));
|
||||
list_replicators_view->addColumn(tr("HOST"));
|
||||
QLabel *list_box_label=
|
||||
list_replicators_view=new RDTableView(this);
|
||||
list_replicators_model=new RDReplicatorListModel(this);
|
||||
list_replicators_model->setFont(defaultFont());
|
||||
list_replicators_model->setPalette(palette());
|
||||
list_replicators_view->setModel(list_replicators_model);
|
||||
list_replicators_label=
|
||||
new QLabel(list_replicators_view,tr("&Replicators:"),this);
|
||||
list_box_label->setFont(labelFont());
|
||||
list_box_label->setGeometry(14,11,85,19);
|
||||
connect(list_replicators_view,
|
||||
SIGNAL(doubleClicked(Q3ListViewItem *,const QPoint &,int)),
|
||||
this,
|
||||
SLOT(doubleClickedData(Q3ListViewItem *,const QPoint &,int)));
|
||||
|
||||
RefreshList();
|
||||
list_replicators_label->setFont(labelFont());
|
||||
connect(list_replicators_view,SIGNAL(doubleClicked(const QModelIndex &)),
|
||||
this,SLOT(doubleClickedData(const QModelIndex &)));
|
||||
connect(list_replicators_model,SIGNAL(modelReset()),
|
||||
list_replicators_view,SLOT(resizeColumnsToContents()));
|
||||
list_replicators_view->resizeColumnsToContents();
|
||||
}
|
||||
|
||||
|
||||
@ -132,29 +120,27 @@ void ListReplicators::addData()
|
||||
QString name;
|
||||
|
||||
AddReplicator *d=new AddReplicator(&name,this);
|
||||
if(d->exec()<0) {
|
||||
delete d;
|
||||
return;
|
||||
if(d->exec()) {
|
||||
QModelIndex row=list_replicators_model->addReplicator(name);
|
||||
if(row.isValid()) {
|
||||
list_replicators_view->selectRow(row.row());
|
||||
}
|
||||
}
|
||||
delete d;
|
||||
RDListViewItem *item=new RDListViewItem(list_replicators_view);
|
||||
item->setText(0,name);
|
||||
RefreshItem(item);
|
||||
item->setSelected(true);
|
||||
list_replicators_view->setCurrentItem(item);
|
||||
list_replicators_view->ensureItemVisible(item);
|
||||
}
|
||||
|
||||
|
||||
void ListReplicators::editData()
|
||||
{
|
||||
RDListViewItem *item=(RDListViewItem *)list_replicators_view->selectedItem();
|
||||
if(item==NULL) {
|
||||
QModelIndexList rows=list_replicators_view->selectionModel()->selectedRows();
|
||||
|
||||
if(rows.size()!=1) {
|
||||
return;
|
||||
}
|
||||
EditReplicator *d=new EditReplicator(item->text(0),this);
|
||||
if(d->exec()==0) {
|
||||
RefreshItem(item);
|
||||
EditReplicator *d=new EditReplicator(list_replicators_model->
|
||||
replicatorName(rows.first()),this);
|
||||
if(d->exec()) {
|
||||
list_replicators_model->refresh(rows.first());
|
||||
}
|
||||
delete d;
|
||||
}
|
||||
@ -162,19 +148,17 @@ void ListReplicators::editData()
|
||||
|
||||
void ListReplicators::deleteData()
|
||||
{
|
||||
RDListViewItem *item=(RDListViewItem *)list_replicators_view->selectedItem();
|
||||
if(item==NULL) {
|
||||
QString sql;
|
||||
QString warning;
|
||||
QModelIndexList rows=list_replicators_view->selectionModel()->selectedRows();
|
||||
|
||||
if(rows.size()!=1) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString sql;
|
||||
RDSqlQuery *q;
|
||||
QString warning;
|
||||
|
||||
QString name=RDEscapeString(item->text(0));
|
||||
QString name=list_replicators_model->replicatorName(rows.first());
|
||||
|
||||
warning+=tr("Are you sure you want to delete replicator")+
|
||||
" \""+item->text(0)+"\"?";
|
||||
" \""+name+"\"?";
|
||||
switch(QMessageBox::warning(this,tr("Delete Replicator"),warning,
|
||||
QMessageBox::Yes,QMessageBox::No)) {
|
||||
case QMessageBox::No:
|
||||
@ -190,46 +174,44 @@ void ListReplicators::deleteData()
|
||||
//
|
||||
sql=QString("delete from REPLICATOR_MAP where ")+
|
||||
"REPLICATOR_NAME=\""+RDEscapeString(name)+"\"";
|
||||
q=new RDSqlQuery(sql);
|
||||
delete q;
|
||||
RDSqlQuery::apply(sql);
|
||||
|
||||
//
|
||||
// Delete State Records
|
||||
//
|
||||
sql=QString("delete from REPL_CART_STATE where ")+
|
||||
"REPLICATOR_NAME=\""+RDEscapeString(name)+"\"";
|
||||
q=new RDSqlQuery(sql);
|
||||
delete q;
|
||||
RDSqlQuery::apply(sql);
|
||||
sql=QString("delete from REPL_CUT_STATE where ")+
|
||||
"REPLICATOR_NAME=\""+RDEscapeString(name)+"\"";
|
||||
q=new RDSqlQuery(sql);
|
||||
delete q;
|
||||
RDSqlQuery::apply(sql);
|
||||
|
||||
//
|
||||
// Delete from Replicator List
|
||||
//
|
||||
sql=QString("delete from REPLICATORS where ")+
|
||||
"NAME=\""+RDEscapeString(name)+"\"";
|
||||
q=new RDSqlQuery(sql);
|
||||
delete q;
|
||||
delete item;
|
||||
RDSqlQuery::apply(sql);
|
||||
|
||||
list_replicators_model->removeReplicator(name);
|
||||
}
|
||||
|
||||
|
||||
void ListReplicators::listData()
|
||||
{
|
||||
RDListViewItem *item=(RDListViewItem *)list_replicators_view->selectedItem();
|
||||
if(item==NULL) {
|
||||
QModelIndexList rows=list_replicators_view->selectionModel()->selectedRows();
|
||||
|
||||
if(rows.size()!=1) {
|
||||
return;
|
||||
}
|
||||
QString name=list_replicators_model->replicatorName(rows.first());
|
||||
ListReplicatorCarts *d=new ListReplicatorCarts(this);
|
||||
d->exec(item->text(0));
|
||||
d->exec(name);
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
void ListReplicators::doubleClickedData(Q3ListViewItem *item,const QPoint &pt,
|
||||
int col)
|
||||
void ListReplicators::doubleClickedData(const QModelIndex &index)
|
||||
{
|
||||
editData();
|
||||
}
|
||||
@ -237,7 +219,7 @@ void ListReplicators::doubleClickedData(Q3ListViewItem *item,const QPoint &pt,
|
||||
|
||||
void ListReplicators::closeData()
|
||||
{
|
||||
done(0);
|
||||
done(true);
|
||||
}
|
||||
|
||||
|
||||
@ -248,48 +230,6 @@ void ListReplicators::resizeEvent(QResizeEvent *e)
|
||||
list_delete_button->setGeometry(size().width()-90,150,80,50);
|
||||
list_list_button->setGeometry(size().width()-90,250,80,50);
|
||||
list_close_button->setGeometry(size().width()-90,size().height()-60,80,50);
|
||||
list_replicators_label->setGeometry(14,11,85,19);
|
||||
list_replicators_view->setGeometry(10,30,size().width()-120,size().height()-40);
|
||||
}
|
||||
|
||||
|
||||
void ListReplicators::RefreshList()
|
||||
{
|
||||
QString sql;
|
||||
RDSqlQuery *q;
|
||||
RDListViewItem *item;
|
||||
|
||||
list_replicators_view->clear();
|
||||
sql="select NAME,TYPE_ID,DESCRIPTION,STATION_NAME from REPLICATORS";
|
||||
q=new RDSqlQuery(sql);
|
||||
while (q->next()) {
|
||||
item=new RDListViewItem(list_replicators_view);
|
||||
item->setText(0,q->value(0).toString());
|
||||
item->setText(1,
|
||||
RDReplicator::typeString((RDReplicator::Type)q->value(1).toUInt()));
|
||||
item->setText(2,q->value(2).toString());
|
||||
item->setText(3,q->value(3).toString());
|
||||
}
|
||||
delete q;
|
||||
}
|
||||
|
||||
|
||||
void ListReplicators::RefreshItem(RDListViewItem *item)
|
||||
{
|
||||
QString sql;
|
||||
RDSqlQuery *q;
|
||||
|
||||
sql=QString("select ")+
|
||||
"TYPE_ID,"+ // 00
|
||||
"DESCRIPTION,"+ // 01
|
||||
"STATION_NAME "+ // 02
|
||||
"from REPLICATORS where "+
|
||||
"NAME=\""+RDEscapeString(item->text(0))+"\"";
|
||||
q=new RDSqlQuery(sql);
|
||||
if(q->first()) {
|
||||
item->setText(1,
|
||||
RDReplicator::typeString((RDReplicator::Type)q->value(0).toUInt()));
|
||||
item->setText(2,q->value(1).toString());
|
||||
item->setText(3,q->value(2).toString());
|
||||
}
|
||||
delete q;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// List Rivendell Replication Configurations
|
||||
//
|
||||
// (C) Copyright 2010-2019 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2010-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
|
||||
@ -21,11 +21,11 @@
|
||||
#ifndef LIST_REPLICATORS_H
|
||||
#define LIST_REPLICATORS_H
|
||||
|
||||
#include <qpushbutton.h>
|
||||
#include <QPushButton>
|
||||
|
||||
#include <rddb.h>
|
||||
#include <rddialog.h>
|
||||
#include <rdlistviewitem.h>
|
||||
#include <rdreplicatorlistmodel.h>
|
||||
#include <rdtableview.h>
|
||||
|
||||
class ListReplicators : public RDDialog
|
||||
{
|
||||
@ -41,16 +41,16 @@ class ListReplicators : public RDDialog
|
||||
void editData();
|
||||
void deleteData();
|
||||
void listData();
|
||||
void doubleClickedData(Q3ListViewItem *item,const QPoint &pt,int col);
|
||||
void doubleClickedData(const QModelIndex &index);
|
||||
void closeData();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
|
||||
private:
|
||||
void RefreshList();
|
||||
void RefreshItem(RDListViewItem *item);
|
||||
RDListView *list_replicators_view;
|
||||
QLabel *list_replicators_label;
|
||||
RDTableView *list_replicators_view;
|
||||
RDReplicatorListModel *list_replicators_model;
|
||||
QPushButton *list_add_button;
|
||||
QPushButton *list_edit_button;
|
||||
QPushButton *list_delete_button;
|
||||
@ -59,6 +59,4 @@ class ListReplicators : public RDDialog
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // LIST_REPLICATORS_H
|
||||
|
@ -5975,19 +5975,19 @@ vozíky</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>NAME</source>
|
||||
<translation>NÁZEV</translation>
|
||||
<translation type="obsolete">NÁZEV</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TYPE</source>
|
||||
<translation>TYP</translation>
|
||||
<translation type="obsolete">TYP</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>DESCRIPTION</source>
|
||||
<translation>POPIS</translation>
|
||||
<translation type="obsolete">POPIS</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>HOST</source>
|
||||
<translation>SERVER</translation>
|
||||
<translation type="obsolete">SERVER</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>&Replicators:</source>
|
||||
@ -5995,11 +5995,11 @@ vozíky</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Are you sure you want to delete replicator</source>
|
||||
<translation>Opravdu chcete smazat toto zopakování</translation>
|
||||
<translation type="unfinished">Opravdu chcete smazat toto zopakování</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Delete Replicator</source>
|
||||
<translation>Smazat zopakování</translation>
|
||||
<translation type="unfinished">Smazat zopakování</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -5619,19 +5619,15 @@ Carts</source>
|
||||
</message>
|
||||
<message>
|
||||
<source>NAME</source>
|
||||
<translation type="unfinished">NAME</translation>
|
||||
<translation type="obsolete">NAME</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TYPE</source>
|
||||
<translation type="unfinished">TYP</translation>
|
||||
<translation type="obsolete">TYP</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>DESCRIPTION</source>
|
||||
<translation type="unfinished">BESCHREIBUNG</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>HOST</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation type="obsolete">BESCHREIBUNG</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>&Replicators:</source>
|
||||
|
@ -5886,19 +5886,19 @@ Cartuchos</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>NAME</source>
|
||||
<translation>NOMBRE</translation>
|
||||
<translation type="obsolete">NOMBRE</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TYPE</source>
|
||||
<translation>TIPO</translation>
|
||||
<translation type="obsolete">TIPO</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>DESCRIPTION</source>
|
||||
<translation>DESCRIPCIÓN</translation>
|
||||
<translation type="obsolete">DESCRIPCIÓN</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>HOST</source>
|
||||
<translation>COMPUTADOR</translation>
|
||||
<translation type="obsolete">COMPUTADOR</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>&Replicators:</source>
|
||||
@ -5906,11 +5906,11 @@ Cartuchos</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Are you sure you want to delete replicator</source>
|
||||
<translation>Desea eliminar el replicador </translation>
|
||||
<translation type="unfinished">Desea eliminar el replicador </translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Delete Replicator</source>
|
||||
<translation>Eliminar Replicador</translation>
|
||||
<translation type="unfinished">Eliminar Replicador</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -4591,22 +4591,6 @@ Carts</source>
|
||||
<source>&Close</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>NAME</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TYPE</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>DESCRIPTION</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>HOST</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>&Replicators:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
|
@ -5476,19 +5476,15 @@ Carts</source>
|
||||
</message>
|
||||
<message>
|
||||
<source>NAME</source>
|
||||
<translation type="unfinished">NAMN</translation>
|
||||
<translation type="obsolete">NAMN</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TYPE</source>
|
||||
<translation type="unfinished">TYPE</translation>
|
||||
<translation type="obsolete">TYPE</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>DESCRIPTION</source>
|
||||
<translation type="unfinished">SKILDRING</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>HOST</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation type="obsolete">SKILDRING</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>&Replicators:</source>
|
||||
|
@ -5476,19 +5476,15 @@ Carts</source>
|
||||
</message>
|
||||
<message>
|
||||
<source>NAME</source>
|
||||
<translation type="unfinished">NAMN</translation>
|
||||
<translation type="obsolete">NAMN</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TYPE</source>
|
||||
<translation type="unfinished">TYPE</translation>
|
||||
<translation type="obsolete">TYPE</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>DESCRIPTION</source>
|
||||
<translation type="unfinished">SKILDRING</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>HOST</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation type="obsolete">SKILDRING</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>&Replicators:</source>
|
||||
|
@ -5591,19 +5591,15 @@ Carts</source>
|
||||
</message>
|
||||
<message>
|
||||
<source>NAME</source>
|
||||
<translation type="unfinished">NOME</translation>
|
||||
<translation type="obsolete">NOME</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TYPE</source>
|
||||
<translation type="unfinished">TIPO</translation>
|
||||
<translation type="obsolete">TIPO</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>DESCRIPTION</source>
|
||||
<translation type="unfinished">DESCRIÇÃO</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>HOST</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation type="obsolete">DESCRIÇÃO</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>&Replicators:</source>
|
||||
|
Loading…
x
Reference in New Issue
Block a user