GUI: LibraryDialog - update presentation of minsizes
This commit is contained in:
parent
b90b751b54
commit
c9d14f4bb0
|
@ -1,20 +1,32 @@
|
||||||
#include "libraryeditargdialog.h"
|
#include "libraryeditargdialog.h"
|
||||||
#include "ui_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),
|
QDialog(parent),
|
||||||
ui(new Ui::LibraryEditArgDialog),
|
ui(new Ui::LibraryEditArgDialog),
|
||||||
arg(a)
|
minsizes(arg.minsizes)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->notbool->setChecked(arg.notbool);
|
ui->notbool->setChecked(arg.notbool);
|
||||||
ui->notnull->setChecked(arg.notnull);
|
ui->notnull->setChecked(arg.notnull);
|
||||||
ui->notuninit->setChecked(arg.notuninit);
|
ui->notuninit->setChecked(arg.notuninit);
|
||||||
ui->strz->setChecked(arg.strz);
|
ui->strz->setChecked(arg.strz);
|
||||||
ui->formatStr->setChecked(arg.formatstr);
|
ui->formatstr->setChecked(arg.formatstr);
|
||||||
ui->formatStrSafe->setVisible(false);
|
|
||||||
ui->formatStrType->setVisible(false);
|
|
||||||
ui->valid->setText(arg.valid);
|
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()
|
LibraryEditArgDialog::~LibraryEditArgDialog()
|
||||||
|
@ -29,8 +41,8 @@ CppcheckLibraryData::Function::Arg LibraryEditArgDialog::getArg() const
|
||||||
ret.notnull = ui->notnull->isChecked();
|
ret.notnull = ui->notnull->isChecked();
|
||||||
ret.notuninit = ui->notuninit->isChecked();
|
ret.notuninit = ui->notuninit->isChecked();
|
||||||
ret.strz = ui->strz->isChecked();
|
ret.strz = ui->strz->isChecked();
|
||||||
ret.formatstr = ui->formatStr->isChecked();
|
ret.formatstr = ui->formatstr->isChecked();
|
||||||
ret.minsizes = arg.minsizes; // TODO : read from GUI
|
ret.minsizes = minsizes;
|
||||||
ret.valid = ui->valid->text();
|
ret.valid = ui->valid->text();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ public:
|
||||||
private:
|
private:
|
||||||
Ui::LibraryEditArgDialog *ui;
|
Ui::LibraryEditArgDialog *ui;
|
||||||
|
|
||||||
CppcheckLibraryData::Function::Arg arg;
|
QList<CppcheckLibraryData::Function::Arg::MinSize> minsizes;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LIBRARYEDITARGDIALOG_H
|
#endif // LIBRARYEDITARGDIALOG_H
|
||||||
|
|
|
@ -59,48 +59,17 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<widget class="QCheckBox" name="formatstr">
|
||||||
<item>
|
<property name="sizePolicy">
|
||||||
<widget class="QCheckBox" name="formatStr">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
<property name="sizePolicy">
|
<horstretch>0</horstretch>
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<verstretch>0</verstretch>
|
||||||
<horstretch>0</horstretch>
|
</sizepolicy>
|
||||||
<verstretch>0</verstretch>
|
</property>
|
||||||
</sizepolicy>
|
<property name="text">
|
||||||
</property>
|
<string>Format string</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Format string</string>
|
</widget>
|
||||||
</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>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
|
|
Loading…
Reference in New Issue