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,31 +151,35 @@ void LibraryDialog::editArg()
LibraryEditArgDialog *d = new LibraryEditArgDialog(0, arg); LibraryEditArgDialog *d = new LibraryEditArgDialog(0, arg);
if (d->exec() == QDialog::Accepted) { if (d->exec() == QDialog::Accepted) {
arg = d->getArg(); arg = d->getArg();
updateArguments(function); ui->arguments->selectedItems().first()->setText(getArgText(arg));
} }
delete d; delete d;
ui->buttonSave->setEnabled(true); ui->buttonSave->setEnabled(true);
} }
QString LibraryDialog::getArgText(const CppcheckLibraryData::Function::Arg &arg)
{
QString s("arg");
if (arg.nr != CppcheckLibraryData::Function::Arg::ANY)
s += QString::number(arg.nr);
s += "\n not bool: " + QString(arg.notbool ? "true" : "false");
s += "\n not null: " + QString(arg.notnull ? "true" : "false");
s += "\n not uninit: " + QString(arg.notuninit ? "true" : "false");
s += "\n format string: " + QString(arg.formatstr ? "true" : "false");
s += "\n strz: " + QString(arg.strz ? "true" : "false");
s += "\n valid: " + QString(arg.valid.isEmpty() ? "any" : arg.valid);
foreach(const CppcheckLibraryData::Function::Arg::MinSize &minsize, arg.minsizes) {
s += "\n minsize: " + minsize.type + " " + minsize.arg + " " + minsize.arg2;
}
return s;
}
void LibraryDialog::updateArguments(const CppcheckLibraryData::Function &function) void LibraryDialog::updateArguments(const CppcheckLibraryData::Function &function)
{ {
ui->arguments->clear(); ui->arguments->clear();
foreach(const CppcheckLibraryData::Function::Arg &arg, function.args) { foreach(const CppcheckLibraryData::Function::Arg &arg, function.args) {
QString s("arg"); ui->arguments->addItem(getArgText(arg));
if (arg.nr != CppcheckLibraryData::Function::Arg::ANY)
s += QString::number(arg.nr);
s += "\n not bool: " + QString(arg.notbool ? "true" : "false");
s += "\n not null: " + QString(arg.notnull ? "true" : "false");
s += "\n not uninit: " + QString(arg.notuninit ? "true" : "false");
s += "\n format string: " + QString(arg.formatstr ? "true" : "false");
s += "\n strz: " + QString(arg.strz ? "true" : "false");
s += "\n valid: " + QString(arg.valid.isEmpty() ? "any" : arg.valid);
foreach(const CppcheckLibraryData::Function::Arg::MinSize &minsize, arg.minsizes) {
s += "\n minsize: " + minsize.type + " " + minsize.arg + " " + minsize.arg2;
}
ui->arguments->addItem(s);
} }
} }

View File

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