~ubuntu-branches/ubuntu/wily/psi/wily-proposed

« back to all changes in this revision

Viewing changes to src/libpsi/tools/mac_dock/privateqt_mac.h

  • Committer: Package Import Robot
  • Author(s): Jan Niehusmann
  • Date: 2014-07-01 21:49:34 UTC
  • mfrom: (6.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20140701214934-gt4dkgm94byi4vnn
Tags: 0.15-1
* New upstream version
* set debhelper compat level to 9
* set Standards-Version to 3.9.5 (no further changes)
* add lintian override regarding license-problem-non-free-RFC
* use qconf to regenerate configure script
* implement hardening using buildflags instead of hardening-wrapper

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * privateqt_mac.h
 
3
 * Copyright (C) 2009  Yandex LLC (Michail Pishchagin)
 
4
 * based on http://doc.trolltech.com/solutions/4/qtspellcheckingtextedit/
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU General Public License
 
8
 * as published by the Free Software Foundation; either version 2
 
9
 * of the License, or (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this library; if not, write to the Free Software
 
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
19
 *
 
20
 */
 
21
 
 
22
#ifndef PRIVATEQT_MAC_H
 
23
#define PRIVATEQT_MAC_H
 
24
 
 
25
#include <CoreFoundation/CoreFoundation.h>
 
26
#include <QtCore/QString>
 
27
 
 
28
template <typename T>
 
29
class QtCFType
 
30
{
 
31
public:
 
32
        inline QtCFType(const T &t = 0) : type(t) {}
 
33
        inline QtCFType(const QtCFType &helper) : type(helper.type) {
 
34
                if (type) CFRetain(type);
 
35
        }
 
36
        inline ~QtCFType() {
 
37
                if (type) CFRelease(type);
 
38
        }
 
39
        inline operator T() {
 
40
                return type;
 
41
        }
 
42
        inline QtCFType operator=(const QtCFType &helper) {
 
43
                if (helper.type)
 
44
                        CFRetain(helper.type);
 
45
                CFTypeRef type2 = type;
 
46
                type = helper.type;
 
47
                if (type2)
 
48
                        CFRelease(type2);
 
49
                return *this;
 
50
        }
 
51
        inline T *operator&() {
 
52
                return &type;
 
53
        }
 
54
        static QtCFType constructFromGet(const T &t) {
 
55
                CFRetain(t);
 
56
                return QtCFType<T>(t);
 
57
        }
 
58
protected:
 
59
        T type;
 
60
};
 
61
 
 
62
class QtCFString : public QtCFType<CFStringRef>
 
63
{
 
64
public:
 
65
        inline QtCFString(const QString &str) : QtCFType<CFStringRef>(0), string(str) {}
 
66
        inline QtCFString(const CFStringRef cfstr = 0) : QtCFType<CFStringRef>(cfstr) {}
 
67
        inline QtCFString(const QtCFType<CFStringRef> &other) : QtCFType<CFStringRef>(other) {}
 
68
        operator QString() const;
 
69
        operator CFStringRef() const;
 
70
        static QString toQString(CFStringRef cfstr);
 
71
        static CFStringRef toCFStringRef(const QString &str);
 
72
private:
 
73
        QString string;
 
74
};
 
75
 
 
76
class QtMacCocoaAutoReleasePool
 
77
{
 
78
private:
 
79
        void *pool;
 
80
public:
 
81
        QtMacCocoaAutoReleasePool();
 
82
        ~QtMacCocoaAutoReleasePool();
 
83
 
 
84
        inline void *handle() const {
 
85
                return pool;
 
86
        }
 
87
};
 
88
 
 
89
struct _NSRange;
 
90
typedef struct _NSRange NSRange;
 
91
 
 
92
#endif