Commit 1e3ce35c authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Clean up. Add parent. Minor poptimization

parent 8fb5f4f4
......@@ -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()));
......
......@@ -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);
......
......@@ -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];
......
......@@ -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) {
......
......@@ -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);
......
......@@ -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;
......
......@@ -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)));
}
......
......@@ -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)
{
......
......@@ -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
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment