Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

trapper.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002  *                                                                             *
00003  *   Copyright (C) 2003  Erik Sjolund,  (<html>Erik Sj&ouml;lund</html>)       *
00004  *                       Center for Genomics and Bioinformatics,               *
00005  *                       Karolinska Institutet,                                *
00006  *                       Stockholm,                                            *
00007  *                       Sweden                                                *
00008  *                                                                             *
00009  *  Author: Erik Sjolund                                                       *
00010  *  Email: erik.sjolund@adivo.se                                               *
00011  *                                                                             *
00012  *******************************************************************************
00013  */
00014 
00015 
00016 #ifndef TRAPPER_H
00017 #define TRAPPER_H
00018 
00019 // include files for QT
00020 #include <qapp.h>
00021 #include <qmainwindow.h>
00022 #include <qaction.h>
00023 #include <qworkspace.h>
00024 #include <qmenubar.h>
00025 #include <qtoolbar.h>
00026 #include <qstatusbar.h>
00027 #include <qwhatsthis.h>
00028 #include <qpopupmenu.h>
00029 #include <qaccel.h>
00030 #include <qtoolbutton.h>
00031 #include <qmsgbox.h>
00032 #include <qfiledialog.h>
00033 #include <qprinter.h>
00034 #include <qstring.h>
00035 #include <qpixmap.h>
00036 #include <qstringlist.h>
00037 #include <qassistantclient.h>
00038 
00039 #include <db_cxx.h>
00040 
00041 #include <map>
00042 
00043 // forward declaration of the Trapper classes
00044 class TrapperDoc;
00045 class TrapperView;
00046 
00047 
00048 /** \brief The base class of the application. It sets up the main
00049   * window and providing a menubar, toolbar
00050   * and statusbar. For the main view, an instance of class TrapperView is
00051   * created which creates your view.
00052   *     
00053   * @author Source Framework Automatically Generated by KDevelop, (c) The KDevelop Team.
00054   * @version KDevelop version 1.3 code generation
00055   */
00056 class TrapperApp : public QMainWindow
00057 {
00058   Q_OBJECT
00059   
00060 public:
00061   /** construtor */
00062   TrapperApp();
00063   /** destructor */
00064   virtual ~TrapperApp();
00065   
00066   /** set the directory home for the database environment */
00067   void setDbHomeDir(QString dir);
00068   /** set the filename for the view modes configuration file */
00069   void setViewModeConfFile( QString filename );
00070   
00071   /** opens a file specified by commandline option
00072    */
00073   void openDocumentFile(const char *file=0);
00074   void exportToFile(QString toXmlFile);
00075   
00076   //typedefs:
00077   typedef std::multimap<QString, TrapperDoc*> str_doc_map;
00078  
00079   
00080 protected:
00081   /** overloaded for Message box on last window exit */
00082   bool queryExit();
00083   /** event filter to catch close events for MDI child windows and is installed in createClient() on every child window.
00084    * Closing a window calls the eventFilter first which removes the view from the connected documents' view list. If the
00085    * last view is going to be closed, the eventFilter() tests if the document is modified; if yes, it asks the user to
00086    * save the document. If the document title contains "Untitled", slotFileSaveAs() gets called to get a save name and path.
00087    */
00088   virtual bool eventFilter(QObject* object, QEvent* event);
00089   /** creates a new child window. The document that will be connected to it
00090    * has to be created before and the instances filled, with e.g. openDocument().
00091    * Then call createClient() to get a new MDI child window.
00092    * @see TrapperDoc#addView
00093    * @see TrapperDoc#openDocument
00094    * @param doc pointer to the document instance that the view will
00095    * be connected to.
00096    */
00097   void createClient(TrapperDoc* doc, QString modeview = QString::null );
00098 public slots:
00099   void slotCreateClient( QString modeView );
00100   /** exits the application */
00101   void slotFileQuit();
00102   
00103 private slots:
00104 
00105   /** generate a new document in the actual view */
00106   void slotFileNew();
00107   /** open a document */
00108   void slotFileOpen();
00109   /** save a document */
00110   void slotFileSave();
00111   /** save a document under a different filename*/
00112   void slotFileSaveAs();
00113   /** close the actual file */
00114   void slotFileClose();
00115   /** Flushes dbs */
00116   void slotFileFlush();
00117   /** print the actual file */
00118   void slotFilePrint();
00119   
00120   /** reverts the last editing action */
00121   void slotEditUndo();
00122   /** put the marked text/object into the clipboard and remove
00123    * it from the document */
00124   void slotEditCut();
00125   /** put the marked text/object into the clipboard*/
00126   void slotEditCopy();
00127   /** paste the clipboard into the document*/
00128   void slotEditPaste();
00129   
00130   /** Selects all reads*/
00131   void slotEditSelectAll();
00132   /** Selects all reads between two rows*/
00133   void slotEditSelectBetween();
00134   /** Finds a specific read*/
00135   void slotEditFindRead();
00136   
00137   /** toggle the toolbar*/
00138   void slotViewToolBar(bool toggle);
00139   /** toggle the statusbar*/
00140   void slotViewStatusBar(bool toggle);
00141   /** creates a new view for the current document */
00142   void slotWindowNewWindow();
00143   /** shows an about dlg*/
00144   void slotHelpAbout();
00145   /** shows the online help*/
00146   void slotHelpManual();
00147   /** change the status message of the whole statusbar temporary */
00148   void slotStatusHelpMsg(const QString &text);
00149   /** Displays error message if assistant isn't working properly*/
00150   void showAssistantErrors(const QString& err);
00151   /** gets called when the window menu is activated; recreates the window menu with all opened window titles. */
00152   void windowMenuAboutToShow();
00153   /** activates the MDI child widget when it gets selected from the window menu. */
00154   void windowMenuActivated( int id );
00155   /** imports data */
00156   void slotImport();
00157   /** imports data */
00158   void slotNewImport();
00159   /** imports chromat data */
00160   void slotChromatImport();
00161   /** imports mate data */
00162   void slotMateImport();
00163   /** imports phd data */
00164   void slotPhdImport();
00165   /** exports data */
00166   void slotExport();
00167   /** zooms in */
00168   void slotZoomIn();
00169   /** zooms in X */
00170   void slotZoomInX();
00171   /** zooms in Y */
00172   void slotZoomInY();
00173   /** zooms out */
00174   void slotZoomOut();
00175   /** zooms out X */
00176   void slotZoomOutX();
00177   /** zooms out Y */
00178   void slotZoomOutY();
00179   /** Enlarges view */
00180   void slotEnlarge();
00181   /** Shrinks view */
00182   void slotShrink();
00183   /** show statistics */
00184   void slotShowStatistics();
00185   /** configure view modes */
00186   void slotConfigureViewModes();
00187   /** normal pointer mode */
00188   void slotNormalMode();
00189   /** drag mode */
00190   void slotDragMode();
00191   /** active window*/
00192   void slotActivatedWindow(QWidget* w);
00193   
00194 private:
00195   
00196   /** initializes all QActions of the application */
00197   void initActions();
00198   /** initMenuBar creates the menu_bar and inserts the menuitems */
00199   void initMenuBar();
00200   /** this creates the toolbars. Change the toobar look and add new toolbars in this
00201    * function */
00202   void initToolBar();
00203   /** setup the statusbar */
00204   void initStatusBar();
00205   /** setup the mainview*/
00206   void initView();
00207   /** scroll active view*/
00208   void scroll(int dx, int dy);
00209   /** opens contigs that weren't already open and put them in list. User is responsible
00210    * for deleting docs after use */
00211   void open_docs_not_already_open(QPtrList<TrapperDoc>& notOpenBefore);
00212   /** fills a map wit read names as keys and pointers to docs they're present in as values */
00213   void map_reads_to_docs(str_doc_map& readmap, QPtrList<TrapperDoc>& notOpenBefore);
00214   
00215   
00216   QFile viewmodefile;
00217   
00218   QStringList contigNamesInProjectDir();
00219   
00220   
00221   
00222   
00223   /** file_menu contains all items of the menubar entry "File" */
00224   QPopupMenu *pFileMenu;
00225   /** edit_menu contains all items of the menubar entry "Edit" */
00226   QPopupMenu *pEditMenu;
00227   /** view_menu contains all items of the menubar entry "View" */
00228   QPopupMenu *pViewMenu;
00229   /** view_menu contains all items of the menubar entry "Help" */
00230   QPopupMenu *pHelpMenu;
00231   /** the window menu */
00232   QPopupMenu *pWindowMenu;
00233   /** the tools menu */
00234   QPopupMenu *pToolsMenu;
00235   
00236   QToolBar *fileToolbar;
00237   
00238   /** pWorkspace is the MDI frame widget that handles MDI child widgets. Inititalized in
00239    * initView()
00240    */
00241   QWorkspace *pWorkspace;
00242   /** the printer instance */
00243   QPrinter *printer;
00244   /** a counter that gets increased each time the user creates a new document with "File"->"New" */
00245   int untitledCount;
00246   /** a list of all open documents. If the last window of a document gets closed, the installed eventFilter
00247    * removes this document from the list. The document list is checked for modified documents when the user
00248    * is about to close the application. */
00249   QList<TrapperDoc> *pDocList;
00250   
00251   QAction *fileNew;
00252   QAction *fileOpen;
00253   QAction *fileSave;
00254   QAction *fileSaveAs;
00255   QAction *fileClose;
00256   QAction *filePrint;
00257   QAction *fileQuit;
00258   QAction *fileFlush;
00259   
00260   QAction *editUndo;
00261   QAction *editCut;
00262   QAction *editCopy;
00263   QAction *editPaste;
00264   QAction *editSelectAll;
00265   QAction *editSelectBetween;
00266   QAction *editFindRead;
00267   
00268   QAction *viewToolBar;
00269   QAction *viewStatusBar;
00270   QAction *zoomInAction;
00271   QAction *zoomInXAction;
00272   QAction *zoomInYAction;
00273   QAction *zoomOutAction;
00274   QAction *zoomOutXAction;
00275   QAction *zoomOutYAction;
00276   QAction *enlargeAction;
00277   QAction *shrinkAction;
00278   QAction *showStatisticsAction;
00279   QAction *configureViewModesAction;
00280   
00281   QActionGroup *windowAction;
00282   QAction *windowNewWindow;
00283   QAction *windowTile;
00284   QAction *windowCascade;
00285 
00286   QActionGroup *modeActionGroup;
00287   QAction *normalModeAction;
00288   QAction *dragModeAction;
00289   
00290   QAction *importAction;
00291   QAction *importNewAction;
00292   QAction *importChromatAction;
00293   QAction *importMateAction;
00294   QAction *importPhdAction;
00295   QAction *exportAction;
00296   QAction *helpAboutApp;
00297   QAction *helpManualApp;
00298 
00299 
00300   QAssistantClient* assistant;
00301  
00302   QString projectDir;
00303   
00304   DbEnv * dbenv;
00305 };
00306 #endif

Generated on Fri Mar 17 17:44:24 2006 for trapper by  doxygen 1.4.4