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 )
QPushButton *addButton = new QPushButton( qtr( "Create" ) );
addButton->setToolTip( qtr( "Create a new bookmark" ) );
buttonsBox->addButton( addButton, QDialogButtonBox::ActionRole );
QPushButton *delButton = new QPushButton( qtr( "Delete" ) );
delButton = new QPushButton( qtr( "Delete" ) );
delButton->setToolTip( qtr( "Delete the selected item" ) );
buttonsBox->addButton( delButton, QDialogButtonBox::ActionRole );
QPushButton *clearButton = new QPushButton( qtr( "Clear" ) );
clearButton = new QPushButton( qtr( "Clear" ) );
clearButton->setToolTip( qtr( "Delete all the bookmarks" ) );
buttonsBox->addButton( clearButton, QDialogButtonBox::ResetRole );
#if 0
......@@ -85,14 +85,21 @@ BookmarksDialog::BookmarksDialog( intf_thread_t *_p_intf ):QVLCFrame( _p_intf )
activateItem( QModelIndex ) );
CONNECT( bookmarksList, itemChanged( 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( delButton, del() );
BUTTONACT( clearButton, clear() );
#if 0
BUTTONACT( extractButton, extract() );
#endif
CONNECT( buttonsBox, rejected(), this, close() );
updateButtons();
restoreWidgetPosition( "Bookmarks", QSize( 435, 280 ) );
updateGeometry();
......@@ -103,6 +110,12 @@ BookmarksDialog::~BookmarksDialog()
saveWidgetPosition( "Bookmarks" );
}
void BookmarksDialog::updateButtons()
{
clearButton->setEnabled( bookmarksList->model()->rowCount() > 0 );
delButton->setEnabled( bookmarksList->selectionModel()->hasSelection() );
}
void BookmarksDialog::update()
{
input_thread_t *p_input = THEMIM->getInput();
......
......@@ -30,6 +30,7 @@
#include <QTreeView>
#include <QTreeWidget>
#include "util/singleton.hpp"
class QPushButton;
class BookmarksDialog : public QVLCFrame, public Singleton<BookmarksDialog>
{
......@@ -39,6 +40,8 @@ private:
virtual ~BookmarksDialog();
QTreeWidget *bookmarksList;
QPushButton *clearButton;
QPushButton *delButton;
private slots:
void update();
......@@ -48,6 +51,7 @@ private slots:
void edit( QTreeWidgetItem *item, int column );
void extract();
void activateItem( QModelIndex index );
void updateButtons();
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