GUI: refactoring librarydialog

This commit is contained in:
Daniel Marjamäki 2015-08-30 18:37:12 +02:00
parent c5a8ecb6f9
commit a65fabebce
2 changed files with 21 additions and 16 deletions

View File

@ -151,17 +151,15 @@ void LibraryDialog::editArg()
LibraryEditArgDialog *d = new LibraryEditArgDialog(0, arg);
if (d->exec() == QDialog::Accepted) {
arg = d->getArg();
updateArguments(function);
ui->arguments->selectedItems().first()->setText(getArgText(arg));
}
delete d;
ui->buttonSave->setEnabled(true);
}
void LibraryDialog::updateArguments(const CppcheckLibraryData::Function &function)
QString LibraryDialog::getArgText(const CppcheckLibraryData::Function::Arg &arg)
{
ui->arguments->clear();
foreach(const CppcheckLibraryData::Function::Arg &arg, function.args) {
QString s("arg");
if (arg.nr != CppcheckLibraryData::Function::Arg::ANY)
s += QString::number(arg.nr);
@ -175,7 +173,13 @@ void LibraryDialog::updateArguments(const CppcheckLibraryData::Function &functio
foreach(const CppcheckLibraryData::Function::Arg::MinSize &minsize, arg.minsizes) {
s += "\n minsize: " + minsize.type + " " + minsize.arg + " " + minsize.arg2;
}
return s;
}
ui->arguments->addItem(s);
void LibraryDialog::updateArguments(const CppcheckLibraryData::Function &function)
{
ui->arguments->clear();
foreach(const CppcheckLibraryData::Function::Arg &arg, function.args) {
ui->arguments->addItem(getArgText(arg));
}
}

View File

@ -51,6 +51,7 @@ private:
QString mFileName;
bool ignoreChanges;
static QString getArgText(const CppcheckLibraryData::Function::Arg &arg);
void updateArguments(const CppcheckLibraryData::Function &function);
};