From 456e3d0b4986916c01c6ee6da40bfea426be1b66 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Tue, 15 Dec 2020 19:25:36 -0500 Subject: [PATCH] 2020-12-15 Fred Gleason * Added a right-click menu to the 'Edit Log' dialog in rdlogedit(1). Signed-off-by: Fred Gleason --- ChangeLog | 3 + lib/rdlogmodel.cpp | 13 ++ lib/rdlogmodel.h | 1 + rdlogedit/Makefile.am | 4 +- rdlogedit/drop_tableview.cpp | 55 -------- rdlogedit/edit_log.cpp | 12 +- rdlogedit/edit_log.h | 6 +- rdlogedit/logtableview.cpp | 119 ++++++++++++++++++ .../{drop_tableview.h => logtableview.h} | 27 +++- rdlogedit/rdlogedit.pro | 4 +- rdlogedit/rdlogedit_cs.ts | 15 +++ rdlogedit/rdlogedit_de.ts | 15 +++ rdlogedit/rdlogedit_es.ts | 15 +++ rdlogedit/rdlogedit_fr.ts | 15 +++ rdlogedit/rdlogedit_nb.ts | 15 +++ rdlogedit/rdlogedit_nn.ts | 15 +++ rdlogedit/rdlogedit_pt_BR.ts | 15 +++ 17 files changed, 281 insertions(+), 68 deletions(-) delete mode 100644 rdlogedit/drop_tableview.cpp create mode 100644 rdlogedit/logtableview.cpp rename rdlogedit/{drop_tableview.h => logtableview.h} (70%) diff --git a/ChangeLog b/ChangeLog index c61c15bd..3a5fedaf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20698,3 +20698,6 @@ logs owning service. 2020-12-15 Fred Gleason * Modified rdcastmanager(1) to use the standard log model. +2020-12-15 Fred Gleason + * Added a right-click menu to the 'Edit Log' dialog in + rdlogedit(1). diff --git a/lib/rdlogmodel.cpp b/lib/rdlogmodel.cpp index b9fdc82c..f40756ab 100644 --- a/lib/rdlogmodel.cpp +++ b/lib/rdlogmodel.cpp @@ -1020,6 +1020,19 @@ QString RDLogModel::xml() const } +void RDLogModel::setTransition(int line,RDLogLine::TransType trans) +{ + RDLogLine *ll=NULL; + + if((ll=logLine(line))!=NULL) { + if(ll->transType()!=trans) { + ll->setTransType(trans); + emitDataChanged(line); + } + } +} + + void RDLogModel::processNotification(RDNotification *notify) { RDLogLine *ll=NULL; diff --git a/lib/rdlogmodel.h b/lib/rdlogmodel.h index 2e0d2f11..902a399e 100644 --- a/lib/rdlogmodel.h +++ b/lib/rdlogmodel.h @@ -82,6 +82,7 @@ class RDLogModel : public QAbstractTableModel QString xml() const; public slots: + void setTransition(int line,RDLogLine::TransType trans); void processNotification(RDNotification *notify); void setStartTimeStyle(StartTimeStyle style); diff --git a/rdlogedit/Makefile.am b/rdlogedit/Makefile.am index b9a31514..8476c7ad 100644 --- a/rdlogedit/Makefile.am +++ b/rdlogedit/Makefile.am @@ -41,7 +41,6 @@ all: bin_PROGRAMS = rdlogedit dist_rdlogedit_SOURCES = add_meta.cpp add_meta.h\ - drop_tableview.cpp drop_tableview.h\ edit_chain.cpp edit_chain.h\ edit_event.cpp edit_event.h\ edit_log.cpp edit_log.h\ @@ -52,12 +51,12 @@ dist_rdlogedit_SOURCES = add_meta.cpp add_meta.h\ list_reports.cpp list_reports.h\ log_listview.cpp log_listview.h\ logmodel.cpp logmodel.h\ + logtableview.cpp logtableview.h\ rdlogedit.cpp rdlogedit.h globals.h\ render_dialog.cpp render_dialog.h\ voice_tracker.cpp voice_tracker.h nodist_rdlogedit_SOURCES = moc_add_meta.cpp\ - moc_drop_tableview.cpp\ moc_edit_chain.cpp\ moc_edit_event.cpp\ moc_edit_log.cpp\ @@ -67,6 +66,7 @@ nodist_rdlogedit_SOURCES = moc_add_meta.cpp\ moc_list_reports.cpp\ moc_log_listview.cpp\ moc_logmodel.cpp\ + moc_logtableview.cpp\ moc_rdlogedit.cpp\ moc_render_dialog.cpp\ moc_voice_tracker.cpp diff --git a/rdlogedit/drop_tableview.cpp b/rdlogedit/drop_tableview.cpp deleted file mode 100644 index 64adb5df..00000000 --- a/rdlogedit/drop_tableview.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// drop_tableview.cpp -// -// The Log TableView widget for RDLogEdit. -// -// (C) Copyright 2002-2020 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 "drop_tableview.h" - -DropTableView::DropTableView(QWidget *parent) - : QTableView(parent) -{ - setAcceptDrops(true); -} - - -void DropTableView::dragEnterEvent(QDragEnterEvent *e) -{ - e->accept(RDCartDrag::canDecode(e)); -} - - -void DropTableView::dragMoveEvent(QDragMoveEvent *e) -{ - e->accept(RDCartDrag::canDecode(e)); -} - - -void DropTableView::dropEvent(QDropEvent *e) -{ - RDLogLine ll; - int line=-1; - int y_pos=e->pos().y(); - - if(RDCartDrag::decode(e,&ll)) { - line=rowAt(y_pos); - emit cartDropped(line,&ll); - } -} diff --git a/rdlogedit/edit_log.cpp b/rdlogedit/edit_log.cpp index a5481ce4..3fa014be 100644 --- a/rdlogedit/edit_log.cpp +++ b/rdlogedit/edit_log.cpp @@ -264,7 +264,7 @@ EditLog::EditLog(QString logname,QString *filter,QString *group, // // Log Event View // - edit_log_view=new DropTableView(this); + edit_log_view=new LogTableView(this); edit_log_view->setSelectionBehavior(QAbstractItemView::SelectRows); edit_log_view->setSelectionMode(QAbstractItemView::ContiguousSelection); edit_log_view->setShowGrid(false); @@ -276,6 +276,9 @@ EditLog::EditLog(QString logname,QString *filter,QString *group, edit_log_model->load(true); edit_log_view->setModel(edit_log_model); edit_log_view->resizeColumnsToContents(); + connect(edit_log_model, + SIGNAL(dataChanged(const QModelIndex &,const QModelIndex &)), + this,SLOT(dataChangedData(const QModelIndex &,const QModelIndex &))); connect(edit_log_view,SIGNAL(doubleClicked(const QModelIndex &)), this,SLOT(doubleClickedData(const QModelIndex &))); connect(edit_log_view,SIGNAL(clicked(const QModelIndex &)), @@ -595,6 +598,13 @@ int EditLog::exec() } +void EditLog::dataChangedData(const QModelIndex &top_left, + const QModelIndex &bottom_right) +{ + SetLogModified(true); +} + + void EditLog::descriptionChangedData(const QString &) { SetLogModified(true); diff --git a/rdlogedit/edit_log.h b/rdlogedit/edit_log.h index a53ba82a..b892076b 100644 --- a/rdlogedit/edit_log.h +++ b/rdlogedit/edit_log.h @@ -31,9 +31,9 @@ #include #include -#include "drop_tableview.h" #include "list_reports.h" #include "logmodel.h" +#include "logtableview.h" #include "render_dialog.h" #define RDLOGEDIT_EDITLOG_DEFAULT_WIDTH 950 @@ -54,6 +54,8 @@ class EditLog : public RDDialog int exec(); private slots: + void dataChangedData(const QModelIndex &top_left, + const QModelIndex &bottom_right); void descriptionChangedData(const QString &); void purgeDateChangedData(const QDate &date); void purgeDateToggledData(bool state); @@ -168,7 +170,7 @@ class EditLog : public RDDialog RDLogLock *edit_log_lock; QPushButton *edit_renderas_button; RenderDialog *edit_render_dialog; - DropTableView *edit_log_view; + LogTableView *edit_log_view; LogModel *edit_log_model; }; diff --git a/rdlogedit/logtableview.cpp b/rdlogedit/logtableview.cpp new file mode 100644 index 00000000..7295bfe6 --- /dev/null +++ b/rdlogedit/logtableview.cpp @@ -0,0 +1,119 @@ +// logtableview.cpp +// +// TableView widget for RDLogEdit +// +// (C) Copyright 2002-2020 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 "logtableview.h" +#include "logmodel.h" + +LogTableView::LogTableView(QWidget *parent) + : QTableView(parent) +{ + d_mouse_row=-1; + + setAcceptDrops(true); + + // + // Mouse menu + // + d_mouse_menu=new QMenu(this); + d_play_action=d_mouse_menu-> + addAction(tr("PLAY Transition"),this,SLOT(setPlayData())); + d_play_action->setCheckable(true); + d_segue_action=d_mouse_menu-> + addAction(tr("SEGUE Transition"),this,SLOT(setSegueData())); + d_segue_action->setCheckable(true); + d_stop_action=d_mouse_menu-> + addAction(tr("STOP Transition"),this,SLOT(setStopData())); + d_stop_action->setCheckable(true); + connect(d_mouse_menu,SIGNAL(aboutToShow()), + this,SLOT(aboutToShowMenuData())); + +} + + +void LogTableView::dragEnterEvent(QDragEnterEvent *e) +{ + e->accept(RDCartDrag::canDecode(e)); +} + + +void LogTableView::dragMoveEvent(QDragMoveEvent *e) +{ + e->accept(RDCartDrag::canDecode(e)); +} + + +void LogTableView::dropEvent(QDropEvent *e) +{ + RDLogLine ll; + int line=-1; + int y_pos=e->pos().y(); + + if(RDCartDrag::decode(e,&ll)) { + line=rowAt(y_pos); + emit cartDropped(line,&ll); + } +} + + +void LogTableView::mousePressEvent(QMouseEvent *e) +{ + if(e->button()==Qt::RightButton) { + d_mouse_row=indexAt(e->pos()).row(); + if((d_mouse_row>=0)&&(d_mouse_row<(model()->rowCount()-1))) { + d_mouse_menu->popup(e->globalPos()); + } + else { + d_mouse_row=-1; + } + } + QTableView::mousePressEvent(e); +} + + +void LogTableView::aboutToShowMenuData() +{ + RDLogLine *ll=((LogModel *)model())->logLine(d_mouse_row); + if(ll!=NULL) { + d_play_action->setChecked(ll->transType()==RDLogLine::Play); + d_segue_action->setChecked(ll->transType()==RDLogLine::Segue); + d_stop_action->setChecked(ll->transType()==RDLogLine::Stop); + } +} + + +void LogTableView::setPlayData() +{ + ((LogModel *)model())->setTransition(d_mouse_row,RDLogLine::Play); +} + + +void LogTableView::setSegueData() +{ + ((LogModel *)model())->setTransition(d_mouse_row,RDLogLine::Segue); +} + + +void LogTableView::setStopData() +{ + ((LogModel *)model())->setTransition(d_mouse_row,RDLogLine::Stop); +} diff --git a/rdlogedit/drop_tableview.h b/rdlogedit/logtableview.h similarity index 70% rename from rdlogedit/drop_tableview.h rename to rdlogedit/logtableview.h index 874f9ad6..c2fec7ab 100644 --- a/rdlogedit/drop_tableview.h +++ b/rdlogedit/logtableview.h @@ -1,4 +1,4 @@ -// drop_tableview.h +// logtableview.h // // The Log TableView widget for RDLogEdit. // @@ -19,20 +19,21 @@ // // -#ifndef DROP_TABLEVIEW_H -#define DROP_TABLEVIEW_H +#ifndef LOGTABLEVIEW_H +#define LOGTABLEVIEW_H #include #include +#include #include #include -class DropTableView : public QTableView +class LogTableView : public QTableView { Q_OBJECT public: - DropTableView(QWidget *parent); + LogTableView(QWidget *parent); signals: void cartDropped(int line,RDLogLine *ll); @@ -41,7 +42,21 @@ class DropTableView : public QTableView void dragEnterEvent(QDragEnterEvent *e); void dragMoveEvent(QDragMoveEvent *e); void dropEvent(QDropEvent *e); + void mousePressEvent(QMouseEvent *e); + + private slots: + void aboutToShowMenuData(); + void setPlayData(); + void setSegueData(); + void setStopData(); + + private: + int d_mouse_row; + QMenu *d_mouse_menu; + QAction *d_play_action; + QAction *d_segue_action; + QAction *d_stop_action; }; -#endif // DROP_TABLEVIEW_H +#endif // LOGTABLEVIEW_H diff --git a/rdlogedit/rdlogedit.pro b/rdlogedit/rdlogedit.pro index a2790574..3b407ee4 100644 --- a/rdlogedit/rdlogedit.pro +++ b/rdlogedit/rdlogedit.pro @@ -25,7 +25,6 @@ # SOURCES += add_meta.cpp -SOURCES += drop_tableview.cpp SOURCES += edit_chain.cpp SOURCES += edit_log.cpp SOURCES += edit_logline.cpp @@ -34,12 +33,12 @@ SOURCES += edit_track.cpp SOURCES += list_listviewitem.cpp SOURCES += list_reports.cpp SOURCES += logmodel.cpp +SOURCES += logtableview.cpp SOURCES += rdlogedit.cpp SOURCES += render_dialog.cpp SOURCES += voice_tracker.cpp HEADERS += add_meta.h -HEADERS += drop_tableview.h HEADERS += edit_chain.h HEADERS += edit_log.h HEADERS += edit_logline.h @@ -49,6 +48,7 @@ HEADERS += globals.h HEADERS += list_listviewitem.h HEADERS += list_reports.h HEADERS += logmodel.h +HEADERS += logtableview.h HEADERS += rdlogedit.h HEADERS += render_dialog.h HEADERS += voice_tracker.h diff --git a/rdlogedit/rdlogedit_cs.ts b/rdlogedit/rdlogedit_cs.ts index 93e7f675..635b98f2 100644 --- a/rdlogedit/rdlogedit_cs.ts +++ b/rdlogedit/rdlogedit_cs.ts @@ -763,6 +763,21 @@ vybrané služby! + + LogTableView + + PLAY Transition + + + + SEGUE Transition + + + + STOP Transition + + + MainWidget diff --git a/rdlogedit/rdlogedit_de.ts b/rdlogedit/rdlogedit_de.ts index 92723479..19f519b1 100644 --- a/rdlogedit/rdlogedit_de.ts +++ b/rdlogedit/rdlogedit_de.ts @@ -763,6 +763,21 @@ Gruppe des ausgewählten Service! + + LogTableView + + PLAY Transition + + + + SEGUE Transition + + + + STOP Transition + + + MainWidget diff --git a/rdlogedit/rdlogedit_es.ts b/rdlogedit/rdlogedit_es.ts index 64a59332..4b0ca732 100644 --- a/rdlogedit/rdlogedit_es.ts +++ b/rdlogedit/rdlogedit_es.ts @@ -767,6 +767,21 @@ desactivado para el servicio especificado! + + LogTableView + + PLAY Transition + + + + SEGUE Transition + + + + STOP Transition + + + MainWidget diff --git a/rdlogedit/rdlogedit_fr.ts b/rdlogedit/rdlogedit_fr.ts index e4fa5788..f9b8441d 100644 --- a/rdlogedit/rdlogedit_fr.ts +++ b/rdlogedit/rdlogedit_fr.ts @@ -363,6 +363,21 @@ group for the specified service! + + LogTableView + + PLAY Transition + + + + SEGUE Transition + + + + STOP Transition + + + MainWidget diff --git a/rdlogedit/rdlogedit_nb.ts b/rdlogedit/rdlogedit_nb.ts index db9843e4..21d94ed4 100644 --- a/rdlogedit/rdlogedit_nb.ts +++ b/rdlogedit/rdlogedit_nb.ts @@ -777,6 +777,21 @@ som er skrudd av for denne tenesta! + + LogTableView + + PLAY Transition + + + + SEGUE Transition + + + + STOP Transition + + + MainWidget diff --git a/rdlogedit/rdlogedit_nn.ts b/rdlogedit/rdlogedit_nn.ts index db9843e4..21d94ed4 100644 --- a/rdlogedit/rdlogedit_nn.ts +++ b/rdlogedit/rdlogedit_nn.ts @@ -777,6 +777,21 @@ som er skrudd av for denne tenesta! + + LogTableView + + PLAY Transition + + + + SEGUE Transition + + + + STOP Transition + + + MainWidget diff --git a/rdlogedit/rdlogedit_pt_BR.ts b/rdlogedit/rdlogedit_pt_BR.ts index 9472ad25..63d92fcc 100644 --- a/rdlogedit/rdlogedit_pt_BR.ts +++ b/rdlogedit/rdlogedit_pt_BR.ts @@ -769,6 +769,21 @@ Ação se Evento anterior estiver sendo executado + + LogTableView + + PLAY Transition + + + + SEGUE Transition + + + + STOP Transition + + + MainWidget