3
* TOra - An Oracle Toolkit for DBA's and developers
4
* Copyright (C) 2003-2005 Quest Software, Inc
5
* Portions Copyright (C) 2005 Other Contributors
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; only version 2 of
10
* the License is valid for this program.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
* As a special exception, you have permission to link this program
22
* with the Oracle Client libraries and distribute executables, as long
23
* as you follow the requirements of the GNU GPL in regard to all of the
24
* software in the executable aside from Oracle client libraries.
26
* Specifically you are not permitted to link this program with the
27
* Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech.
28
* And you are not permitted to distribute binaries compiled against
29
* these libraries without written consent from Quest Software, Inc.
30
* Observe that this does not disallow linking to the Qt Free Edition.
32
* You may link this product with any GPL'd Qt library such as Qt/Free
34
* All trademarks belong to their respective owners.
38
#include "tochangeconnection.h"
39
#include "toconnection.h"
43
#include <qpopupmenu.h>
46
#include "tochangeconnection.moc"
48
#include "icons/changeconnect.xpm"
50
toChangeConnection::toChangeConnection(QToolBar *parent, const char *name)
51
: toPopupButton(QPixmap(const_cast<const char**>(changeconnect_xpm)),
52
tr("Change the connection of the tool."),
53
tr("Change the connection of the tool."),
56
setPopup(new QPopupMenu(this));
57
connect(popup(), SIGNAL(aboutToShow()), this, SLOT(popupMenu()));
58
connect(popup(), SIGNAL(activated(int)), this, SLOT(changeConnection(int)));
61
void toChangeConnection::popupMenu(void)
66
toConnection &conn = toCurrentConnection(this);
67
std::list<QString> cons = toMainWidget()->connections();
69
for (std::list<QString>::iterator i = cons.begin();i != cons.end();i++, idx++)
71
if (toCurrentTool(this)->canHandle(toMainWidget()->connection(*i)))
73
popup()->insertItem(*i, idx);
74
if (conn.description() == *i)
75
popup()->setItemChecked(idx, true);
82
void toChangeConnection::changeConnection(int val)
84
if (popup()->isItemChecked(val))
86
std::list<QString> cons = toMainWidget()->connections();
87
std::list<QString>::iterator i = cons.begin();
88
while (i != cons.end() && val > 0)
96
throw tr("Couldn't find selected connection");
97
QWidget *cur = parentWidget();
100
toToolWidget *tool = dynamic_cast<toToolWidget *>(cur);
103
tool->setConnection(toMainWidget()->connection(*i));
104
toMainWidget()->windowActivated(tool);
105
toMainWidget()->changeConnection();
108
cur = cur->parentWidget();
110
throw tr("Couldn't find parent connection. Internal error.");