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
|
/* This file is part of the KDE project
Copyright (C) 2003,2005 Jaroslaw Staniek <js@iidea.pl>
This program 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 program 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 program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KEXICONNSELECTOR_H
#define KEXICONNSELECTOR_H
#include <kexidbconnectionset.h>
#include <kexidb/driver.h>
#include "KexiStartupFileDialog.h"
#include <kdialogbase.h>
#include <klistview.h>
#include <tqguardedptr.h>
class KexiConnSelectorBase;
//! helper class
class ConnectionDataLVItem : public TQListViewItem
{
public:
ConnectionDataLVItem(KexiDB::ConnectionData *data,
const KexiDB::Driver::Info& info, TQListView *list);
~ConnectionDataLVItem();
void update(const KexiDB::Driver::Info& info);
KexiDB::ConnectionData *data() const { return m_data; }
protected:
KexiDB::ConnectionData *m_data;
};
//class KexiOpenExistingFile;
class KexiConnSelectorWidgetPrivate;
/*! Widget that allows to select a database connection (without choosing database itself)
*/
class KEXIMAIN_EXPORT KexiConnSelectorWidget : public TQWidget
{
Q_OBJECT
public:
enum ConnType { FileBased=1, ServerBased=2 };
/*! Constructs a KexiConnSelector which contain \a conn_set as connection set.
\a conn_set can be altered, because Add/Edit/Remove buttons are available
to users. \a startDirOrVariable can be provided to specify a start dir for file browser
(it can also contain a configuration variable name with ":" prefix as described
in TDERecentDirs documentation). */
KexiConnSelectorWidget( KexiDBConnectionSet& conn_set,
const TQString& startDirOrVariable,
TQWidget* parent = 0, const char* name = 0 );
virtual ~KexiConnSelectorWidget();
/*! After accepting this dialog this method returns wherher user selected
file- or server- based connection (ConnType enum). */
int selectedConnectionType() const;
/*! \return data of selected connection, if server-based connection was selected.
Returns NULL if no selection has been made or file-based connection
has been selected.
@see selectedConnectionType()
*/
KexiDB::ConnectionData* selectedConnectionData() const;
/*! \return the name of database file, if file-based connection was selected.
Returns null string if no selection has been made or server-based connection
has been selected.
@see selectedConnectionType()
*/
TQString selectedFileName();
/*! Sets selected filename to \a fileName.
Only works when selectedConnectionType()==FileBased. */
void setSelectedFileName(const TQString& fileName);
// //! Usable when we want to do other things for "back" button
// void disconnectShowSimpleConnButton();
TQListView* connectionsList() const;
KexiConnSelectorBase *m_remote;
// KexiOpenExistingFile *m_file;
KexiStartupFileDialog *m_fileDlg;
/*! If true, user will be asked to accept overwriting existing project.
This is true by default. */
void setConfirmOverwrites(bool set);
bool confirmOverwrites() const;
signals:
void connectionItemExecuted(ConnectionDataLVItem *item);
void connectionItemHighlighted(ConnectionDataLVItem *item);
public slots:
void showSimpleConn();
void showAdvancedConn();
virtual void setFocus();
/*! Hides helpers on the server based connection page
(sometimes it's convenient not to have these):
- "Select existing database server's connection..." (label at the top)
- "Click "Back" button" (label at the bottom)
- "Back" button itself */
void hideHelpers();
void hideConnectonIcon();
protected slots:
void slotConnectionItemExecuted(TQListViewItem *item);
void slotRemoteAddBtnClicked();
void slotRemoteEditBtnClicked();
void slotRemoteRemoveBtnClicked();
void slotConnectionSelectionChanged();
void slotPrjTypeSelected(int id);
private:
ConnectionDataLVItem* addConnectionData( KexiDB::ConnectionData* data );
ConnectionDataLVItem* selectedConnectionDataItem() const;
KexiConnSelectorWidgetPrivate *d;
};
#endif // KEXICONNSELECTOR_H
|