GUI: LibraryDialog - update presentation of minsizes

This commit is contained in:
Daniel Marjamäki 2015-08-31 09:04:35 +02:00
parent b90b751b54
commit c9d14f4bb0
3 changed files with 31 additions and 50 deletions

View File

@ -1,20 +1,32 @@
#include "libraryeditargdialog.h"
#include "ui_libraryeditargdialog.h"
LibraryEditArgDialog::LibraryEditArgDialog(QWidget *parent, const CppcheckLibraryData::Function::Arg &a) :
LibraryEditArgDialog::LibraryEditArgDialog(QWidget *parent, const CppcheckLibraryData::Function::Arg &arg) :
QDialog(parent),
ui(new Ui::LibraryEditArgDialog),
arg(a)
minsizes(arg.minsizes)
{
ui->setupUi(this);
ui->notbool->setChecked(arg.notbool);
ui->notnull->setChecked(arg.notnull);
ui->notuninit->setChecked(arg.notuninit);
ui->strz->setChecked(arg.strz);
ui->formatStr->setChecked(arg.formatstr);
ui->formatStrSafe->setVisible(false);
ui->formatStrType->setVisible(false);
ui->formatstr->setChecked(arg.formatstr);
ui->valid->setText(arg.valid);
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);
}
}
LibraryEditArgDialog::~LibraryEditArgDialog()
@ -29,8 +41,8 @@ CppcheckLibraryData::Function::Arg LibraryEditArgDialog::getArg() const
ret.notnull = ui->notnull->isChecked();
ret.notuninit = ui->notuninit->isChecked();
ret.strz = ui->strz->isChecked();
ret.formatstr = ui->formatStr->isChecked();
ret.minsizes = arg.minsizes; // TODO : read from GUI
ret.formatstr = ui->formatstr->isChecked();
ret.minsizes = minsizes;
ret.valid = ui->valid->text();
return ret;
}

View File

@ -20,7 +20,7 @@ public:
private:
Ui::LibraryEditArgDialog *ui;
CppcheckLibraryData::Function::Arg arg;
QList<CppcheckLibraryData::Function::Arg::MinSize> minsizes;
};
#endif // LIBRARYEDITARGDIALOG_H

View File

@ -59,48 +59,17 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="formatStr">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Format string</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="formatStrType">
<item>
<property name="text">
<string>output (like printf)</string>
</property>
</item>
<item>
<property name="text">
<string>input (like scanf)</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QCheckBox" name="formatStrSafe">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Safe</string>
</property>
</widget>
</item>
</layout>
<widget class="QCheckBox" name="formatstr">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Format string</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">