1 | /**********************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2005-2007 Trolltech ASA. All rights reserved.
|
---|
4 | **
|
---|
5 | ** This file is part of Qt Designer.
|
---|
6 | **
|
---|
7 | ** This file may be distributed and/or modified under the terms of the
|
---|
8 | ** GNU General Public License version 2 as published by the Free Software
|
---|
9 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
10 | ** packaging of this file.
|
---|
11 | **
|
---|
12 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
13 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
14 | ** Agreement provided with the Software.
|
---|
15 | **
|
---|
16 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
17 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
18 | **
|
---|
19 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
20 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
21 | ** information about Qt Commercial License Agreements.
|
---|
22 | **
|
---|
23 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
24 | ** not clear to you.
|
---|
25 | **
|
---|
26 | **********************************************************************/
|
---|
27 |
|
---|
28 | #include "preferenceinterfaceimpl.h"
|
---|
29 | #include <preferences.h>
|
---|
30 |
|
---|
31 | PreferenceInterfaceImpl::PreferenceInterfaceImpl( QUnknownInterface *outer )
|
---|
32 | : parent( outer ),
|
---|
33 | ref( 0 ),
|
---|
34 | cppEditorSyntax( 0 )
|
---|
35 | {
|
---|
36 | }
|
---|
37 |
|
---|
38 | PreferenceInterfaceImpl::~PreferenceInterfaceImpl()
|
---|
39 | {
|
---|
40 | }
|
---|
41 |
|
---|
42 | ulong PreferenceInterfaceImpl::addRef()
|
---|
43 | {
|
---|
44 | return parent ? parent->addRef() : ref++;
|
---|
45 | }
|
---|
46 |
|
---|
47 | ulong PreferenceInterfaceImpl::release()
|
---|
48 | {
|
---|
49 | if ( parent )
|
---|
50 | return parent->release();
|
---|
51 | if ( !--ref ) {
|
---|
52 | delete this;
|
---|
53 | return 0;
|
---|
54 | }
|
---|
55 | return ref;
|
---|
56 | }
|
---|
57 |
|
---|
58 | QRESULT PreferenceInterfaceImpl::queryInterface( const QUuid &uuid, QUnknownInterface** iface )
|
---|
59 | {
|
---|
60 | if ( parent )
|
---|
61 | return parent->queryInterface( uuid, iface );
|
---|
62 |
|
---|
63 | *iface = 0;
|
---|
64 | if ( uuid == IID_QUnknown )
|
---|
65 | *iface = (QUnknownInterface*)this;
|
---|
66 | else if ( uuid == IID_Preference )
|
---|
67 | *iface = (PreferenceInterface*)this;
|
---|
68 | else
|
---|
69 | return QE_NOINTERFACE;
|
---|
70 |
|
---|
71 | (*iface)->addRef();
|
---|
72 | return QS_OK;
|
---|
73 | }
|
---|
74 |
|
---|
75 | PreferenceInterface::Preference *PreferenceInterfaceImpl::preference()
|
---|
76 | {
|
---|
77 | if ( !cppEditorSyntax ) {
|
---|
78 | cppEditorSyntax = new PreferencesBase( 0, "cppeditor_syntax" );
|
---|
79 | ( (PreferencesBase*)cppEditorSyntax )->setPath( "/Trolltech/CppEditor/" );
|
---|
80 | cppEditorSyntax->hide();
|
---|
81 | }
|
---|
82 | Preference *pf = 0;
|
---|
83 | pf = new Preference;
|
---|
84 | pf->tab = cppEditorSyntax;
|
---|
85 | pf->title = "C++ Editor";
|
---|
86 | pf->receiver = pf->tab;
|
---|
87 | pf->init_slot = SLOT( reInit() );
|
---|
88 | pf->accept_slot = SLOT( save() );
|
---|
89 | return pf;
|
---|
90 | }
|
---|
91 |
|
---|
92 | void PreferenceInterfaceImpl::deletePreferenceObject( Preference *p )
|
---|
93 | {
|
---|
94 | delete p;
|
---|
95 | }
|
---|