summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-15 05:54:07 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-15 05:54:07 (GMT)
commiteffb2f673b5d06318cf4b26b71df74fd2ce9dec9 (patch)
tree9fe53ccae93be9e65645e753f26af0cf82f0dc04
parent1b73d7ee7297df4ca8ba42f33a28392e3d3e94b5 (diff)
Minor optimization
-rw-r--r--kaddressbook/importexportplugins/csv/csvimportexportplugininterface.cpp3
-rw-r--r--kaddressbook/importexportplugins/gmx/gmximportexportplugininterface.cpp5
-rw-r--r--kaddressbook/importexportplugins/vcards/engine/vcardviewerdialog.cpp11
3 files changed, 11 insertions, 8 deletions
diff --git a/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.cpp b/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.cpp
index ecf95ea..697eb19 100644
--- a/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.cpp
+++ b/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.cpp
@@ -111,7 +111,8 @@ void CSVImportExportPluginInterface::exportToFile(QFile *file, const KContacts::
bool first = true;
// First output the column headings
- for (int i = 0; i < fields.count(); ++i) {
+ const int fieldsCount(fields.count());
+ for (int i = 0; i < fieldsCount; ++i) {
if (!first) {
stream << ",";
}
diff --git a/kaddressbook/importexportplugins/gmx/gmximportexportplugininterface.cpp b/kaddressbook/importexportplugins/gmx/gmximportexportplugininterface.cpp
index 5f56fdd..7158dde 100644
--- a/kaddressbook/importexportplugins/gmx/gmximportexportplugininterface.cpp
+++ b/kaddressbook/importexportplugins/gmx/gmximportexportplugininterface.cpp
@@ -441,7 +441,8 @@ void GMXImportExportPluginInterface::doExport(QFile *fp, const KContacts::Addres
// Write Category List (beware: Category_ID 0 is reserved for none
// Interestingly: The index here is an int sequence and does not
// correspond to the bit reference used above.
- for (int i = 0; i < categoryMap.size(); ++i) {
+ const int categoryCount(categoryMap.size());
+ for (int i = 0; i < categoryCount; ++i) {
t << (i + 1) << DELIM << categoryMap.at(i) << DELIM << 0 << endl;
}
t << "####" << endl;
@@ -459,7 +460,7 @@ void GMXImportExportPluginInterface::importGMX()
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) {
- QString msg = i18n("<qt>Unable to open <b>%1</b> for reading.</qt>", fileName);
+ const QString msg = i18n("<qt>Unable to open <b>%1</b> for reading.</qt>", fileName);
KMessageBox::error(parentWidget(), msg);
return;
}
diff --git a/kaddressbook/importexportplugins/vcards/engine/vcardviewerdialog.cpp b/kaddressbook/importexportplugins/vcards/engine/vcardviewerdialog.cpp
index be0180f..a010db7 100644
--- a/kaddressbook/importexportplugins/vcards/engine/vcardviewerdialog.cpp
+++ b/kaddressbook/importexportplugins/vcards/engine/vcardviewerdialog.cpp
@@ -33,13 +33,14 @@ VCardViewerDialog::VCardViewerDialog(const KContacts::Addressee::List &list, QWi
mContacts(list)
{
setWindowTitle(i18nc("@title:window", "Import vCard"));
- QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Apply);
- QVBoxLayout *mainLayout = new QVBoxLayout;
- setLayout(mainLayout);
- QPushButton *user1Button = new QPushButton;
+ QVBoxLayout *mainLayout = new QVBoxLayout(this);
+ QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Apply, this);
+
+ QPushButton *user1Button = new QPushButton(this);
buttonBox->addButton(user1Button, QDialogButtonBox::ActionRole);
- QPushButton *user2Button = new QPushButton;
+ QPushButton *user2Button = new QPushButton(this);
buttonBox->addButton(user2Button, QDialogButtonBox::ActionRole);
+
connect(buttonBox, &QDialogButtonBox::accepted, this, &VCardViewerDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &VCardViewerDialog::reject);
KGuiItem::assign(user1Button, KStandardGuiItem::no());