00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef __TOMAIN_H
00036 #define __TOMAIN_H
00037
00038 #include <list>
00039 #include <map>
00040
00041 #include <qmainwindow.h>
00042 #include <qtimer.h>
00043 #include <qtoolbutton.h>
00044
00045 #include "tobackground.h"
00046
00047 #if 0
00048
00051 class TOPrinter : public QPrinter {
00052
00053 };
00057 class TODock : public QWidget {
00058
00059 };
00063 class TOFileDialog : public QFileDialog {
00064
00065 };
00069 class TOMessageBox : public QMessageBox {
00070
00071 };
00072 #endif
00073
00074 #ifdef TO_KDE
00075 # include <kapp.h>
00076 # include <kdockwidget.h>
00077 # if KDE_VERSION < 220
00078 # define TOPrinter QPrinter
00079 # else
00080 # define TOPrinter KPrinter
00081 # define TO_HAS_KPRINT
00082 # endif
00083 # define TODock QWidget
00084 # define TOFileDialog KFileDialog
00085 # include "tomainwindow.kde.h"
00086 #else
00087 # include <qtoolbar.h>
00088 # define TOPrinter QPrinter
00089 # define TODock QWidget
00090 # define TOFileDialog QFileDialog
00091 # include "tomainwindow.h"
00092 #endif
00093 #define TOMessageBox QMessageBox
00094
00095 class QWorkspace;
00096 class QComboBox;
00097 class QToolButton;
00098 class QPopupMenu;
00099 class QLabel;
00100 class toSearchReplace;
00101 class toTool;
00102 class toToolWidget;
00103 class toConnection;
00104 class toMarkedText;
00105 class QListView;
00106 class QListViewItem;
00107 class toEditWidget;
00108
00113 class toMain : public toMainWindow {
00114 Q_OBJECT
00115 private:
00119 std::list<toConnection *> Connections;
00123 QWorkspace *Workspace;
00127 QComboBox *ConnectionSelection;
00131 void addConnection(toConnection *conn);
00135 std::map<int,toTool *> Tools;
00140 std::map<QToolButton *,toTool *> NeedConnection;
00144 int SQLEditor;
00145
00148 std::list<QString> StatusMessages;
00152 QToolButton *DisconnectButton;
00156 QToolButton *LoadButton;
00160 QToolButton *SaveButton;
00164 QToolButton *PrintButton;
00168 QToolButton *UndoButton;
00172 QToolButton *RedoButton;
00176 QToolButton *CutButton;
00180 QToolButton *CopyButton;
00184 QToolButton *PasteButton;
00185
00189 QPopupMenu *FileMenu;
00193 QPopupMenu *EditMenu;
00197 QPopupMenu *ToolsMenu;
00201 QPopupMenu *WindowsMenu;
00205 QPopupMenu *HelpMenu;
00209 QPopupMenu *StatusMenu;
00213 QLabel *ColumnLabel;
00217 QLabel *RowLabel;
00218 toBackground Poll;
00222 toSearchReplace *Search;
00226 int DefaultTool;
00227
00228 toEditWidget *Edit;
00229
00230 toEditWidget *findEdit(QWidget *edit);
00231 void editEnable(toEditWidget *edit,
00232 bool open,bool save,bool print,
00233 bool undo,bool redo,
00234 bool cut,bool copy,bool paste,
00235 bool search,
00236 bool selectAll,bool readAll);
00237 public:
00238
00241 static const int TO_FILE_MENU;
00244 static const int TO_EDIT_MENU;
00247 static const int TO_TOOLS_MENU;
00250 static const int TO_WINDOWS_MENU;
00253 static const int TO_HELP_MENU;
00254
00257 static const int TO_TOOL_MENU_ID;
00260 static const int TO_TOOL_MENU_ID_END;
00261
00264 static const int TO_TOOL_ABOUT_ID;
00267 static const int TO_TOOL_ABOUT_ID_END;
00268
00272 toMain();
00273
00278 QWorkspace *workspace()
00279 { return Workspace; }
00280
00285 toConnection ¤tConnection(void);
00286
00290 static void setEditWidget(toEditWidget *edit);
00297 static void editEnable(toEditWidget *edit);
00303 static void editDisable(toEditWidget *edit);
00304
00310 virtual bool close(bool del);
00316 void createDefault(void);
00322 void setCoordinates(int,int);
00323
00328 QPopupMenu *fileMenu()
00329 { return FileMenu; }
00334 QPopupMenu *editMenu()
00335 { return EditMenu; }
00340 QPopupMenu *toolsMenu()
00341 { return ToolsMenu; }
00346 QPopupMenu *helpMenu()
00347 { return HelpMenu; }
00348
00354 std::list<QString> connections(void);
00359 toConnection &connection(const QString &);
00362 void setNeedCommit(toConnection &conn,bool needCommit=true);
00363
00367 void editSQL(const QString &str);
00377 void registerSQLEditor(int toolid);
00380 void displayMessage(const QString &str);
00381 signals:
00385 void sqlEditor(const QString &str);
00389 void addedConnection(const QString &str);
00393 void removedConnection(const QString &str);
00398 void willCommit(toConnection &conn,bool cmt);
00399 public slots:
00402 void windowsMenu(void);
00405 void statusMenu(void);
00408 void contextHelp(void);
00411 void windowActivated(QWidget *);
00414 void editFileMenu(void);
00417 void checkCaching(void);
00420 void changeConnection(void);
00421 private slots:
00424 void addConnection(void);
00427 bool delConnection(void);
00431 void commandCallback(int cmd);
00432
00435 void commitButton(void);
00438 void rollbackButton(void);
00439
00442 void loadButton(void);
00445 void saveButton(void);
00448 void printButton(void);
00451 void undoButton(void);
00454 void redoButton(void);
00457 void copyButton(void);
00460 void cutButton(void);
00463 void pasteButton(void);
00466 void displayMessage(void);
00467 };
00468
00469
00475 void toStatusMessage(const QString &str,bool save=false,bool log=true);
00479 toMain *toMainWidget(void);
00488 QString toSQLToAddress(toConnection &conn,const QString &sql);
00496 QString toSQLString(toConnection &conn,const QString &address);
00500 void toReadableColumn(QString &col);
00505 QString toNow(toConnection &conn);
00510 void toSetSessionType(const QString &str);
00515 QString toGetSessionType(void);
00522 QComboBox *toRefreshCreate(QWidget *parent,const char *name=NULL,const QString &def=QString::null,
00523 QComboBox *item=NULL);
00528 void toRefreshParse(toTimer *timer,const QString &str=QString::null);
00532 bool toMonolithic(void);
00537 QString toDeepCopy(const QString &str);
00544 QToolBar *toAllocBar(QWidget *parent,const QString &name,const QString &db);
00553 TODock *toAllocDock(const QString &name,
00554 const QString &db,
00555 const QPixmap &icon);
00561 void toAttachDock(TODock *dock,QWidget *container,QMainWindow::ToolBarDock place);
00566 int toSizeDecode(const QString &str);
00567
00572 template <class T> T toShift(std::list<T> &lst)
00573 {
00574 if (lst.begin()==lst.end()) {
00575 T ret;
00576 return ret;
00577 }
00578 T ret=(*lst.begin());
00579 lst.erase(lst.begin());
00580 return ret;
00581 }
00582
00587 template <class T> void toUnShift(std::list<T> &lst,const T &str)
00588 {
00589 lst.insert(lst.begin(),str);
00590 }
00591
00596 template <class T> T toPop(std::list<T> &lst)
00597 {
00598 if (lst.begin()==lst.end()) {
00599 T ret;
00600 return ret;
00601 }
00602 T ret=(*lst.rbegin());
00603 lst.pop_back();
00604 return ret;
00605 }
00606
00611 template <class T> void toPush(std::list<T> &lst,const T &str)
00612 {
00613 lst.push_back(str);
00614 }
00615
00620
00621
00622
00623 template <class T> typename std::list<T,std::allocator<T> >::iterator toFind( typename std::list<T, std::allocator<T> > &lst,const T &str)
00624 {
00625 for(typename std::list<T,std::allocator<T> >::iterator i=lst.begin();i!=lst.end();i++)
00626 if (*i==str)
00627 return i;
00628 return lst.end();
00629 }
00630
00639 QString toGetToken(toMarkedText *text,int &curLine,int &pos,
00640 bool forward=true,bool comments=false);
00641
00647 QFont toStringToFont(const QString &str);
00652 QString toFontToString(const QFont &fnt);
00656 QString toHelpPath(void);
00662 QCString toReadFile(const QString &filename);
00667 bool toWriteFile(const QString &filename,const QCString &data);
00672 bool toWriteFile(const QString &filename,const QString &data);
00679 bool toCompareLists(QStringList &l1,QStringList &l2,unsigned int len);
00684 void toSetEnv(const QCString &var,const QCString &val);
00688 void toUnSetEnv(const QCString &var);
00695 QString toOpenFilename(const QString &filename,const QString &filter,QWidget *parent);
00702 QString toSaveFilename(const QString &filename,const QString &filter,QWidget *parent);
00706 int toToolMenuIndex(void);
00711 inline bool toIsIdent(QChar c)
00712 {
00713 return c.isLetterOrNumber()||c=='_'||c=='%'||c=='$'||c=='#';
00714 }
00719 QString toPluginPath(void);
00722 std::list<QString> toStatusMessages(void);
00726 QColor toChartColor(int index);
00731 toConnection &toCurrentConnection(QObject *widget);
00735 toToolWidget *toCurrentTool(QObject *widget);
00738 bool toIsOracle(const toConnection &);
00745 QString toSQLStripSpecifier(const QString &sql);
00750 QString toSQLStripBind(const QString &sql);
00751
00756 QListViewItem *toFindItem(QListView *list,const QString &str);
00761 class toBusy {
00762 static unsigned int Count;
00763 public:
00764 static void clear(void);
00765 toBusy();
00766 ~toBusy();
00767 };
00773 void toToolCaption(toToolWidget *tool,const QString &caption);
00774
00778 template <class T>
00779 T max(T a, T b)
00780 {
00781 return a > b ? a : b ;
00782 }
00783
00787 template <class T>
00788 T min(T a, T b)
00789 {
00790 return a < b ? a : b ;
00791 }
00792
00796 class toPopupButton : public QToolButton {
00797 Q_OBJECT
00798 public:
00801 toPopupButton(const QIconSet &iconSet,const QString &textLabel,
00802 const QString &grouptext,QToolBar *parent,const char *name=0);
00805 toPopupButton(QWidget *parent,const char *name=0);
00806 private slots:
00807 void click(void);
00808 };
00809
00810
00811
00812
00813 #define TOCATCH \
00814 catch (const QString &str) {\
00815 toStatusMessage(str);\
00816 }
00817
00818 #endif