Skip to content

Commit

Permalink
use switch
Browse files Browse the repository at this point in the history
clarify case count()==1
  • Loading branch information
octaeder committed Jan 19, 2024
1 parent ff50e9c commit 4119538
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/texdocdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,21 +161,21 @@ void TexdocDialog::itemChanged(QTableWidgetItem* item)
buttonGroup.removeButton(bt);
delete bt;
}
if (package.descriptions.count()>1){
for(const CTANDescription &description : package.descriptions){
QPushButton * langButton = new QPushButton(description.language,this);
langButton->setCheckable(true);
buttonGroup.addButton(langButton);
ui->languagesLayout->addWidget(langButton);
connect(langButton,&QPushButton::toggled,this,[=](){
ui->packageDescriptions->setHtml(description.text);
});
langButton->setChecked(true);
}
}else{
if(package.descriptions.count()>0){
ui->packageDescriptions->setHtml(package.descriptions.first().text);
}
switch(package.descriptions.count()) {
case 0: break;
case 1: ui->packageDescriptions->setHtml(package.descriptions.first().text);
break;
default:
for(const CTANDescription &description : package.descriptions){
QPushButton * langButton = new QPushButton(description.language,this);
langButton->setCheckable(true);
buttonGroup.addButton(langButton);
ui->languagesLayout->addWidget(langButton);
connect(langButton,&QPushButton::toggled,this,[=](){
ui->packageDescriptions->setHtml(description.text);
});
langButton->setChecked(true);
}
}
}

Expand Down

0 comments on commit 4119538

Please sign in to comment.