2021-08-03 Fred Gleason <fredg@paravelsystems.com>

* Added 'SYSTEM.LONG_DATE_FORMAT', 'SYSTEM.SHORT_DATE_FORMAT'
	and 'SYSTEM.TIME_FORMAT' fields to the database.
	* Incremented the database version to 351.
	* Added 'RDSystem::longDateFormat()', 'RDSystem'setLongDateFormat()',
	'RDSystem::shortDateFormat()', 'RDSystem::setShortDateFormat()',
	'RDSystem::timeFormat()' and 'RDSystem::setTimeFormat()' methods.
	* Added a 'Date/Time Formats' section to the 'System-Wide Settings'
	dialog in rdadmin(1).

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2021-08-03 20:44:58 -04:00
parent f48fb2ef5c
commit 15ff31483d
15 changed files with 373 additions and 14 deletions

View File

@ -22149,3 +22149,12 @@
fails to find the specified log.
2021-08-03 Fred Gleason <fredg@paravelsystems.com>
* Added Raspian support to the 'AR_GET_DISTRO()' autoconf macro.
2021-08-03 Fred Gleason <fredg@paravelsystems.com>
* Added 'SYSTEM.LONG_DATE_FORMAT', 'SYSTEM.SHORT_DATE_FORMAT'
and 'SYSTEM.TIME_FORMAT' fields to the database.
* Incremented the database version to 351.
* Added 'RDSystem::longDateFormat()', 'RDSystem'setLongDateFormat()',
'RDSystem::shortDateFormat()', 'RDSystem::setShortDateFormat()',
'RDSystem::timeFormat()' and 'RDSystem::setTimeFormat()' methods.
* Added a 'Date/Time Formats' section to the 'System-Wide Settings'
dialog in rdadmin(1).

View File

@ -15,3 +15,6 @@ SHOW_USER_LIST enum('N','Y')
NOTIFICATION_ADDRESS varchar(15)
RSS_PROCESSOR_STATION varchar(64)
ORIGIN_EMAIL_ADDRESS varchar(64)
LONG_DATE_FORMAT varchar(32) Default 'dddd, MMMM d yyyy'
SHORT_DATE_FORMAT varchar(32) Default 'MM/dd/yyyy'
TIME_FORMAT varchar(32) Default 'hh:mm:ss'

View File

@ -2,7 +2,7 @@
//
// The Current Database Schema Version for Rivendell
//
// (C) Copyright 2002-2020 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
@ -24,7 +24,7 @@
/*
* Current Database Version
*/
#define RD_VERSION_DATABASE 350
#define RD_VERSION_DATABASE 351
#endif // DBVERSION_H

View File

@ -2,7 +2,7 @@
//
// System-Wide Values for Rivendell
//
// (C) Copyright 2002-2020 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
@ -649,5 +649,12 @@
#define RD_LISTWIDGET_ITEM_HEIGHT 25
#define RD_LISTWIDGET_ITEM_WIDTH_PADDING 20
/*
* Default Date/Time Formats
*/
#define RD_DEFAULT_LONG_DATE_FORMAT "dddd, MMMM d yyyy"
#define RD_DEFAULT_SHORT_DATE_FORMAT "MM/dd/yy"
#define RD_DEFAULT_TIME_FORMAT "hh:mm:ss"
#endif // RD_H

View File

@ -205,6 +205,42 @@ void RDSystem::setRssProcessorStation(const QString &str) const
}
QString RDSystem::longDateFormat() const
{
return GetValue("LONG_DATE_FORMAT").toString();
}
void RDSystem::setLongDateFormat(const QString &str)
{
SetRow("LONG_DATE_FORMAT",str);
}
QString RDSystem::shortDateFormat() const
{
return GetValue("SHORT_DATE_FORMAT").toString();
}
void RDSystem::setShortDateFormat(const QString &str)
{
SetRow("SHORT_DATE_FORMAT",str);
}
QString RDSystem::timeFormat() const
{
return GetValue("TIME_FORMAT").toString();
}
void RDSystem::setTimeFormat(const QString &str)
{
SetRow("TIME_FORMAT",str);
}
QString RDSystem::xml() const
{
QString xml="<systemSettings>\n";
@ -214,6 +250,9 @@ QString RDSystem::xml() const
xml+=RDXmlField("maxPostLength",maxPostLength());
xml+=RDXmlField("isciXreferencePath",isciXreferencePath());
xml+=RDXmlField("tempCartGroup",tempCartGroup());
xml+=RDXmlField("longDateFormat",longDateFormat());
xml+=RDXmlField("shortDateFormat",shortDateFormat());
xml+=RDXmlField("timeFormat",timeFormat());
xml+="</systemSettings>\n";
return xml;

View File

@ -2,7 +2,7 @@
//
// System-wide Rivendell settings
//
// (C) Copyright 2009,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2009-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
@ -48,6 +48,12 @@ class RDSystem
void setNotificationAddress(const QHostAddress &addr);
QString rssProcessorStation() const;
void setRssProcessorStation(const QString &str=QString()) const;
QString longDateFormat() const;
void setLongDateFormat(const QString &str);
QString shortDateFormat() const;
void setShortDateFormat(const QString &str);
QString timeFormat() const;
void setTimeFormat(const QString &str);
QString xml() const;
private:

View File

@ -123,6 +123,7 @@ dist_rdadmin_SOURCES = add_feed.cpp add_feed.h\
rdadmin.cpp rdadmin.h\
rename_group.cpp rename_group.h\
test_import.cpp test_import.h\
test_datetimes.cpp test_datetimes.h\
view_adapters.cpp view_adapters.h\
view_node_info.cpp view_node_info.h\
view_pypad_errors.cpp view_pypad_errors.h
@ -204,6 +205,7 @@ nodist_rdadmin_SOURCES = global_credits.c\
moc_rdadmin.cpp\
moc_rename_group.cpp\
moc_test_import.cpp\
moc_test_datetimes.cpp\
moc_view_adapters.cpp\
moc_view_node_info.cpp\
moc_view_pypad_errors.cpp

View File

@ -50,6 +50,11 @@ EditSystem::EditSystem(QWidget *parent)
edit_encoders_dialog=new ListEncoders(this);
edit_station_list_model=new RDStationListModel(true,"",this);
//
// Dialogs
//
edit_test_datetimes_dialog=new TestDatetimes(this);
//
// System Sample Rate
//
@ -183,6 +188,45 @@ EditSystem::EditSystem(QWidget *parent)
connect(edit_save_button,SIGNAL(clicked()),this,SLOT(saveData()));
edit_save_button->hide();
//
// Date/Time Formats
//
edit_datetime_group=new QGroupBox(tr("Date/Time Formats"),this);
edit_datetime_group->setFont(labelFont());
edit_long_date_label=
new QLabel(tr("Long Date Format")+":",edit_datetime_group);
edit_long_date_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
edit_long_date_label->setFont(labelFont());
edit_long_date_edit=new QLineEdit(edit_datetime_group);
edit_long_date_edit->setFont(defaultFont());
edit_long_date_edit->setMaxLength(32);
edit_short_date_label=
new QLabel(tr("Short Date Format")+":",edit_datetime_group);
edit_short_date_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
edit_short_date_label->setFont(labelFont());
edit_short_date_edit=new QLineEdit(edit_datetime_group);
edit_short_date_edit->setFont(defaultFont());
edit_short_date_edit->setMaxLength(32);
edit_time_label=
new QLabel(tr("Time Format")+":",edit_datetime_group);
edit_time_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
edit_time_label->setFont(labelFont());
edit_time_edit=new QLineEdit(edit_datetime_group);
edit_time_edit->setFont(defaultFont());
edit_time_edit->setMaxLength(32);
edit_datetime_test_button=new QPushButton(tr("Test"),edit_datetime_group);
connect(edit_datetime_test_button,SIGNAL(clicked()),
this,SLOT(datetimeTestData()));
edit_datetime_defaults_button=
new QPushButton(tr("Restore\nDefaults"),edit_datetime_group);
connect(edit_datetime_defaults_button,SIGNAL(clicked()),
this,SLOT(datetimeDefaultsData()));
//
// Encoders Button
//
@ -207,6 +251,9 @@ EditSystem::EditSystem(QWidget *parent)
edit_cancel_button->setText(tr("Cancel"));
connect(edit_cancel_button,SIGNAL(clicked()),this,SLOT(cancelData()));
//
// Load Values
//
edit_duplicate_carts_box->setChecked(edit_system->allowDuplicateCartTitles());
edit_fix_duplicate_carts_box->
setChecked(edit_system->fixDuplicateCartTitles());
@ -217,8 +264,9 @@ EditSystem::EditSystem(QWidget *parent)
edit_notification_address_edit->
setText(edit_system->notificationAddress().toString());
edit_show_user_list_box->setChecked(edit_system->showUserList());
edit_long_date_edit->setText(edit_system->longDateFormat());
edit_short_date_edit->setText(edit_system->shortDateFormat());
edit_time_edit->setText(edit_system->timeFormat());
QString station=edit_system->rssProcessorStation();
for(int i=0;i<edit_rss_processor_box->count();i++) {
@ -246,12 +294,13 @@ EditSystem::~EditSystem()
delete edit_duplicate_label;
delete edit_duplicate_view;
delete edit_duplicate_model;
delete edit_test_datetimes_dialog;
}
QSize EditSystem::sizeHint() const
{
return QSize(500,306+y_pos);
return QSize(500,406+y_pos);
}
@ -328,6 +377,29 @@ void EditSystem::encodersData()
}
void EditSystem::datetimeTestData()
{
edit_test_datetimes_dialog->exec(edit_long_date_edit->text(),
edit_short_date_edit->text(),
edit_time_edit->text());
}
void EditSystem::datetimeDefaultsData()
{
if(QMessageBox::warning(this,"RDAdmin - "+tr("Warning"),
tr("This will reset all date/time display formats to default values!")+
"\n"+
tr("Proceed?"),
QMessageBox::No,QMessageBox::Yes)!=QMessageBox::Yes) {
return;
}
edit_long_date_edit->setText(RD_DEFAULT_LONG_DATE_FORMAT);
edit_short_date_edit->setText(RD_DEFAULT_SHORT_DATE_FORMAT);
edit_time_edit->setText(RD_DEFAULT_TIME_FORMAT);
}
void EditSystem::okData()
{
QString sql;
@ -439,14 +511,17 @@ void EditSystem::okData()
else {
edit_system->setRssProcessorStation(edit_rss_processor_box->currentText());
}
edit_system->setLongDateFormat(edit_long_date_edit->text());
edit_system->setShortDateFormat(edit_short_date_edit->text());
edit_system->setTimeFormat(edit_time_edit->text());
done(0);
done(true);
}
void EditSystem::cancelData()
{
done(-1);
done(false);
}
@ -504,9 +579,19 @@ void EditSystem::resizeEvent(QResizeEvent *e)
edit_rss_processor_label->setGeometry(10,207,235,20);
edit_rss_processor_box->setGeometry(250,207,200,20);
edit_duplicate_hidden_label->setGeometry(15,229,size().width()-30,50);
edit_duplicate_view->setGeometry(10,277,size().width()-20,215);
edit_save_button->setGeometry(size().width()-85,497,70,25);
edit_datetime_group->setGeometry(10,229,size().width()-20,100);
edit_datetime_test_button->setGeometry(5,22,80,35);
edit_datetime_defaults_button->setGeometry(5,60,80,35);
edit_long_date_label->setGeometry(110,27,120,20);
edit_long_date_edit->setGeometry(235,27,edit_datetime_group->width()-240,20);
edit_short_date_label->setGeometry(110,49,120,20);
edit_short_date_edit->setGeometry(235,49,edit_datetime_group->width()-240,20);
edit_time_label->setGeometry(110,71,120,20);
edit_time_edit->setGeometry(235,71,edit_datetime_group->width()-240,20);
edit_duplicate_hidden_label->setGeometry(15,329,size().width()-30,50);
edit_duplicate_view->setGeometry(10,377,size().width()-20,215);
edit_save_button->setGeometry(size().width()-85,597,70,25);
edit_encoders_button->setGeometry(10,size().height()-60,120,50);
edit_ok_button->setGeometry(size().width()-180,size().height()-60,80,50);

View File

@ -22,6 +22,7 @@
#define EDIT_SYSTEM_H
#include <QCheckBox>
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
@ -37,6 +38,7 @@
#include <rdtableview.h>
#include "list_encoders.h"
#include "test_datetimes.h"
class EditSystem : public RDDialog
{
@ -52,6 +54,8 @@ class EditSystem : public RDDialog
void duplicatesCheckedData(bool state);
void saveData();
void encodersData();
void datetimeTestData();
void datetimeDefaultsData();
void okData();
void cancelData();
@ -94,6 +98,16 @@ class EditSystem : public RDDialog
ListEncoders *edit_encoders_dialog;
int y_pos;
RDStationListModel *edit_station_list_model;
QGroupBox *edit_datetime_group;
QLabel *edit_long_date_label;
QLineEdit *edit_long_date_edit;
QLabel *edit_short_date_label;
QLineEdit *edit_short_date_edit;
QLabel *edit_time_label;
QLineEdit *edit_time_edit;
QPushButton *edit_datetime_test_button;
QPushButton *edit_datetime_defaults_button;
TestDatetimes *edit_test_datetimes_dialog;
};

View File

@ -82,6 +82,7 @@ x11 {
SOURCES += rdadmin.cpp
SOURCES += rename_group.cpp
SOURCES += test_import.cpp
SOURCES += test_datetimes.cpp
SOURCES += view_adapters.cpp
SOURCES += view_pypad_errors.cpp
SOURCES += xpm_info_banner1.cpp
@ -151,6 +152,7 @@ x11 {
HEADERS += rdadmin.h
HEADERS += rename_group.h
HEADERS += test_import.h
HEADERS += test_datetimes.h
HEADERS += view_adapters.h
HEADERS += view_pypad_errors.h
}

View File

@ -0,0 +1,97 @@
// test_datetimes.cpp
//
// Test Rivendell Date/Time Formats
//
// (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 "test_datetimes.h"
TestDatetimes::TestDatetimes(QWidget *parent)
: RDDialog(parent)
{
setWindowTitle("RDAdmin - "+tr("Test Date/Time Formats"));
d_sample_datetime=QDateTime(QDate(2021,12,28),QTime(14,10,23));
d_sample_datetime_label_label=new QLabel(tr("Sample Date/Time")+":",this);
d_sample_datetime_label_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
d_sample_datetime_label_label->setFont(labelFont());
d_sample_datetime_label=new QLabel(this);
d_sample_datetime_label->
setText(d_sample_datetime.toString("dddd MMMM d yyyy - h:mm:ss AP"));
d_long_date_label_label=new QLabel(tr("Long Date")+":",this);
d_long_date_label_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
d_long_date_label_label->setFont(labelFont());
d_long_date_label=new QLabel(this);
d_short_date_label_label=new QLabel(tr("Short Date")+":",this);
d_short_date_label_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
d_short_date_label_label->setFont(labelFont());
d_short_date_label=new QLabel(this);
d_time_label_label=new QLabel(tr("Time")+":",this);
d_time_label_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
d_time_label_label->setFont(labelFont());
d_time_label=new QLabel(this);
d_close_button=new QPushButton(tr("Close"),this);
d_close_button->setFont(buttonFont());
connect(d_close_button,SIGNAL(clicked()),this,SLOT(closeData()));
}
QSize TestDatetimes::sizeHint() const
{
return QSize(400,150);
}
int TestDatetimes::exec(const QString &long_date_fmt,\
const QString &short_date_fmt,
const QString &time_fmt)
{
d_long_date_label->setText(d_sample_datetime.toString(long_date_fmt));
d_short_date_label->setText(d_sample_datetime.toString(short_date_fmt));
d_time_label->setText(d_sample_datetime.toString(time_fmt));
return QDialog::exec();
}
void TestDatetimes::closeData()
{
done(true);
}
void TestDatetimes::resizeEvent(QResizeEvent *e)
{
d_sample_datetime_label_label->setGeometry(10,2,120,20);
d_sample_datetime_label->setGeometry(135,2,size().width()-145,20);
d_long_date_label_label->setGeometry(10,30,120,20);
d_long_date_label->setGeometry(135,30,size().width()-145,20);
d_short_date_label_label->setGeometry(10,50,120,20);
d_short_date_label->setGeometry(135,50,size().width()-145,20);
d_time_label_label->setGeometry(10,70,120,20);
d_time_label->setGeometry(135,70,size().width()-145,20);
d_close_button->setGeometry(size().width()-90,size().height()-60,80,50);
}

60
rdadmin/test_datetimes.h Normal file
View File

@ -0,0 +1,60 @@
// test_datetimes.h
//
// Test Rivendell Date/Time Formats
//
// (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 TEST_DATETIMES_H
#define TEST_DATETIMES_H
#include <QLabel>
#include <QPushButton>
#include <rddialog.h>
class TestDatetimes : public RDDialog
{
Q_OBJECT
public:
TestDatetimes(QWidget *parent=0);
QSize sizeHint() const;
public slots:
int exec(const QString &long_date_fmt,const QString &short_date_fmt,
const QString &time_fmt);
private slots:
void closeData();
protected:
void resizeEvent(QResizeEvent *e);
private:
QDateTime d_sample_datetime;
QLabel *d_sample_datetime_label;
QLabel *d_sample_datetime_label_label;
QLabel *d_long_date_label;
QLabel *d_long_date_label_label;
QLabel *d_short_date_label;
QLabel *d_short_date_label_label;
QLabel *d_time_label;
QLabel *d_time_label_label;
QPushButton *d_close_button;
};
#endif // TEST_DATETIMES_H

View File

@ -40,6 +40,16 @@ bool MainObject::RevertSchema(int cur_schema,int set_schema,QString *err_msg)
// NEW SCHEMA REVERSIONS GO HERE...
//
// Revert 351
//
if((cur_schema==351)&&(set_schema<cur_schema)) {
DropColumn("SYSTEM","TIME_FORMAT");
DropColumn("SYSTEM","SHORT_DATE_FORMAT");
DropColumn("SYSTEM","LONG_DATE_FORMAT");
WriteSchemaVersion(--cur_schema);
}
//
// Revert 350
//

View File

@ -160,7 +160,7 @@ void MainObject::InitializeSchemaMap() {
global_version_map["3.4"]=317;
global_version_map["3.5"]=346;
global_version_map["3.6"]=347;
global_version_map["4.0"]=350;
global_version_map["4.0"]=351;
}

View File

@ -10798,7 +10798,7 @@ bool MainObject::UpdateSchema(int cur_schema,int set_schema,QString *err_msg)
//
// Maintainer's Note:
//
// Use hard-coded maximum card/port quantities (24 four for each) here,
// Use hard-coded maximum card/port quantities (24 for each) here,
// in case the #define'd values change in future!
//
sql=QString("select `NAME` from `STATIONS`");
@ -10830,6 +10830,31 @@ bool MainObject::UpdateSchema(int cur_schema,int set_schema,QString *err_msg)
WriteSchemaVersion(++cur_schema);
}
if((cur_schema<351)&&(set_schema>cur_schema)) {
sql=QString("alter table `SYSTEM` ")+
"add column `LONG_DATE_FORMAT` varchar(32) not null default 'dddd, MMMM d yyyy' "+
"after `ORIGIN_EMAIL_ADDRESS`";
if(!RDSqlQuery::apply(sql,err_msg)) {
return false;
}
sql=QString("alter table `SYSTEM` ")+
"add column `SHORT_DATE_FORMAT` varchar(32) not null default 'MM/dd/yy' "+
"after `LONG_DATE_FORMAT`";
if(!RDSqlQuery::apply(sql,err_msg)) {
return false;
}
sql=QString("alter table `SYSTEM` ")+
"add column `TIME_FORMAT` varchar(32) not null default 'hh:mm:ss' "+
"after `SHORT_DATE_FORMAT`";
if(!RDSqlQuery::apply(sql,err_msg)) {
return false;
}
WriteSchemaVersion(++cur_schema);
}
// NEW SCHEMA UPDATES GO HERE...