mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
[Code] Skip one allocation of QDialog on heap.
This commit is contained in:
parent
650f474113
commit
a8fad834ce
@ -127,39 +127,35 @@ QStringList AcceptLanguage::expand(const QLocale::Language &language)
|
|||||||
|
|
||||||
void AcceptLanguage::addLanguage()
|
void AcceptLanguage::addLanguage()
|
||||||
{
|
{
|
||||||
Ui_AddAcceptLanguage _ui = Ui_AddAcceptLanguage();
|
Ui_AddAcceptLanguage acceptLangUi;
|
||||||
QDialog* dialog = new QDialog(this);
|
QDialog dialog(this);
|
||||||
_ui.setupUi(dialog);
|
acceptLangUi.setupUi(&dialog);
|
||||||
|
|
||||||
QStringList allLanguages;
|
QStringList allLanguages;
|
||||||
for (int i = 1 + (int)QLocale::C; i <= (int)QLocale::LastLanguage; ++i) {
|
for (int i = 1 + (int)QLocale::C; i <= (int)QLocale::LastLanguage; ++i) {
|
||||||
allLanguages += expand(QLocale::Language(i));
|
allLanguages += expand(QLocale::Language(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
_ui.listWidget->addItems(allLanguages);
|
acceptLangUi.listWidget->addItems(allLanguages);
|
||||||
|
|
||||||
connect(_ui.listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), dialog, SLOT(accept()));
|
connect(acceptLangUi.listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), &dialog, SLOT(accept()));
|
||||||
|
|
||||||
if (dialog->exec() == QDialog::Rejected) {
|
if (dialog.exec() == QDialog::Rejected) {
|
||||||
delete dialog;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_ui.ownDefinition->text().isEmpty()) {
|
if (!acceptLangUi.ownDefinition->text().isEmpty()) {
|
||||||
QString title = tr("Personal [%1]").arg(_ui.ownDefinition->text());
|
QString title = tr("Personal [%1]").arg(acceptLangUi.ownDefinition->text());
|
||||||
ui->listWidget->addItem(title);
|
ui->listWidget->addItem(title);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QListWidgetItem* c = _ui.listWidget->currentItem();
|
QListWidgetItem* c = acceptLangUi.listWidget->currentItem();
|
||||||
if (!c) {
|
if (!c) {
|
||||||
delete dialog;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->listWidget->addItem(c->text());
|
ui->listWidget->addItem(c->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
delete dialog;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AcceptLanguage::removeLanguage()
|
void AcceptLanguage::removeLanguage()
|
||||||
|
Loading…
Reference in New Issue
Block a user