casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TBMain.qo.h
Go to the documentation of this file.
00001 //# TBMain.qo.h: Main window which is mainly responsible for menu actions.
00002 //# Copyright (C) 2005
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: $
00027 #ifndef TBMAIN_H_
00028 #define TBMAIN_H_
00029 
00030 #include <casaqt/QtBrowser/TBMain.ui.h>
00031 #include <casaqt/QtBrowser/TBBrowser.qo.h>
00032 
00033 #include <QtGui>
00034 
00035 #include <casa/BasicSL/String.h>
00036 
00037 #include <casa/namespace.h>
00038 
00039 namespace casa {
00040 
00041 //# Forward Declarations
00042 class TBBrowser;
00043 class TBAction;
00044 class DriverParams;
00045 class TBOptions;
00046 
00047 // <summary>
00048 // Main window which is mainly responsible for menu actions.
00049 // <summary>
00050 //
00051 // <synopsis>
00052 // TBMain is a QMainWindow subclass that wraps about a TBBrowser object.  Its
00053 // main responsibility is to provide menu commands and interact with the
00054 // TBBrowser.
00055 // </synopsis>
00056 
00057 class TBMain : public QMainWindow, Ui::MainWindow {
00058     Q_OBJECT
00059     
00060 public:
00061     // Default Constructor.
00062     TBMain();
00063 
00064     ~TBMain();
00065 
00066     
00067     // Opens a table with the given file name and driver parameters.  If the
00068     // driver parameters are NULL, the defaults are used.  If a start and num
00069     // are provided, those rows are loaded into the new table; otherwise
00070     // the default number of rows are loaded.
00071     void openTable(String filename, DriverParams* dp = NULL, int start = 0,
00072                    int num = TBConstants::DEFAULT_SELECT_NUM);
00073 
00074 signals:
00075     // This signal is emitted when a close menu command is given with
00076     // a table name.
00077     void closeTableTriggered(String name);
00078 
00079 protected:
00080     // Catches a close event for the window.  If a background task is running,
00081     // a confirmation dialog is presented to the user.  If the "save view on
00082     // close" option is turned on, the current view is saved to the default
00083     // location.
00084     void closeEvent(QCloseEvent* event);
00085     
00086 private:
00087     // Browser object.
00088     TBBrowser browser;
00089 
00090     // The window's status bar.
00091     QStatusBar* statusBar;
00092 
00093     // Close menu that lists all currently opened tables.
00094     QMenu* closeMenu;
00095 
00096     // Columns menu that lists the table fields in the currently selected
00097     // table.
00098     QMenu* columnsMenu;
00099 
00100     // Edit menu that lists all currently opened tables.
00101     QMenu* editTablesMenu;
00102 
00103     // Indicates whether the main window is waiting for some other task to
00104     // complete or not.  If the window is waiting, menu commands will not
00105     // respond.
00106     bool waiting;
00107 
00108     // Separator added in the Edit menu before the Options command.
00109     QAction* separator;
00110 
00111     // Format menu that lists the table fields in the currently selected
00112     // table.
00113     QMenu* formatMenu;
00114 
00115     // Toolbar holding "file"-related menu commands.
00116     QToolBar* fileBar;
00117 
00118     // Toolbar holding "edit"-related menu commands.
00119     QToolBar* editBar;
00120 
00121     // Toolbar holding "view"-related menu commands.
00122     QToolBar* viewBar;
00123 
00124     // Toolbar holding "tool"-related menu commands.
00125     QToolBar* toolBar;
00126 
00127     // Indicates whether the TBMain should save the current view on close or
00128     // not.
00129     bool saveView;
00130 
00131     
00132     // Sets up GUI components and signal/slot connections.
00133     void setup();
00134 
00135     // Sets up the keyboard shortcuts.
00136     void setupKeyboardShortcuts();
00137 
00138     // Calls setEnabled() on all menus with the given parameter.
00139     void enableMenus(bool en);
00140     
00141     // Turns on/off editing, if write lock is available, on the given table.
00142     void editTable(TBTableTabs* table, bool edit);
00143 
00144 private slots:
00145     // Opens a filechooser dialog to allow the user to open a table.
00146     void openTable();
00147     
00148     // Opens a TBTaQL dialog to allow the user to open a table using a TaQL
00149     // command.
00150     void openTaQL();
00151     
00152     // Connects with TBBrowser::tableOpened() signal.  Updates dynamic menus
00153     // as necessary.
00154     void tableOpened(String name, String fullpath);
00155 
00156     //void openTableWithOptions();
00157     
00158     // Closes the currently selected table.
00159     void closeTable();
00160 
00161     // Closes the table corresponding to the given action's name.
00162     void closeTable(QAction* which);
00163 
00164     // Closes all opened tables.
00165     void closeAll();
00166     
00167     // Closes all currently opened tables and closes the window.
00168     void closeAllAndExit();
00169     
00170     // Connects with TBBrowser::tableClosed() signal.  Updates dynamic menus
00171     // as necessary.
00172     void tableClosed(String name);
00173     
00174     // Slot for when the tab is changed in the browser.  Updates all necessary
00175     // menus.
00176     void tabChanged(int tableIndex);
00177 
00178     // Shows or hides the column on the current table that corresponds to
00179     // the name of the given action.
00180     void viewColumn(QAction* which);
00181     
00182     // Updates the column menu to indicate that the given column has been
00183     // shown/hidden.
00184     void columnHidden(int index, bool hidden);
00185 
00186     // Updates display to indicate the last action performed.
00187     void actionPerformed(TBAction* action);
00188 
00189     // Updates display to indicate that the last action was undone.
00190     void actionUndone();
00191 
00192     // Update display to indicate that the last undone action was redone.
00193     void actionRedone();
00194     
00195     // Undoes the last performed action.  See TBBrowser::undoAction().
00196     void undoAction();
00197 
00198     // Redoes the last undone action.  See TBBrowser::redoAction().
00199     void redoAction();
00200 
00201     // Enters the currently selected table into editing mode.
00202     void editCurrentTable();
00203     
00204     // Enters the table corresponding to the given edit action into editing
00205     // mode.
00206     void editTable(QAction* action);
00207 
00208     // Exports the current table to VOTable format.  See
00209     // TBBrowser::exportVOTable().
00210     void exportVOTable();
00211 
00212     // Reenables menus after a task thread has completed.
00213     void threadFinished();
00214 
00215     // Opens a new TBValidityChecker widget.
00216     void checkValidity();
00217 
00218     // Opens a new TBPlotter window.
00219     void plot2D();
00220 
00221     // Shows all the columns in the currently selected table.
00222     void showAllColumns();
00223 
00224     // Hides all the columns in the currently selected table.
00225     void hideAllColumns();
00226 
00227     // Opens widget to enter filter rules for the current table.  See
00228     // TBBrowser::filterOnFields().
00229     void filterOnFields();
00230 
00231     // Clears the current filter on the current table.  See
00232     // TBBrowser::clearFilterOnFields().
00233     void clearFilterOnFields();
00234     
00235     // Enables the "clear filter" action.
00236     void filterRuleAvailable(int i);
00237     
00238     // Disables the "clear filter" action.
00239     void filterRuleCleared(int i);
00240 
00241     // Opens widget to enter search rules for the current table.  See
00242     // TBBrowser::find().
00243     void find();
00244 
00245     // Searches for the next row matching the search rule for the current
00246     // table.  See TBBrowser::findNext().
00247     void findNext();
00248 
00249     // Searches for the previous row matching the search rule for the current
00250     // table.  See TBBrowser::findPrev().
00251     void findPrev();
00252 
00253     // Slot for when the current table has a find rule associated with it.
00254     void findRuleAvailable();
00255     
00256     // Slot for when a sort has been entered for the current table.
00257     void sortEntered();
00258     
00259     // Slot for when a sort has been cleared for the current table.
00260     void sortCleared();
00261 
00262     // Displays table information for the currently selected table.
00263     void viewTableInfo();
00264 
00265     // Formats the field with the name in the given QAction.
00266     void formatDisplay(QAction* which);
00267 
00268     // Opens the help window.  See TBHelp.
00269     void openHelp();
00270 
00271     // Shows an insert rows dialog.
00272     void insertRows();
00273 
00274     // Shows a delete rows dialog.
00275     void deleteRows();
00276 
00277     // Shows a sort dialog.  See TBSorter.
00278     void sort();
00279     
00280     // Clears the current sort.
00281     void clearSort();
00282 
00283     // Sort the current table with the given order.  See TBBrowser::sort().
00284     void sort(vector<pair<String, bool> >& sort);
00285 
00286     // Allows the user to edit table options.  See TBOptions.
00287     void options();
00288 
00289     // Applies the user-provided options and deletes the TBOptions widget.
00290     void saveOptions(TBOptions* opt);
00291 };
00292 
00293 }
00294 
00295 #endif /* TBMAIN_H_ */