diff --git a/ChangeLog b/ChangeLog index 430ef76c..87246972 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21056,3 +21056,6 @@ * Removed 'Q3TextEdit' dependencies from rdadmin(1). 2021-02-06 Fred Gleason * Removed the 'Edit Hotkeys' dialog from rdadmin(1). +2021-02-08 Fred Gleason + * Refactored the library list in the 'Edit Event' dialog in + rdlogmanger(1) to use the model based API. diff --git a/lib/rdgrouplistmodel.cpp b/lib/rdgrouplistmodel.cpp index f57cc581..5c1627d9 100644 --- a/lib/rdgrouplistmodel.cpp +++ b/lib/rdgrouplistmodel.cpp @@ -168,6 +168,25 @@ QString RDGroupListModel::groupName(const QModelIndex &row) const } +QStringList RDGroupListModel::allGroupNames() const +{ + QStringList ret; + + if(d_show_all) { + for(int i=1;i #include +#include #include #include #include @@ -96,6 +97,9 @@ EditEvent::EditEvent(QString eventname,bool new_event, // event_group_box=new QComboBox(this); event_group_box->setGeometry(55,25,CENTER_LINE-70,20); + event_group_model=new RDGroupListModel(true,false,this); + event_group_model->changeUser(); + event_group_box->setModel(event_group_model); connect(event_group_box,SIGNAL(activated(const QString &)), this,SLOT(filterActivatedData(const QString &))); label=new QLabel(event_group_box,tr("Group:"),this); @@ -137,23 +141,22 @@ EditEvent::EditEvent(QString eventname,bool new_event, // // Cart List // - event_lib_list=new LibListView(this); - event_lib_list->setGeometry(10,80,CENTER_LINE-20,sizeHint().height()-300); - event_lib_list->setAllColumnsShowFocus(true); - event_lib_list->setItemMargin(5); - event_lib_list->addColumn(""); - event_lib_list->addColumn(tr("Cart")); - event_lib_list->addColumn(tr("Group")); - event_lib_list->addColumn(tr("Length")); - event_lib_list->setColumnAlignment(3,Qt::AlignRight); - event_lib_list->addColumn(tr("Title")); - event_lib_list->addColumn(tr("Artist")); - event_lib_list->addColumn(tr("Start")); - event_lib_list->addColumn(tr("End")); - event_lib_list->addColumn(tr("Type")); - connect(event_lib_list,SIGNAL(clicked(Q3ListViewItem *)), - this,SLOT(cartClickedData(Q3ListViewItem *))); - + event_lib_view=new LibraryTableView(this); + event_lib_view->setGeometry(10,80,CENTER_LINE-20,sizeHint().height()-300); + event_lib_view->setDragEnabled(true); + event_lib_model=new RDLibraryModel(this); + event_lib_model->setFont(font()); + event_lib_model->setPalette(palette()); + event_lib_view->setModel(event_lib_model); + event_lib_view->hideColumn(3); + connect(event_lib_view->selectionModel(), + SIGNAL(selectionChanged(const QItemSelection &,const QItemSelection &)), + this, + SLOT(selectionChangedData(const QItemSelection &, + const QItemSelection &))); + connect(event_lib_model,SIGNAL(modelReset()), + event_lib_view,SLOT(resizeColumnsToContents())); + // // Empty Cart Source // @@ -202,14 +205,6 @@ EditEvent::EditEvent(QString eventname,bool new_event, // // Load Group List // - sql="select NAME from GROUPS order by NAME"; - q=new RDSqlQuery(sql); - event_group_box->insertItem(tr("ALL")); - while(q->next()) { - event_group_box->insertItem(q->value(0).toString()); - } - delete q; - RefreshLibrary(); // ******************************* @@ -448,8 +443,6 @@ EditEvent::EditEvent(QString eventname,bool new_event, event_preimport_list->addColumn(tr("Title")); event_preimport_list->addColumn(tr("Transition")); event_preimport_list->addColumn(tr("Count")); - connect(event_preimport_list,SIGNAL(clicked(Q3ListViewItem *)), - this,SLOT(cartClickedData(Q3ListViewItem *))); connect(event_preimport_list,SIGNAL(lengthChanged(int)), this,SLOT(preimportLengthChangedData(int))); event_preimport_up_button=new RDTransportButton(RDTransportButton::Up,this); @@ -668,8 +661,8 @@ EditEvent::EditEvent(QString eventname,bool new_event, event_postimport_list->addColumn(tr("Title")); event_postimport_list->addColumn(tr("Transition")); event_postimport_list->addColumn(tr("Count")); - connect(event_postimport_list,SIGNAL(clicked(Q3ListViewItem *)), - this,SLOT(cartClickedData(Q3ListViewItem *))); + // connect(event_postimport_list,SIGNAL(clicked(Q3ListViewItem *)), + // this,SLOT(cartClickedData(Q3ListViewItem *))); connect(event_postimport_list,SIGNAL(lengthChanged(int)), this,SLOT(postimportLengthChangedData(int))); connect(event_postimport_list,SIGNAL(validationNeeded()), @@ -865,7 +858,7 @@ EditEvent::EditEvent(QString eventname,bool new_event, EditEvent::~EditEvent() { - delete event_lib_list; + delete event_lib_view; delete event_preimport_list; delete event_postimport_list; } @@ -923,14 +916,19 @@ void EditEvent::searchData() } -void EditEvent::cartClickedData(Q3ListViewItem *item) +void EditEvent::selectionChangedData(const QItemSelection &before, + const QItemSelection &after) { - if (!event_player) return; - if(item==NULL) { + QModelIndexList rows=event_lib_view->selectionModel()->selectedRows(); + + if(event_player==NULL) { + return; + } + if(rows.size()!=1) { event_player->setCart(0); return; } - event_player->setCart(item->text(1).toUInt()); + event_player->setCart(event_lib_model->cartNumber(rows.first())); } @@ -1355,78 +1353,21 @@ void EditEvent::paintEvent(QPaintEvent *e) p->end(); } - void EditEvent::RefreshLibrary() { - QString type_filter; - - switch(event_lib_type_group->checkedId()) { - case 0: - type_filter="((TYPE=1)||(TYPE=2)||(TYPE=3))"; - break; - - case 1: - type_filter="((TYPE=1)||(TYPE=3))"; - break; - - case 2: - type_filter="(TYPE=2)"; - break; - } - QString sql=QString("select ")+ - "TYPE,"+ // 00 - "NUMBER,"+ // 01 - "GROUP_NAME,"+ // 02 - "FORCED_LENGTH,"+ // 03 - "TITLE,"+ // 04 - "ARTIST,"+ // 05 - "START_DATETIME,"+ // 06 - "END_DATETIME "+ // 07 - "from CART "; - QString group=event_group_box->currentText(); - if(group==QString(tr("ALL"))) { - group=""; - } - sql+=RDCartSearchText(event_lib_filter_edit->text(),group,"",false)+" && "+ - type_filter; - RDSqlQuery *q=new RDSqlQuery(sql); - Q3ListViewItem *item; - event_lib_list->clear(); - while(q->next()) { - item=new Q3ListViewItem(event_lib_list); - switch((RDCart::Type)q->value(0).toInt()) { - case RDCart::Audio: - item->setPixmap(0,*event_playout_map); - item->setText(8,tr("Audio")); - break; - - case RDCart::Macro: - item->setPixmap(0,*event_macro_map); - item->setText(8,tr("Macro")); - break; - - case RDCart::All: - break; - } - item->setText(1,QString().sprintf("%06u",q->value(1).toInt())); - item->setText(2,q->value(2).toString()); - item->setText(3,RDGetTimeLength(q->value(3).toInt(),false,false)); - item->setText(4,q->value(4).toString()); - item->setText(5,q->value(5).toString()); - if(!q->value(6).toDateTime().isNull()) { - item->setText(6,q->value(7).toDateTime().toString("MM/dd/yyyy")); - } - if(!q->value(7).toDateTime().isNull()) { - item->setText(7,q->value(7).toDateTime().toString("MM/dd/yyyy")); - } - else { - item->setText(7,"TFN"); - } - } - delete q; + QString sql=QString("where ")+ + RDCartFilter::typeFilter(event_lib_type_group->button(0)->isChecked()|| + event_lib_type_group->button(1)->isChecked(), + event_lib_type_group->button(0)->isChecked()|| + event_lib_type_group->button(2)->isChecked(), + RDCart::All)+ + RDCartFilter::phraseFilter(event_lib_filter_edit->text(),false)+ + RDCartFilter::groupFilter(event_group_box->currentText(), + event_group_model->allGroupNames()); + sql=sql.left(sql.length()-3); + event_lib_model->setFilterSql(sql); } - void EditEvent::Save() { QString properties; diff --git a/rdlogmanager/edit_event.h b/rdlogmanager/edit_event.h index 251b9897..68d81638 100644 --- a/rdlogmanager/edit_event.h +++ b/rdlogmanager/edit_event.h @@ -2,7 +2,7 @@ // // Edit a Rivendell Log Event // -// (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 @@ -22,23 +22,26 @@ #define EDIT_EVENT_H -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include +#include +#include #include +#include #include "import_listview.h" -#include "lib_listview.h" +#include "librarytableview.h" // // Layout @@ -60,7 +63,8 @@ class EditEvent : public RDDialog void filterActivatedData(const QString &str); void filterClickedData(int id); void searchData(); - void cartClickedData(Q3ListViewItem *item); + void selectionChangedData(const QItemSelection &before, + const QItemSelection &after); void prepositionToggledData(bool state); void timeToggledData(bool); void graceClickedData(int); @@ -99,6 +103,7 @@ class EditEvent : public RDDialog QLineEdit *event_lib_filter_edit; QButtonGroup *event_lib_type_group; QComboBox *event_group_box; + RDGroupListModel *event_group_model; QComboBox *event_sched_group_box; QSpinBox* event_artist_sep_spinbox; QLabel *event_artist_sep_label; @@ -110,7 +115,8 @@ class EditEvent : public RDDialog QLabel *event_have_code_label; QComboBox* event_have_code2_box; QLabel *event_have_code2_label; - LibListView *event_lib_list; + LibraryTableView *event_lib_view; + RDLibraryModel *event_lib_model; QPushButton *event_search_button; QPixmap *event_playout_map; QPixmap *event_macro_map; diff --git a/rdlogmanager/lib_listview.cpp b/rdlogmanager/lib_listview.cpp deleted file mode 100644 index 1568e305..00000000 --- a/rdlogmanager/lib_listview.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// lib_listview.cpp -// -// The Library ListView widget for RDLogManager. -// -// (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 -// 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 - -#include - -LibListView::LibListView(QWidget *parent) - : Q3ListView(parent) -{ -} - - -void LibListView::contentsMousePressEvent(QMouseEvent *e) -{ - Q3ListView::contentsMousePressEvent(e); - Q3ListViewItem *item=selectedItem(); - if(item==NULL) { - return; - } - RD3CartDrag *d=new RD3CartDrag(item->text(1).toUInt(),item->pixmap(0), - Qt::lightGray,this); - d->dragCopy(); - - emit clicked(item); -} diff --git a/rdlogmanager/librarytableview.cpp b/rdlogmanager/librarytableview.cpp new file mode 100644 index 00000000..d30d1121 --- /dev/null +++ b/rdlogmanager/librarytableview.cpp @@ -0,0 +1,54 @@ +// librarytableview.cpp +// +// QTableView widget that supports cart dragging. +// +// (C) Copyright 2020-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 +#include +#include + +#include +#include + +#include "librarytableview.h" + +LibraryTableView::LibraryTableView(QWidget *parent) + : RDTableView(parent) +{ +} + + +void LibraryTableView::mousePressEvent(QMouseEvent *e) +{ + QTableView::mousePressEvent(e); + + if(dragEnabled()&&(e->button()==Qt::LeftButton)) { + RDLibraryModel *mod=(RDLibraryModel *)model(); + QModelIndex index=indexAt(e->pos()); + QDrag *drag=new QDrag(this); + RDCartDrag *cd= + new RDCartDrag(mod->cartNumber(index), + mod->data(mod->index(index.row(),4)).toString(), + mod->data(mod->index(index.row(),0),Qt::TextColorRole). + value()); + drag->setMimeData(cd); + drag->setPixmap(mod->data(mod->index(index.row(),0),Qt::DecorationRole). + value()); + drag->exec(); + } +} diff --git a/rdlogmanager/lib_listview.h b/rdlogmanager/librarytableview.h similarity index 61% rename from rdlogmanager/lib_listview.h rename to rdlogmanager/librarytableview.h index c683c518..7650faff 100644 --- a/rdlogmanager/lib_listview.h +++ b/rdlogmanager/librarytableview.h @@ -1,14 +1,13 @@ -// lib_listview.h +// librarytableview.h // -// The Library ListView widget for RDLogManager. +// QTableView widget that supports cart dragging. // -// (C) Copyright 2002-2018 Fred Gleason +// (C) Copyright 2020-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 @@ -18,27 +17,21 @@ // License along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -// -#ifndef LIB_LISTVIEW_H -#define LIB_LISTVIEW_H +#ifndef LIBRARYTABLEVIEW_H +#define LIBRARYTABLEVIEW_H -#include -#include -//Added by qt3to4: -#include -#include +#include -class LibListView : public Q3ListView +class LibraryTableView : public RDTableView { Q_OBJECT - public: - LibListView(QWidget *parent); + LibraryTableView(QWidget *parent); protected: - void contentsMousePressEvent(QMouseEvent *e); + void mousePressEvent(QMouseEvent *e); }; -#endif // LIB_LISTVIEW_H +#endif // LIBRARYTABLEVIEW diff --git a/rdlogmanager/rdlogmanager.pro b/rdlogmanager/rdlogmanager.pro index 6751001e..86e3b29d 100644 --- a/rdlogmanager/rdlogmanager.pro +++ b/rdlogmanager/rdlogmanager.pro @@ -39,7 +39,7 @@ SOURCES += edit_schedcoderules.cpp SOURCES += edit_track.cpp SOURCES += generate_log.cpp SOURCES += import_listview.cpp -SOURCES += lib_listview.cpp +SOURCES += librarytableview.cpp SOURCES += list_clocks.cpp SOURCES += list_events.cpp SOURCES += list_grids.cpp @@ -65,7 +65,7 @@ HEADERS += edit_track.h HEADERS += generate_log.h HEADERS += globals.h HEADERS += import_listview.h -HEADERS += lib_listview.h +HEADERS += librarytableview.h HEADERS += list_clocks.h HEADERS += list_events.h HEADERS += list_grids.h diff --git a/rdlogmanager/rdlogmanager_cs.ts b/rdlogmanager/rdlogmanager_cs.ts index e629527f..ac52d192 100644 --- a/rdlogmanager/rdlogmanager_cs.ts +++ b/rdlogmanager/rdlogmanager_cs.ts @@ -285,7 +285,7 @@ Chcete je uložit? ALL - VŠE + VŠE PRE-POSITION LOG @@ -477,11 +477,11 @@ Chcete ji přepsat? Audio - Zvuk + Zvuk Macro - Makro + Makro Cue @@ -575,21 +575,13 @@ Chcete ji přepsat? Title - - Artist - - Start - Začátek + Začátek End - Konec - - - Type - + Konec Transition diff --git a/rdlogmanager/rdlogmanager_de.ts b/rdlogmanager/rdlogmanager_de.ts index 83127a0f..5bc86c4a 100644 --- a/rdlogmanager/rdlogmanager_de.ts +++ b/rdlogmanager/rdlogmanager_de.ts @@ -285,7 +285,7 @@ Wollen Sie sie speichern? ALL - ALLE + ALLE PRE-POSITION LOG @@ -477,11 +477,11 @@ Wollen Sie es überschreiben? Audio - Audio + Audio Macro - Makro + Makro Cue @@ -575,21 +575,13 @@ Wollen Sie es überschreiben? Title - - Artist - - Start - Start + Start End - Ende - - - Type - + Ende Transition diff --git a/rdlogmanager/rdlogmanager_es.ts b/rdlogmanager/rdlogmanager_es.ts index de5aecd9..c84ecc82 100644 --- a/rdlogmanager/rdlogmanager_es.ts +++ b/rdlogmanager/rdlogmanager_es.ts @@ -287,7 +287,7 @@ horario ALL - TODO + TODO PRE-POSITION LOG @@ -441,11 +441,11 @@ List Audio - Audio + Audio Macro - Macro + Macro Cue @@ -577,21 +577,13 @@ Do you want to overwrite it? Title - - Artist - - Start - Inicio + Inicio End - Fin - - - Type - + Fin Transition diff --git a/rdlogmanager/rdlogmanager_fr.ts b/rdlogmanager/rdlogmanager_fr.ts index e7ff2ed5..ebc22d7a 100644 --- a/rdlogmanager/rdlogmanager_fr.ts +++ b/rdlogmanager/rdlogmanager_fr.ts @@ -227,10 +227,6 @@ Do you want to save? Macros Only - - ALL - - PRE-POSITION LOG @@ -385,14 +381,6 @@ Do you want to overwrite it? Edit Event - - Audio - - - - Macro - - Len: @@ -425,22 +413,6 @@ Do you want to overwrite it? Title - - Artist - - - - Start - - - - End - - - - Type - - Transition diff --git a/rdlogmanager/rdlogmanager_nb.ts b/rdlogmanager/rdlogmanager_nb.ts index 1b71148d..a2ee4068 100644 --- a/rdlogmanager/rdlogmanager_nb.ts +++ b/rdlogmanager/rdlogmanager_nb.ts @@ -282,7 +282,7 @@ Vil du lagra? ALL - ALT + ALT PRE-POSITION LOG @@ -478,11 +478,11 @@ Vil du byta henne ut? Audio - Lyd + Lyd Macro - Makro + Makro Cue @@ -576,21 +576,13 @@ Vil du byta henne ut? Title - - Artist - - Start - Start + Start End - Slutt - - - Type - + Slutt Transition diff --git a/rdlogmanager/rdlogmanager_nn.ts b/rdlogmanager/rdlogmanager_nn.ts index 1b71148d..a2ee4068 100644 --- a/rdlogmanager/rdlogmanager_nn.ts +++ b/rdlogmanager/rdlogmanager_nn.ts @@ -282,7 +282,7 @@ Vil du lagra? ALL - ALT + ALT PRE-POSITION LOG @@ -478,11 +478,11 @@ Vil du byta henne ut? Audio - Lyd + Lyd Macro - Makro + Makro Cue @@ -576,21 +576,13 @@ Vil du byta henne ut? Title - - Artist - - Start - Start + Start End - Slutt - - - Type - + Slutt Transition diff --git a/rdlogmanager/rdlogmanager_pt_BR.ts b/rdlogmanager/rdlogmanager_pt_BR.ts index 8f3c32f4..ecbcea22 100644 --- a/rdlogmanager/rdlogmanager_pt_BR.ts +++ b/rdlogmanager/rdlogmanager_pt_BR.ts @@ -291,7 +291,7 @@ Você quer salvar? ALL - TODOS + TODOS PRE-POSITION LOG @@ -487,11 +487,11 @@ Você quer sobreescrêve-lo? Audio - Áudio + Áudio Macro - Macro + Macro Cue @@ -577,21 +577,13 @@ Você quer sobreescrêve-lo? Title - - Artist - - Start - Início + Início End - Fim - - - Type - + Fim Transition