GUI: Rename private variable ui to mUi

This commit is contained in:
Daniel Marjamäki 2018-06-18 10:13:33 +02:00
parent 86c5f44d19
commit 7d00b30488
6 changed files with 122 additions and 122 deletions

View File

@ -6,26 +6,26 @@
LibraryAddFunctionDialog::LibraryAddFunctionDialog(QWidget *parent) : LibraryAddFunctionDialog::LibraryAddFunctionDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::LibraryAddFunctionDialog) mUi(new Ui::LibraryAddFunctionDialog)
{ {
ui->setupUi(this); mUi->setupUi(this);
QRegExp rx(NAMES); QRegExp rx(NAMES);
QValidator *validator = new QRegExpValidator(rx, this); QValidator *validator = new QRegExpValidator(rx, this);
ui->functionName->setValidator(validator); mUi->functionName->setValidator(validator);
} }
LibraryAddFunctionDialog::~LibraryAddFunctionDialog() LibraryAddFunctionDialog::~LibraryAddFunctionDialog()
{ {
delete ui; delete mUi;
} }
QString LibraryAddFunctionDialog::functionName() const QString LibraryAddFunctionDialog::functionName() const
{ {
return ui->functionName->text(); return mUi->functionName->text();
} }
int LibraryAddFunctionDialog::numberOfArguments() const int LibraryAddFunctionDialog::numberOfArguments() const
{ {
return ui->numberOfArguments->value(); return mUi->numberOfArguments->value();
} }

View File

@ -24,7 +24,7 @@ public:
int numberOfArguments() const; int numberOfArguments() const;
private: private:
Ui::LibraryAddFunctionDialog *ui; Ui::LibraryAddFunctionDialog *mUi;
}; };
#endif // LIBRARYADDFUNCTIONDIALOG_H #endif // LIBRARYADDFUNCTIONDIALOG_H

View File

@ -46,15 +46,15 @@ public:
LibraryDialog::LibraryDialog(QWidget *parent) : LibraryDialog::LibraryDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::LibraryDialog), mUi(new Ui::LibraryDialog),
ignoreChanges(false) ignoreChanges(false)
{ {
ui->setupUi(this); mUi->setupUi(this);
ui->buttonSave->setEnabled(false); mUi->buttonSave->setEnabled(false);
ui->buttonSaveAs->setEnabled(false); mUi->buttonSaveAs->setEnabled(false);
ui->sortFunctions->setEnabled(false); mUi->sortFunctions->setEnabled(false);
ui->filter->setEnabled(false); mUi->filter->setEnabled(false);
ui->addFunction->setEnabled(false); mUi->addFunction->setEnabled(false);
//As no function selected, this disables function editing widgets //As no function selected, this disables function editing widgets
selectFunction(); selectFunction();
@ -62,12 +62,12 @@ LibraryDialog::LibraryDialog(QWidget *parent) :
LibraryDialog::~LibraryDialog() LibraryDialog::~LibraryDialog()
{ {
delete ui; delete mUi;
} }
CppcheckLibraryData::Function *LibraryDialog::currentFunction() CppcheckLibraryData::Function *LibraryDialog::currentFunction()
{ {
QList<QListWidgetItem *> selitems = ui->functions->selectedItems(); QList<QListWidgetItem *> selitems = mUi->functions->selectedItems();
if (selitems.count() != 1) if (selitems.count() != 1)
return nullptr; return nullptr;
return static_cast<FunctionListItem *>(selitems.first())->function; return static_cast<FunctionListItem *>(selitems.first())->function;
@ -115,18 +115,18 @@ void LibraryDialog::openCfg()
ignoreChanges = true; ignoreChanges = true;
data.swap(tempdata); data.swap(tempdata);
mFileName = selectedFile; mFileName = selectedFile;
ui->buttonSave->setEnabled(false); mUi->buttonSave->setEnabled(false);
ui->buttonSaveAs->setEnabled(true); mUi->buttonSaveAs->setEnabled(true);
ui->filter->clear(); mUi->filter->clear();
ui->functions->clear(); mUi->functions->clear();
for (CppcheckLibraryData::Function &function : data.functions) { for (CppcheckLibraryData::Function &function : data.functions) {
ui->functions->addItem(new FunctionListItem(ui->functions, mUi->functions->addItem(new FunctionListItem(mUi->functions,
&function, &function,
false)); false));
} }
ui->sortFunctions->setEnabled(!data.functions.empty()); mUi->sortFunctions->setEnabled(!data.functions.empty());
ui->filter->setEnabled(!data.functions.empty()); mUi->filter->setEnabled(!data.functions.empty());
ui->addFunction->setEnabled(true); mUi->addFunction->setEnabled(true);
ignoreChanges = false; ignoreChanges = false;
} }
@ -138,7 +138,7 @@ void LibraryDialog::saveCfg()
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QTextStream ts(&file); QTextStream ts(&file);
ts << data.toString() << '\n'; ts << data.toString() << '\n';
ui->buttonSave->setEnabled(false); mUi->buttonSave->setEnabled(false);
} else { } else {
QMessageBox msg(QMessageBox::Critical, QMessageBox msg(QMessageBox::Critical,
tr("Cppcheck"), tr("Cppcheck"),
@ -182,10 +182,10 @@ void LibraryDialog::addFunction()
f.args.append(arg); f.args.append(arg);
} }
data.functions.append(f); data.functions.append(f);
ui->functions->addItem(new FunctionListItem(ui->functions, &data.functions.back(), false)); mUi->functions->addItem(new FunctionListItem(mUi->functions, &data.functions.back(), false));
ui->buttonSave->setEnabled(true); mUi->buttonSave->setEnabled(true);
ui->sortFunctions->setEnabled(!data.functions.empty()); mUi->sortFunctions->setEnabled(!data.functions.empty());
ui->filter->setEnabled(!data.functions.empty()); mUi->filter->setEnabled(!data.functions.empty());
} }
delete d; delete d;
} }
@ -199,7 +199,7 @@ void LibraryDialog::editFunctionName(QListWidgetItem* item)
if (functionName != function->name) { if (functionName != function->name) {
if (QRegExp(NAMES).exactMatch(functionName)) { if (QRegExp(NAMES).exactMatch(functionName)) {
function->name = functionName; function->name = functionName;
ui->buttonSave->setEnabled(true); mUi->buttonSave->setEnabled(true);
} else { } else {
ignoreChanges = true; ignoreChanges = true;
item->setText(function->name); item->setText(function->name);
@ -213,67 +213,67 @@ void LibraryDialog::selectFunction()
const CppcheckLibraryData::Function * const function = currentFunction(); const CppcheckLibraryData::Function * const function = currentFunction();
if (function == nullptr) { if (function == nullptr) {
ui->comments->clear(); mUi->comments->clear();
ui->comments->setEnabled(false); mUi->comments->setEnabled(false);
ui->noreturn->setCurrentIndex(0); mUi->noreturn->setCurrentIndex(0);
ui->noreturn->setEnabled(false); mUi->noreturn->setEnabled(false);
ui->useretval->setChecked(false); mUi->useretval->setChecked(false);
ui->useretval->setEnabled(false); mUi->useretval->setEnabled(false);
ui->leakignore->setChecked(false); mUi->leakignore->setChecked(false);
ui->leakignore->setEnabled(false); mUi->leakignore->setEnabled(false);
ui->arguments->clear(); mUi->arguments->clear();
ui->arguments->setEnabled(false); mUi->arguments->setEnabled(false);
ui->editArgButton->setEnabled(false); mUi->editArgButton->setEnabled(false);
return; return;
} }
ignoreChanges = true; ignoreChanges = true;
ui->comments->setPlainText(function->comments); mUi->comments->setPlainText(function->comments);
ui->comments->setEnabled(true); mUi->comments->setEnabled(true);
ui->noreturn->setCurrentIndex(function->noreturn); mUi->noreturn->setCurrentIndex(function->noreturn);
ui->noreturn->setEnabled(true); mUi->noreturn->setEnabled(true);
ui->useretval->setChecked(function->useretval); mUi->useretval->setChecked(function->useretval);
ui->useretval->setEnabled(true); mUi->useretval->setEnabled(true);
ui->leakignore->setChecked(function->leakignore); mUi->leakignore->setChecked(function->leakignore);
ui->leakignore->setEnabled(true); mUi->leakignore->setEnabled(true);
updateArguments(*function); updateArguments(*function);
ui->arguments->setEnabled(true); mUi->arguments->setEnabled(true);
ui->editArgButton->setEnabled(true); mUi->editArgButton->setEnabled(true);
ignoreChanges = false; ignoreChanges = false;
} }
void LibraryDialog::sortFunctions(bool sort) void LibraryDialog::sortFunctions(bool sort)
{ {
if (sort) { if (sort) {
ui->functions->sortItems(); mUi->functions->sortItems();
} else { } else {
ignoreChanges = true; ignoreChanges = true;
CppcheckLibraryData::Function *selfunction = currentFunction(); CppcheckLibraryData::Function *selfunction = currentFunction();
ui->functions->clear(); mUi->functions->clear();
for (CppcheckLibraryData::Function &function : data.functions) { for (CppcheckLibraryData::Function &function : data.functions) {
ui->functions->addItem(new FunctionListItem(ui->functions, mUi->functions->addItem(new FunctionListItem(mUi->functions,
&function, &function,
selfunction == &function)); selfunction == &function));
} }
if (!ui->filter->text().isEmpty()) if (!mUi->filter->text().isEmpty())
filterFunctions(ui->filter->text()); filterFunctions(mUi->filter->text());
ignoreChanges = false; ignoreChanges = false;
} }
} }
void LibraryDialog::filterFunctions(QString filter) void LibraryDialog::filterFunctions(QString filter)
{ {
QList<QListWidgetItem *> allItems = ui->functions->findItems(QString(), Qt::MatchContains); QList<QListWidgetItem *> allItems = mUi->functions->findItems(QString(), Qt::MatchContains);
if (filter.isEmpty()) { if (filter.isEmpty()) {
foreach (QListWidgetItem *item, allItems) { foreach (QListWidgetItem *item, allItems) {
@ -295,12 +295,12 @@ void LibraryDialog::changeFunction()
if (!function) if (!function)
return; return;
function->comments = ui->comments->toPlainText(); function->comments = mUi->comments->toPlainText();
function->noreturn = (CppcheckLibraryData::Function::TrueFalseUnknown)ui->noreturn->currentIndex(); function->noreturn = (CppcheckLibraryData::Function::TrueFalseUnknown)mUi->noreturn->currentIndex();
function->useretval = ui->useretval->isChecked(); function->useretval = mUi->useretval->isChecked();
function->leakignore = ui->leakignore->isChecked(); function->leakignore = mUi->leakignore->isChecked();
ui->buttonSave->setEnabled(true); mUi->buttonSave->setEnabled(true);
} }
void LibraryDialog::editArg() void LibraryDialog::editArg()
@ -309,20 +309,20 @@ void LibraryDialog::editArg()
if (!function) if (!function)
return; return;
if (ui->arguments->selectedItems().count() != 1) if (mUi->arguments->selectedItems().count() != 1)
return; return;
CppcheckLibraryData::Function::Arg &arg = function->args[ui->arguments->row(ui->arguments->selectedItems().first())]; CppcheckLibraryData::Function::Arg &arg = function->args[mUi->arguments->row(mUi->arguments->selectedItems().first())];
LibraryEditArgDialog *d = new LibraryEditArgDialog(0, arg); LibraryEditArgDialog *d = new LibraryEditArgDialog(0, arg);
if (d->exec() == QDialog::Accepted) { if (d->exec() == QDialog::Accepted) {
unsigned number = arg.nr; unsigned number = arg.nr;
arg = d->getArg(); arg = d->getArg();
arg.nr = number; arg.nr = number;
ui->arguments->selectedItems().first()->setText(getArgText(arg)); mUi->arguments->selectedItems().first()->setText(getArgText(arg));
} }
delete d; delete d;
ui->buttonSave->setEnabled(true); mUi->buttonSave->setEnabled(true);
} }
QString LibraryDialog::getArgText(const CppcheckLibraryData::Function::Arg &arg) QString LibraryDialog::getArgText(const CppcheckLibraryData::Function::Arg &arg)
@ -345,8 +345,8 @@ QString LibraryDialog::getArgText(const CppcheckLibraryData::Function::Arg &arg)
void LibraryDialog::updateArguments(const CppcheckLibraryData::Function &function) void LibraryDialog::updateArguments(const CppcheckLibraryData::Function &function)
{ {
ui->arguments->clear(); mUi->arguments->clear();
foreach (const CppcheckLibraryData::Function::Arg &arg, function.args) { foreach (const CppcheckLibraryData::Function::Arg &arg, function.args) {
ui->arguments->addItem(getArgText(arg)); mUi->arguments->addItem(getArgText(arg));
} }
} }

View File

@ -52,7 +52,7 @@ private slots:
void sortFunctions(bool); void sortFunctions(bool);
private: private:
Ui::LibraryDialog *ui; Ui::LibraryDialog *mUi;
CppcheckLibraryData data; CppcheckLibraryData data;
QString mFileName; QString mFileName;
bool ignoreChanges; bool ignoreChanges;

View File

@ -3,97 +3,97 @@
LibraryEditArgDialog::LibraryEditArgDialog(QWidget *parent, const CppcheckLibraryData::Function::Arg &arg) : LibraryEditArgDialog::LibraryEditArgDialog(QWidget *parent, const CppcheckLibraryData::Function::Arg &arg) :
QDialog(parent), QDialog(parent),
ui(new Ui::LibraryEditArgDialog), mUi(new Ui::LibraryEditArgDialog),
minsizes(arg.minsizes) minsizes(arg.minsizes)
{ {
ui->setupUi(this); mUi->setupUi(this);
ui->notbool->setChecked(arg.notbool); mUi->notbool->setChecked(arg.notbool);
ui->notnull->setChecked(arg.notnull); mUi->notnull->setChecked(arg.notnull);
ui->notuninit->setChecked(arg.notuninit); mUi->notuninit->setChecked(arg.notuninit);
ui->strz->setChecked(arg.strz); mUi->strz->setChecked(arg.strz);
ui->formatstr->setChecked(arg.formatstr); mUi->formatstr->setChecked(arg.formatstr);
ui->valid->setText(arg.valid); mUi->valid->setText(arg.valid);
ui->minsize1type->setEnabled(true); mUi->minsize1type->setEnabled(true);
ui->minsize1arg->setEnabled(arg.minsizes.count() >= 1); mUi->minsize1arg->setEnabled(arg.minsizes.count() >= 1);
ui->minsize1arg2->setEnabled(arg.minsizes.count() >= 1 && arg.minsizes[0].type == "mul"); mUi->minsize1arg2->setEnabled(arg.minsizes.count() >= 1 && arg.minsizes[0].type == "mul");
ui->minsize2type->setEnabled(arg.minsizes.count() >= 1); mUi->minsize2type->setEnabled(arg.minsizes.count() >= 1);
ui->minsize2arg->setEnabled(arg.minsizes.count() >= 2); mUi->minsize2arg->setEnabled(arg.minsizes.count() >= 2);
ui->minsize2arg2->setEnabled(arg.minsizes.count() >= 2 && arg.minsizes[1].type == "mul"); mUi->minsize2arg2->setEnabled(arg.minsizes.count() >= 2 && arg.minsizes[1].type == "mul");
QStringList items; QStringList items;
items << "None" << "argvalue" << "mul" << "sizeof" << "strlen"; items << "None" << "argvalue" << "mul" << "sizeof" << "strlen";
ui->minsize1type->clear(); mUi->minsize1type->clear();
ui->minsize1type->addItems(items); mUi->minsize1type->addItems(items);
if (arg.minsizes.count() >= 1) { if (arg.minsizes.count() >= 1) {
ui->minsize1type->setCurrentIndex(items.indexOf(minsizes[0].type)); mUi->minsize1type->setCurrentIndex(items.indexOf(minsizes[0].type));
ui->minsize1arg->setValue(minsizes[0].arg.toInt()); mUi->minsize1arg->setValue(minsizes[0].arg.toInt());
if (arg.minsizes[0].type == "mul") if (arg.minsizes[0].type == "mul")
ui->minsize1arg2->setValue(minsizes[0].arg2.toInt()); mUi->minsize1arg2->setValue(minsizes[0].arg2.toInt());
else else
ui->minsize1arg2->setValue(0); mUi->minsize1arg2->setValue(0);
} else { } else {
ui->minsize1type->setCurrentIndex(0); mUi->minsize1type->setCurrentIndex(0);
ui->minsize1arg->setValue(0); mUi->minsize1arg->setValue(0);
ui->minsize1arg2->setValue(0); mUi->minsize1arg2->setValue(0);
} }
ui->minsize2type->clear(); mUi->minsize2type->clear();
ui->minsize2type->addItems(items); mUi->minsize2type->addItems(items);
if (arg.minsizes.count() >= 2) { if (arg.minsizes.count() >= 2) {
ui->minsize2type->setCurrentIndex(items.indexOf(minsizes[1].type)); mUi->minsize2type->setCurrentIndex(items.indexOf(minsizes[1].type));
ui->minsize2arg->setValue(minsizes[1].arg.toInt()); mUi->minsize2arg->setValue(minsizes[1].arg.toInt());
if (arg.minsizes[1].type == "mul") if (arg.minsizes[1].type == "mul")
ui->minsize2arg2->setValue(minsizes[1].arg2.toInt()); mUi->minsize2arg2->setValue(minsizes[1].arg2.toInt());
else else
ui->minsize2arg2->setValue(0); mUi->minsize2arg2->setValue(0);
} else { } else {
ui->minsize2type->setCurrentIndex(0); mUi->minsize2type->setCurrentIndex(0);
ui->minsize2arg->setValue(0); mUi->minsize2arg->setValue(0);
ui->minsize2arg2->setValue(0); mUi->minsize2arg2->setValue(0);
} }
} }
LibraryEditArgDialog::~LibraryEditArgDialog() LibraryEditArgDialog::~LibraryEditArgDialog()
{ {
delete ui; delete mUi;
} }
CppcheckLibraryData::Function::Arg LibraryEditArgDialog::getArg() const CppcheckLibraryData::Function::Arg LibraryEditArgDialog::getArg() const
{ {
CppcheckLibraryData::Function::Arg ret; CppcheckLibraryData::Function::Arg ret;
ret.notbool = ui->notbool->isChecked(); ret.notbool = mUi->notbool->isChecked();
ret.notnull = ui->notnull->isChecked(); ret.notnull = mUi->notnull->isChecked();
ret.notuninit = ui->notuninit->isChecked(); ret.notuninit = mUi->notuninit->isChecked();
ret.strz = ui->strz->isChecked(); ret.strz = mUi->strz->isChecked();
ret.formatstr = ui->formatstr->isChecked(); ret.formatstr = mUi->formatstr->isChecked();
if (ui->minsize1type->currentIndex() != 0) { if (mUi->minsize1type->currentIndex() != 0) {
CppcheckLibraryData::Function::Arg::MinSize minsize1; CppcheckLibraryData::Function::Arg::MinSize minsize1;
minsize1.type = ui->minsize1type->currentText(); minsize1.type = mUi->minsize1type->currentText();
minsize1.arg = QString::number(ui->minsize1arg->value()); minsize1.arg = QString::number(mUi->minsize1arg->value());
if (minsize1.type == "mul") if (minsize1.type == "mul")
minsize1.arg2 = QString::number(ui->minsize1arg2->value()); minsize1.arg2 = QString::number(mUi->minsize1arg2->value());
ret.minsizes.append(minsize1); ret.minsizes.append(minsize1);
if (ui->minsize2type->currentIndex() != 0) { if (mUi->minsize2type->currentIndex() != 0) {
CppcheckLibraryData::Function::Arg::MinSize minsize2; CppcheckLibraryData::Function::Arg::MinSize minsize2;
minsize2.type = ui->minsize2type->currentText(); minsize2.type = mUi->minsize2type->currentText();
minsize2.arg = QString::number(ui->minsize2arg->value()); minsize2.arg = QString::number(mUi->minsize2arg->value());
if (minsize2.type == "mul") if (minsize2.type == "mul")
minsize2.arg2 = QString::number(ui->minsize2arg2->value()); minsize2.arg2 = QString::number(mUi->minsize2arg2->value());
ret.minsizes.append(minsize2); ret.minsizes.append(minsize2);
} }
} }
ret.valid = ui->valid->text(); ret.valid = mUi->valid->text();
return ret; return ret;
} }
void LibraryEditArgDialog::minsizeChanged(int) void LibraryEditArgDialog::minsizeChanged(int)
{ {
ui->minsize1arg->setEnabled(ui->minsize1type->currentIndex() != 0); mUi->minsize1arg->setEnabled(mUi->minsize1type->currentIndex() != 0);
ui->minsize1arg2->setEnabled(ui->minsize1type->currentText() == "mul"); mUi->minsize1arg2->setEnabled(mUi->minsize1type->currentText() == "mul");
ui->minsize2type->setEnabled(ui->minsize1type->currentIndex() != 0); mUi->minsize2type->setEnabled(mUi->minsize1type->currentIndex() != 0);
ui->minsize2arg->setEnabled(ui->minsize2type->currentIndex() != 0); mUi->minsize2arg->setEnabled(mUi->minsize2type->currentIndex() != 0);
ui->minsize2arg2->setEnabled(ui->minsize2type->currentText() == "mul"); mUi->minsize2arg2->setEnabled(mUi->minsize2type->currentText() == "mul");
} }

View File

@ -23,7 +23,7 @@ private slots:
void minsizeChanged(int); void minsizeChanged(int);
private: private:
Ui::LibraryEditArgDialog *ui; Ui::LibraryEditArgDialog *mUi;
QList<CppcheckLibraryData::Function::Arg::MinSize> minsizes; QList<CppcheckLibraryData::Function::Arg::MinSize> minsizes;
}; };