diff options
author | Chris Xiong <chirs241097@gmail.com> | 2019-10-08 11:18:27 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2019-10-08 11:18:27 +0800 |
commit | 3032c0021389b2a5211b4a6e5d1c2929ce307bf5 (patch) | |
tree | 4e9ec46dc450358ee2693e3fc3949d6fe2a65b0d /qmidiplayer-desktop/qmpsettingswindow.cpp | |
parent | dfdd98ae185a46949b668d01fcce3f5f2646970a (diff) | |
download | QMidiPlayer-3032c0021389b2a5211b4a6e5d1c2929ce307bf5.tar.xz |
Continue reducing usage of widgets in QTableWidget.
Diffstat (limited to 'qmidiplayer-desktop/qmpsettingswindow.cpp')
-rw-r--r-- | qmidiplayer-desktop/qmpsettingswindow.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/qmidiplayer-desktop/qmpsettingswindow.cpp b/qmidiplayer-desktop/qmpsettingswindow.cpp index 3aef529..ee08fb9 100644 --- a/qmidiplayer-desktop/qmpsettingswindow.cpp +++ b/qmidiplayer-desktop/qmpsettingswindow.cpp @@ -288,7 +288,7 @@ void qmpSettingsWindow::settingsUpdate() for(int i=0;i<ui->twPluginList->rowCount();++i) settings->setValue( QString("PluginSwitch/")+ui->twPluginList->item(i,1)->text(), - ((QCheckBox*)ui->twPluginList->cellWidget(i,0))->isChecked()?1:0); + ui->twPluginList->item(i,0)->checkState()==Qt::CheckState::Checked?1:0); updateCustomOptions(); settings->sync(); } @@ -360,11 +360,12 @@ void qmpSettingsWindow::updatePluginList(qmpPluginManager *pmgr) for(unsigned i=0;i<plugins->size();++i) { ui->twPluginList->insertRow(i); - ui->twPluginList->setCellWidget(i,0,new QCheckBox("")); - if(settings->value(QString("PluginSwitch/")+QString(plugins->at(i).name.c_str()),1).toInt()) - {((QCheckBox*)ui->twPluginList->cellWidget(i,0))->setChecked(true);plugins->at(i).enabled=true;} - else - {((QCheckBox*)ui->twPluginList->cellWidget(i,0))->setChecked(false);plugins->at(i).enabled=false;} + QTableWidgetItem *icb; + ui->twPluginList->setItem(i,0,icb=new QTableWidgetItem()); + bool enabled=settings->value(QString("PluginSwitch/")+QString(plugins->at(i).name.c_str()),1).toInt(); + icb->setCheckState(enabled?Qt::CheckState::Checked:Qt::CheckState::Unchecked); + icb->setFlags(Qt::ItemFlag::ItemIsEnabled|Qt::ItemFlag::ItemIsSelectable|Qt::ItemFlag::ItemIsUserCheckable); + plugins->at(i).enabled=enabled; ui->twPluginList->setItem(i,1,new QTableWidgetItem(plugins->at(i).name.c_str())); ui->twPluginList->setItem(i,2,new QTableWidgetItem(plugins->at(i).version.c_str())); ui->twPluginList->setItem(i,3,new QTableWidgetItem(plugins->at(i).path.c_str())); |