casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlotMSTab.qo.h
Go to the documentation of this file.
1 //# PlotMSTabs.qo.h: Tab GUI 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 PLOTMSTABS_QO_H_
28 #define PLOTMSTABS_QO_H_
29 
30 #include <casa/BasicSL/String.h>
32 
33 #include <QComboBox>
34 #include <QLabel>
35 #include <QList>
36 #include <QToolButton>
37 #include <QGroupBox>
38 
39 namespace casa {
40 
41 //# Forward declarations
42 class PlotMSApp;
43 class PlotMSPlotter;
44 
45 
46 // Abstract parent for any widget that goes in the tabbed side panel of the
47 // PlotMSPlotter.
48 class PlotMSTab : public QWidget, public PlotMSParametersWatcher {
49  Q_OBJECT
50 
51 public:
52  // Static //
53 
54  // Convenience methods for setting the current value of the given QComboBox
55  // to the given.
56  // <group>
57  static bool setChooser(QComboBox* chooser, const QString& value);
58  static bool setChooser(QComboBox* chooser, const casacore::String& value) {
59  QString str(value.c_str());
60  return setChooser(chooser, str); }
61  static bool setChooser(QComboBox* chooser, const char* value) {
62  QString str(value);
63  return setChooser(chooser, str); }
64  // </group>
65 
66 
67  // Non-Static //
68 
69  // Constructor that takes the parent plotter for this tab.
70  PlotMSTab(PlotMSPlotter* parent);
71 
72  // Destructor.
73  virtual ~PlotMSTab();
74 
75 
76  // Returns a string to use as the tab name for this widget.
77  virtual QString tabName() const = 0;
78 
79 
80 
81  // Returns all tool buttons on this tab.
82  virtual QList<QToolButton*> toolButtons() const {
83  return QList<QToolButton*>(); }
84 
85  // Sets up the tab for the given maximum width.
86  virtual void setupForMaxWidth(int maxWidth) { (void)maxWidth; }
87 
88 protected:
89  // Parent.
91 
92  // Plotter.
94 
95  // Default text for labels, so that they can be easily switched to red or
96  // normal depending on whether the item has changed or not.
97  QMap<QLabel*, QString> itsLabelDefaults_;
98 
99 
100  // These alter the displayed text of
101  // Some widget types have a .title not a .text, and there's no
102  // Qt4 abstract class that encompasses all types that do have .text,
103  // so we overload highlightWidgetText for several classes.
104  // Note that the Button version is meant for QCheckBox and QRadioButton,
105  // and probably isn't as useful for pushbuttons.
106  // Note: was formerly named changedText(). Name and purpose was unclear.
107  // <group>
108  void highlightWidgetText(QLabel* label, bool highlight);
109  void highlightWidgetText(QGroupBox *box, bool highlight);
110  void highlightWidgetText(QAbstractButton *but, bool highlight);
111  // </group>
112 
113 
114  // Returns the given text altered with HTML tags for highlighting,
115  // meant to be assigned to a Qt widget's title or similar property.
116  // If highlight is false, the text is returned stripped of any HTML.
117  // If highlighted, the text is made red using a <font> tag.
118  // <group>
119  static QString highlightifyText(const QString& text, bool highlight);
120 
121  // Variation taking a casacore String.
122  static QString highlightifyText(const casacore::String& text, bool changed) {
123  QString str(text.c_str());
124  return highlightifyText(str, changed); }
125 
126  // Variation of highlightifyText taking plain C-style text.
127  static QString highlightifyText(const char* text, bool changed) {
128  QString str(text);
129  return highlightifyText(str, changed); }
130 
131 
132 
133  // </group>
134 };
135 
136 }
137 
138 #endif /* PLOTMSTABS_QO_H_ */
QMap< QLabel *, QString > itsLabelDefaults_
Default text for labels, so that they can be easily switched to red or normal depending on whether th...
Definition: PlotMSTab.qo.h:97
static bool setChooser(QComboBox *chooser, const casacore::String &value)
Definition: PlotMSTab.qo.h:58
static QString highlightifyText(const QString &text, bool highlight)
Returns the given text altered with HTML tags for highlighting, meant to be assigned to a Qt widget&#39;s...
static QString highlightifyText(const casacore::String &text, bool changed)
Variation taking a casacore String.
Definition: PlotMSTab.qo.h:122
PlotMSPlotter * itsPlotter_
Plotter.
Definition: PlotMSTab.qo.h:93
void highlightWidgetText(QLabel *label, bool highlight)
These alter the displayed text of Some widget types have a.title not a.text, and there&#39;s no Qt4 abstr...
Controller class for plotms.
Definition: PlotMS.h:55
virtual ~PlotMSTab()
Destructor.
PlotMSTab(PlotMSPlotter *parent)
Non-Static //.
const Char * c_str() const
Get char array.
Definition: String.h:555
PlotMSApp * itsParent_
Parent.
Definition: PlotMSTab.qo.h:90
static QString highlightifyText(const char *text, bool changed)
Variation of highlightifyText taking plain C-style text.
Definition: PlotMSTab.qo.h:127
virtual QList< QToolButton * > toolButtons() const
Returns all tool buttons on this tab.
Definition: PlotMSTab.qo.h:82
Abstract parent for any widget that goes in the tabbed side panel of the PlotMSPlotter.
Definition: PlotMSTab.qo.h:48
Interface for classes that wish to be notified when PlotMSWatchedParameters have changed.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
High(ish)-level plotter class that manages the GUI (semi-) transparently to the rest of PlotMS...
static bool setChooser(QComboBox *chooser, const QString &value)
Static //.
virtual void setupForMaxWidth(int maxWidth)
Sets up the tab for the given maximum width.
Definition: PlotMSTab.qo.h:86
virtual QString tabName() const =0
Returns a string to use as the tab name for this widget.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
static bool setChooser(QComboBox *chooser, const char *value)
Definition: PlotMSTab.qo.h:61