Commit 1a2f7b20 authored by Daniel Amm's avatar Daniel Amm Committed by Jean-Baptiste Kempf

Qt: extension dialog: update checkboxes if a check state was changed

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent aee51fec
......@@ -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;
......
......@@ -122,6 +122,7 @@ private slots:
void langChanged( int );
#ifdef _WIN32
void assoDialog();
void updateCheckBoxes( QTreeWidgetItem*, int );
void saveAsso();
#endif
void configML();
......
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