From 2ea048a80b5209bd974de2a2d05be22b44e61819 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Tue, 26 Jan 2021 19:36:48 -0500 Subject: [PATCH] 2021-01-26 Fred Gleason * Added 'RDLogImportModel'. * Refactored the 'Test Import' dialog in rdadmin(1) to use the model-based API. Signed-off-by: Fred Gleason --- ChangeLog | 4 + docs/examples/0320090805.cpi | 3 +- lib/Makefile.am | 2 + lib/lib.pro | 2 + lib/librd_cs.ts | 47 ++++++ lib/librd_de.ts | 47 ++++++ lib/librd_es.ts | 47 ++++++ lib/librd_fr.ts | 47 ++++++ lib/librd_nb.ts | 47 ++++++ lib/librd_nn.ts | 47 ++++++ lib/librd_pt_BR.ts | 47 ++++++ lib/rdlogimportmodel.cpp | 294 +++++++++++++++++++++++++++++++++++ lib/rdlogimportmodel.h | 69 ++++++++ rdadmin/rdadmin_cs.ts | 36 +---- rdadmin/rdadmin_de.ts | 36 +---- rdadmin/rdadmin_es.ts | 36 +---- rdadmin/rdadmin_fr.ts | 52 +------ rdadmin/rdadmin_nb.ts | 36 +---- rdadmin/rdadmin_nn.ts | 36 +---- rdadmin/rdadmin_pt_BR.ts | 36 +---- rdadmin/test_import.cpp | 143 ++++------------- rdadmin/test_import.h | 23 ++- 22 files changed, 790 insertions(+), 347 deletions(-) create mode 100644 lib/rdlogimportmodel.cpp create mode 100644 lib/rdlogimportmodel.h diff --git a/ChangeLog b/ChangeLog index 11111086..99b2e4e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20916,3 +20916,7 @@ * Added 'RDPypadListModel'. * Refactored the 'Encoder 'PyPAD Instances' dialog in rdadmin(1) to use the model-based API. +2021-01-26 Fred Gleason + * Added 'RDLogImportModel'. + * Refactored the 'Test Import' dialog in rdadmin(1) to use the + model-based API. diff --git a/docs/examples/0320090805.cpi b/docs/examples/0320090805.cpi index f512d1e2..010620d8 100644 --- a/docs/examples/0320090805.cpi +++ b/docs/examples/0320090805.cpi @@ -1,8 +1,9 @@ 00:00:00 10001 Lonely Cowboy 00:02:53 ISCI4567890123456789012345678901 GUID4567890123456789012345678901 00:02:53 10002 E Song 00:03:27 ISCI4567890123456789012345678901 GUID4567890123456789012345678901 +00:06:20 MARKER Let the cat out! 00:06:20 10003 Likeness 00:02:54 ISCI4567890123456789012345678901 GUID4567890123456789012345678901 00:09:14 10004 Atchafalaya 00:28:02 ISCI4567890123456789012345678901 GUID4567890123456789012345678901 00:30:00 BREAK Spot Break 00:02:00 00:32:00 10005 Mr. Banks 00:03:54 ISCI4567890123456789012345678901 GUID4567890123456789012345678901 -00:35:54 VOICETRACK 00:01:30 +00:35:54 VT VOICETRACK 00:01:30 00:38:24 10006 The Grey and the Green 00:03:23 ISCI4567890123456789012345678901 GUID4567890123456789012345678901 diff --git a/lib/Makefile.am b/lib/Makefile.am index fc468030..eaf04769 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -175,6 +175,7 @@ dist_librd_la_SOURCES = dbversion.h\ rdlog_line.cpp rdlog_line.h\ rdlogedit_conf.cpp rdlogedit_conf.h\ rdlogfilter.cpp rdlogfilter.h\ + rdlogimportmodel.cpp rdlogimportmodel.h\ rdloglock.cpp rdloglock.h\ rdloglistmodel.cpp rdloglistmodel.h\ rdlogmodel.cpp rdlogmodel.h\ @@ -335,6 +336,7 @@ nodist_librd_la_SOURCES = moc_rdadd_cart.cpp\ moc_rdlistview.cpp\ moc_rdlivewire.cpp\ moc_rdlogfilter.cpp\ + moc_rdlogimportmodel.cpp\ moc_rdloglock.cpp\ moc_rdloglistmodel.cpp\ moc_rdlogmodel.cpp\ diff --git a/lib/lib.pro b/lib/lib.pro index f468de6c..6e75d3a7 100644 --- a/lib/lib.pro +++ b/lib/lib.pro @@ -129,6 +129,7 @@ SOURCES += rdlog.cpp SOURCES += rdlog_line.cpp SOURCES += rdlogedit_conf.cpp SOURCES += rdlogfilter.cpp +SOURCES += rdlogimportmodel.cpp SOURCES += rdloglock.cpp SOURCES += rdloglistmodel.cpp SOURCES += rdlogmodel.cpp @@ -289,6 +290,7 @@ HEADERS += rdlog.h HEADERS += rdlog_line.h HEADERS += rdlogedit_conf.h HEADERS += rdlogfilter.h +HEADERS += rdlogimportmodel.h HEADERS += rdloglock.h HEADERS += rdloglistmodel.h HEADERS += rdlogmodel.h diff --git a/lib/librd_cs.ts b/lib/librd_cs.ts index b85f33ae..ec01e754 100644 --- a/lib/librd_cs.ts +++ b/lib/librd_cs.ts @@ -2964,6 +2964,53 @@ Bitte Kofiguration prüfen und erneut versuchen. + + RDLogImportModel + + Start Time + + + + Cart + Vozík + + + Len + + + + Title + + + + GUID + + + + Event ID + + + + Annc Type + + + + Line + + + + NOTE + + + + [spot break] + + + + [voice track] + + + RDLogLine diff --git a/lib/librd_de.ts b/lib/librd_de.ts index 0bec293a..a40398ce 100644 --- a/lib/librd_de.ts +++ b/lib/librd_de.ts @@ -2945,6 +2945,53 @@ Bitte Kofiguration prüfen und erneut versuchen. ALLE + + RDLogImportModel + + Start Time + + + + Cart + Cart + + + Len + + + + Title + + + + GUID + + + + Event ID + + + + Annc Type + + + + Line + + + + NOTE + + + + [spot break] + + + + [voice track] + + + RDLogLine diff --git a/lib/librd_es.ts b/lib/librd_es.ts index 38db52b4..054565e0 100644 --- a/lib/librd_es.ts +++ b/lib/librd_es.ts @@ -2936,6 +2936,53 @@ Do you still want to proceed? + + RDLogImportModel + + Start Time + + + + Cart + Cartucho + + + Len + + + + Title + + + + GUID + + + + Event ID + + + + Annc Type + + + + Line + + + + NOTE + + + + [spot break] + + + + [voice track] + + + RDLogLine diff --git a/lib/librd_fr.ts b/lib/librd_fr.ts index 538c4046..0bbd19ff 100644 --- a/lib/librd_fr.ts +++ b/lib/librd_fr.ts @@ -2452,6 +2452,53 @@ Do you want to overwrite it? + + RDLogImportModel + + Start Time + + + + Cart + Cart + + + Len + + + + Title + + + + GUID + + + + Event ID + + + + Annc Type + + + + Line + + + + NOTE + + + + [spot break] + + + + [voice track] + + + RDLogLine diff --git a/lib/librd_nb.ts b/lib/librd_nb.ts index 7bbaddf2..3e2007de 100644 --- a/lib/librd_nb.ts +++ b/lib/librd_nb.ts @@ -2895,6 +2895,53 @@ Sjekk eksportoppsettet ditt og prøv att. ALLE + + RDLogImportModel + + Start Time + + + + Cart + Korg + + + Len + + + + Title + + + + GUID + + + + Event ID + + + + Annc Type + + + + Line + + + + NOTE + + + + [spot break] + + + + [voice track] + + + RDLogLine diff --git a/lib/librd_nn.ts b/lib/librd_nn.ts index 7bbaddf2..3e2007de 100644 --- a/lib/librd_nn.ts +++ b/lib/librd_nn.ts @@ -2895,6 +2895,53 @@ Sjekk eksportoppsettet ditt og prøv att. ALLE + + RDLogImportModel + + Start Time + + + + Cart + Korg + + + Len + + + + Title + + + + GUID + + + + Event ID + + + + Annc Type + + + + Line + + + + NOTE + + + + [spot break] + + + + [voice track] + + + RDLogLine diff --git a/lib/librd_pt_BR.ts b/lib/librd_pt_BR.ts index 0834e3e9..eae77582 100644 --- a/lib/librd_pt_BR.ts +++ b/lib/librd_pt_BR.ts @@ -2934,6 +2934,53 @@ Por Favor, cheque suas configurações e tenbte outra vez. TODOS + + RDLogImportModel + + Start Time + + + + Cart + Cartão + + + Len + + + + Title + + + + GUID + + + + Event ID + + + + Annc Type + + + + Line + + + + NOTE + + + + [spot break] + + + + [voice track] + + + RDLogLine diff --git a/lib/rdlogimportmodel.cpp b/lib/rdlogimportmodel.cpp new file mode 100644 index 00000000..fa2612b8 --- /dev/null +++ b/lib/rdlogimportmodel.cpp @@ -0,0 +1,294 @@ +// rdlogimportmodel.cpp +// +// Data model for Rivendell log imports +// +// (C) Copyright 2021 Fred Gleason +// +// 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 "rdconf.h" +#include "rdescape_string.h" +#include "rdlogimportmodel.h" +#include "rdsvc.h" + +RDLogImportModel::RDLogImportModel(const QString &hostname,pid_t proc_id, + QObject *parent) + : QAbstractTableModel(parent) +{ + d_station_name=hostname; + d_process_id=proc_id; + + // + // Column Attributes + // + unsigned left=Qt::AlignLeft|Qt::AlignVCenter; + unsigned center=Qt::AlignCenter; + unsigned right=Qt::AlignRight|Qt::AlignVCenter; + + d_headers.push_back(tr("Start Time")); + d_alignments.push_back(left); + + d_headers.push_back(tr("Cart")); + d_alignments.push_back(center); + + d_headers.push_back(tr("Len")); + d_alignments.push_back(right); + + d_headers.push_back(tr("Title")); + d_alignments.push_back(left); + + d_headers.push_back(tr("GUID")); + d_alignments.push_back(left); + + d_headers.push_back(tr("Event ID")); + d_alignments.push_back(left); + + d_headers.push_back(tr("Annc Type")); + d_alignments.push_back(left); + + d_headers.push_back(tr("Line")); + d_alignments.push_back(right); + + updateModel(); +} + + +RDLogImportModel::~RDLogImportModel() +{ +} + + +QPalette RDLogImportModel::palette() +{ + return d_palette; +} + + +void RDLogImportModel::setPalette(const QPalette &pal) +{ + d_palette=pal; +} + + +void RDLogImportModel::setFont(const QFont &font) +{ + d_font=font; + d_bold_font=font; + d_bold_font.setWeight(QFont::Bold); +} + + +int RDLogImportModel::columnCount(const QModelIndex &parent) const +{ + return d_headers.size(); +} + + +int RDLogImportModel::rowCount(const QModelIndex &parent) const +{ + return d_texts.size(); +} + + +QVariant RDLogImportModel::headerData(int section,Qt::Orientation orient, + int role) const +{ + if((orient==Qt::Horizontal)&&(role==Qt::DisplayRole)) { + return d_headers.at(section); + } + return QVariant(); +} + + +QVariant RDLogImportModel::data(const QModelIndex &index,int role) const +{ + QString str; + int col=index.column(); + int row=index.row(); + + if(row texts; + + RDSqlQuery *q=NULL; + QString sql=sqlFields()+ + "where "+ + "IMPORTER_LINES.STATION_NAME=\""+RDEscapeString(d_station_name)+"\"&&"+ + QString().sprintf("PROCESS_ID=%u ",d_process_id)+ + "order by IMPORTER_LINES.LINE_ID "; + beginResetModel(); + d_texts.clear(); + q=new RDSqlQuery(sql); + while(q->next()) { + d_ids.push_back(0); + d_icons.push_back(QVariant()); + d_texts.push_back(texts); + updateRow(d_texts.size()-1,q); + } + delete q; + endResetModel(); +} + + +void RDLogImportModel::updateRowLine(int line) +{ + if(linefirst()) { + updateRow(line,q); + } + delete q; + } +} + + +void RDLogImportModel::updateRow(int row,RDSqlQuery *q) +{ + QList texts; + for(int i=0;ivalue(1).toInt(),q->value(2).toInt()); + + // Cart + // texts.push_back(q->value(2)); + + // Length + if(!q->value(4).isNull()) { + texts[2]=RDGetTimeLength(q->value(4).toInt(),false,false); + } + + // Title + // texts.push_back(q->value(2)); + + // GUID + texts[4]=q->value(5).toString().trimmed(); + + // Event ID + texts[5]=q->value(6).toString().trimmed(); + + // Annc Type + texts[6]=q->value(7).toString().trimmed(); + + // Line + texts[7]=QString().sprintf("%u",1+q->value(10).toUInt()); + + switch((RDLogLine::Type)q->value(9).toUInt()) { + case RDLogLine::Cart: + d_icons[row]=rda->iconEngine()->typeIcon(RDLogLine::Cart); + texts[1]=q->value(3); // Cart Number + texts[3]=q->value(8).toString().trimmed(); // Title + break; + + case RDLogLine::Marker: + d_icons[row]=rda->iconEngine()->typeIcon(RDLogLine::Marker); + texts[1]=tr("NOTE"); // Cart Number + texts[3]=q->value(8).toString().trimmed(); // Title + break; + + case RDLogLine::TrafficLink: + d_icons[row]=rda->iconEngine()->typeIcon(RDLogLine::TrafficLink); + texts[3]=tr("[spot break]"); // Title + break; + + case RDLogLine::Track: + d_icons[row]=rda->iconEngine()->typeIcon(RDLogLine::Track); + texts[3]=tr("[voice track]"); // Title + break; + + case RDLogLine::Macro: + case RDLogLine::OpenBracket: + case RDLogLine::CloseBracket: + case RDLogLine::Chain: + case RDLogLine::MusicLink: + case RDLogLine::UnknownType: + break; + } + + d_ids[row]=q->value(0).toUInt(); + d_texts[row]=texts; +} + + +QString RDLogImportModel::sqlFields() const +{ + QString sql=QString("select ")+ + "ID,"+ // 00 + "START_HOUR,"+ // 01 + "START_SECS,"+ // 02 + "EXT_CART_NAME,"+ // 03 + "LENGTH,"+ // 04 + "EXT_DATA,"+ // 05 + "EXT_EVENT_ID,"+ // 06 + "EXT_ANNC_TYPE,"+ // 07 + "TITLE,"+ // 08 + "TYPE,"+ // 09 + "FILE_LINE "+ // 10 + "from IMPORTER_LINES "; + + return sql; +} diff --git a/lib/rdlogimportmodel.h b/lib/rdlogimportmodel.h new file mode 100644 index 00000000..293aeaa0 --- /dev/null +++ b/lib/rdlogimportmodel.h @@ -0,0 +1,69 @@ +// rdlogimportmodel.h +// +// Data model for Rivendell log imports +// +// (C) Copyright 2021 Fred Gleason +// +// 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 RDLOGIMPORTMODEL_H +#define RDLOGIMPORTMODEL_H + +#include +#include +#include +#include + +#include +#include + +class RDLogImportModel : public QAbstractTableModel +{ + Q_OBJECT + public: + RDLogImportModel(const QString &hostname,pid_t proc_id,QObject *parent=0); + ~RDLogImportModel(); + 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; + int lineId(const QModelIndex &row) const; + void refresh(); + + 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 d_headers; + QList d_alignments; + QList > d_texts; + QList d_icons; + QList d_ids; + QString d_station_name; + pid_t d_process_id; +}; + + +#endif // RDLOGIMPORTMODEL_H diff --git a/rdadmin/rdadmin_cs.ts b/rdadmin/rdadmin_cs.ts index 8743b951..1e77bcda 100644 --- a/rdadmin/rdadmin_cs.ts +++ b/rdadmin/rdadmin_cs.ts @@ -6737,19 +6737,19 @@ Chcete obě spojit? Start Time - Počáteční čas + Počáteční čas Cart - Vozík + Vozík Len - Délka + Délka Title - Název + Název Contract # @@ -6757,7 +6757,7 @@ Chcete obě spojit? Event ID - ID události + ID události Announcement Type @@ -6773,37 +6773,17 @@ Chcete obě spojit? Import Error - Chyba při zavedení + Chyba při zavedení There was an error during import please check your settings and try again. - Během zavedení se vyskytla chyba. + Během zavedení se vyskytla chyba. Prověřte, prosím, svá nastavení a zkuste to znovu. [spot break] - [přerušení místa] - - - GUID - - - - Annc Type - - - - [voice track] - - - - Line - - - - NOTE - + [přerušení místa] diff --git a/rdadmin/rdadmin_de.ts b/rdadmin/rdadmin_de.ts index 27252a35..872b52ff 100644 --- a/rdadmin/rdadmin_de.ts +++ b/rdadmin/rdadmin_de.ts @@ -6247,19 +6247,19 @@ Wollen Sie die beiden kombinieren? Start Time - Startzeit + Startzeit Cart - Cart + Cart Len - Länge + Länge Title - Titel + Titel Contract # @@ -6267,7 +6267,7 @@ Wollen Sie die beiden kombinieren? Event ID - Event-ID + Event-ID Announcement Type @@ -6283,37 +6283,17 @@ Wollen Sie die beiden kombinieren? Import Error - Importfehler + Importfehler There was an error during import please check your settings and try again. - Es gab einen Fehler während des Imports. + Es gab einen Fehler während des Imports. Bitte überprüfen Sie ihre Einstellungen und versuchen sie es erneut. [spot break] - [spot break] - - - GUID - - - - Annc Type - - - - [voice track] - - - - Line - - - - NOTE - + [spot break] diff --git a/rdadmin/rdadmin_es.ts b/rdadmin/rdadmin_es.ts index 4c8e53ba..73887eac 100644 --- a/rdadmin/rdadmin_es.ts +++ b/rdadmin/rdadmin_es.ts @@ -6692,19 +6692,19 @@ Do you want to combine the two? Start Time - Hora de inicio + Hora de inicio Cart - Cartucho + Cartucho Len - Lon + Lon Title - Título + Título Contract # @@ -6712,7 +6712,7 @@ Do you want to combine the two? Event ID - ID de evento + ID de evento Announcement Type @@ -6728,37 +6728,17 @@ Do you want to combine the two? Import Error - Error de importación + Error de importación There was an error during import please check your settings and try again. - Ha habido un error durante la importación + Ha habido un error durante la importación Revise los parámetros e intente de nuevo. [spot break] - [parada del spot] - - - GUID - - - - Annc Type - - - - [voice track] - - - - Line - - - - NOTE - + [parada del spot] diff --git a/rdadmin/rdadmin_fr.ts b/rdadmin/rdadmin_fr.ts index 69679c48..010659f6 100644 --- a/rdadmin/rdadmin_fr.ts +++ b/rdadmin/rdadmin_fr.ts @@ -4970,6 +4970,10 @@ Replicators &Close + + Imported Events + + Import Error @@ -4979,54 +4983,6 @@ Replicators please check your settings and try again. - - Start Time - - - - Cart - - - - Len - - - - Title - - - - GUID - - - - Event ID - - - - Imported Events - - - - Annc Type - - - - [spot break] - - - - [voice track] - - - - Line - - - - NOTE - - ViewAdapters diff --git a/rdadmin/rdadmin_nb.ts b/rdadmin/rdadmin_nb.ts index db7db621..09c4d5ca 100644 --- a/rdadmin/rdadmin_nb.ts +++ b/rdadmin/rdadmin_nb.ts @@ -6081,19 +6081,19 @@ Vil du kombinera desse to? Start Time - Starttid + Starttid Cart - Korg + Korg Len - Len + Len Title - Tittel + Tittel Contract # @@ -6101,7 +6101,7 @@ Vil du kombinera desse to? Event ID - Hendings-ID + Hendings-ID Announcement Type @@ -6117,37 +6117,17 @@ Vil du kombinera desse to? Import Error - Importfeil + Importfeil There was an error during import please check your settings and try again. - Det vart ein feil under importen. + Det vart ein feil under importen. Sjekk oppsettet ditt og prøv att. [spot break] - [spott-avbrot] - - - GUID - - - - Annc Type - - - - [voice track] - - - - Line - - - - NOTE - + [spott-avbrot] diff --git a/rdadmin/rdadmin_nn.ts b/rdadmin/rdadmin_nn.ts index db7db621..09c4d5ca 100644 --- a/rdadmin/rdadmin_nn.ts +++ b/rdadmin/rdadmin_nn.ts @@ -6081,19 +6081,19 @@ Vil du kombinera desse to? Start Time - Starttid + Starttid Cart - Korg + Korg Len - Len + Len Title - Tittel + Tittel Contract # @@ -6101,7 +6101,7 @@ Vil du kombinera desse to? Event ID - Hendings-ID + Hendings-ID Announcement Type @@ -6117,37 +6117,17 @@ Vil du kombinera desse to? Import Error - Importfeil + Importfeil There was an error during import please check your settings and try again. - Det vart ein feil under importen. + Det vart ein feil under importen. Sjekk oppsettet ditt og prøv att. [spot break] - [spott-avbrot] - - - GUID - - - - Annc Type - - - - [voice track] - - - - Line - - - - NOTE - + [spott-avbrot] diff --git a/rdadmin/rdadmin_pt_BR.ts b/rdadmin/rdadmin_pt_BR.ts index eac1c262..686e5f0d 100644 --- a/rdadmin/rdadmin_pt_BR.ts +++ b/rdadmin/rdadmin_pt_BR.ts @@ -6211,19 +6211,19 @@ Do you want to combine the two? Start Time - Hora de Início + Hora de Início Cart - Cartão + Cartão Len - Duração + Duração Title - Título + Título Contract # @@ -6231,7 +6231,7 @@ Do you want to combine the two? Event ID - ID do Evento + ID do Evento Announcement Type @@ -6247,37 +6247,17 @@ Do you want to combine the two? Import Error - Erro ao Importar + Erro ao Importar There was an error during import please check your settings and try again. - Houve um Erro ao importar + Houve um Erro ao importar por favor, cheque suas configurações e tente novamente [spot break] - [spot break] - - - GUID - - - - Annc Type - - - - [voice track] - - - - Line - - - - NOTE - + [spot break] diff --git a/rdadmin/test_import.cpp b/rdadmin/test_import.cpp index cde4ae6b..07231d05 100644 --- a/rdadmin/test_import.cpp +++ b/rdadmin/test_import.cpp @@ -2,7 +2,7 @@ // // Test a Rivendell Log Import // -// (C) Copyright 2002-2020 Fred Gleason +// (C) Copyright 2002-2021 Fred Gleason // // 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,9 +18,9 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include -#include -#include +#include +#include +#include #include #include @@ -35,16 +35,9 @@ #include "globals.h" #include "test_import.h" -#include "../icons/play.xpm" -#include "../icons/marker.xpm" -#include "../icons/mic16.xpm" -#include "../icons/traffic.xpm" - TestImport::TestImport(RDSvc *svc,RDSvc::ImportSource src,QWidget *parent) : RDDialog(parent) { - setModal(true); - QString sql; QDate current_date=QDate::currentDate(); @@ -66,23 +59,16 @@ TestImport::TestImport(RDSvc *svc,RDSvc::ImportSource src,QWidget *parent) break; } - // - // Create Icons - // - test_playout_map=new QPixmap(play_xpm); - test_marker_map=new QPixmap(marker_xpm); - test_mic16_map=new QPixmap(mic16_xpm); - test_traffic_map=new QPixmap(traffic_xpm); - // // Date Selector // - test_date_edit=new Q3DateEdit(this); + test_date_edit=new QDateEdit(this); + test_date_edit->setDisplayFormat("MM/dd/yyyy"); test_date_label=new QLabel(test_date_edit,tr("Test Date:"),this); test_date_label->setFont(labelFont()); test_date_label->setAlignment(Qt::AlignVCenter|Qt::AlignRight); test_date_edit->setDate(current_date); - connect(test_date_edit,SIGNAL(valueChanged(const QDate &)), + connect(test_date_edit,SIGNAL(dateChanged(const QDate &)), this,SLOT(dateChangedData(const QDate &))); // @@ -115,33 +101,22 @@ TestImport::TestImport(RDSvc *svc,RDSvc::ImportSource src,QWidget *parent) // // Events List // - test_events_list=new RDListView(this); - test_events_list->setItemMargin(2); - test_events_list->setSortColumn(0); - test_events_list->setSortOrder(Qt::Ascending); - test_events_list->setAllColumnsShowFocus(true); - test_events_list->addColumn(""); - test_events_list->setColumnAlignment(0,Qt::AlignCenter); - test_events_list->addColumn(tr("Start Time")); - test_events_list->setColumnAlignment(1,Qt::AlignCenter); - test_events_list->addColumn(tr("Cart")); - test_events_list->setColumnAlignment(2,Qt::AlignCenter); - test_events_list->addColumn(tr("Len")); - test_events_list->setColumnAlignment(3,Qt::AlignRight); - test_events_list->addColumn(tr("Title")); - test_events_list->setColumnAlignment(4,Qt::AlignLeft); - test_events_list->addColumn(tr("GUID")); - test_events_list->setColumnAlignment(5,Qt::AlignCenter); - test_events_list->addColumn(tr("Event ID")); - test_events_list->setColumnAlignment(6,Qt::AlignCenter); - test_events_list->addColumn(tr("Annc Type")); - test_events_list->setColumnAlignment(7,Qt::AlignCenter); - test_events_list->addColumn(tr("Line")); - test_events_list->setColumnAlignment(8,Qt::AlignRight); - test_events_list->setColumnSortType(0,RDListView::LineSort); - test_events_label=new QLabel(test_events_list,tr("Imported Events"),this); + test_events_view=new QTableView(this); + test_events_view->setSelectionBehavior(QAbstractItemView::SelectRows); + test_events_view->setSelectionMode(QAbstractItemView::NoSelection); + test_events_view->setShowGrid(false); + test_events_view->setSortingEnabled(false); + test_events_view->setWordWrap(false); + test_events_view->verticalHeader()->setVisible(false); + test_events_view->horizontalHeader()->setStretchLastSection(true); + test_events_model=new RDLogImportModel(rda->station()->name(),getpid(),this); + test_events_view->setModel(test_events_model); + test_events_label=new QLabel(test_events_view,tr("Imported Events"),this); test_events_label->setGeometry(15,160,sizeHint().width()-30,18); test_events_label->setFont(labelFont()); + connect(test_events_model,SIGNAL(modelReset()), + test_events_view,SLOT(resizeColumnsToContents())); + test_events_view->resizeColumnsToContents(); // // Close Button @@ -162,13 +137,13 @@ TestImport::~TestImport() QSize TestImport::sizeHint() const { - return QSize(700,400); + return QSize(1000,600); } QSizePolicy TestImport::sizePolicy() const { - return QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); } @@ -189,81 +164,15 @@ void TestImport::selectData() void TestImport::importData() { - RDListViewItem *item; - int next_line=0; - - test_events_list->clear(); if(!test_svc->import(test_src,test_date_edit->date(),test_svc->breakString(), test_svc->trackString(test_src),true)) { QMessageBox::information(this,tr("Import Error"), tr("There was an error during import\nplease check your settings and try again.")); return; } - QString sql=QString("select ")+ - "START_HOUR,"+ // 00 - "START_SECS,"+ // 01 - "EXT_CART_NAME,"+ // 02 - "LENGTH,"+ // 03 - "EXT_DATA,"+ // 04 - "EXT_EVENT_ID,"+ // 05 - "EXT_ANNC_TYPE,"+ // 06 - "TITLE,"+ // 07 - "TYPE,"+ // 08 - "FILE_LINE "+ // 09 - "from IMPORTER_LINES where "+ - "STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\" && "+ - QString().sprintf("PROCESS_ID=%u ",getpid())+ - "order by LINE_ID"; - RDSqlQuery *q=new RDSqlQuery(sql); - while(q->next()) { - item=new RDListViewItem(test_events_list); - item->setLine(next_line++); - if((!q->value(0).isNull())&&(!q->value(1).isNull())) { - item->setText(1,RDSvc::timeString(q->value(0).toInt(), - q->value(1).toInt())); - } - if(!q->value(3).isNull()) { - item->setText(3,RDGetTimeLength(q->value(3).toInt(),false,false)); - } - item->setText(5,q->value(4).toString().trimmed()); - item->setText(6,q->value(5).toString().trimmed()); - item->setText(7,q->value(6).toString().trimmed()); - item->setText(8,QString().sprintf("%u",1+q->value(9).toUInt())); - switch((RDLogLine::Type)q->value(8).toUInt()) { - case RDLogLine::Cart: - item->setPixmap(0,*test_playout_map); - item->setText(2,q->value(2).toString()); - item->setText(4,q->value(7).toString().trimmed()); - break; + test_events_model->refresh(); - case RDLogLine::Marker: - item->setPixmap(0,*test_marker_map); - item->setText(2,tr("NOTE")); - item->setText(4,q->value(7).toString().trimmed()); - break; - - case RDLogLine::TrafficLink: - item->setPixmap(0,*test_traffic_map); - item->setText(4,tr("[spot break]")); - break; - - case RDLogLine::Track: - item->setPixmap(0,*test_mic16_map); - item->setText(4,tr("[voice track]")); - break; - - case RDLogLine::Macro: - case RDLogLine::OpenBracket: - case RDLogLine::CloseBracket: - case RDLogLine::Chain: - case RDLogLine::MusicLink: - case RDLogLine::UnknownType: - break; - } - } - delete q; - - sql=QString("delete from IMPORTER_LINES where ")+ + QString sql=QString("delete from IMPORTER_LINES where ")+ "STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\" && "+ QString().sprintf("PROCESS_ID=%u",getpid()); // printf("IMPORTER_LINES cleanup SQL: %s\n",(const char *)sql); @@ -301,7 +210,7 @@ void TestImport::resizeEvent(QResizeEvent *e) test_date_label->setGeometry(5,10,85,20); test_filename_edit->setGeometry(10,133,size().width()-20,18); test_import_button->setGeometry(30,45,size().width()-60,50); - test_events_list-> + test_events_view-> setGeometry(10,178,size().width()-20,size().height()-248); test_close_button->setGeometry(size().width()-90,size().height()-60,80,50); } diff --git a/rdadmin/test_import.h b/rdadmin/test_import.h index bf7ace69..e70f46bf 100644 --- a/rdadmin/test_import.h +++ b/rdadmin/test_import.h @@ -2,7 +2,7 @@ // // Test a Rivendell Log Import // -// (C) Copyright 2002-2020 Fred Gleason +// (C) Copyright 2002-2021 Fred Gleason // // 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,14 +21,14 @@ #ifndef TEST_IMPORT_H #define TEST_IMPORT_H -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include -#include +#include #include class TestImport : public RDDialog @@ -54,17 +54,14 @@ class TestImport : public RDDialog RDSvc *test_svc; RDSvc::ImportSource test_src; QLabel *test_date_label; - Q3DateEdit *test_date_edit; + QDateEdit *test_date_edit; QPushButton *test_import_button; QLabel *test_events_label; - RDListView *test_events_list; + QTableView *test_events_view; + RDLogImportModel *test_events_model; QLabel *test_filename_label; QLineEdit *test_filename_edit; QPushButton *test_close_button; - QPixmap *test_playout_map; - QPixmap *test_marker_map; - QPixmap *test_mic16_map; - QPixmap *test_traffic_map; };