• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

messageviewer

  • sources
  • kde-4.12
  • kdepim
  • messageviewer
  • utils
autoqpointer.h
Go to the documentation of this file.
1 /*
2  * autoqpointer.h - QPointer which on destruction deletes object
3  * This is a (mostly) verbatim, private copy of kdepim/kalarm/lib/autoqpointer.h
4  *
5  * Copyright © 2009 by David Jarvie <djarvie@kde.org>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef MESSAGEVIEWER_AUTOQPOINTER_H
23 #define MESSAGEVIEWER_AUTOQPOINTER_H
24 
25 #include <QPointer>
26 #include <QObject>
27 
28 #include <kdemacros.h>
29 
30 namespace MessageViewer {
31 
37 template <class T>
38 class AutoQPointer
39 {
40  Q_DISABLE_COPY( AutoQPointer )
41  struct SafeBool { void func() {} };
42  typedef void (SafeBool::*save_bool)();
43  QPointer<QObject> o;
44 public:
45  AutoQPointer() : o() {}
46  explicit AutoQPointer( T * p ) : o(p) {}
47  ~AutoQPointer() { delete o; }
48  T * data() const { return static_cast<T*>(o.data()); }
49  T * get() const { return data(); }
50  bool isNull() const { return o.isNull(); }
51  T * operator->() const { return data(); }
52  T & operator*() const { return *data(); }
53 #if 0 // enable when all users of operator T*() have been converted to use .get()
54  operator save_bool() const { return isNull() ? 0 : &SafeBool::func ; }
55 #else
56  // unsafe - use explicit .get()
57  KDE_DEPRECATED operator T*() const { return get(); }
58  // unsafe - only provided to prevent the above warning in bool contexts
59  operator bool() const { return get(); }
60 #endif
61 
62 };
63 
64 }
65 
66 #endif // MESSAGEVIEWER_AUTOQPOINTER_H
MessageViewer::AutoQPointer::AutoQPointer
AutoQPointer()
Definition: autoqpointer.h:45
MessageViewer::AutoQPointer::AutoQPointer
AutoQPointer(T *p)
Definition: autoqpointer.h:46
MessageViewer::AutoQPointer
A QPointer which when destructed, deletes the object it points to.
Definition: autoqpointer.h:38
MessageViewer::AutoQPointer::~AutoQPointer
~AutoQPointer()
Definition: autoqpointer.h:47
MessageViewer::AutoQPointer::operator->
T * operator->() const
Definition: autoqpointer.h:51
MessageViewer::AutoQPointer::isNull
bool isNull() const
Definition: autoqpointer.h:50
MessageViewer::AutoQPointer::operator*
T & operator*() const
Definition: autoqpointer.h:52
MessageViewer::AutoQPointer::data
T * data() const
Definition: autoqpointer.h:48
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:57 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

messageviewer

Skip menu "messageviewer"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal