summaryrefslogtreecommitdiffstats
path: root/kexi/migration/importwizard.h
blob: 97ffec4f0c437db2989f8f0f4146ec6a7370636d (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
/* This file is part of the KDE project
   Copyright (C) 2004 Adam Pigg <[email protected]>
   Copyright (C) 2004-2006 Jaroslaw Staniek <[email protected]>
   Copyright (C) 2005 Martin Ellis <[email protected]>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

#ifndef KEXIMIGRATIONIMPORTWIZARD_H
#define KEXIMIGRATIONIMPORTWIZARD_H

#include <kwizard.h>
#include <kprogress.h>
#include <kapplication.h>

#include <kexiutils/tristate.h> 
#include "migratemanager.h"

class TQLabel;
class TQCheckBox;
class TQPushButton;
class TQHBoxLayout;
class TQVBoxLayout;
class TQVButtonGroup;
class KComboBox;
class KListView;
class KLineEdit;
class KexiConnSelectorWidget;
class KexiProjectSelectorWidget;
class KexiProjectSet;
class KexiDBTitlePage;
class KexiDBDriverComboBox;
class KexiPrjTypeSelector;

namespace Kexi
{
	class ObjectStatus;
}

namespace KexiDB
{
	class ConnectionData;
}

namespace KexiMigration {

class KexiMigrate;

//! GUI for importing external databases (file-based and server-based)
class KEXIMIGR_EXPORT ImportWizard : public KWizard
{
Q_OBJECT
  
public:
	/*! Creates wizard's instance. 
	 \a args contains arguments that can be parsed by parseArguments().
	 \a *arg will be also set to imported project's filename on success
	 and to null value on failure or cancellation. */
	ImportWizard(TQWidget *parent = 0, TQMap<TQString,TQString>* args = 0);
	virtual ~ImportWizard();

public slots:
	void progressUpdated(int percent);

protected slots:
	virtual void next();
	virtual void back();
	void pageSelected(const TQString &);
	virtual void accept();
	virtual void reject();
	void helpClicked();
	void slotOptionsButtonClicked();

private:
	void parseArguments();
	void setupIntro();
//	void setupSrcType();
	void setupSrcConn();
	void setupSrcDB();
	void setupDstType();
	void setupDstTitle();
	void setupDst();
	void setupFinish();
	void setupImportType();
	void setupImporting();
	bool checkUserInput();

	KexiMigrate* prepareImport(Kexi::ObjectStatus& result);

	/*! Performs import. \return true/false on success/faulure 
	 or cancelled when user cancelled importing (mainly 
	 because didn't allow overwriting an existing database by a new one). */
	tristate import();

	bool fileBasedSrcSelected() const;
	bool fileBasedDstSelected() const;
	TQString driverNameForSelectedSource();
//	void checkIfSrcTypeFileBased(const TQString& srcType);
//	void checkIfDstTypeFileBased(const TQString& dstType);

	void arriveSrcConnPage();
	void arriveSrcDBPage();
	void arriveDstTitlePage();
	void arriveDstPage();
	void arriveFinishPage();
	void arriveImportingPage();

	TQWidget *m_introPage, /* *m_srcTypePage,*/ *m_srcConnPage, *m_srcDBPage, 
		*m_dstTypePage, *m_dstPage, *m_importTypePage, *m_importingPage, *m_finishPage;

	TQVButtonGroup *m_importTypeButtonGroup;
	KexiDBTitlePage* m_dstTitlePage;

	KComboBox *m_srcTypeCombo;
	KexiDBDriverComboBox *m_dstServerTypeCombo;
	KexiPrjTypeSelector *m_dstPrjTypeSelector;

	KexiConnSelectorWidget *m_srcConn, *m_dstConn;
	KLineEdit *m_dstNewDBNameLineEdit;
	KexiProjectSelectorWidget *m_srcDBName;

	TQLabel *m_lblImportingTxt, *m_lblImportingErrTxt, *m_finishLbl;
	TQCheckBox *m_openImportedProjectCheckBox;
	bool m_fileBasedDstWasPresented, m_setupFileBasedSrcNeeded, 
		m_importExecuted; //!< used in import()
	KexiProjectSet* m_prjSet;
	KProgress *m_progressBar;
	TQPushButton* m_importOptionsButton;
	TQMap<TQString,TQString> *m_args;
	TQString m_predefinedDatabaseName, m_predefinedMimeType;
	KexiDB::ConnectionData *m_predefinedConnectionData;
	MigrateManager m_migrateManager; //!< object lives here, so status messages can be globally preserved

	//! Encoding for source db. Currently only used for MDB driver.
//! @todo Hardcoded. Move to KexiMigrate driver's impl.
	TQString m_sourceDBEncoding;
};

}

#endif