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