mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-05-24 16:41:40 +02:00
2021-01-22 Fred Gleason <fredg@paravelsystems.com>
* Refactored the 'Edit Host' dialog in rdadmin(1) to use the model-based API. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
1d40b6076c
commit
d5c465d78f
@ -20871,3 +20871,6 @@
|
|||||||
2021-01-22 Fred Gleason <fredg@paravelsystems.com>
|
2021-01-22 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Added an 'RDIconEngine::stationIcon()' method.
|
* Added an 'RDIconEngine::stationIcon()' method.
|
||||||
* Added an icons for 'host' objects.
|
* Added an icons for 'host' objects.
|
||||||
|
2021-01-22 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Refactored the 'Edit Host' dialog in rdadmin(1) to use the
|
||||||
|
model-based API.
|
||||||
|
@ -22,9 +22,12 @@
|
|||||||
#include "rdescape_string.h"
|
#include "rdescape_string.h"
|
||||||
#include "rdstationlistmodel.h"
|
#include "rdstationlistmodel.h"
|
||||||
|
|
||||||
RDStationListModel::RDStationListModel(QObject *parent)
|
RDStationListModel::RDStationListModel(const QString &localhost_name,
|
||||||
|
QObject *parent)
|
||||||
: QAbstractTableModel(parent)
|
: QAbstractTableModel(parent)
|
||||||
{
|
{
|
||||||
|
d_localhost_name=localhost_name;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Column Attributes
|
// Column Attributes
|
||||||
//
|
//
|
||||||
@ -167,7 +170,7 @@ QVariant RDStationListModel::data(const QModelIndex &index,int role) const
|
|||||||
|
|
||||||
QString RDStationListModel::stationName(const QModelIndex &row) const
|
QString RDStationListModel::stationName(const QModelIndex &row) const
|
||||||
{
|
{
|
||||||
return d_texts.at(row.row()).at(0).toString();
|
return d_hostnames.at(row.row());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -178,7 +181,7 @@ QModelIndex RDStationListModel::addStation(const QString &hostname)
|
|||||||
//
|
//
|
||||||
int offset=d_texts.size();
|
int offset=d_texts.size();
|
||||||
for(int i=0;i<d_texts.size();i++) {
|
for(int i=0;i<d_texts.size();i++) {
|
||||||
if(hostname.toLower()<d_texts.at(i).at(0).toString().toLower()) {
|
if(hostname.toLower()<d_hostnames.at(i).toLower()) {
|
||||||
offset=i;
|
offset=i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -188,7 +191,13 @@ QModelIndex RDStationListModel::addStation(const QString &hostname)
|
|||||||
for(int i=0;i<columnCount();i++) {
|
for(int i=0;i<columnCount();i++) {
|
||||||
list.push_back(QVariant());
|
list.push_back(QVariant());
|
||||||
}
|
}
|
||||||
|
if(hostname==d_localhost_name) {
|
||||||
|
list[0]="localhost";
|
||||||
|
}
|
||||||
|
else {
|
||||||
list[0]=hostname;
|
list[0]=hostname;
|
||||||
|
}
|
||||||
|
d_hostnames.insert(offset,hostname);
|
||||||
d_texts.insert(offset,list);
|
d_texts.insert(offset,list);
|
||||||
d_icons.insert(offset,list);
|
d_icons.insert(offset,list);
|
||||||
updateRowLine(offset);
|
updateRowLine(offset);
|
||||||
@ -202,6 +211,7 @@ void RDStationListModel::removeStation(const QModelIndex &row)
|
|||||||
{
|
{
|
||||||
beginRemoveRows(QModelIndex(),row.row(),row.row());
|
beginRemoveRows(QModelIndex(),row.row(),row.row());
|
||||||
|
|
||||||
|
d_hostnames.removeAt(row.row());
|
||||||
d_texts.removeAt(row.row());
|
d_texts.removeAt(row.row());
|
||||||
d_icons.removeAt(row.row());
|
d_icons.removeAt(row.row());
|
||||||
|
|
||||||
@ -212,7 +222,7 @@ void RDStationListModel::removeStation(const QModelIndex &row)
|
|||||||
void RDStationListModel::removeStation(const QString &hostname)
|
void RDStationListModel::removeStation(const QString &hostname)
|
||||||
{
|
{
|
||||||
for(int i=0;i<d_texts.size();i++) {
|
for(int i=0;i<d_texts.size();i++) {
|
||||||
if(d_texts.at(i).at(0)==hostname) {
|
if(d_hostnames.at(i)==hostname) {
|
||||||
removeStation(createIndex(i,0));
|
removeStation(createIndex(i,0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -224,9 +234,7 @@ void RDStationListModel::refresh(const QModelIndex &row)
|
|||||||
{
|
{
|
||||||
if(row.row()<d_texts.size()) {
|
if(row.row()<d_texts.size()) {
|
||||||
QString sql=sqlFields()+
|
QString sql=sqlFields()+
|
||||||
"where STATIONS.NAME=\""+
|
"where STATIONS.NAME=\""+RDEscapeString(d_hostnames.at(0))+"\"";
|
||||||
RDEscapeString(d_texts.at(row.row()).at(0).toString())+
|
|
||||||
"\"";
|
|
||||||
RDSqlQuery *q=new RDSqlQuery(sql);
|
RDSqlQuery *q=new RDSqlQuery(sql);
|
||||||
if(q->first()) {
|
if(q->first()) {
|
||||||
updateRow(row.row(),q);
|
updateRow(row.row(),q);
|
||||||
@ -258,10 +266,12 @@ void RDStationListModel::updateModel()
|
|||||||
QString sql=sqlFields();
|
QString sql=sqlFields();
|
||||||
sql+="order by NAME ";
|
sql+="order by NAME ";
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
|
d_hostnames.clear();
|
||||||
d_texts.clear();
|
d_texts.clear();
|
||||||
d_icons.clear();
|
d_icons.clear();
|
||||||
q=new RDSqlQuery(sql);
|
q=new RDSqlQuery(sql);
|
||||||
while(q->next()) {
|
while(q->next()) {
|
||||||
|
d_hostnames.push_back(QString());
|
||||||
d_texts.push_back(texts);
|
d_texts.push_back(texts);
|
||||||
d_icons.push_back(texts);
|
d_icons.push_back(texts);
|
||||||
updateRow(d_texts.size()-1,q);
|
updateRow(d_texts.size()-1,q);
|
||||||
@ -275,7 +285,7 @@ void RDStationListModel::updateRowLine(int line)
|
|||||||
{
|
{
|
||||||
if(line<d_texts.size()) {
|
if(line<d_texts.size()) {
|
||||||
QString sql=sqlFields()+
|
QString sql=sqlFields()+
|
||||||
"where NAME=\""+RDEscapeString(d_texts.at(line).at(0).toString())+"\"";
|
"where NAME=\""+RDEscapeString(d_hostnames.at(0))+"\"";
|
||||||
RDSqlQuery *q=new RDSqlQuery(sql);
|
RDSqlQuery *q=new RDSqlQuery(sql);
|
||||||
if(q->first()) {
|
if(q->first()) {
|
||||||
updateRow(line,q);
|
updateRow(line,q);
|
||||||
@ -291,7 +301,13 @@ void RDStationListModel::updateRow(int row,RDSqlQuery *q)
|
|||||||
QList<QVariant> icons;
|
QList<QVariant> icons;
|
||||||
|
|
||||||
// Hostname
|
// Hostname
|
||||||
|
d_hostnames[row]=q->value(0).toString();
|
||||||
|
if(q->value(0).toString()==d_localhost_name) {
|
||||||
|
texts.push_back("localhost");
|
||||||
|
}
|
||||||
|
else {
|
||||||
texts.push_back(q->value(0));
|
texts.push_back(q->value(0));
|
||||||
|
}
|
||||||
icons.push_back(rda->iconEngine()->stationIcon());
|
icons.push_back(rda->iconEngine()->stationIcon());
|
||||||
|
|
||||||
// Description
|
// Description
|
||||||
|
@ -41,7 +41,7 @@ class RDStationListModel : public QAbstractTableModel
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
RDStationListModel(QObject *parent=0);
|
RDStationListModel(const QString &localhost_name,QObject *parent=0);
|
||||||
~RDStationListModel();
|
~RDStationListModel();
|
||||||
QPalette palette();
|
QPalette palette();
|
||||||
void setPalette(const QPalette &pal);
|
void setPalette(const QPalette &pal);
|
||||||
@ -68,9 +68,10 @@ class RDStationListModel : public QAbstractTableModel
|
|||||||
QPalette d_palette;
|
QPalette d_palette;
|
||||||
QFont d_font;
|
QFont d_font;
|
||||||
QFont d_bold_font;
|
QFont d_bold_font;
|
||||||
QStringList d_service_names;
|
QString d_localhost_name;
|
||||||
QList<QVariant> d_headers;
|
QList<QVariant> d_headers;
|
||||||
QList<QVariant> d_alignments;
|
QList<QVariant> d_alignments;
|
||||||
|
QStringList d_hostnames;
|
||||||
QList<QList<QVariant> > d_texts;
|
QList<QList<QVariant> > d_texts;
|
||||||
QList<QList<QVariant> > d_icons;
|
QList<QList<QVariant> > d_icons;
|
||||||
};
|
};
|
||||||
|
@ -18,7 +18,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 <rdapplication.h>
|
#include <rdapplication.h>
|
||||||
#include <rdcatch_connect.h>
|
#include <rdcatch_connect.h>
|
||||||
@ -48,9 +48,7 @@
|
|||||||
EditStation::EditStation(QString sname,QWidget *parent)
|
EditStation::EditStation(QString sname,QWidget *parent)
|
||||||
: RDDialog(parent)
|
: RDDialog(parent)
|
||||||
{
|
{
|
||||||
RDSqlQuery *q;
|
char temp[1024];
|
||||||
QString sql;
|
|
||||||
char temp[256];
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Fix the Window Size
|
// Fix the Window Size
|
||||||
@ -74,6 +72,12 @@ EditStation::EditStation(QString sname,QWidget *parent)
|
|||||||
RDTextValidator *validator=new RDTextValidator(this);
|
RDTextValidator *validator=new RDTextValidator(this);
|
||||||
QIntValidator *macro_validator=new QIntValidator(1,RD_MAX_CART_NUMBER,this);
|
QIntValidator *macro_validator=new QIntValidator(1,RD_MAX_CART_NUMBER,this);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Models
|
||||||
|
//
|
||||||
|
station_username_model=new RDUserListModel(this);
|
||||||
|
station_station_model=new RDStationListModel(sname,this);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Station Name
|
// Station Name
|
||||||
//
|
//
|
||||||
@ -109,7 +113,6 @@ EditStation::EditStation(QString sname,QWidget *parent)
|
|||||||
//
|
//
|
||||||
station_username_box=new QComboBox(this);
|
station_username_box=new QComboBox(this);
|
||||||
station_username_box->setEditable(false);
|
station_username_box->setEditable(false);
|
||||||
station_username_model=new RDUserListModel(this);
|
|
||||||
station_username_model->setTypeFilter(RDUser::TypeUser);
|
station_username_model->setTypeFilter(RDUser::TypeUser);
|
||||||
station_username_box->setModel(station_username_model);
|
station_username_box->setModel(station_username_model);
|
||||||
station_username_label=
|
station_username_label=
|
||||||
@ -319,6 +322,7 @@ EditStation::EditStation(QString sname,QWidget *parent)
|
|||||||
//
|
//
|
||||||
station_http_station_box=new QComboBox(this);
|
station_http_station_box=new QComboBox(this);
|
||||||
station_http_station_box->setEditable(false);
|
station_http_station_box->setEditable(false);
|
||||||
|
station_http_station_box->setModel(station_station_model);
|
||||||
station_http_station_label=
|
station_http_station_label=
|
||||||
new QLabel(station_http_station_box,tr("HTTP Xport:"),this);
|
new QLabel(station_http_station_box,tr("HTTP Xport:"),this);
|
||||||
station_http_station_label->setFont(labelFont());
|
station_http_station_label->setFont(labelFont());
|
||||||
@ -329,6 +333,7 @@ EditStation::EditStation(QString sname,QWidget *parent)
|
|||||||
//
|
//
|
||||||
station_cae_station_box=new QComboBox(this);
|
station_cae_station_box=new QComboBox(this);
|
||||||
station_cae_station_box->setEditable(false);
|
station_cae_station_box->setEditable(false);
|
||||||
|
station_cae_station_box->setModel(station_station_model);
|
||||||
connect(station_cae_station_box,SIGNAL(activated(const QString &)),
|
connect(station_cae_station_box,SIGNAL(activated(const QString &)),
|
||||||
this,SLOT(caeStationActivatedData(const QString &)));
|
this,SLOT(caeStationActivatedData(const QString &)));
|
||||||
station_cae_station_label=
|
station_cae_station_label=
|
||||||
@ -342,7 +347,8 @@ EditStation::EditStation(QString sname,QWidget *parent)
|
|||||||
station_rdlibrary_button=new QPushButton(this);
|
station_rdlibrary_button=new QPushButton(this);
|
||||||
station_rdlibrary_button->setFont(buttonFont());
|
station_rdlibrary_button->setFont(buttonFont());
|
||||||
station_rdlibrary_button->setText(tr("RD&Library"));
|
station_rdlibrary_button->setText(tr("RD&Library"));
|
||||||
connect(station_rdlibrary_button,SIGNAL(clicked()),this,SLOT(editLibraryData()));
|
connect(station_rdlibrary_button,SIGNAL(clicked()),
|
||||||
|
this,SLOT(editLibraryData()));
|
||||||
|
|
||||||
//
|
//
|
||||||
// RDCatch Configuration Button
|
// RDCatch Configuration Button
|
||||||
@ -549,25 +555,8 @@ EditStation::EditStation(QString sname,QWidget *parent)
|
|||||||
station_panel_enforce_label->setDisabled(true);
|
station_panel_enforce_label->setDisabled(true);
|
||||||
station_panel_enforce_box->setDisabled(true);
|
station_panel_enforce_box->setDisabled(true);
|
||||||
}
|
}
|
||||||
|
station_http_station_box->setCurrentText(station_station->httpStation());
|
||||||
station_http_station_box->insertItem("localhost");
|
station_cae_station_box->setCurrentText(station_station->caeStation());
|
||||||
station_cae_station_box->insertItem("localhost");
|
|
||||||
sql=QString("select NAME from STATIONS where ")+
|
|
||||||
"NAME!=\""+RDEscapeString(sname)+"\" order by NAME";
|
|
||||||
q=new RDSqlQuery(sql);
|
|
||||||
while(q->next()) {
|
|
||||||
station_http_station_box->insertItem(q->value(0).toString());
|
|
||||||
if(q->value(0).toString()==station_station->httpStation()) {
|
|
||||||
station_http_station_box->
|
|
||||||
setCurrentItem(station_http_station_box->count()-1);
|
|
||||||
}
|
|
||||||
station_cae_station_box->insertItem(q->value(0).toString());
|
|
||||||
if(q->value(0).toString()==station_station->caeStation()) {
|
|
||||||
station_cae_station_box->
|
|
||||||
setCurrentItem(station_cae_station_box->count()-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete q;
|
|
||||||
for(int i=0;i<station_http_station_box->count();i++) {
|
for(int i=0;i<station_http_station_box->count();i++) {
|
||||||
if(station_http_station_box->text(i)==station_station->httpStation()) {
|
if(station_http_station_box->text(i)==station_station->httpStation()) {
|
||||||
station_http_station_box->setCurrentItem(i);
|
station_http_station_box->setCurrentItem(i);
|
||||||
@ -584,6 +573,7 @@ EditStation::~EditStation()
|
|||||||
delete station_station;
|
delete station_station;
|
||||||
delete station_cae_station;
|
delete station_cae_station;
|
||||||
delete station_username_model;
|
delete station_username_model;
|
||||||
|
delete station_station_model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,19 +21,20 @@
|
|||||||
#ifndef EDIT_STATION_H
|
#ifndef EDIT_STATION_H
|
||||||
#define EDIT_STATION_H
|
#define EDIT_STATION_H
|
||||||
|
|
||||||
#include <qcombobox.h>
|
#include <QComboBox>
|
||||||
#include <qcheckbox.h>
|
#include <QCheckBox>
|
||||||
#include <qgroupbox.h>
|
#include <QGroupBox>
|
||||||
#include <qlabel.h>
|
#include <QLabel>
|
||||||
#include <qlineedit.h>
|
#include <QLineEdit>
|
||||||
#include <qpushbutton.h>
|
#include <QPushButton>
|
||||||
#include <qspinbox.h>
|
#include <QSpinBox>
|
||||||
|
|
||||||
#include <rddialog.h>
|
#include <rddialog.h>
|
||||||
#include <rdcardselector.h>
|
#include <rdcardselector.h>
|
||||||
#include <rdcatch_connect.h>
|
#include <rdcatch_connect.h>
|
||||||
#include <rdripc.h>
|
#include <rdripc.h>
|
||||||
#include <rdstation.h>
|
#include <rdstation.h>
|
||||||
|
#include <rdstationlistmodel.h>
|
||||||
#include <rduserlistmodel.h>
|
#include <rduserlistmodel.h>
|
||||||
|
|
||||||
class EditStation : public RDDialog
|
class EditStation : public RDDialog
|
||||||
@ -134,6 +135,7 @@ class EditStation : public RDDialog
|
|||||||
QComboBox *station_http_station_box;
|
QComboBox *station_http_station_box;
|
||||||
QLabel *station_cae_station_label;
|
QLabel *station_cae_station_label;
|
||||||
QComboBox *station_cae_station_box;
|
QComboBox *station_cae_station_box;
|
||||||
|
RDStationListModel *station_station_model;
|
||||||
QPushButton *station_rdlibrary_button;
|
QPushButton *station_rdlibrary_button;
|
||||||
QPushButton *station_rdcatch_button;
|
QPushButton *station_rdcatch_button;
|
||||||
QPushButton *station_rdairplay_button;
|
QPushButton *station_rdairplay_button;
|
||||||
|
@ -83,7 +83,7 @@ ListStations::ListStations(QWidget *parent)
|
|||||||
list_stations_view->setShowGrid(false);
|
list_stations_view->setShowGrid(false);
|
||||||
list_stations_view->setSortingEnabled(false);
|
list_stations_view->setSortingEnabled(false);
|
||||||
list_stations_view->setWordWrap(false);
|
list_stations_view->setWordWrap(false);
|
||||||
list_stations_model=new RDStationListModel(this);
|
list_stations_model=new RDStationListModel("",this);
|
||||||
list_stations_model->setFont(defaultFont());
|
list_stations_model->setFont(defaultFont());
|
||||||
list_stations_model->setPalette(palette());
|
list_stations_model->setPalette(palette());
|
||||||
list_stations_view->setModel(list_stations_model);
|
list_stations_view->setModel(list_stations_model);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user