diff --git a/ChangeLog b/ChangeLog index eea759c0..bc558315 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17999,3 +17999,5 @@ * Tweaked layout and appearance of the status bubble in rdmonitor(1). 2018-11-09 Fred Gleason * Removed superceded 'StatusTip' class from rdmonitor(1). +2018-11-09 Fred Gleason + * Restored cart note bubbles in rdlibrary(1). diff --git a/rdlibrary/Makefile.am b/rdlibrary/Makefile.am index 85a77a55..77ee38ad 100644 --- a/rdlibrary/Makefile.am +++ b/rdlibrary/Makefile.am @@ -56,6 +56,7 @@ dist_rdlibrary_SOURCES = audio_cart.cpp audio_cart.h\ lib_listview.cpp lib_listview.h\ list_reports.cpp list_reports.h\ macro_cart.cpp macro_cart.h\ + notebubble.cpp notebubble.h\ rdlibrary.cpp rdlibrary.h\ record_cut.cpp record_cut.h\ validate_cut.cpp validate_cut.h @@ -72,6 +73,7 @@ nodist_rdlibrary_SOURCES = moc_audio_cart.cpp\ moc_lib_listview.cpp\ moc_list_reports.cpp\ moc_macro_cart.cpp\ + moc_notebubble.cpp\ moc_rdlibrary.cpp\ moc_record_cut.cpp diff --git a/rdlibrary/cart_tip.cpp b/rdlibrary/cart_tip.cpp deleted file mode 100644 index 16a1bb55..00000000 --- a/rdlibrary/cart_tip.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// cart_tip.cpp -// -// Custom ToolTip for RDLibrary's Cart List -// -// (C) Copyright 2009,2016 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 - -CartTip::CartTip(QWidget *widget,QToolTipGroup *group) - : QToolTip(widget,group) -{ -} - - -void CartTip::setCartNumber(const QRect &item_rect,unsigned cartnum) -{ - RDCart *cart=new RDCart(cartnum); - tip_notes=cart->notes(); - delete cart; - tip_item_rect=item_rect; - tip_cart_number=cartnum; -} - - -void CartTip::maybeTip(const QPoint &pt) -{ - tip(tip_item_rect,tip_notes); -} diff --git a/rdlibrary/lib_listview.cpp b/rdlibrary/lib_listview.cpp index 83f98bd2..ed10bd99 100644 --- a/rdlibrary/lib_listview.cpp +++ b/rdlibrary/lib_listview.cpp @@ -30,6 +30,28 @@ LibListView::LibListView(QWidget *parent) : RDListView(parent) { list_move_count=-1; + list_note_bubbles_enabled=false; + + list_note_bubble=new NoteBubble(this); + list_note_bubble->hide(); +} + + +bool LibListView::noteBubblesEnabled() const +{ + return list_note_bubbles_enabled; +} + + +void LibListView::enableNoteBubbles(bool state) +{ + list_note_bubbles_enabled=state; +} + + +void LibListView::leaveEvent(QEvent *e) +{ + list_note_bubble->hide(); } @@ -42,10 +64,39 @@ void LibListView::contentsMousePressEvent(QMouseEvent *e) void LibListView::contentsMouseMoveEvent(QMouseEvent *e) { + RDListViewItem *item=NULL; + Q3ListView::contentsMouseMoveEvent(e); + + // + // Note Bubbles + // + if(list_note_bubbles_enabled) { + if((item=(RDListViewItem *)itemAt(contentsToViewport(e->pos())))!=NULL) { + unsigned cartnum=item->text(1).left(6).toUInt(); + if(cartnum!=list_note_bubble->cartNumber()) { + list_note_bubble->setCartNumber(cartnum); + QRect box(contentsToViewport(e->pos()).x(), + itemRect(item).y()+itemRect(item).height(), + list_note_bubble->sizeHint().width(), + list_note_bubble->sizeHint().height()); + if((box.x()+box.width())>width()) { + box.moveLeft(width()-box.width()-20); + } + if((box.y()+box.height())>height()) { + box.moveTop(height()-box.height()-20); + } + list_note_bubble->setGeometry(box); + } + } + } + + // + // Drag-n-Drop + // list_move_count--; if(list_move_count==0) { - RDListViewItem *item=(RDListViewItem *)selectedItem(); + item=(RDListViewItem *)selectedItem(); if(item==NULL) { return; diff --git a/rdlibrary/lib_listview.h b/rdlibrary/lib_listview.h index e7d70483..3c62b0b6 100644 --- a/rdlibrary/lib_listview.h +++ b/rdlibrary/lib_listview.h @@ -23,18 +23,27 @@ #include +#include "notebubble.h" + class LibListView : public RDListView { Q_OBJECT public: LibListView(QWidget *parent); + bool noteBubblesEnabled() const; + + public slots: + void enableNoteBubbles(bool state); protected: + void leaveEvent(QEvent *e); void contentsMousePressEvent(QMouseEvent *e); void contentsMouseMoveEvent(QMouseEvent *e); void contentsMouseReleaseEvent(QMouseEvent *e); private: + NoteBubble *list_note_bubble; + bool list_note_bubbles_enabled; int list_move_count; }; diff --git a/rdlibrary/notebubble.cpp b/rdlibrary/notebubble.cpp new file mode 100644 index 00000000..7863872d --- /dev/null +++ b/rdlibrary/notebubble.cpp @@ -0,0 +1,68 @@ +// notebubble.cpp +// +// Bubble for displaying a cart note +// +// (C) Copyright 2018 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 "notebubble.h" + +NoteBubble::NoteBubble(QWidget *parent) + : QLabel(parent,(Qt::WindowFlags)(Qt::WStyle_Customize| + Qt::WStyle_NoBorder| + Qt::WStyle_StaysOnTop)) +{ + note_cart_number=0; + + setAlignment(Qt::AlignLeft|Qt::AlignVCenter); + setWordWrap(true); + setMargin(5); + setStyleSheet(QString("background-color:")+RD_STATUS_BACKGROUND_COLOR); + + note_show_timer=new QTimer(this); + note_show_timer->setSingleShot(true); + connect(note_show_timer,SIGNAL(timeout()),this,SLOT(show())); +} + + +unsigned NoteBubble::cartNumber() const +{ + return note_cart_number; +} + + +bool NoteBubble::setCartNumber(unsigned cartnum) +{ + bool ret=false; + + note_show_timer->stop(); + hide(); + QString sql=QString("select NOTES from CART where ")+ + QString().sprintf("NUMBER=%u",cartnum); + RDSqlQuery *q=new RDSqlQuery(sql); + if(q->first()&&(!q->value(0).toString().trimmed().isEmpty())) { + setText(q->value(0).toString()); + note_show_timer->start(1000); + ret=true; + } + delete q; + note_cart_number=cartnum; + + return ret; +} diff --git a/rdlibrary/cart_tip.h b/rdlibrary/notebubble.h similarity index 59% rename from rdlibrary/cart_tip.h rename to rdlibrary/notebubble.h index 97fc666a..77b39e9f 100644 --- a/rdlibrary/cart_tip.h +++ b/rdlibrary/notebubble.h @@ -1,8 +1,8 @@ -// cart_tip.h +// notebubble.h // -// Custom ToolTip for RDLibrary's Cart List +// Bubble for displaying a cart note // -// (C) Copyright 2009,2016 Fred Gleason +// (C) Copyright 2018 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,24 +18,24 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#ifndef CART_TIP_H -#define CART_TIP_H +#ifndef NOTEBUBBLE_H +#define NOTEBUBBLE_H -#include +#include +#include -class CartTip : public QToolTip +class NoteBubble : public QLabel { + Q_OBJECT public: - CartTip(QWidget *widget,QToolTipGroup *group=0); - void setCartNumber(const QRect &item_rect,unsigned cartnum); - - protected: - void maybeTip(const QPoint &pt); + NoteBubble(QWidget *parent=0); + unsigned cartNumber() const; + bool setCartNumber(unsigned cartnum); private: - unsigned tip_cart_number; - QRect tip_item_rect; - QString tip_notes; + unsigned note_cart_number; + QTimer *note_show_timer; }; -#endif // CART_TIP_H + +#endif // NOTEBUBBLE_H diff --git a/rdlibrary/rdlibrary.cpp b/rdlibrary/rdlibrary.cpp index e4c1640b..4a951fec 100644 --- a/rdlibrary/rdlibrary.cpp +++ b/rdlibrary/rdlibrary.cpp @@ -324,7 +324,7 @@ MainWidget::MainWidget(QWidget *parent) lib_cart_list->setItemMargin(5); lib_cart_list->setSelectionMode(Q3ListView::Extended); lib_cart_list->setRootIsDecorated(true); - // lib_cart_tip=new CartTip(lib_cart_list->viewport()); + lib_cart_list->enableNoteBubbles(true); connect(lib_cart_list, SIGNAL(doubleClicked(Q3ListViewItem *,const QPoint &,int)), this, @@ -333,6 +333,8 @@ MainWidget::MainWidget(QWidget *parent) this,SLOT(cartClickedData())); connect(lib_cart_list,SIGNAL(onItem(Q3ListViewItem *)), this,SLOT(cartOnItemData(Q3ListViewItem *))); + connect(lib_shownotes_box,SIGNAL(toggled(bool)), + lib_cart_list,SLOT(enableNoteBubbles(bool))); lib_cart_list->addColumn(""); lib_cart_list->setColumnAlignment(Icon,Qt::AlignHCenter); lib_cart_list->addColumn(tr("Cart")); diff --git a/rdlibrary/rdlibrary.h b/rdlibrary/rdlibrary.h index d59c7c61..dc0e6ead 100644 --- a/rdlibrary/rdlibrary.h +++ b/rdlibrary/rdlibrary.h @@ -44,7 +44,6 @@ #include -//#include "cart_tip.h" #include "disk_gauge.h" #include "lib_listview.h" @@ -120,7 +119,6 @@ class MainWidget : public QWidget bool UnlockUser(); void SendNotification(RDNotification::Action action,unsigned cartnum); LibListView *lib_cart_list; - // CartTip *lib_cart_tip; QString lib_filter_text; QString lib_search_text; QPixmap *lib_playout_map;