casa
$Rev:20696$
|
00001 //# QtEditingWidget.qo.h: Simple editing widgets. 00002 //# Copyright (C) 2009 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 QTEDITINGWIDGET_QO_H_ 00028 #define QTEDITINGWIDGET_QO_H_ 00029 00030 #include <casaqt/QtUtilities/PlotFileWidget.ui.h> 00031 #include <casaqt/QtUtilities/PlotLabelWidget.ui.h> 00032 00033 #include <casa/BasicSL/String.h> 00034 00035 #include <casa/namespace.h> 00036 00037 namespace casa { 00038 00039 // A simple parent for editing widgets. 00040 class QtEditingWidget : public QWidget { 00041 Q_OBJECT 00042 00043 public: 00044 // Constructor which takes an optional parent widget. 00045 QtEditingWidget(QWidget* parent = NULL) : QWidget(parent) { } 00046 00047 // Destructor. 00048 virtual ~QtEditingWidget() { } 00049 00050 // Adds any radio buttons in the widget to the given button group. This 00051 // method should be overridden by children that have radio buttons. 00052 virtual void addRadioButtonsToGroup(QButtonGroup* group) const { (void)group; } 00053 00054 signals: 00055 // This signal should be emitted whenever the user changes any value 00056 // settings in the GUI. 00057 void changed(); 00058 00059 // This signal should be emitted when the user changes any value settings 00060 // in the GUI AND the new value is different from the last set value. 00061 void differentFromSet(); 00062 }; 00063 00064 00065 // Widget for choosing a label. Lets the user choose between no label, a 00066 // default label given at construction, or a custom label they can set. 00067 class QtLabelWidget : public QtEditingWidget, Ui::LabelWidget { 00068 Q_OBJECT 00069 00070 public: 00071 // Constructor which takes the label associated with the "default" option, 00072 // and an optional parent widget. 00073 QtLabelWidget(const String& defaultLabel, QWidget* parent = NULL); 00074 00075 // Destructor. 00076 ~QtLabelWidget(); 00077 00078 // Gets/Sets the currently set label on the widget. 00079 // <group> 00080 String getValue() const; 00081 void setValue(const String& value); 00082 // </group> 00083 00084 // Overrides PlotMSWidget::addRadioButtonsToGroup(). 00085 void addRadioButtonsToGroup(QButtonGroup* group) const; 00086 00087 private: 00088 // Default label. 00089 String itsDefault_; 00090 00091 // Last set label. 00092 String itsValue_; 00093 00094 private slots: 00095 // Slot for when the set label changes. The "check" flag can be used to 00096 // avoid emitting the changed signals twice (for example, when one radio 00097 // button turns off when another turns on). 00098 void labelChanged(bool check = true); 00099 }; 00100 00101 00102 // Widget for choosing a file. 00103 class QtFileWidget : public QtEditingWidget, Ui::FileWidget { 00104 Q_OBJECT 00105 00106 public: 00107 // Constructor which takes a flag for whether the file is a directory or 00108 // not (for the file chooser), a flag for whether the file is for saving 00109 // (and thus doesn't need to exist, for the file chooser), and an optional 00110 // parent widget. 00111 QtFileWidget(bool chooseDirectory, bool saveFile, QWidget* parent= NULL); 00112 00113 // Destructor. 00114 ~QtFileWidget(); 00115 00116 // Gets/Sets the currently set file. 00117 // <group> 00118 String getFile() const; 00119 void setFile(const String& file); 00120 // </group> 00121 00122 private: 00123 // File chooser directory flag. 00124 bool isDirectory_; 00125 00126 // File chooser save file flag. 00127 bool isSave_; 00128 00129 // Last set file. 00130 String itsFile_; 00131 00132 private slots: 00133 // Slot to show a file chooser and set the result in the line edit. 00134 void browse(); 00135 00136 // Slot for when the set file changes. 00137 void fileChanged(); 00138 void trimFileName(); 00139 }; 00140 00141 } 00142 00143 #endif /* QTEDITINGWIDGET_QO_H_ */