casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QtIndexChooser.qo.h
Go to the documentation of this file.
1 //# QtIndexChooser.qo.h: Simple widget for choosing an index.
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 QTINDEXCHOOSER_QO_H_
28 #define QTINDEXCHOOSER_QO_H_
29 
30 #include <casaqt/QtUtilities/QtIndexChooser.ui.h>
31 
32 #include <casa/BasicSL/String.h>
33 
34 #include <vector>
35 
36 namespace casa {
37 
38 // Widget that allows the user to pick an index, with a number of choices on
39 // how the index can be chosen. (See Type enum.)
40 class QtIndexChooser : public QWidget, Ui::IndexChooser {
41  Q_OBJECT
42 
43 public:
44  // Static //
45 
46  // The type of the chooser; i.e., how the user picks the index.
47  enum Type {
48  NAME, // Display a chooser that shows names associated with indices.
49  ROW_COL, // Display a row and column spinner box.
50  INDEX // Display an index spinner box.
51  };
52 
53 
54  // Non-Static //
55 
56  // Constructor which takes the type and an optional parent widget.
57  QtIndexChooser(Type type, QWidget* parent = NULL);
58 
59  // Destructor.
61 
62 
63  // Returns the currently set index on the widget.
64  unsigned int index() const;
65 
66  // Sets the type to the given, resizing if indicated.
67  void setType(Type type, bool resizeToHint = true);
68 
69  // Only valid if type is NAME. Sets the name for the given index and makes
70  // it available in the GUI.
71  void setName(unsigned int index, const casacore::String& name);
72 
73  // Only valid if type is NAME. Sets the available names to the given.
74  // <group>
75  void setNames(const std::vector<casacore::String>& names);
76  void setNames(const std::vector<unsigned int>& indices,
77  const std::vector<casacore::String>& names);
78  void setNames(const std::map<unsigned int, casacore::String>& names);
79  void setNames(const std::map<casacore::String, unsigned int>& names);
80  // </group>
81 
82  // Only valid if type is ROW_COL. Sets the number of rows and columns.
83  void setRowsCols(unsigned int nRows, unsigned int nCols);
84 
85  // Only valid if type is INDEX. Sets the maximum index (inclusive).
86  void setMaxIndex(unsigned int maxIndex);
87 
88 signals:
89  // Emitted when the index changes, and contains the new index value.
90  void indexChanged(unsigned int newIndex);
91 
92 private:
93  // Type.
95 
96  // Name/Index map.
97  QMap<QString, unsigned int> itsNames_;
98 
99 private:
100  // Sets up the name chooser for the currently set name/index mappings.
101  void setupNameChooser();
102 
103 private slots:
104  // Slot for when the index changes.
105  void indexChanged_() { emit indexChanged(index()); }
106 };
107 
108 }
109 
110 #endif /* QTINDEXCHOOSER_QO_H_ */
void setRowsCols(unsigned int nRows, unsigned int nCols)
Only valid if type is ROW_COL.
void indexChanged_()
Slot for when the index changes.
~QtIndexChooser()
Destructor.
QtIndexChooser(Type type, QWidget *parent=NULL)
Non-Static //.
virtual Type type()
Return the type enum.
void setType(Type type, bool resizeToHint=true)
Sets the type to the given, resizing if indicated.
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the if a human readable name(i.e."black").In many places throughout the plotter
Widget that allows the user to pick an index, with a number of choices on how the index can be chosen...
void setNames(const std::vector< casacore::String > &names)
Only valid if type is NAME.
void setMaxIndex(unsigned int maxIndex)
Only valid if type is INDEX.
void setName(unsigned int index, const casacore::String &name)
Only valid if type is NAME.
void indexChanged(unsigned int newIndex)
Emitted when the index changes, and contains the new index value.
unsigned int index() const
Returns the currently set index on the widget.
void setupNameChooser()
Sets up the name chooser for the currently set name/index mappings.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
QMap< QString, unsigned int > itsNames_
Name/Index map.