00001 //# TBTableTabs.qo.h: Collection of table backend and display tabs. 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 TBTABLETABS_H_ 00028 #define TBTABLETABS_H_ 00029 00030 #include <casaqt/QtBrowser/TBTableTabs.ui.h> 00031 00032 #include <casaqt/QtBrowser/TBConstants.h> 00033 #include <casaqt/QtBrowser/TBTable.h> 00034 #include <casaqt/QtBrowser/TBDataTab.qo.h> 00035 #include <casaqt/QtBrowser/TBKeywordsTab.qo.h> 00036 #include <casaqt/QtBrowser/TBAction.h> 00037 00038 #include <QtGui> 00039 00040 #include <casa/BasicSL/String.h> 00041 00042 namespace casa { 00043 00044 //# Forward Declarations 00045 class TBBrowser; 00046 class DriverParams; 00047 00048 // <summary> 00049 // Collection of table backend and display tabs. 00050 // </summary> 00051 // 00052 // <synopsis> 00053 // TBTableTabs keeps track of the underlying TBTable object as well as the 00054 // three tabs associated with its view (data, table keywords, and field 00055 // keywords). It is the unifying interface over the GUI and non-GUI aspects 00056 // of a table. Methods called on a TBTableTabs object tend to update the 00057 // backend via the TBTable and then update the GUIs with the new data. 00058 // </synopsis> 00059 00060 class TBTableTabs : public QWidget, Ui::TableTabs { 00061 Q_OBJECT 00062 00063 public: 00064 // Constructor that takes the browser parent, the location of the table, 00065 // the driver parameters for opening the table, and whether the table is 00066 // from a TaQL command or not. 00067 TBTableTabs(TBBrowser* b, String filename, DriverParams* dp, bool taql); 00068 00069 ~TBTableTabs(); 00070 00071 00072 // Returns true if the table is available, false otherwise. 00073 bool isAvailable(); 00074 00075 // Returns true if the table is currently in editing mode, false otherwise. 00076 bool isEditable(); 00077 00078 // Returns the "name" of this table (which is the last part of the 00079 // filename). 00080 String getName(); 00081 00082 // Returns the location of this table. 00083 String getFileName(); 00084 00085 // Returns the browser associated with this table. 00086 TBBrowser* getBrowser(); 00087 00088 // Returns the data tab associated with this table. 00089 TBDataTab* getDataTab(); 00090 00091 // Returns the table keywords tab associated with this table. 00092 TBTableKeywordsTab* getKeywordsTab(); 00093 00094 // Returns the field keywords tab assicated with this table. 00095 TBFieldKeywordsTab* getFieldKeywordsTab(); 00096 00097 // Returns the QTableWidget used to display table data. 00098 QTableWidget* getTableWidget(); 00099 00100 // Returns the QTableWidget used to display table keywords. 00101 QTableWidget* getTableKeywords(); 00102 00103 // Returns the QTreeWidget used to display the field keywords. 00104 QTreeWidget* getFieldKeywords(); 00105 00106 // Returns the underlying table backend. 00107 TBTable* getTable(); 00108 00109 // Returns the current sort on the table data tab, or an empty list 00110 // if there is none. 00111 std::vector<std::pair<String, bool> >* getSortFields(); 00112 00113 00114 // Loads rows into the table backend and, if successful, updates the three 00115 // GUI displays to reflect the new table data. Returns whether the 00116 // loading was successful or not. If the loading was not successful an 00117 // error message is displayed. 00118 bool loadRows(int start = 0, int num = TBConstants::DEFAULT_SELECT_NUM); 00119 00120 // If the table allows for insertion of rows, the given number of rows 00121 // is inserted at the end of the table and, if successful, the GUI display 00122 // is updated accordingly. If the insertion was not successful an error 00123 // message is displayed. 00124 void insertRows(int n); 00125 00126 // Deletes the given rows from the table, if the table allows for deletion 00127 // of rows. Each element in the vector should be a row number. If 00128 // successful, the GUI display is updated; otherwise an error message is 00129 // displayed. 00130 void deleteRows(std::vector<int> r); 00131 00132 // Clears the current sort on the table data tab. 00133 void clearSort(); 00134 00135 // Sorts the table data tab with the given sort order. See 00136 // TBDataTab::sortBy(). 00137 void sort(std::vector<std::pair<String, bool> >& s); 00138 00139 // Selects and highlights the given row in the data tab. If the given 00140 // row is not loaded in the table, the user is prompted on whether they 00141 // want to load the appropriate page or not. 00142 void highlight(int row); 00143 00144 public slots: 00145 // Updates the underlying table with the new data and then updates the 00146 // GUI displays if successful. The new value is first checked for 00147 // validity. If the update fails, an error message is displayed. 00148 void dataChanged(int row, int col, String newVal); 00149 00150 // Sets whether this table is currently in editing mode or not. 00151 void setEditable(bool e); 00152 00153 // Shows the given widget in the side panel on the table data tab. 00154 void showWidgetInTableSplitter(QWidget* widget, bool isArray = false); 00155 00156 // Shows the given widget in the side panel on the table keywords tab. 00157 void showWidgetInKeywordSplitter(QWidget* widget); 00158 00159 // Shows the given widget in the side panel on the field keywords tab. 00160 void showWidgetInFieldKeywordSplitter(QWidget* widget); 00161 00162 // Shows the given widget in the side panel of the tab that is currently 00163 // selected. 00164 void showWidgetInCurrentSplitter(QWidget* widget); 00165 00166 // Clears the side panel on the table data tab. 00167 void clearWidgetInTableSplitter(); 00168 00169 // Clears the side panel on the table keywords tab. 00170 void clearWidgetInKeywordSplitter(); 00171 00172 // Clears the side panel on the field keywords tab. 00173 void clearWidgetInFieldKeywordSplitter(); 00174 00175 // Clears the side panel on the currently selected tab. 00176 void clearWidgetInCurrentSplitter(); 00177 00178 private: 00179 // Indicates whether this table is currently available. 00180 bool available; 00181 00182 // Indicates whether this table is currently in editing mode or not. 00183 bool editable; 00184 00185 // This table's location. 00186 String filename; 00187 00188 // This table's name. 00189 String name; 00190 00191 // Table backend. 00192 TBTable table; 00193 00194 // Table data tab. 00195 TBDataTab dataTab; 00196 00197 // Table keywords tab. 00198 TBTableKeywordsTab keywordsTab; 00199 00200 // Field keywords tab. 00201 TBFieldKeywordsTab fieldKeywordsTab; 00202 00203 // Reference to parent. 00204 TBBrowser* browser; 00205 }; 00206 00207 } 00208 00209 #endif /* TBTABLETABS_H_ */