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 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558
|
/*****
*
* TOra - An Oracle Toolkit for DBA's and developers
* Copyright (C) 2003-2005 Quest Software, Inc
* Portions Copyright (C) 2005 Other Contributors
*
* 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; only version 2 of
* the License is valid for this program.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* As a special exception, you have permission to link this program
* with the Oracle Client libraries and distribute executables, as long
* as you follow the requirements of the GNU GPL in regard to all of the
* software in the executable aside from Oracle client libraries.
*
* Specifically you are not permitted to link this program with the
* Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech.
* And you are not permitted to distribute binaries compiled against
* these libraries without written consent from Quest Software, Inc.
* Observe that this does not disallow linking to the Qt Free Edition.
*
* You may link this product with any GPL'd Qt library such as Qt/Free
*
* All trademarks belong to their respective owners.
*
*****/
#ifndef TOMAIN_H
#define TOMAIN_H
#include "config.h"
#include "tobackground.h"
#ifdef TO_KDE
#include "tomainwindow.kde.h"
#else
#include "tomainwindow.h"
#endif
#include <list>
#include <map>
#include <qtimer.h>
#if QT_VERSION >= 0x030000
class QUrlOperator;
#endif
#define TOMessageBox QMessageBox
class QComboBox;
class QLabel;
class QListView;
class QListViewItem;
class QNetworkOperation;
class QPopupMenu;
class QToolBar;
class QToolButton;
class QWorkspace;
class toConnection;
class toEditWidget;
class toLineChart;
class toMarkedText;
class toSearchReplace;
class toTool;
class toToolWidget;
/** This class defines the main window. Observe that this class will have different baseclass
* depending on if TOra is a Qt or KDE application. In the case of Qt this will be a
* QMainWindow descendant.
*/
class toMain : public toMainWindow {
Q_OBJECT
private:
/**
* The connections that have been opened in TOra.
*/
std::list<toConnection *> Connections;
/**
* Workspace of main window.
*/
QWorkspace *Workspace;
/**
* Handles available connections list in toolbar.
*/
QComboBox *ConnectionSelection;
/**
* Add a new connection. The connection itself must already be created.
* Returns the connection or it's duplicate already opened connection.
*/
toConnection *addConnection(toConnection *conn,bool def=true);
/**
* A map from menu ID:s to tools.
*/
std::map<int,toTool *> Tools;
/**
* A list of toolbuttons that need an open connection to be enabled.
*/
std::map<QToolButton *,bool> NeedConnection;
/**
* The ID of the tool providing the SQL editor.
*/
int SQLEditor;
/** Status messages to display
*/
std::list<QString> StatusMessages;
/**
* Disconnect connection button.
*/
QToolButton *DisconnectButton;
/**
* Load file button.
*/
QToolButton *LoadButton;
/**
* Save file button.
*/
QToolButton *SaveButton;
/**
* Print button.
*/
QToolButton *PrintButton;
/**
* Undo button.
*/
QToolButton *UndoButton;
/**
* Redo button.
*/
QToolButton *RedoButton;
/**
* Cut button.
*/
QToolButton *CutButton;
/**
* Copy button.
*/
QToolButton *CopyButton;
/**
* Paste button.
*/
QToolButton *PasteButton;
/**
* Paste button.
*/
QToolButton *SearchButton;
/**
* Edit buttons toolbar.
*/
QToolBar *EditToolbar;
/**
* Tool buttons toolbar.
*/
QToolBar *ToolsToolbar;
/**
* Connection buttons toolbar.
*/
QToolBar *ConnectionToolbar;
/**
* File menu.
*/
QPopupMenu *FileMenu;
/**
* Edit menu.
*/
QPopupMenu *EditMenu;
/**
* Tools menu.
*/
QPopupMenu *ToolsMenu;
/**
* Windows menu.
*/
QPopupMenu *WindowsMenu;
/**
* Help menu.
*/
QPopupMenu *HelpMenu;
/**
* Display latest status messages
*/
QPopupMenu *StatusMenu;
/**
* Current column label.
*/
QLabel *ColumnLabel;
/**
* Current row label.
*/
QLabel *RowLabel;
toBackground Poll;
/**
* Search & replace dialog if available.
*/
toSearchReplace *Search;
/**
* Default tool id
*/
int DefaultTool;
QTimer KeepAlive;
toEditWidget *Edit;
toEditWidget *findEdit(QWidget *edit);
void updateRecent(void);
void editEnable(toEditWidget *edit,
bool open,bool save,bool print,
bool undo,bool redo,
bool cut,bool copy,bool paste,
bool search,
bool selectAll,bool readAll);
public:
/** ID of the file menu
*/
static const int TO_FILE_MENU;
/** ID of the edit menu
*/
static const int TO_EDIT_MENU;
/** ID of the tools menu
*/
static const int TO_TOOLS_MENU;
/** ID of the windows menu
*/
static const int TO_WINDOWS_MENU;
/** ID of the help menu
*/
static const int TO_HELP_MENU;
/** First ID of the tool specific menu items.
*/
static const int TO_TOOL_MENU_ID;
/** Last ID of the tool specific menu items.
*/
static const int TO_TOOL_MENU_ID_END;
/** First ID of the tool specific menu items.
*/
static const int TO_LAST_FILE_ID;
/** Last ID of the tool specific menu items.
*/
static const int TO_LAST_FILE_ID_END;
/** First ID of the tool specific about menu items.
*/
static const int TO_TOOL_ABOUT_ID;
/** Last ID of the tool specific about menu items.
*/
static const int TO_TOOL_ABOUT_ID_END;
/**
* Create main window. Always NULL as parent.
*/
toMain();
/**
* Get the workspace widget of the main window.
* @return Workspace widget.
*/
QWorkspace *workspace()
{ return Workspace; }
/**
* Get the current database connection
* @return Reference to current connection.
*/
toConnection ¤tConnection(void);
/**
* Set the widget to edit through menues and toolbar.
*/
static void setEditWidget(toEditWidget *edit);
/**
* Set available menu items in user interface. It is not enough to just call
* this function to make open for instance to actually work. It is a lot of
* more especially in @ref commandCallback and @ref editFileMenu. Will only
* update if this is the current editing widget.
*/
static void editEnable(toEditWidget *edit);
/**
* Disable all the current available items in the user interface (That @ref
* editEnable can enable). If specified widget has the focus the edit widget
* is cleared.
*/
static void editDisable(toEditWidget *edit);
/** Get current edit widget
*/
toEditWidget *editWidget()
{ return Edit; }
/**
* Close window
* @param del If user interaction is allowed.
* @return True if close was allowed, otherwise false.
*/
virtual bool close(bool del);
/**
* Create the default tool for the current connection.
*
* This is the tool with the highest priority, usually the SQL worksheet.
*/
void createDefault(void);
/**
* Set coordinates in the statusbar.
*
* Used to indicate current cursor position by child widgets.
*/
void setCoordinates(int,int);
/**
* Get the file menu.
* @return File menu
*/
QPopupMenu *fileMenu()
{ return FileMenu; }
/**
* Get the edit menu.
* @return Edit menu
*/
QPopupMenu *editMenu()
{ return EditMenu; }
/**
* Get the tools menu.
* @return Tools menu
*/
QPopupMenu *toolsMenu()
{ return ToolsMenu; }
/**
* Get the help menu.
* @return Help menu
*/
QPopupMenu *helpMenu()
{ return HelpMenu; }
/* Update the keepalive from configuration
*/
void updateKeepAlive();
/**
* Get a list of currently open connections.
* @return List of connection names. The returned list can then be used by
* @ref connection to get the actual connection.
*/
std::list<QString> connections(void);
/** Get a connection identified by a string.
* @return A reference to a connection.
* @exception QString If connection wasn't found.
*/
toConnection &connection(const QString &);
/** Set if a connection needs to be commited. Also updates visual feedback in interface.
*/
void setNeedCommit(toConnection &conn,bool needCommit=true);
/** Edit an SQL statement in the SQL editor if any connected.
* @param str Identifier of the SQL to edit.
*/
void editSQL(const QString &str);
/**
* Register a tool which to use as an SQL editor. When something is to be edited
* first a toolwindow will be created and the @ref sqlEditor will be emited, so
* the SQL editor must connect to this signal as well.
*
* @param toolid Which tool identifier to register as the SQL editor. This
* is the value which is passed to the @ref toTool::customSetup
* member.
*/
void registerSQLEditor(int toolid);
/** Called by @ref toTool when a new tool is created.
* @param tool The tool widget created.
*/
void toolWidgetAdded(toToolWidget *tool);
/** Called by @ref toToolWidget when a new tool is about to be destroyed.
* @param tool The tool widget created.
*/
void toolWidgetRemoved(toToolWidget *tool);
/** Export data to a map.
* @param data A map that can be used to recreate the session.
* @param prefix Prefix to add to the map.
*/
virtual void exportData(std::map<QCString,QString> &data,const QCString &prefix);
/** Import data
* @param data Data to read from a map.
* @param prefix Prefix to read data from.
*/
virtual void importData(std::map<QCString,QString> &data,const QCString &prefix);
/** Get edit toolbar pointer.
*/
QToolBar *editToolbar()
{ return EditToolbar; }
/** Get connection toolbar pointer.
*/
QToolBar *connectionToolbar()
{ return ConnectionToolbar; }
/** Added chart.
*/
void addChart(toLineChart *chart);
/** Removed chart.
*/
void removeChart(toLineChart *chart);
/** Setup chart.
*/
void setupChart(toLineChart *chart);
/** Display status message in dialog.
*/
void displayMessage(const QString &str);
/** Add recent file
*/
void addRecentFile(const QString &filename);
signals:
/** Invoked to start editing an SQL identifier.
* @param str Identifier to start editing.
*/
void sqlEditor(const QString &str);
/** Invoked when a new chart is created.
*/
void chartAdded(toLineChart *chart);
/** Invoked before a chart is destroyed.
*/
void chartSetup(toLineChart *chart);
/** Invoked before a chart is destroyed.
*/
void chartRemoved(toLineChart *chart);
/** Invoked when a connection is added.
* @param str Connection identifier.
*/
void addedConnection(const QString &str);
/** Invoked when a connection is removed.
* @param str Connection identifier.
*/
void removedConnection(const QString &str);
/** Invoked when a tool window is created.
* @param tool The tool created.
*/
void addedToolWidget(toToolWidget *tool);
/** Invoked when a tool window is closed.
* @param tool Tool about to be removed.
*/
void removedToolWidget(toToolWidget *tool);
/** Emitted before a commit or rollback is made to the current connection.
* @param conn Connection that is commited
* @param cmt True if commit, false if rollback.
*/
void willCommit(toConnection &conn,bool cmt);
public slots:
/** Used to enable/disable entries in the windows menu
*/
void windowsMenu(void);
/** Used to fill the status menu with the latest status entries
*/
void statusMenu(void);
/** Display context help.
*/
void contextHelp(void);
/** Called when active window is changed.
*/
void windowActivated(QWidget *);
/** Used to enable/disable entries in the file menu
*/
void showFileMenu(void);
/** Check if object caching is done.
*/
void checkCaching(void);
/** Save the current TOra session
*/
void saveSession(void);
/** Load a session (Merge with current)
*/
void loadSession(void);
/** Close all windows and connections.
*/
void closeSession(void);
/** Change current connection
*/
void changeConnection(void);
private slots:
/** Add a connection
*/
void addConnection(void);
/** Remove a connection
*/
bool delConnection(void);
/** Handles menu selections
* @param cmd Menu entry ID selected
*/
void commandCallback(int cmd);
/** Commit button pressed
*/
void commitButton(void);
/** Rollback button pressed
*/
void rollbackButton(void);
/** Load button pressed
*/
void loadButton(void);
/** Save button pressed
*/
void saveButton(void);
/** Print button pressed
*/
void printButton(void);
/** Options button pressed
*/
void optionButton(void);
/** Undo button pressed
*/
void undoButton(void);
/** Redo button pressed
*/
void redoButton(void);
/** Copy button pressed
*/
void copyButton(void);
/** Cut button pressed
*/
void cutButton(void);
/** Paste button pressed
*/
void pasteButton(void);
/** Paste button pressed
*/
void searchButton(void);
/** Stop running queries on connection
*/
void stopButton(void);
/** Display status message
*/
void displayMessage(void);
void keepAlive();
};
/** Get a pointer to the main window
* @return Pointer to main window.
*/
toMain *toMainWidget(void);
#endif
|