casa
$Rev:20696$
|
00001 //# TBKeywordsTab.qo.h: Widgets used to display table and field keywords. 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 TBKEYWORDSTAB_H_ 00028 #define TBKEYWORDSTAB_H_ 00029 00030 #include <casaqt/QtBrowser/TBTableKeywordsTab.ui.h> 00031 #include <casaqt/QtBrowser/TBFieldKeywordsTab.ui.h> 00032 #include <casaqt/QtBrowser/TBNewKeyword.ui.h> 00033 00034 #include <QtGui> 00035 00036 #include <casa/BasicSL/String.h> 00037 00038 #include <casa/namespace.h> 00039 using namespace std; 00040 00041 namespace casa { 00042 00043 //# Forward Declarations 00044 class TBTable; 00045 class TBTableTabs; 00046 class QCloseableWidget; 00047 class ProgressHelper; 00048 class TBTypes; 00049 class TBArrayPanel; 00050 00051 class TBNewKeyword : public QDialog, Ui::NewKeyword { 00052 Q_OBJECT 00053 00054 // <summary> 00055 // GUI for entering a new keyword. 00056 // <summary> 00057 // 00058 // <synopsis> 00059 // (Not Completed.) A TBNewKeyword is a dialog that allows the user to enter a 00060 // new keyword. The parent/caller is responsible for connecting the signal and 00061 // actually adding the new keyword. 00062 // </synopsis> 00063 00064 public: 00065 // Constructor that takes an optional vector of fields for entering a new 00066 // field keyword. If this vector is null, a table keyword is entered. 00067 TBNewKeyword(vector<String>* fields = NULL, QWidget* parent = NULL); 00068 00069 ~TBNewKeyword(); 00070 00071 signals: 00072 // newKeyword is emitted when the user has entered a new keyword. The 00073 // field index is -1 for a table keyword; otherwise it holds the index of 00074 // the field to which the keyword should be added. 00075 void newKeyword(int field, String name, String type, void* value); 00076 00077 private: 00078 // Displayed data types. 00079 vector<String>* types; 00080 00081 // Widget to enter the value based on the type. 00082 TBTypes* typesWidget; 00083 00084 private slots: 00085 // Catches when the user changes the type and changes the types widget 00086 // accordingly. 00087 void typeChanged(int index); 00088 }; 00089 00090 // <summary> 00091 // Widget used to display table keywords. 00092 // <summary> 00093 // 00094 // <synopsis> 00095 // Table keywords are displayed in a QTableWidget which cannot be edited. 00096 // Double-clicking certain types of keywords has certain effects: 00097 // double-clicking a table keyword will open that subtable while 00098 // double-clicking an array will open the array in a side panel. 00099 // </synopsis> 00100 00101 class TBTableKeywordsTab : public QWidget, Ui::TableKeywordsTab { 00102 Q_OBJECT 00103 00104 public: 00105 // Constructor which takes pointers to the table backend. 00106 TBTableKeywordsTab(TBTableTabs* tt, TBTable* t); 00107 00108 ~TBTableKeywordsTab(); 00109 00110 00111 // Returns the table widget used to display the keywords. 00112 QTableWidget* getTableWidget(); 00113 00114 00115 // Updates the QTableWidget with the new data that has been loaded into the 00116 // table backend. If a ProgressHelper is provided, it will be updated 00117 // periodically with progress information. 00118 void updateTable(ProgressHelper* pp = NULL); 00119 00120 public slots: 00121 // Clears whatever widget (if any) is currently being displayed in the side 00122 // panel. 00123 void clearWidgetInSplitter(); 00124 00125 // Show the given widget on the right side of the splitter. 00126 void showWidgetInSplitter(QWidget* widget); 00127 00128 signals: 00129 // This signal is emitted when the right widget is closed. The QWidget 00130 // points to the widget that was just closed. 00131 void rightWidgetClosed(QWidget* widget); 00132 00133 private: 00134 // Useful pointers to table backend. 00135 TBTableTabs* ttabs; 00136 TBTable* table; 00137 00138 // Flag on whether events generated by the QTableWidget are "genuine." 00139 bool update; 00140 00141 // Side panel. 00142 QCloseableWidget* rightWidget; 00143 00144 // Array panel. 00145 TBArrayPanel* arrayPanel; 00146 00147 private slots: 00148 // Slot for when a keyword is double-clicked. 00149 void doubleClicked(int row, int col); 00150 00151 // Slot for "Add Keyword" button. (Not currently implemented.) 00152 void addKeyword(); 00153 00154 // Slot for "Edit Keyword" button. (Not currently implemented.) 00155 void editKeyword(); 00156 00157 // Slot for "Remove Keyword" button. (Not currently implemented.) 00158 void removeKeyword(); 00159 00160 // Slot for when a keyword is selected in the table. 00161 void cellSelected(int row); 00162 }; 00163 00164 // <summary> 00165 // Widget used to display field keywords. 00166 // <summary> 00167 // 00168 // <synopsis> 00169 // Field keywords are displayed in a QTreeWidget which cannot be edited. 00170 // Double-clicking certain types of keywords has certain effects: 00171 // double-clicking a table keyword will open that subtable while 00172 // double-clicking an array will open the array in a side panel. 00173 // </synopsis> 00174 00175 class TBFieldKeywordsTab : public QWidget, Ui::FieldKeywordsTab { 00176 Q_OBJECT 00177 00178 public: 00179 // Constructor which takes pointers to the table backend. 00180 TBFieldKeywordsTab(TBTableTabs* tt, TBTable* t); 00181 00182 ~TBFieldKeywordsTab(); 00183 00184 00185 // Returns the QTreeWidget in which the field keywords are displayed. 00186 QTreeWidget* getTreeWidget(); 00187 00188 00189 // Updates the QTreeWidget with the new data that has been loaded into the 00190 // table backend. If a ProgressHelper is provided, it will be updated 00191 // periodically with progress information. 00192 void updateTable(ProgressHelper* pp = NULL); 00193 00194 public slots: 00195 // Clears whatever widget (if any) is currently being displayed in the side 00196 // panel. 00197 void clearWidgetInSplitter(); 00198 00199 // Show the given widget on the right side of the splitter. 00200 void showWidgetInSplitter(QWidget* widget); 00201 00202 signals: 00203 // This signal is emitted when the right widget is closed. The QWidget 00204 // points to the widget that was just closed. 00205 void rightWidgetClosed(QWidget* widget); 00206 00207 private: 00208 // Useful pointers to the table backend. 00209 TBTableTabs* ttabs; 00210 TBTable* table; 00211 00212 // Flag on whether events generated by the QTableWidget are "genuine." 00213 bool update; 00214 00215 // Side panel. 00216 QCloseableWidget* rightWidget; 00217 00218 // Array panel. 00219 TBArrayPanel* arrayPanel; 00220 00221 private slots: 00222 // Slot for when a field keyword is double-clicked. 00223 void doubleClicked(QTreeWidgetItem* item, int col); 00224 }; 00225 00226 } 00227 00228 #endif /* TBKEYWORDSTAB_H_ */