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 namespace casa { 00038 00039 //# Forward Declarations 00040 class TBBrowser; 00041 class TBAction; 00042 class DriverParams; 00043 class TBOptions; 00044 00045 // <summary> 00046 // Main window which is mainly responsible for menu actions. 00047 // <summary> 00048 // 00049 // <synopsis> 00050 // TBMain is a QMainWindow subclass that wraps about a TBBrowser object. Its 00051 // main responsibility is to provide menu commands and interact with the 00052 // TBBrowser. 00053 // </synopsis> 00054 00055 class TBMain : public QMainWindow, Ui::MainWindow { 00056 Q_OBJECT 00057 00058 public: 00059 // Default Constructor. 00060 TBMain(); 00061 00062 ~TBMain(); 00063 00064 00065 // Opens a table with the given file name and driver parameters. If the 00066 // driver parameters are NULL, the defaults are used. If a start and num 00067 // are provided, those rows are loaded into the new table; otherwise 00068 // the default number of rows are loaded. 00069 void openTable(String filename, DriverParams* dp = NULL, int start = 0, 00070 int num = TBConstants::DEFAULT_SELECT_NUM); 00071 00072 signals: 00073 // This signal is emitted when a close menu command is given with 00074 // a table name. 00075 void closeTableTriggered(String name); 00076 00077 protected: 00078 // Catches a close event for the window. If a background task is running, 00079 // a confirmation dialog is presented to the user. If the "save view on 00080 // close" option is turned on, the current view is saved to the default 00081 // location. 00082 void closeEvent(QCloseEvent* event); 00083 00084 private: 00085 // Browser object. 00086 TBBrowser browser; 00087 00088 // The window's status bar. 00089 QStatusBar* statusBar; 00090 00091 // Close menu that lists all currently opened tables. 00092 QMenu* closeMenu; 00093 00094 // Columns menu that lists the table fields in the currently selected 00095 // table. 00096 QMenu* columnsMenu; 00097 00098 // Edit menu that lists all currently opened tables. 00099 QMenu* editTablesMenu; 00100 00101 // Indicates whether the main window is waiting for some other task to 00102 // complete or not. If the window is waiting, menu commands will not 00103 // respond. 00104 bool waiting; 00105 00106 // Separator added in the Edit menu before the Options command. 00107 QAction* separator; 00108 00109 // Format menu that lists the table fields in the currently selected 00110 // table. 00111 QMenu* formatMenu; 00112 00113 // Toolbar holding "file"-related menu commands. 00114 QToolBar* fileBar; 00115 00116 // Toolbar holding "edit"-related menu commands. 00117 QToolBar* editBar; 00118 00119 // Toolbar holding "view"-related menu commands. 00120 QToolBar* viewBar; 00121 00122 // Toolbar holding "tool"-related menu commands. 00123 QToolBar* toolBar; 00124 00125 // Indicates whether the TBMain should save the current view on close or 00126 // not. 00127 bool saveView; 00128 00129 00130 // Sets up GUI components and signal/slot connections. 00131 void setup(); 00132 00133 // Sets up the keyboard shortcuts. 00134 void setupKeyboardShortcuts(); 00135 00136 // Calls setEnabled() on all menus with the given parameter. 00137 void enableMenus(bool en); 00138 00139 // Turns on/off editing, if write lock is available, on the given table. 00140 void editTable(TBTableTabs* table, bool edit); 00141 00142 private slots: 00143 // Opens a filechooser dialog to allow the user to open a table. 00144 void openTable(); 00145 00146 // Opens a TBTaQL dialog to allow the user to open a table using a TaQL 00147 // command. 00148 void openTaQL(); 00149 00150 // Connects with TBBrowser::tableOpened() signal. Updates dynamic menus 00151 // as necessary. 00152 void tableOpened(String name, String fullpath); 00153 00154 //void openTableWithOptions(); 00155 00156 // Closes the currently selected table. 00157 void closeTable(); 00158 00159 // Closes the table corresponding to the given action's name. 00160 void closeTable(QAction* which); 00161 00162 // Closes all opened tables. 00163 void closeAll(); 00164 00165 // Closes all currently opened tables and closes the window. 00166 void closeAllAndExit(); 00167 00168 void showVersion(); 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(std::vector<std::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_ */