casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TBBrowser.qo.h
Go to the documentation of this file.
1 //# TBBrowser.qo.h: Browser widget for managing opened tables.
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 TBBROWSER_H_
28 #define TBBROWSER_H_
29 
30 #include <casaqt/QtBrowser/TBBrowser.ui.h>
32 
33 #include <QtGui>
34 
35 #include <casa/BasicSL/String.h>
36 
37 #include <vector>
38 
39 namespace casa {
40 
41 //# Forward Declarations
42 class TBTableTabs;
43 class QProgressPanel;
44 class ProgressHelper;
45 class TBExportThread;
46 class TBTable;
47 class TBFilterRuleSequence;
48 class TBFilterRules;
49 class DriverParams;
50 class TBView;
51 
52 // <summary>
53 // Browser widget for managing opened tables.
54 // <summary>
55 //
56 // <synopsis>
57 // TBBrowser is a container for multiple TBTableTabs. Its main responsibility
58 // is to keep these tabs up-to-date and handle their opening and closing.
59 // TBBrowser is the main interface for the GUI of the table browser and thus
60 // also provides public methods to operate on opened tables.
61 // </synopsis>
62 
63 class TBBrowser : public QWidget, Ui::Browser {
64  Q_OBJECT
65 
66 public:
67  // Default Constructor. Sets up GUI with no tabs or opened tables.
68  TBBrowser();
69 
70  ~TBBrowser();
71 
72 
73  /* Accessors/Mutators */
74 
75  // Returns true if the browser is available, false otherwise.
76  bool isAvailable();
77 
78  // Returns the number of tables that are currently opened.
79  int openedTables();
80 
81  // Returns the widget managing the tabs (QTabWidget).
82  QTabWidget* getTabWidget();
83 
84  // Returns the number of performed actions. See TBActionList::size().
85  int getNumActions();
86 
87  // Returns the number of undone actions. See TBActionList::undoneSize().
88  int getNumUndoneActions();
89 
90  // Returns the name of the last performed action, or blank if there is
91  // none. See TBActionList::lastActionName().
93 
94  // Returns the name of the last undone action, or blank if there is none.
95  // See TBActionList::lastUndoneActionName().
97 
98 
99  /* casacore::Table Access Methods */
100 
101  // Returns the name of the currently selected table, or blank if there is
102  // none.
104 
105  // Returns the currently selected table.
107 
108  // Returns the currently selected table tab.
110 
111  // Returns the names of all opened tables.
112  std::vector<casacore::String> openedTableNames();
113 
114  // Returns the TBTableTabs for the table with the given name.
116 
117  // Returns the index of the indicated table tabs, or -1 if the pointer is
118  // invalid.
119  int indexOf(TBTableTabs* tt);
120 
121  // Return the table at index i, or NULL if the index is invalid.
122  TBTableTabs* tableAt(int i);
123 
124 
125  /* casacore::Table Operation Methods */
126 
127  // Opens a table tab from the given file, with the given parameters. Loads
128  // rows from start to (start + num). If the DriverParameters are NULL,
129  // the default is used.
130  int openTable(casacore::String filename, DriverParams* dp = NULL, int start = 0,
132 
133  // Opens a table tab from the given file, with the given parameters. Loads
134  // rows from start to (start + num). If the DriverParameters are NULL,
135  // the default is used.
136  int openTable(casacore::String filename, bool taql, DriverParams* dp = NULL,
137  int start = 0, int num = TBConstants::DEFAULT_SELECT_NUM);
138 
139  // Closes the currently selected table and returns its name.
141 
142  // Closes the table at the given tab index and returns its name.
143  casacore::String closeTable(int index);
144 
145  // Closes the table with the given name and returns whether the close
146  // succeeded or not.
147  bool closeTable(casacore::String name);
148 
149  // Returns the column (field) names for the table at the given index.
150  QStringList getColumnsAt(unsigned int index);
151 
152  // Returns true if the indicated column on the indicated tab is hidden,
153  // false otherwise.
154  bool columnIsHidden(unsigned int index, int col);
155 
156  // Sets whether the indicated column on the currently selected tab is
157  // hidden.
158  void setColumnHidden(int col, bool hidden);
159 
160  // Sets whether the indicated column on the indicated tab is hidden.
161  void setColumnHidden(unsigned int index, int col, bool hidden);
162 
163  // Exports the currently selected table to VOTable XML format to the given
164  // filename. See TBTable::exportVOTable().
166 
167  // Returns true if the table at the given index has a find rule entered,
168  // false otherwise.
169  bool findRuleAvailable(int index);
170 
171  // Shows a find dialog, and connects the signal to run the find rules as
172  // indicated.
173  void find();
174 
175  // If the currently selected table has a find rule, finds the next row that
176  // passes the rule. The second parameter is used to control the
177  // wrap-around search such that the search will go through each row exactly
178  // once.
179  void findNext(bool second = false);
180 
181  // If the currently selected table has a find rule, finds the previous row
182  // that passes the rule. The second parameter is used to control the
183  // wrap-around search such that the search will go through each row exactly
184  // once.
185  void findPrev(bool second = false);
186 
187  // Returns true if the table at the given index has a filter, false
188  // otherwise.
189  bool filterAvailable(int index);
190 
191  // Shows a filter rules dialog in the side panel of the currently selected
192  // table and connects its signal such that when the user clicks the
193  // "Filter" button, the filter is run on the table.
194  void filterOnFields();
195 
196  // Clears the filter on the currently selected table.
197  void clearFilterOnFields();
198 
199  // Returns the filter for the table at the indicated index, or NULL if
200  // there is none.
201  TBFilterRuleSequence* filterAt(int index);
202 
203  // Displays a format dialog for the currently selected table for the field
204  // at index i, and connects the signal to format the display accordingly.
205  void formatDisplay(int i);
206 
207  // Shows a table information panel in the side panel of the currently
208  // selected table.
209  void viewTableInfo();
210 
211  // casacore::Sort the currently selected table by the indicated fields.
212  void sort(std::vector<std::pair<casacore::String, bool> >& s);
213 
214  // casacore::Sort the table at index i with the fields in s. Each entry in s should
215  // be a field name paired with a bool indicating whether the sort order is
216  // ascending. See TBTableTabs::sort().
217  void sort(int i, std::vector<std::pair<casacore::String, bool> >& s);
218 
219 
220  /* Action Methods */
221 
222  // Does the specified action and returns the result. See
223  // TBActionList::doAction().
224  Result doAction(TBAction* action);
225 
226  // Undoes the last performed action and returns the result. See
227  // TBActionList::undoAction().
228  Result undoAction();
229 
230  // Redoes the last undone action and returns the result. See
231  // TBActionList::redoAction().
232  Result redoAction();
233 
234 
235  /* Progress Methods */
236 
237  // Adds a QProgressPanel to the front of the browser and dims the GUI
238  // behind the progress panel, then returns the QProgressPanel.
239  QProgressPanel* addProgressPanel(casacore::String label, bool hideable,
240  bool cancelable);
241 
242  // Removes the given QProgressPanel from the browser and restores it to
243  // its fully-enabled state.
244  void removeProgressPanel(QProgressPanel* panel);
245 
246  // Shows the progress frame on the bottom of the browser and returns a
247  // ProgressHelper encapsulating it.
249 
250  // Hides the progress frame on the bottom of the browser.
251  void disableProgressFrame();
252 
253 
254  /* Miscellaneous Browser Methods */
255 
256  // Returns true if a background task is currently running, false otherwise.
257  bool bgTaskIsRunning();
258 
259  // Returns the current view of the browser. See TBView.
260  TBView* view();
261 
262  // Shows the given view in the browser. See TBView.
263  void showView(TBView* view);
264 
265 public slots:
266  // Displays the given error in a dialog to the user.
267  void displayError(casacore::String message);
268 
269  // Opens a TaQL table with the given command. See openTable().
270  void openTaQL(casacore::String command);
271 
272  // Opens the subtable located at the given filename, and load the rows such
273  // that row r can be selected.
274  void followReference(casacore::String subtable, int r);
275 
276  // Removes all actions associated with the given widget.
277  void removeActionsAssociatedWithWidget(QWidget* widget);
278 
279  // Removes all actions associated with the given object.
280  void removeActionsAssociatedWith(void* widget);
281 
282 signals:
283  // This signal is emitted when a new table is opened and its tab added.
284  // The casacore::String parameter holds the name of the newly opened table.
285  void tableOpened(casacore::String name, casacore::String fullpath);
286 
287  // This signal is emitted when a table is closed and its tab removed.
288  // The casacore::String parameter holds the name of the table that was closed.
289  void tableClosed(casacore::String name);
290 
291  // This signal is emitted whenever an action is performed. The
292  // TBAction parameter points to the action that was performed.
293  void actionPerformed(TBAction* action);
294 
295  // This signal is emitted whenever the latest action was undone.
296  void actionUndone();
297 
298  // This signal is emitted whenever the latest undone action was redone.
299  void actionRedone();
300 
301  // This signal is emitted whenever a task thread has completed.
302  void threadIsFinished();
303 
304  // This signal is emitted whenever the user enters a find rule for the
305  // currently selected table.
306  void findRuleAvailable();
307 
308  // This signal is emitted whenever the user enters a filter rule for the
309  // table with the given index.
310  void filterRuleAvailable(int index);
311 
312  // This signal is emitted whenever the user clears the filter rule for the
313  // table with the given index.
314  void filterRuleCleared(int index);
315 
316  // This signal is emitted whenever the tab is changed. The int parameter
317  // indicates the new current tab index.
318  void tabChanged(int tableIndex);
319 
320 private:
321  // Indicates whether the browser is available.
322  bool available;
323 
324  // Holds the opened tables.
325  std::vector<TBTableTabs*> tables;
326 
327  // Error dialog.
328  QErrorMessage* errorDialog;
329 
330  // Actions, both performed and undone.
332 
333  // The current progress panel, or NULL if there is none.
335 
336  // The current export thread, or NULL if there is none.
338 
339  // Find rules for all opened tables.
340  std::vector<TBFilterRuleSequence*> currentFindRules;
341 
342  // Filters for all opened tables.
343  std::vector<TBFilterRuleSequence*> currentFilters;
344 
345  // Indicates whether a background task is currently running or not.
347 
348  // Indicates whether an export thread is both active and hidden or not.
350 
351 
352  // Enable or disable the widgets based upon availability.
353  void updateEnabled();
354 
355  // Adds a table tab from the given file, with the given parameters. Loads
356  // rows from start to (start + num). If the DriverParameters are NULL,
357  // the default is used.
358  int addTable(casacore::String filename, bool taql, DriverParams* dp, int start,
359  int num);
360 
361 private slots:
362  // Slot to close the currently opened table.
363  void doCloseTable();
364 
365  // Slot for when a task thread has finished.
366  void threadFinished();
367 
368  // Slot for hiding a task thread in the background.
369  void hideThread();
370 
371  // Slot for when the user has entered a filter rule. Applies the given
372  // TBFilterRulesSequence to the currently selected table.
374 
375  // Slot for when the user has entered a search rule. Searches the
376  // currently selected table for a row that passes and, if one is found
377  // on the currently loaded pages, selects that row.
378  void findRulesEntered(TBFilterRuleSequence* rules, TBFilterRules* rDialog);
379 
380  // Slot for when the QTabWidget detects a change in tab. Emits the
381  // tabChanged() signal.
382  void tabChange(int index);
383 };
384 
385 }
386 
387 #endif /* TBBROWSER_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
bool columnIsHidden(unsigned int index, int col)
Returns true if the indicated column on the indicated tab is hidden, false otherwise.
bool bgTaskIsRunning()
Returns true if a background task is currently running, false otherwise.
void tableOpened(casacore::String name, casacore::String fullpath)
This signal is emitted when a new table is opened and its tab added.
void findRuleAvailable()
This signal is emitted whenever the user enters a find rule for the currently selected table...
void actionUndone()
This signal is emitted whenever the latest action was undone.
std::vector< TBFilterRuleSequence * > currentFilters
Filters for all opened tables.
Definition: TBBrowser.qo.h:343
int addTable(casacore::String filename, bool taql, DriverParams *dp, int start, int num)
Adds a table tab from the given file, with the given parameters.
bool available
Indicates whether the browser is available.
Definition: TBBrowser.qo.h:322
Convenience class for a casacore::String/bool tuple.
Definition: TBConstants.h:93
void clearFilterOnFields()
Clears the filter on the currently selected table.
Current &quot;view&quot; or state of the browser that can be serialized.
Definition: TBView.h:105
void viewTableInfo()
Shows a table information panel in the side panel of the currently selected table.
QStringList getColumnsAt(unsigned int index)
Returns the column (field) names for the table at the given index.
int indexOf(TBTableTabs *tt)
Returns the index of the indicated table tabs, or -1 if the pointer is invalid.
void tabChange(int index)
Slot for when the QTabWidget detects a change in tab.
void removeActionsAssociatedWith(void *widget)
Removes all actions associated with the given object.
void exportVOTable(casacore::String file)
Exports the currently selected table to VOTable XML format to the given filename. ...
Browser widget for managing opened tables.
Definition: TBBrowser.qo.h:63
void removeProgressPanel(QProgressPanel *panel)
Removes the given QProgressPanel from the browser and restores it to its fully-enabled state...
bool isAvailable()
Returns true if the browser is available, false otherwise.
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the if a human readable name(i.e."black").In many places throughout the plotter
int openedTables()
Returns the number of tables that are currently opened.
std::vector< TBTableTabs * > tables
Holds the opened tables.
Definition: TBBrowser.qo.h:325
bool exportHidden
Indicates whether an export thread is both active and hidden or not.
Definition: TBBrowser.qo.h:349
void removeActionsAssociatedWithWidget(QWidget *widget)
Removes all actions associated with the given widget.
void sort(std::vector< std::pair< casacore::String, bool > > &s)
casacore::Sort the currently selected table by the indicated fields.
Result redoAction()
Redoes the last undone action and returns the result.
void followReference(casacore::String subtable, int r)
Opens the subtable located at the given filename, and load the rows such that row r can be selected...
void openTaQL(casacore::String command)
Opens a TaQL table with the given command.
Contains an list of performed actions and a list of undone actions.
Definition: TBAction.h:111
bool bgTaskRunning
Indicates whether a background task is currently running or not.
Definition: TBBrowser.qo.h:346
Wrapper around a QProgressPanel or other QLabel/QProgressBar pairing.
void doCloseTable()
Slot to close the currently opened table.
void filterRulesEntered(TBFilterRuleSequence *rules)
Slot for when the user has entered a filter rule.
TBTableTabs * tableAt(int i)
Return the table at index i, or NULL if the index is invalid.
Result undoAction()
Undoes the last performed action and returns the result.
void findNext(bool second=false)
If the currently selected table has a find rule, finds the next row that passes the rule...
void filterOnFields()
Shows a filter rules dialog in the side panel of the currently selected table and connects its signal...
int getNumUndoneActions()
Returns the number of undone actions.
bool filterAvailable(int index)
Returns true if the table at the given index has a filter, false otherwise.
void setColumnHidden(int col, bool hidden)
Sets whether the indicated column on the currently selected tab is hidden.
TBTableTabs * currentlySelectedTableTabs()
Returns the currently selected table tab.
void tableClosed(casacore::String name)
This signal is emitted when a table is closed and its tab removed.
TBActionList actions
Actions, both performed and undone.
Definition: TBBrowser.qo.h:331
Primary interface for the rest of the browser to a table.
Definition: TBTable.h:152
TBTableTabs * table(casacore::String name)
Returns the TBTableTabs for the table with the given name.
int openTable(casacore::String filename, DriverParams *dp=NULL, int start=0, int num=TBConstants::DEFAULT_SELECT_NUM)
Opens a table tab from the given file, with the given parameters.
void findRulesEntered(TBFilterRuleSequence *rules, TBFilterRules *rDialog)
Slot for when the user has entered a search rule.
void formatDisplay(int i)
Displays a format dialog for the currently selected table for the field at index i, and connects the signal to format the display accordingly.
void showView(TBView *view)
Shows the given view in the browser.
TBBrowser()
Default Constructor.
void find()
Shows a find dialog, and connects the signal to run the find rules as indicated.
void disableProgressFrame()
Hides the progress frame on the bottom of the browser.
Widget to allow the user to enter a filter rule sequence.
TBView * view()
Returns the current view of the browser.
void updateEnabled()
Enable or disable the widgets based upon availability.
TBFilterRuleSequence * filterAt(int index)
Returns the filter for the table at the indicated index, or NULL if there is none.
void actionPerformed(TBAction *action)
This signal is emitted whenever an action is performed.
QTabWidget * getTabWidget()
Returns the widget managing the tabs (QTabWidget).
const Double second
Time interval [T]:
std::vector< TBFilterRuleSequence * > currentFindRules
Find rules for all opened tables.
Definition: TBBrowser.qo.h:340
void filterRuleCleared(int index)
This signal is emitted whenever the user clears the filter rule for the table with the given index...
void threadIsFinished()
This signal is emitted whenever a task thread has completed.
A sequence of TBFilterRules that can be used to filter rows.
QProgressPanel * progressPanel
The current progress panel, or NULL if there is none.
Definition: TBBrowser.qo.h:334
Convenience class with a label and progress meter.
casacore::String lastUndoneActionName()
Returns the name of the last undone action, or blank if there is none.
int getNumActions()
Returns the number of performed actions.
QProgressPanel * addProgressPanel(casacore::String label, bool hideable, bool cancelable)
Adds a QProgressPanel to the front of the browser and dims the GUI behind the progress panel...
Collection of table backend and display tabs.
void hideThread()
Slot for hiding a task thread in the background.
QErrorMessage * errorDialog
Error dialog.
Definition: TBBrowser.qo.h:328
ProgressHelper * enableProgressFrame(casacore::String label)
Shows the progress frame on the bottom of the browser and returns a ProgressHelper encapsulating it...
void threadFinished()
Slot for when a task thread has finished.
void filterRuleAvailable(int index)
This signal is emitted whenever the user enters a filter rule for the table with the given index...
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::String closeTable()
Closes the currently selected table and returns its name.
void findPrev(bool second=false)
If the currently selected table has a find rule, finds the previous row that passes the rule...
void actionRedone()
This signal is emitted whenever the latest undone action was redone.
Result doAction(TBAction *action)
Does the specified action and returns the result.
casacore::String lastActionName()
Returns the name of the last performed action, or blank if there is none.
std::vector< casacore::String > openedTableNames()
Returns the names of all opened tables.
Parameters to indicate what driver should be used for the table backend.
Definition: TBTable.h:62
Abstract parent class of any action that can be performed.
Definition: TBAction.h:54
void tabChanged(int tableIndex)
This signal is emitted whenever the tab is changed.
TBTable * currentlySelectedTable()
Returns the currently selected table.
void displayError(casacore::String message)
Displays the given error in a dialog to the user.
casacore::String currentlySelectedTableName()
Returns the name of the currently selected table, or blank if there is none.
Defines nreal time structures used by the VLA table filler.
Definition: nreal.h:100
TBExportThread * exportThread
The current export thread, or NULL if there is none.
Definition: TBBrowser.qo.h:337
Thread that exports a table to VOTable XML format.