vlc | branch: master | Daniel Amm <[email protected]> | Mon Jun 15 18:19:46 2015 +0200| [1a2f7b20412973d6748bd3188130aba7b6d5e855] | committer: Jean-Baptiste Kempf
Qt: extension dialog: update checkboxes if a check state was changed Signed-off-by: Jean-Baptiste Kempf <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1a2f7b20412973d6748bd3188130aba7b6d5e855 --- modules/gui/qt4/components/simple_preferences.cpp | 43 +++++++++++++++++++++ modules/gui/qt4/components/simple_preferences.hpp | 1 + 2 files changed, 44 insertions(+) diff --git a/modules/gui/qt4/components/simple_preferences.cpp b/modules/gui/qt4/components/simple_preferences.cpp index 8195b18..8372700 100644 --- a/modules/gui/qt4/components/simple_preferences.cpp +++ b/modules/gui/qt4/components/simple_preferences.cpp @@ -1352,6 +1352,8 @@ void SPrefsPanel::assoDialog() #undef aTv #undef aTa + CONNECT( filetypeList, itemChanged(QTreeWidgetItem*, int), this, updateCheckBoxes(QTreeWidgetItem*, int) ); + QDialogButtonBox *buttonBox = new QDialogButtonBox( d ); QPushButton *closeButton = new QPushButton( qtr( "&Apply" ) ); QPushButton *clearButton = new QPushButton( qtr( "&Cancel" ) ); @@ -1368,6 +1370,47 @@ void SPrefsPanel::assoDialog() listAsso.clear(); } +void SPrefsPanel::updateCheckBoxes(QTreeWidgetItem* item, int column) +{ + if( column != 0 ) + return; + + /* temporarily block signals to avoid signal loops */ + bool b_signalsBlocked = item->treeWidget()->blockSignals(true); + + /* A parent checkbox was changed */ + if( item->parent() == 0 ) + { + Qt::CheckState checkState = item->checkState(0); + for( int i = 0; i < item->childCount(); i++ ) + { + item->child(i)->setCheckState(0, checkState); + } + } + + /* A child checkbox was changed */ + else + { + bool b_diff = false; + for( int i = 0; i < item->parent()->childCount(); i++ ) + { + if( i != item->parent()->indexOfChild(item) && item->checkState(0) != item->parent()->child(i)->checkState(0) ) + { + b_diff = true; + break; + } + } + + if( b_diff ) + item->parent()->setCheckState(0, Qt::PartiallyChecked); + else + item->parent()->setCheckState(0, item->checkState(0)); + } + + /* Stop signal blocking */ + item->treeWidget()->blockSignals(b_signalsBlocked); +} + void addAsso( QVLCRegistry *qvReg, const char *psz_ext ) { QString s_path( "VLC" ); s_path += psz_ext; diff --git a/modules/gui/qt4/components/simple_preferences.hpp b/modules/gui/qt4/components/simple_preferences.hpp index 531fb94..8b14323 100644 --- a/modules/gui/qt4/components/simple_preferences.hpp +++ b/modules/gui/qt4/components/simple_preferences.hpp @@ -122,6 +122,7 @@ private slots: void langChanged( int ); #ifdef _WIN32 void assoDialog(); + void updateCheckBoxes( QTreeWidgetItem*, int ); void saveAsso(); #endif void configML(); _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
