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

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

Added QtDesigner

File size: 3.1 KB
Line 
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 <filterinterface.h>
29
30#include <qapplication.h>
31#include <qstring.h>
32#include <qdir.h>
33
34#include "kdevdlg2ui.h"
35
36class KDevDlgFilter : public ImportFilterInterface, public QLibraryInterface
37{
38public:
39 KDevDlgFilter();
40
41 QRESULT queryInterface( const QUuid&, QUnknownInterface **iface );
42 Q_REFCOUNT;
43
44 QStringList featureList() const;
45 QStringList import( const QString& filter, const QString& filename );
46
47 bool init();
48 void cleanup();
49 bool canUnload() const;
50};
51
52KDevDlgFilter::KDevDlgFilter()
53{
54}
55
56QRESULT KDevDlgFilter::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
57{
58 *iface = 0;
59 if ( uuid == IID_QUnknown )
60 *iface = (QUnknownInterface*)(ImportFilterInterface*)this;
61 else if ( uuid == IID_QFeatureList )
62 *iface = (QFeatureListInterface*)this;
63 else if ( uuid == IID_ImportFilter )
64 *iface = (ImportFilterInterface*)this;
65 else if ( uuid == IID_QLibrary )
66 *iface = (QLibraryInterface*)this;
67 else
68 return QE_NOINTERFACE;
69
70 (*iface)->addRef();
71 return QS_OK;
72}
73
74QStringList KDevDlgFilter::featureList() const
75{
76 QStringList list;
77 list << "KDevelop Dialog Files (*.kdevdlg)" ;
78 return list;
79}
80
81QStringList KDevDlgFilter::import( const QString &, const QString& filename )
82{
83 QFile file( filename );
84 if ( !file.open( IO_ReadOnly ) )
85 qWarning( "uic: Could not open file '%s' ", filename.latin1() );
86 QTextStream in;
87 in.setDevice( &file );
88
89 QString name = filename.right( filename.length() - filename.findRev( QDir::separator() ) - 1 ).section( ".", 0, 0 );
90 KDEVDLG2UI c( &in, name );
91 QStringList files;
92 c.parse();
93 return c.targetFiles;
94}
95
96bool KDevDlgFilter::init()
97{
98 return TRUE;
99}
100
101void KDevDlgFilter::cleanup()
102{
103}
104
105bool KDevDlgFilter::canUnload() const
106{
107 return TRUE;
108}
109
110Q_EXPORT_COMPONENT()
111{
112 Q_CREATE_INSTANCE( KDevDlgFilter )
113}
Note: See TracBrowser for help on using the repository browser.