Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 7580b074 authored by Laurent Montel's avatar Laurent Montel 😁

Replace by qpointer directly

parent 6d4aedb7
/*
* autoqpointer.h - QPointer which on destruction deletes object
* This is a (mostly) verbatim, private copy of kdepim/kalarm/lib/autoqpointer.h
*
* Copyright © 2009 by David Jarvie <djarvie@kde.org>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Library General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
* License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef AUTOQPOINTER_H
#define AUTOQPOINTER_H
#include <QPointer>
/**
* A QPointer which when destructed, deletes the object it points to.
*
* @author David Jarvie <djarvie@kde.org>
*/
template<class T>
class AutoQPointer : public QPointer<T>
{
public:
inline AutoQPointer()
: QPointer<T>()
{
}
inline AutoQPointer(T *p)
: QPointer<T>(p)
{
}
inline AutoQPointer(const QPointer<T> &p)
: QPointer<T>(p)
{
}
inline ~AutoQPointer()
{
delete this->data();
}
inline AutoQPointer<T> &operator=(const AutoQPointer<T> &p)
{
QPointer<T>::operator=(p);
return *this;
}
inline AutoQPointer<T> &operator=(T *p)
{
QPointer<T>::operator=(p);
return *this;
}
};
#endif // AUTOQPOINTER_H
......@@ -22,7 +22,6 @@
#include "contacteditor.h"
#include "abstractcontacteditorwidget_p.h"
#include "autoqpointer_p.h"
#include "contactmetadataakonadi_p.h"
#include "attributes/contactmetadataattribute_p.h"
#include "editor/contacteditorwidget.h"
......@@ -272,14 +271,16 @@ void Akonadi::AkonadiContactEditor::saveContactInAddressBook()
if (!d->mDefaultCollection.isValid()) {
const QStringList mimeTypeFilter(KContacts::Addressee::mimeType());
AutoQPointer<CollectionDialog> dlg = new CollectionDialog(this);
QPointer<CollectionDialog> dlg = new CollectionDialog(this);
dlg->setMimeTypeFilter(mimeTypeFilter);
dlg->setAccessRightsFilter(Collection::CanCreateItem);
dlg->setWindowTitle(i18n("Select Address Book"));
dlg->setDescription(i18n("Select the address book the new contact shall be saved in:"));
if (dlg->exec() == QDialog::Accepted) {
setDefaultAddressBook(dlg->selectedCollection());
delete dlg;
} else {
delete dlg;
return;
}
}
......
......@@ -22,7 +22,6 @@
#include "contactgroupeditor.h"
#include "contactgroupeditor_p.h"
#include "autoqpointer_p.h"
#include "contactgroupmodel_p.h"
#include "contactgroupeditordelegate_p.h"
#include "waitingoverlay_p.h"
......@@ -138,7 +137,7 @@ void ContactGroupEditor::Private::storeDone(KJob *job)
void ContactGroupEditor::Private::itemChanged(const Item &item, const QSet<QByteArray> &)
{
Q_UNUSED(item)
AutoQPointer<QMessageBox> dlg = new QMessageBox(mParent); //krazy:exclude=qclasses
QPointer<QMessageBox> dlg = new QMessageBox(mParent); //krazy:exclude=qclasses
dlg->setInformativeText(i18n("The contact group has been changed by someone else.\nWhat should be done?"));
dlg->addButton(i18n("Take over changes"), QMessageBox::AcceptRole);
......@@ -152,6 +151,7 @@ void ContactGroupEditor::Private::itemChanged(const Item &item, const QSet<QByte
mParent->connect(job, SIGNAL(result(KJob*)), mParent, SLOT(itemFetchDone(KJob*)));
new WaitingOverlay(job, mParent);
}
delete dlg;
}
void ContactGroupEditor::Private::loadContactGroup(const KContacts::ContactGroup &group)
......@@ -276,7 +276,7 @@ bool ContactGroupEditor::saveContactGroup()
if (!d->mDefaultCollection.isValid()) {
const QStringList mimeTypeFilter(KContacts::ContactGroup::mimeType());
AutoQPointer<CollectionDialog> dlg = new CollectionDialog(this);
QPointer<CollectionDialog> dlg = new CollectionDialog(this);
dlg->setMimeTypeFilter(mimeTypeFilter);
dlg->setAccessRightsFilter(Collection::CanCreateItem);
dlg->setWindowTitle(i18n("Select Address Book"));
......@@ -284,7 +284,9 @@ bool ContactGroupEditor::saveContactGroup()
if (dlg->exec() == QDialog::Accepted) {
setDefaultAddressBook(dlg->selectedCollection());
delete dlg;
} else {
delete dlg;
return false;
}
}
......
/*
* autoqpointer.h - QPointer which on destruction deletes object
* This is a (mostly) verbatim, private copy of kdepim/kalarm/lib/autoqpointer.h
*
* Copyright © 2009 by David Jarvie <djarvie@kde.org>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Library General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
* License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef AUTOQPOINTER_H
#define AUTOQPOINTER_H
#include <QPointer>
/**
* A QPointer which when destructed, deletes the object it points to.
*
* @author David Jarvie <djarvie@kde.org>
*/
template<class T>
class AutoQPointer : public QPointer<T>
{
public:
inline AutoQPointer()
: QPointer<T>()
{
}
inline AutoQPointer(T *p)
: QPointer<T>(p)
{
}
inline AutoQPointer(const QPointer<T> &p)
: QPointer<T>(p)
{
}
inline ~AutoQPointer()
{
delete this->data();
}
inline AutoQPointer<T> &operator=(const AutoQPointer<T> &p)
{
QPointer<T>::operator=(p);
return *this;
}
inline AutoQPointer<T> &operator=(T *p)
{
QPointer<T>::operator=(p);
return *this;
}
};
#endif // AUTOQPOINTER_H
......@@ -23,7 +23,7 @@
#include "phonecomboboxtype.h"
#include "phonetypedialog.h"
#include <KLocalizedString>
#include <autoqpointer_p.h>
#include <QPointer>
using namespace ContactEditor;
......@@ -101,7 +101,7 @@ void PhoneComboBoxType::selected(int pos)
void PhoneComboBoxType::otherSelected()
{
AutoQPointer<ContactEditor::PhoneTypeDialog> dlg = new ContactEditor::PhoneTypeDialog(mType, this);
QPointer<ContactEditor::PhoneTypeDialog> dlg = new ContactEditor::PhoneTypeDialog(mType, this);
if (dlg->exec()) {
mType = dlg->type();
if (!mTypeList.contains(mType)) {
......@@ -112,6 +112,6 @@ void PhoneComboBoxType::otherSelected()
} else {
setType(KContacts::PhoneNumber::Type(mTypeList.at(mLastSelected)));
}
delete dlg;
update();
}
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