aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-01 20:42:06 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-01 20:42:06 (GMT)
commit1e3ce35cf3a9cc1f10799e3ead18492270c230b1 (patch)
tree647c12638d7419d62f1fc3c02446006b3f43718d
parent8fb5f4f48c0ceb93892b44943ddfea10eea9d82a (diff)
Clean up. Add parent. Minor poptimization
-rw-r--r--src/contacteditordialog.cpp3
-rw-r--r--src/editor/addresseditor/addresseslocationwidget.cpp6
-rw-r--r--src/editor/addresseditor/addresstypedialog.cpp6
-rw-r--r--src/editor/addresseditor/selectaddresstypecombobox.cpp3
-rw-r--r--src/editor/businesseditor/freebusyeditwidget.cpp2
-rw-r--r--src/editor/customfieldeditor/customfieldslistwidget.cpp6
-rw-r--r--src/editor/generalinfoeditor/displaynameeditwidget.cpp3
-rw-r--r--src/editor/personaleditor/kdatepickerpopup.cpp7
-rw-r--r--src/editor/personaleditor/kdatepickerpopup_p.h9
9 files changed, 19 insertions, 26 deletions
diff --git a/src/contacteditordialog.cpp b/src/contacteditordialog.cpp
index 83f8e49..d88a4c3 100644
--- a/src/contacteditordialog.cpp
+++ b/src/contacteditordialog.cpp
@@ -51,8 +51,7 @@ public:
{
q->setWindowTitle(mode == ContactEditorDialog::CreateMode ? i18n("New Contact") : i18n("Edit Contact"));
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
- QVBoxLayout *mainLayout = new QVBoxLayout;
- q->setLayout(mainLayout);
+ QVBoxLayout *mainLayout = new QVBoxLayout(q);
q->connect(buttonBox, SIGNAL(accepted()), q, SLOT(slotOkClicked()));
q->connect(buttonBox, SIGNAL(rejected()), q, SLOT(slotCancelClicked()));
diff --git a/src/editor/addresseditor/addresseslocationwidget.cpp b/src/editor/addresseditor/addresseslocationwidget.cpp
index 38b02b4..d76d8f6 100644
--- a/src/editor/addresseditor/addresseslocationwidget.cpp
+++ b/src/editor/addresseditor/addresseslocationwidget.cpp
@@ -56,13 +56,15 @@ void AddressesLocationWidget::storeContact(KContacts::Addressee &contact) const
{
// delete all previous addresses
const KContacts::Address::List oldAddresses = contact.addresses();
- for (int i = 0; i < oldAddresses.count(); ++i) {
+ const int numberOfOldAddresses(oldAddresses.count());
+ for (int i = 0; i < numberOfOldAddresses; ++i) {
contact.removeAddress(oldAddresses.at(i));
}
const KContacts::Address::List addressList = mAddressesLocationViewer->addresses();
// insert the new ones
- for (int i = 0; i < addressList.count(); ++i) {
+ const int numberOfAddress(addressList.count());
+ for (int i = 0; i < numberOfAddress; ++i) {
const KContacts::Address address(addressList.at(i));
if (!address.isEmpty()) {
contact.insertAddress(address);
diff --git a/src/editor/addresseditor/addresstypedialog.cpp b/src/editor/addresseditor/addresstypedialog.cpp
index a9ae953..e47327c 100644
--- a/src/editor/addresseditor/addresstypedialog.cpp
+++ b/src/editor/addresseditor/addresstypedialog.cpp
@@ -60,7 +60,8 @@ AddressTypeDialog::AddressTypeDialog(KContacts::Address::Type type, QWidget *par
KContacts::Address::TypeList::ConstIterator it;
int i = 0;
int row = 0;
- for (it = mTypeList.constBegin(); it != mTypeList.constEnd(); ++it, ++i) {
+ KContacts::Address::TypeList::ConstIterator end(mTypeList.constEnd());
+ for (it = mTypeList.constBegin(); it != end; ++it, ++i) {
QCheckBox *cb = new QCheckBox(KContacts::Address::typeLabel(*it), box);
cb->setChecked(type & mTypeList[i]);
buttonLayout->addWidget(cb, row, i % 3);
@@ -79,7 +80,8 @@ AddressTypeDialog::~AddressTypeDialog()
KContacts::Address::Type AddressTypeDialog::type() const
{
KContacts::Address::Type type;
- for (int i = 0; i < mGroup->buttons().count(); ++i) {
+ const int numberOfButtons(mGroup->buttons().count());
+ for (int i = 0; i < numberOfButtons; ++i) {
QCheckBox *box = qobject_cast<QCheckBox *>(mGroup->buttons().at(i));
if (box && box->isChecked()) {
type |= mTypeList[i];
diff --git a/src/editor/addresseditor/selectaddresstypecombobox.cpp b/src/editor/addresseditor/selectaddresstypecombobox.cpp
index e782625..672a7d7 100644
--- a/src/editor/addresseditor/selectaddresstypecombobox.cpp
+++ b/src/editor/addresseditor/selectaddresstypecombobox.cpp
@@ -69,7 +69,8 @@ void SelectAddressTypeComboBox::update()
blockSignals(true);
clear();
- for (int i = 0; i < mTypeList.count(); ++i) {
+ const int numberOfType(mTypeList.count());
+ for (int i = 0; i < numberOfType; ++i) {
if (mTypeList.at(i) == -1) { // "Other..." entry
addItem(i18nc("@item:inlistbox Category of contact info field", "Other..."));
} else if (mTypeList.at(i) == -2) {
diff --git a/src/editor/businesseditor/freebusyeditwidget.cpp b/src/editor/businesseditor/freebusyeditwidget.cpp
index 15f2231..0c57c9f 100644
--- a/src/editor/businesseditor/freebusyeditwidget.cpp
+++ b/src/editor/businesseditor/freebusyeditwidget.cpp
@@ -38,7 +38,7 @@ FreeBusyEditWidget::FreeBusyEditWidget(QWidget *parent)
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setMargin(0);
- mURL = new KUrlRequester;
+ mURL = new KUrlRequester(this);
mURL->lineEdit()->setTrapReturnKey(true);
mURL->lineEdit()->setPlaceholderText(i18n("Add FreeBusy"));
layout->addWidget(mURL);
diff --git a/src/editor/customfieldeditor/customfieldslistwidget.cpp b/src/editor/customfieldeditor/customfieldslistwidget.cpp
index 0f2f9a5..b99e192 100644
--- a/src/editor/customfieldeditor/customfieldslistwidget.cpp
+++ b/src/editor/customfieldeditor/customfieldslistwidget.cpp
@@ -103,7 +103,8 @@ void CustomFieldsListWidget::loadContact(const KContacts::Addressee &contact)
// check whether it correspond to a local custom field
bool isLocalCustomField = false;
- for (int i = 0; i < mLocalCustomFields.count(); ++i) {
+ const int localCustomFieldsCount(mLocalCustomFields.count());
+ for (int i = 0; i < localCustomFieldsCount; ++i) {
if (mLocalCustomFields[i].key() == name) {
mLocalCustomFields[i].setValue(value);
isLocalCustomField = true;
@@ -113,7 +114,8 @@ void CustomFieldsListWidget::loadContact(const KContacts::Addressee &contact)
// check whether it correspond to a global custom field
bool isGlobalCustomField = false;
- for (int i = 0; i < globalCustomFields.count(); ++i) {
+ const int globalCustomFieldsCount(globalCustomFields.count());
+ for (int i = 0; i < globalCustomFieldsCount; ++i) {
if (globalCustomFields[i].key() == name) {
globalCustomFields[i].setValue(value);
isGlobalCustomField = true;
diff --git a/src/editor/generalinfoeditor/displaynameeditwidget.cpp b/src/editor/generalinfoeditor/displaynameeditwidget.cpp
index 2274db5..7ff600c 100644
--- a/src/editor/generalinfoeditor/displaynameeditwidget.cpp
+++ b/src/editor/generalinfoeditor/displaynameeditwidget.cpp
@@ -209,7 +209,8 @@ bool DisplayNameEditWidget::eventFilter(QObject *object, QEvent *event)
int maxWidth = 0;
QFontMetrics metrics(mView->font());
- for (int i = 0; i < mView->count(); ++i) {
+ const int viewCount(mView->count());
+ for (int i = 0; i < viewCount; ++i) {
maxWidth = qMax(maxWidth, metrics.width(mView->itemText(i)));
}
diff --git a/src/editor/personaleditor/kdatepickerpopup.cpp b/src/editor/personaleditor/kdatepickerpopup.cpp
index 9006e9b..5bcc1d0 100644
--- a/src/editor/personaleditor/kdatepickerpopup.cpp
+++ b/src/editor/personaleditor/kdatepickerpopup.cpp
@@ -114,13 +114,6 @@ void KDatePickerPopup::setDate(const QDate &date)
mDatePicker->setDate(date);
}
-#if 0
-void KDatePickerPopup::setItems(int items)
-{
- mItems = items;
- buildMenu();
-}
-#endif
void KDatePickerPopup::slotDateChanged(const QDate &date)
{
diff --git a/src/editor/personaleditor/kdatepickerpopup_p.h b/src/editor/personaleditor/kdatepickerpopup_p.h
index 2ba26d0..d3cd3ad 100644
--- a/src/editor/personaleditor/kdatepickerpopup_p.h
+++ b/src/editor/personaleditor/kdatepickerpopup_p.h
@@ -66,7 +66,7 @@ public:
*/
explicit KDatePickerPopup(Items items = DatePicker,
const QDate &date = QDate::currentDate(),
- QWidget *parent = 0);
+ QWidget *parent = Q_NULLPTR);
/**
@return A pointer to the private variable mDatePicker, an instance of
@@ -76,13 +76,6 @@ public:
void setDate(const QDate &date);
-#if 0
- /** Set items which should be shown and rebuilds the menu afterwards.
- Only if the menu is not visible.
- @param items List of all desirable items, separated with a bitwise OR.
- */
- void setItems(int items = 1);
-#endif
/** @return Returns the bitwise result of the active items in the popup. */
int items() const
{