Commit 1debd199 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: Bookmarks: correctly apply buttons states

parent 4bea14e2
...@@ -45,10 +45,10 @@ BookmarksDialog::BookmarksDialog( intf_thread_t *_p_intf ):QVLCFrame( _p_intf ) ...@@ -45,10 +45,10 @@ BookmarksDialog::BookmarksDialog( intf_thread_t *_p_intf ):QVLCFrame( _p_intf )
QPushButton *addButton = new QPushButton( qtr( "Create" ) ); QPushButton *addButton = new QPushButton( qtr( "Create" ) );
addButton->setToolTip( qtr( "Create a new bookmark" ) ); addButton->setToolTip( qtr( "Create a new bookmark" ) );
buttonsBox->addButton( addButton, QDialogButtonBox::ActionRole ); buttonsBox->addButton( addButton, QDialogButtonBox::ActionRole );
QPushButton *delButton = new QPushButton( qtr( "Delete" ) ); delButton = new QPushButton( qtr( "Delete" ) );
delButton->setToolTip( qtr( "Delete the selected item" ) ); delButton->setToolTip( qtr( "Delete the selected item" ) );
buttonsBox->addButton( delButton, QDialogButtonBox::ActionRole ); buttonsBox->addButton( delButton, QDialogButtonBox::ActionRole );
QPushButton *clearButton = new QPushButton( qtr( "Clear" ) ); clearButton = new QPushButton( qtr( "Clear" ) );
clearButton->setToolTip( qtr( "Delete all the bookmarks" ) ); clearButton->setToolTip( qtr( "Delete all the bookmarks" ) );
buttonsBox->addButton( clearButton, QDialogButtonBox::ResetRole ); buttonsBox->addButton( clearButton, QDialogButtonBox::ResetRole );
#if 0 #if 0
...@@ -85,14 +85,21 @@ BookmarksDialog::BookmarksDialog( intf_thread_t *_p_intf ):QVLCFrame( _p_intf ) ...@@ -85,14 +85,21 @@ BookmarksDialog::BookmarksDialog( intf_thread_t *_p_intf ):QVLCFrame( _p_intf )
activateItem( QModelIndex ) ); activateItem( QModelIndex ) );
CONNECT( bookmarksList, itemChanged( QTreeWidgetItem*, int ), CONNECT( bookmarksList, itemChanged( QTreeWidgetItem*, int ),
this, edit( QTreeWidgetItem*, int ) ); this, edit( QTreeWidgetItem*, int ) );
CONNECT( bookmarksList->model(), rowsInserted( const QModelIndex &, int, int ),
this, updateButtons() );
CONNECT( bookmarksList->model(), rowsRemoved( const QModelIndex &, int, int ),
this, updateButtons() );
CONNECT( bookmarksList->selectionModel(), selectionChanged( const QItemSelection &, const QItemSelection & ),
this, updateButtons() );
BUTTONACT( addButton, add() ); BUTTONACT( addButton, add() );
BUTTONACT( delButton, del() ); BUTTONACT( delButton, del() );
BUTTONACT( clearButton, clear() ); BUTTONACT( clearButton, clear() );
#if 0 #if 0
BUTTONACT( extractButton, extract() ); BUTTONACT( extractButton, extract() );
#endif #endif
CONNECT( buttonsBox, rejected(), this, close() ); CONNECT( buttonsBox, rejected(), this, close() );
updateButtons();
restoreWidgetPosition( "Bookmarks", QSize( 435, 280 ) ); restoreWidgetPosition( "Bookmarks", QSize( 435, 280 ) );
updateGeometry(); updateGeometry();
...@@ -103,6 +110,12 @@ BookmarksDialog::~BookmarksDialog() ...@@ -103,6 +110,12 @@ BookmarksDialog::~BookmarksDialog()
saveWidgetPosition( "Bookmarks" ); saveWidgetPosition( "Bookmarks" );
} }
void BookmarksDialog::updateButtons()
{
clearButton->setEnabled( bookmarksList->model()->rowCount() > 0 );
delButton->setEnabled( bookmarksList->selectionModel()->hasSelection() );
}
void BookmarksDialog::update() void BookmarksDialog::update()
{ {
input_thread_t *p_input = THEMIM->getInput(); input_thread_t *p_input = THEMIM->getInput();
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <QTreeView> #include <QTreeView>
#include <QTreeWidget> #include <QTreeWidget>
#include "util/singleton.hpp" #include "util/singleton.hpp"
class QPushButton;
class BookmarksDialog : public QVLCFrame, public Singleton<BookmarksDialog> class BookmarksDialog : public QVLCFrame, public Singleton<BookmarksDialog>
{ {
...@@ -39,6 +40,8 @@ private: ...@@ -39,6 +40,8 @@ private:
virtual ~BookmarksDialog(); virtual ~BookmarksDialog();
QTreeWidget *bookmarksList; QTreeWidget *bookmarksList;
QPushButton *clearButton;
QPushButton *delButton;
private slots: private slots:
void update(); void update();
...@@ -48,6 +51,7 @@ private slots: ...@@ -48,6 +51,7 @@ private slots:
void edit( QTreeWidgetItem *item, int column ); void edit( QTreeWidgetItem *item, int column );
void extract(); void extract();
void activateItem( QModelIndex index ); void activateItem( QModelIndex index );
void updateButtons();
friend class Singleton<BookmarksDialog>; friend class Singleton<BookmarksDialog>;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment