casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QtEditingWidget.qo.h
Go to the documentation of this file.
1 //# QtEditingWidget.qo.h: Simple editing widgets.
2 //# Copyright (C) 2009
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 QTEDITINGWIDGET_QO_H_
28 #define QTEDITINGWIDGET_QO_H_
29 
30 #include <casaqt/QtUtilities/PlotFileWidget.ui.h>
31 #include <casaqt/QtUtilities/PlotLabelWidget.ui.h>
32 
33 #include <casa/BasicSL/String.h>
34 
35 namespace casa {
36 
37 // A simple parent for editing widgets.
38 class QtEditingWidget : public QWidget {
39  Q_OBJECT
40 
41 public:
42  // Constructor which takes an optional parent widget.
43  QtEditingWidget(QWidget* parent = NULL) : QWidget(parent) { }
44 
45  // Destructor.
46  virtual ~QtEditingWidget() { }
47 
48  // Adds any radio buttons in the widget to the given button group. This
49  // method should be overridden by children that have radio buttons.
50  virtual void addRadioButtonsToGroup(QButtonGroup* group) const { (void)group; }
51 
52 signals:
53  // This signal should be emitted whenever the user changes any value
54  // settings in the GUI.
55  void changed();
56 
57  // This signal should be emitted when the user changes any value settings
58  // in the GUI AND the new value is different from the last set value.
59  void differentFromSet();
60 
61  // to change widget focus when editing done
62  void editDone();
63 };
64 
65 
66 // Widget for choosing a label. Lets the user choose between no label, a
67 // default label given at construction, or a custom label they can set.
68 class QtLabelWidget : public QtEditingWidget, Ui::LabelWidget {
69  Q_OBJECT
70 
71 public:
72  // Constructor which takes the label associated with the "default" option,
73  // and an optional parent widget.
74  QtLabelWidget(const casacore::String& defaultLabel, QWidget* parent = NULL);
75 
76  // Destructor.
78 
79  // Gets/Sets the currently set label on the widget.
80  // <group>
81  casacore::String getValue() const;
82  void setValue(const casacore::String& value);
83  // </group>
84 
85  // Overrides PlotMSWidget::addRadioButtonsToGroup().
86  void addRadioButtonsToGroup(QButtonGroup* group) const;
87 
88 private:
89  // Default label.
91 
92  // Last set label.
94 
95 private slots:
96  // Slot for when the set label changes. The "check" flag can be used to
97  // avoid emitting the changed signals twice (for example, when one radio
98  // button turns off when another turns on).
99  void labelChanged(bool check = true);
100 };
101 
102 
103 // Widget for choosing a file.
104 class QtFileWidget : public QtEditingWidget, Ui::FileWidget {
105  Q_OBJECT
106 
107 public:
108  // Constructor which takes a flag for whether the file is a directory or
109  // not (for the file chooser), a flag for whether the file is for saving
110  // (and thus doesn't need to exist, for the file chooser), and an optional
111  // parent widget.
112  QtFileWidget(bool chooseDirectory, bool saveFile, QWidget* parent= NULL);
113 
114  // Destructor.
115  ~QtFileWidget();
116 
117  // Gets/Sets the currently set file.
118  // <group>
119  casacore::String getFile() const;
120  void setFile(const casacore::String& file);
121  // </group>
122 
123 private:
124  // casacore::File chooser directory flag.
126 
127  // casacore::File chooser save file flag.
128  bool isSave_;
129 
130  // Last set file.
132 
133 private slots:
134  // Slot to show a file chooser and set the result in the line edit.
135  void browse();
136 
137  // Slot for when the set file changes.
138  void fileChanged();
139  void trimFileName();
140 };
141 
142 }
143 
144 #endif /* QTEDITINGWIDGET_QO_H_ */
void browse()
Slot to show a file chooser and set the result in the line edit.
Widget for choosing a file.
virtual void addRadioButtonsToGroup(QButtonGroup *group) const
Adds any radio buttons in the widget to the given button group.
QtFileWidget(bool chooseDirectory, bool saveFile, QWidget *parent=NULL)
Constructor which takes a flag for whether the file is a directory or not (for the file chooser)...
casacore::String itsFile_
Last set file.
casacore::String itsDefault_
Default label.
void setFile(const casacore::String &file)
~QtLabelWidget()
Destructor.
void changed()
This signal should be emitted whenever the user changes any value settings in the GUI...
~QtFileWidget()
Destructor.
bool isDirectory_
casacore::File chooser directory flag.
void labelChanged(bool check=true)
Slot for when the set label changes.
casacore::String itsValue_
Last set label.
casacore::String getValue() const
Gets/Sets the currently set label on the widget.
void fileChanged()
Slot for when the set file changes.
bool isSave_
casacore::File chooser save file flag.
void setValue(const casacore::String &value)
void differentFromSet()
This signal should be emitted when the user changes any value settings in the GUI AND the new value i...
virtual ~QtEditingWidget()
Destructor.
void addRadioButtonsToGroup(QButtonGroup *group) const
Overrides PlotMSWidget::addRadioButtonsToGroup().
Widget for choosing a label.
void editDone()
to change widget focus when editing done
QtEditingWidget(QWidget *parent=NULL)
Constructor which takes an optional parent widget.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::String getFile() const
Gets/Sets the currently set file.
A simple parent for editing widgets.
QtLabelWidget(const casacore::String &defaultLabel, QWidget *parent=NULL)
Constructor which takes the label associated with the &quot;default&quot; option, and an optional parent widget...
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
Defines nreal time structures used by the VLA table filler.
Definition: nreal.h:100