casa
$Rev:20696$
|
00001 //# TBTaQL.qo.h: GUI for entering a TaQL command. 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 TBTAQL_H_ 00028 #define TBTAQL_H_ 00029 00030 #include <casaqt/QtBrowser/TBTaQL.ui.h> 00031 00032 #include <QtGui> 00033 00034 #include <casa/BasicSL/String.h> 00035 00036 #include <casa/namespace.h> 00037 using namespace std; 00038 00039 namespace casa { 00040 00041 // <summary> 00042 // GUI for entering a TaQL command. 00043 // </summary> 00044 // 00045 // <synopsis> 00046 // A TBTaQL widget contains two basic parts: the builder and the command text 00047 // edit. The builder contains GUI components that allow the user to visually 00048 // put together a TaQL command; once the command is built, the actual comamnd 00049 // can be generated. The command can also be manually edited. When the 00050 // command is accepted, a signal is emitted with the command in String format; 00051 // it is the parent/caller's responsibility to collect the command. 00052 // NOTE: at this time, only the builder for the SELECT command has been 00053 // implemented (and not a very advanced implementation, at that). 00054 // </synopsis> 00055 00056 class TBTaQL : public QDialog, Ui::TaQL { 00057 Q_OBJECT 00058 00059 public: 00060 // Available commands. Makes use of the QFlags for easy combining of 00061 // multiple Command enums into one Command enum. 00062 // <group> 00063 enum Command { 00064 SELECT = 0x1, 00065 UPDATE = 0x2, 00066 INSERT = 0x4, 00067 DELETE = 0x8, 00068 CALC = 0x16, 00069 CREATE = 0x32 00070 }; 00071 Q_DECLARE_FLAGS(Commands, Command); 00072 // </group> 00073 00074 // Returns the String representation of the given command. 00075 static String command(Command c) { 00076 switch(c) { 00077 case SELECT: return "SELECT"; 00078 case UPDATE: return "UPDATE"; 00079 case INSERT: return "INSERT"; 00080 case DELETE: return "DELETE"; 00081 case CALC: return "CALC"; 00082 case CREATE: return "CREATE"; 00083 default: return ""; 00084 } 00085 } 00086 00087 // Constructor which optionally takes the parent and the commands to show 00088 // in the builder command chooser. If parent is NULL, the TBTaQL is 00089 // presented as a QDialog. 00090 TBTaQL(QWidget* parent = NULL, Commands commands = SELECT); 00091 00092 ~TBTaQL(); 00093 00094 signals: 00095 // This signal is emitted whenever the user has accepted the entered TaQL 00096 // command. 00097 void command(String command); 00098 00099 // This signal is emitted whenever the user presses the "Close" button. 00100 // NOTE: if this TBTaQL is in dialog mode, it will close itself; if it is 00101 // in widget mode, the parent is responsible for closing it. This signal 00102 // is not emitted if in dialog mode. 00103 void closeRequested(); 00104 00105 private slots: 00106 // Slot for the "browse" button. Opens a file browser and puts the result 00107 // in the location text edit. 00108 void doBrowse(); 00109 00110 // Slot for the "generate" button. Generates the TaQL command from the 00111 // state of the builder widgets. 00112 void doGenerate(); 00113 00114 // Slot for the "accept" button. Emits the command() signal and, if the 00115 // TBTaQL is in dialog mode, closes the dialog. 00116 void doAccept(); 00117 00118 // Slot for the "close" button. If the TBTaQL is in dialog mode, closes 00119 // the dialog; otherwise, emits the closeRequested() signal. 00120 void doClose(); 00121 }; 00122 00123 Q_DECLARE_OPERATORS_FOR_FLAGS(TBTaQL::Commands) 00124 00125 } 00126 00127 #endif /*TBTAQL_H_*/