summaryrefslogtreecommitdiffstats
path: root/parts/appwizard/appwizarddlg.h
blob: 7ce8c2ff37045c7495d61e0395879a3da2242ceb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/***************************************************************************
 *   Copyright (C) 2001 by Bernd Gehrmann                                  *
 *   bernd@kdevelop.org                                                    *
 *   Copyright (C) 2001 by Sandy Meier                                     *
 *   smeier@kdevelop.org                                                   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef _APPWIZARDDIALOG_H_
#define _APPWIZARDDIALOG_H_

class AppWizardPart;
class QMultiLineEdit;
class QRadioButton;
class KTempFile;
class QWidgetStack;
class QVBox;
class KPopupMenu;
class QHBoxLayout;
class KArchiveDirectory;
class KArchiveFile;
class ProfileSupport;
#include <qptrlist.h>
#include <qdict.h>
#include <klineedit.h>
#include <qlabel.h>
#include <qstringlist.h>
#include <klistview.h>
#include <kiconview.h>
#include "kdevversioncontrol.h"
#include "kdevvcsintegrator.h"
#include "appwizarddlgbase.h"
#include "vcs_form.h"
//#include "autoform.h"
#include "kdevlicense.h"

namespace PropertyLib {
	class PropertyList;
	class PropertyEditor;
}

struct installFile
{
	QString source;
	QString dest;
	QString option;
	bool process;
	bool isXML;
};

struct installArchive
{
	QString source;
	QString dest;
	QString option;
	bool process;
};

struct installDir
{
	QString dir;
	QString option;
	int perms;
};

struct ApplicationInfo
{
    QString templateName;
    QString name;
    QString comment;
    QString icon;
    QString category;
    QString defaultDestDir;
    QString fileTemplates;
    QStringList openFilesAfterGeneration;
    QString templateFile;
    QMap<QString,QString> subMap;
	QMap<QString,QString> subMapXML;
    QStringList includes;

	//QMap<autoKey,QVariant> subValues;
	PropertyLib::PropertyList *propValues;

    QValueList<installFile> fileList;
    QValueList<installArchive> archList;
    QValueList<installDir> dirList;
    QString customUI;
    QString message;
    QString finishCmd;
    QString finishCmdDir;
    QString sourceArchive;

    //! item pointer to the listview
    QListViewItem *item;

	//! pointer to favourite icon (NULL if there isn't one)
	QIconViewItem *favourite;

    ApplicationInfo()
    : item( 0 ), favourite( 0 )
    {}
};

struct AppWizardFileTemplate
{
    QString suffix;
    QString style;
    QMultiLineEdit *edit;

    AppWizardFileTemplate()
    : edit( 0 )
    {}
};


class AppWizardDialog : public AppWizardDialogBase
{
    Q_OBJECT

public:
    AppWizardDialog( AppWizardPart *part, QWidget *parent=0, const char *name=0 );
    ~AppWizardDialog();
    QString getProjectName() { return appname_edit->text(); }
    QString getProjectLocation() { return finalLoc_label->text(); }

protected:
    virtual void accept();

	virtual QDict<KDevLicense> licenses();
	void loadLicenses();

protected slots:
    virtual void templatesTreeViewClicked(QListViewItem*);
    virtual void textChanged();
    virtual void licenseChanged();
    virtual void destButtonClicked(const QString&);
    virtual void projectNameChanged();
    virtual void projectLocationChanged();
    virtual void favouritesIconViewClicked( QIconViewItem * );
	virtual void templatesContextMenu(QListViewItem*, const QPoint&, int);
	virtual void favouritesContextMenu(QIconViewItem* item, const QPoint& point);
	virtual void addTemplateToFavourites();
	virtual void done(int r);
	virtual void removeFavourite();
	virtual void pageChanged();

private: //methods

    ApplicationInfo *templateForItem(QListViewItem *item);
    void insertCategoryIntoTreeView(const QString &completeCategoryPath);
    void loadVcs();
	void updateNextButtons();

	void populateFavourites();
	void addFavourite(QListViewItem* item, QString favouriteName="");
	ApplicationInfo* findFavouriteInfo(QIconViewItem* item);

	void unpackArchive( const KArchiveDirectory *dir, const QString &dest, bool process );
	bool copyFile( const installFile& file );
	bool copyFile( const QString &source, const QString &dest, bool isXML, bool process );
	QString kdevRoot(const QString &templateName ) const;
	void openAfterGeneration();

	void setPermissions(const KArchiveFile *source, QString dest);
	void setPermissions(const installFile &file);

	void checkAndHideItems(QListView *view);
	bool checkAndHideItems(QListViewItem *item);

private: //data

    QPtrList<ApplicationInfo> m_appsInfo;
	QValueList<AppWizardFileTemplate> m_fileTemplates;
    //! Store the category name and the pointer in the treeview
    QDict<QListViewItem> m_categoryMap;
	QValueList<QListViewItem*> m_categoryItems;
    //! A list of currently available version control systems
//    QDict<KDevVersionControl> m_availVcs;

    QHBoxLayout *m_custom_options_layout;
	PropertyLib::PropertyEditor *m_customOptions;
    AppWizardPart *m_part;
    QWidget *m_lastPage;
    QPtrList<KTempFile> m_tempFiles;
    ApplicationInfo* m_pCurrentAppInfo;
    bool m_projectLocationWasChanged;
    VcsForm *m_vcsForm;
    bool m_pathIsValid;
	KPopupMenu* m_favouritesMenu;
	KPopupMenu* m_templatesMenu;

	QDict<KDevLicense> m_licenses;
	QDict<KDevVCSIntegrator> m_integrators;
	QMap<int, VCSDialog*> m_integratorDialogs;

	ProfileSupport *m_profileSupport;

public slots:
    virtual void showTemplates(bool all);
};

#endif

// kate: indent-width 4; replace-tabs off; tab-width 4; space-indent off;