casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TBTableTabs.qo.h
Go to the documentation of this file.
1 //# TBTableTabs.qo.h: Collection of table backend and display tabs.
2 //# Copyright (C) 2005
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: $
27 #ifndef TBTABLETABS_H_
28 #define TBTABLETABS_H_
29 
30 #include <casaqt/QtBrowser/TBTableTabs.ui.h>
31 
37 
38 #include <QtGui>
39 
40 #include <casa/BasicSL/String.h>
41 
42 namespace casa {
43 
44 //# Forward Declarations
45 class TBBrowser;
46 class DriverParams;
47 
48 // <summary>
49 // Collection of table backend and display tabs.
50 // </summary>
51 //
52 // <synopsis>
53 // TBTableTabs keeps track of the underlying TBTable object as well as the
54 // three tabs associated with its view (data, table keywords, and field
55 // keywords). It is the unifying interface over the GUI and non-GUI aspects
56 // of a table. Methods called on a TBTableTabs object tend to update the
57 // backend via the TBTable and then update the GUIs with the new data.
58 // </synopsis>
59 
60 class TBTableTabs : public QWidget, Ui::TableTabs {
61  Q_OBJECT
62 
63 public:
64  // Constructor that takes the browser parent, the location of the table,
65  // the driver parameters for opening the table, and whether the table is
66  // from a TaQL command or not.
68 
69  ~TBTableTabs();
70 
71 
72  // Returns true if the table is available, false otherwise.
73  bool isAvailable();
74 
75  // Returns true if the table is currently in editing mode, false otherwise.
76  bool isEditable();
77 
78  // Returns the "name" of this table (which is the last part of the
79  // filename).
81 
82  // Returns the location of this table.
84 
85  // Returns the browser associated with this table.
87 
88  // Returns the data tab associated with this table.
90 
91  // Returns the table keywords tab associated with this table.
93 
94  // Returns the field keywords tab assicated with this table.
96 
97  // Returns the QTableWidget used to display table data.
98  QTableWidget* getTableWidget();
99 
100  // Returns the QTableWidget used to display table keywords.
101  QTableWidget* getTableKeywords();
102 
103  // Returns the QTreeWidget used to display the field keywords.
104  QTreeWidget* getFieldKeywords();
105 
106  // Returns the underlying table backend.
107  TBTable* getTable();
108 
109  // Returns the current sort on the table data tab, or an empty list
110  // if there is none.
111  std::vector<std::pair<casacore::String, bool> >* getSortFields();
112 
113 
114  // Loads rows into the table backend and, if successful, updates the three
115  // GUI displays to reflect the new table data. Returns whether the
116  // loading was successful or not. If the loading was not successful an
117  // error message is displayed.
118  bool loadRows(int start = 0, int num = TBConstants::DEFAULT_SELECT_NUM);
119 
120  // If the table allows for insertion of rows, the given number of rows
121  // is inserted at the end of the table and, if successful, the GUI display
122  // is updated accordingly. If the insertion was not successful an error
123  // message is displayed.
124  void insertRows(int n);
125 
126  // Deletes the given rows from the table, if the table allows for deletion
127  // of rows. Each element in the vector should be a row number. If
128  // successful, the GUI display is updated; otherwise an error message is
129  // displayed.
130  void deleteRows(std::vector<int> r);
131 
132  // Clears the current sort on the table data tab.
133  void clearSort();
134 
135  // Sorts the table data tab with the given sort order. See
136  // TBDataTab::sortBy().
137  void sort(std::vector<std::pair<casacore::String, bool> >& s);
138 
139  // Selects and highlights the given row in the data tab. If the given
140  // row is not loaded in the table, the user is prompted on whether they
141  // want to load the appropriate page or not.
142  void highlight(int row);
143 
144 public slots:
145  // Updates the underlying table with the new data and then updates the
146  // GUI displays if successful. The new value is first checked for
147  // validity. If the update fails, an error message is displayed.
148  void dataChanged(int row, int col, casacore::String newVal);
149 
150  // Sets whether this table is currently in editing mode or not.
151  void setEditable(bool e);
152 
153  // Shows the given widget in the side panel on the table data tab.
154  void showWidgetInTableSplitter(QWidget* widget, bool isArray = false);
155 
156  // Shows the given widget in the side panel on the table keywords tab.
157  void showWidgetInKeywordSplitter(QWidget* widget);
158 
159  // Shows the given widget in the side panel on the field keywords tab.
160  void showWidgetInFieldKeywordSplitter(QWidget* widget);
161 
162  // Shows the given widget in the side panel of the tab that is currently
163  // selected.
164  void showWidgetInCurrentSplitter(QWidget* widget);
165 
166  // Clears the side panel on the table data tab.
168 
169  // Clears the side panel on the table keywords tab.
171 
172  // Clears the side panel on the field keywords tab.
174 
175  // Clears the side panel on the currently selected tab.
177 
178 private:
179  // Indicates whether this table is currently available.
180  bool available;
181 
182  // Indicates whether this table is currently in editing mode or not.
183  bool editable;
184 
185  // This table's location.
187 
188  // This table's name.
190 
191  // casacore::Table backend.
193 
194  // casacore::Table data tab.
196 
197  // casacore::Table keywords tab.
199 
200  // Field keywords tab.
202 
203  // Reference to parent.
205 };
206 
207 }
208 
209 #endif /* TBTABLETABS_H_ */
static const unsigned int DEFAULT_SELECT_NUM
The default number of rows to load from the table at a time.
Definition: TBConstants.h:168
void insertRows(int n)
If the table allows for insertion of rows, the given number of rows is inserted at the end of the tab...
casacore::String getFileName()
Returns the location of this table.
QTreeWidget * getFieldKeywords()
Returns the QTreeWidget used to display the field keywords.
TBDataTab dataTab
casacore::Table data tab.
casacore::String name
This table&#39;s name.
QTableWidget * getTableKeywords()
Returns the QTableWidget used to display table keywords.
casacore::String filename
This table&#39;s location.
void deleteRows(std::vector< int > r)
Deletes the given rows from the table, if the table allows for deletion of rows.
void dataChanged(int row, int col, casacore::String newVal)
Updates the underlying table with the new data and then updates the GUI displays if successful...
bool available
Indicates whether this table is currently available.
void sort(std::vector< std::pair< casacore::String, bool > > &s)
Sorts the table data tab with the given sort order.
bool loadRows(int start=0, int num=TBConstants::DEFAULT_SELECT_NUM)
Loads rows into the table backend and, if successful, updates the three GUI displays to reflect the n...
Widget used to display table data.
Definition: TBDataTab.qo.h:107
Browser widget for managing opened tables.
Definition: TBBrowser.qo.h:63
TBTableTabs(TBBrowser *b, casacore::String filename, DriverParams *dp, bool taql)
Constructor that takes the browser parent, the location of the table, the driver parameters for openi...
void clearWidgetInFieldKeywordSplitter()
Clears the side panel on the field keywords tab.
Widget used to display table keywords.
TBFieldKeywordsTab fieldKeywordsTab
Field keywords tab.
void showWidgetInFieldKeywordSplitter(QWidget *widget)
Shows the given widget in the side panel on the field keywords tab.
void setEditable(bool e)
Sets whether this table is currently in editing mode or not.
TBTableKeywordsTab keywordsTab
casacore::Table keywords tab.
TBBrowser * browser
Reference to parent.
void clearWidgetInKeywordSplitter()
Clears the side panel on the table keywords tab.
Primary interface for the rest of the browser to a table.
Definition: TBTable.h:152
bool isAvailable()
Returns true if the table is available, false otherwise.
Widget used to display field keywords.
TBTable table
casacore::Table backend.
QTableWidget * getTableWidget()
Returns the QTableWidget used to display table data.
void clearSort()
Clears the current sort on the table data tab.
void clearWidgetInCurrentSplitter()
Clears the side panel on the currently selected tab.
TBBrowser * getBrowser()
Returns the browser associated with this table.
TBTableKeywordsTab * getKeywordsTab()
Returns the table keywords tab associated with this table.
bool isEditable()
Returns true if the table is currently in editing mode, false otherwise.
TBDataTab * getDataTab()
Returns the data tab associated with this table.
std::vector< std::pair< casacore::String, bool > > * getSortFields()
Returns the current sort on the table data tab, or an empty list if there is none.
void clearWidgetInTableSplitter()
Clears the side panel on the table data tab.
void highlight(int row)
Selects and highlights the given row in the data tab.
TBFieldKeywordsTab * getFieldKeywordsTab()
Returns the field keywords tab assicated with this table.
bool editable
Indicates whether this table is currently in editing mode or not.
const Double e
e and functions thereof:
Collection of table backend and display tabs.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
void showWidgetInTableSplitter(QWidget *widget, bool isArray=false)
Shows the given widget in the side panel on the table data tab.
casacore::String getName()
Returns the &quot;name&quot; of this table (which is the last part of the filename).
void showWidgetInKeywordSplitter(QWidget *widget)
Shows the given widget in the side panel on the table keywords tab.
Parameters to indicate what driver should be used for the table backend.
Definition: TBTable.h:62
void showWidgetInCurrentSplitter(QWidget *widget)
Shows the given widget in the side panel of the tab that is currently selected.
TBTable * getTable()
Returns the underlying table backend.