QtIndexChooser.qo.h

Go to the documentation of this file.
00001 //# QtIndexChooser.qo.h: Simple widget for choosing an index.
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 QTINDEXCHOOSER_QO_H_
00028 #define QTINDEXCHOOSER_QO_H_
00029 
00030 #include <casaqt/QtUtilities/QtIndexChooser.ui.h>
00031 
00032 #include <casa/BasicSL/String.h>
00033 
00034 #include <vector>
00035 
00036 namespace casa {
00037 
00038 // Widget that allows the user to pick an index, with a number of choices on
00039 // how the index can be chosen.  (See Type enum.)
00040 class QtIndexChooser : public QWidget, Ui::IndexChooser {
00041     Q_OBJECT
00042     
00043 public:
00044     // Static //
00045     
00046     // The type of the chooser; i.e., how the user picks the index.
00047     enum Type {
00048         NAME,    // Display a chooser that shows names associated with indices.
00049         ROW_COL, // Display a row and column spinner box.
00050         INDEX    // Display an index spinner box.
00051     };
00052     
00053     
00054     // Non-Static //
00055     
00056     // Constructor which takes the type and an optional parent widget.
00057     QtIndexChooser(Type type, QWidget* parent = NULL);
00058     
00059     // Destructor.
00060     ~QtIndexChooser();
00061     
00062     
00063     // Returns the currently set index on the widget.
00064     unsigned int index() const;
00065     
00066     // Sets the type to the given, resizing if indicated.
00067     void setType(Type type, bool resizeToHint = true);
00068     
00069     // Only valid if type is NAME.  Sets the name for the given index and makes
00070     // it available in the GUI.
00071     void setName(unsigned int index, const String& name);
00072     
00073     // Only valid if type is NAME.  Sets the available names to the given.
00074     // <group>
00075     void setNames(const std::vector<String>& names);
00076     void setNames(const std::vector<unsigned int>& indices,
00077             const std::vector<String>& names);
00078     void setNames(const std::map<unsigned int, String>& names);
00079     void setNames(const std::map<String, unsigned int>& names);
00080     // </group>
00081     
00082     // Only valid if type is ROW_COL.  Sets the number of rows and columns.
00083     void setRowsCols(unsigned int nRows, unsigned int nCols);
00084     
00085     // Only valid if type is INDEX.  Sets the maximum index (inclusive).
00086     void setMaxIndex(unsigned int maxIndex);
00087     
00088 signals:
00089     // Emitted when the index changes, and contains the new index value.
00090     void indexChanged(unsigned int newIndex);
00091     
00092 private:
00093     // Type.
00094     Type itsType_;
00095     
00096     // Name/Index map.
00097     QMap<QString, unsigned int> itsNames_;
00098     
00099 private:
00100     // Sets up the name chooser for the currently set name/index mappings.
00101     void setupNameChooser();
00102     
00103 private slots:    
00104     // Slot for when the index changes.
00105     void indexChanged_() { emit indexChanged(index()); }
00106 };
00107 
00108 }
00109 
00110 #endif /* QTINDEXCHOOSER_QO_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1