source: trunk/tools/designer/plugins/wizards/main.cpp

Last change on this file was 197, checked in by rudi, 14 years ago

Added QtDesigner

File size: 3.8 KB
Line 
1/**********************************************************************
2** Copyright (C) 2005-2007 Trolltech ASA. All rights reserved.
3**
4** This file is part of Qt Designer.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
12** licenses may use this file in accordance with the Qt Commercial License
13** Agreement provided with the Software.
14**
15** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17**
18** See http://www.trolltech.com/gpl/ for GPL licensing information.
19** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
20** information about Qt Commercial License Agreements.
21**
22** Contact info@trolltech.com if any conditions of this licensing are
23** not clear to you.
24**
25**********************************************************************/
26
27#include <designerinterface.h>
28#include <qfeatures.h>
29#include <qwidget.h>
30#include <templatewizardiface.h>
31#ifndef QT_NO_SQL
32#include "sqlformwizardimpl.h"
33#endif
34#include "mainwindowwizard.h"
35#include <qapplication.h>
36
37class StandardTemplateWizardInterface : public TemplateWizardInterface, public QLibraryInterface
38{
39public:
40 StandardTemplateWizardInterface();
41 virtual ~StandardTemplateWizardInterface();
42
43 QRESULT queryInterface( const QUuid&, QUnknownInterface** );
44 Q_REFCOUNT;
45
46 QStringList featureList() const;
47
48 void setup( const QString &templ, QWidget *widget, DesignerFormWindow *fw, QUnknownInterface *aIface );
49
50 bool init();
51 void cleanup();
52 bool canUnload() const;
53
54private:
55 bool inUse;
56};
57
58StandardTemplateWizardInterface::StandardTemplateWizardInterface()
59 : inUse( FALSE )
60{
61}
62
63StandardTemplateWizardInterface::~StandardTemplateWizardInterface()
64{
65}
66
67bool StandardTemplateWizardInterface::init()
68{
69 return TRUE;
70}
71
72void StandardTemplateWizardInterface::cleanup()
73{
74}
75
76bool StandardTemplateWizardInterface::canUnload() const
77{
78 return !inUse;
79}
80
81QStringList StandardTemplateWizardInterface::featureList() const
82{
83 QStringList list;
84#ifndef QT_NO_SQL
85 list << "QDataBrowser" << "QDesignerDataBrowser" << "QDataView" << \
86 "QDesignerDataView" << "QDataTable";
87#endif
88 list << "QMainWindow";
89
90 return list;
91}
92
93void StandardTemplateWizardInterface::setup( const QString &templ, QWidget *widget, DesignerFormWindow *fw, QUnknownInterface *aIface )
94{
95 inUse = TRUE;
96#ifndef QT_NO_SQL
97 if ( templ == "QDesignerDataView" ||
98 templ == "QDesignerDataBrowser" ||
99 templ == "QDataView" ||
100 templ == "QDataBrowser" ||
101 templ == "QDataTable" ) {
102 SqlFormWizard wizard( aIface, widget, qApp->mainWidget(), fw, 0, TRUE );
103 wizard.exec();
104 }
105#endif
106 if ( templ == "QMainWindow" ) {
107 MainWindowWizardBase wizard( qApp->mainWidget(), 0, TRUE );
108 wizard.setAppInterface( aIface, fw, widget );
109 wizard.exec();
110 }
111 inUse = FALSE;
112}
113
114QRESULT StandardTemplateWizardInterface::queryInterface( const QUuid& uuid, QUnknownInterface** iface )
115{
116 *iface = 0;
117 if ( uuid == IID_QUnknown )
118 *iface = (QUnknownInterface*)(TemplateWizardInterface*) this;
119 else if ( uuid == IID_QFeatureList )
120 *iface = (QFeatureListInterface*)this;
121 else if ( uuid == IID_TemplateWizard )
122 *iface = (TemplateWizardInterface*)this;
123 else if ( uuid == IID_QLibrary )
124 *iface = (QLibraryInterface*)this;
125 else
126 return QE_NOINTERFACE;
127
128 (*iface)->addRef();
129 return QS_OK;
130}
131
132Q_EXPORT_COMPONENT()
133{
134 Q_CREATE_INSTANCE( StandardTemplateWizardInterface )
135}
Note: See TracBrowser for help on using the repository browser.