2015-08-30 13:35:02 +02:00
|
|
|
#include "libraryeditargdialog.h"
|
|
|
|
#include "ui_libraryeditargdialog.h"
|
|
|
|
|
2015-08-31 09:04:35 +02:00
|
|
|
LibraryEditArgDialog::LibraryEditArgDialog(QWidget *parent, const CppcheckLibraryData::Function::Arg &arg) :
|
2015-08-30 13:35:02 +02:00
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::LibraryEditArgDialog),
|
2015-08-31 09:04:35 +02:00
|
|
|
minsizes(arg.minsizes)
|
2015-08-30 13:35:02 +02:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
ui->notbool->setChecked(arg.notbool);
|
|
|
|
ui->notnull->setChecked(arg.notnull);
|
|
|
|
ui->notuninit->setChecked(arg.notuninit);
|
|
|
|
ui->strz->setChecked(arg.strz);
|
2015-08-31 09:04:35 +02:00
|
|
|
ui->formatstr->setChecked(arg.formatstr);
|
2015-08-30 13:35:02 +02:00
|
|
|
ui->valid->setText(arg.valid);
|
2015-08-31 09:04:35 +02:00
|
|
|
foreach(const CppcheckLibraryData::Function::Arg::MinSize &minsize, arg.minsizes) {
|
|
|
|
if (ui->minsizes->count() > 0)
|
|
|
|
ui->minsizes->addItem("and");
|
|
|
|
if (minsize.type == "argvalue")
|
|
|
|
ui->minsizes->addItem("Buffer size must be at least as many bytes as given by argument " + minsize.arg);
|
|
|
|
else if (minsize.type == "constant")
|
|
|
|
ui->minsizes->addItem("Buffer size must be at least " + minsize.arg + " bytes");
|
|
|
|
else if (minsize.type == "mul")
|
|
|
|
ui->minsizes->addItem("Buffer size must be at least as many bytes as multiplication result of argument " + minsize.arg + " and " + minsize.arg2);
|
|
|
|
else if (minsize.type == "strlen")
|
|
|
|
ui->minsizes->addItem("Buffer size must be at least as big as the string in argument " + minsize.arg + "");
|
|
|
|
else
|
|
|
|
ui->minsizes->addItem("unhandled type: " + minsize.type);
|
|
|
|
}
|
2015-08-30 13:35:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
LibraryEditArgDialog::~LibraryEditArgDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2015-08-30 13:41:57 +02:00
|
|
|
CppcheckLibraryData::Function::Arg LibraryEditArgDialog::getArg() const
|
2015-08-30 13:35:02 +02:00
|
|
|
{
|
2015-08-30 13:41:57 +02:00
|
|
|
CppcheckLibraryData::Function::Arg ret;
|
2015-08-30 13:35:02 +02:00
|
|
|
ret.notbool = ui->notbool->isChecked();
|
|
|
|
ret.notnull = ui->notnull->isChecked();
|
|
|
|
ret.notuninit = ui->notuninit->isChecked();
|
|
|
|
ret.strz = ui->strz->isChecked();
|
2015-08-31 09:04:35 +02:00
|
|
|
ret.formatstr = ui->formatstr->isChecked();
|
|
|
|
ret.minsizes = minsizes;
|
2015-08-30 13:35:02 +02:00
|
|
|
ret.valid = ui->valid->text();
|
|
|
|
return ret;
|
|
|
|
}
|