casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TBSorter.qo.h
Go to the documentation of this file.
1 //# TBSorter.qo.h: Widget to configure a multi-field sort ordering.
2 //# Copyright (C) 2005
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 TBSORTER_H_
28 #define TBSORTER_H_
29 
30 #include <casaqt/QtBrowser/TBSorter.ui.h>
31 
32 #include <QtGui>
33 
34 #include <casa/BasicSL/String.h>
35 
36 namespace casa {
37 
38 // <summary>
39 // Widget to configure a multi-field sort ordering.
40 // </summary>
41 //
42 // <synopsis>
43 // TBSorter allows the user to create an ordered list of fields for sorting.
44 // Each field in the list also has a checkbox to indicate whether the sort
45 // on that field should be ascending or not. Once a sort order has been
46 // entered a signal is emitted; it is the parent's/caller's responsibility
47 // to connect the signal and implement the sort.
48 // </synopsis>
49 
50 class TBSorter : public QDialog, Ui::Sorter {
51  Q_OBJECT
52 
53 public:
54  // Constructor that takes the list of fields, an optional current sort
55  // order to display, and an optional parent. If parent is NULL, the
56  // widget is displayed as a dialog; otherwise it is displayed in the
57  // parent.
58  TBSorter(std::vector<casacore::String>& cols, std::vector<std::pair<casacore::String, bool> >* sort = NULL,
59  QWidget* parent = NULL);
60 
61  ~TBSorter();
62 
63 signals:
64  // sortEntered is emitted when the "casacore::Sort" button is clicked. The sort
65  // parameter contains the ordered list of fields and ascending bools.
66  void sortEntered(std::vector<std::pair<casacore::String, bool> >& sort);
67 
68 private:
69  // The sortable fields.
70  std::vector<casacore::String> cols;
71 
72 
73  // Adds the specified field from the field list to the sort list.
74  void add(int row, bool asc = true);
75 
76  // Removes the specified field from the sort list.
77  void remove(int row);
78 
79  // Swaps the two indicated rows in the sort list.
80  void swapRows(int r1, int r2);
81 
82 private slots:
83  // Slot for the "Add" button that adds the selected row in the field list
84  // to the bottom of the sort list.
85  void add();
86 
87  // Slot for the "Add All" button that adds all rows in the field list to
88  // the bottom of the sort list.
89  void addAll();
90 
91  // Slot for the "Remove" button that removes the selected row from the
92  // sort list and returns it to its previous position in the field list.
93  void remove();
94 
95  // Slot for the "Remove All" button that removes all the rows from the
96  // sort list and returns them to the field list.
97  void removeAll();
98 
99  // Slot for when the currently selected index in the sort list is changed.
100  void tableIndexChanged(int row);
101 
102  // Slot for the "Move Up" button that moves the selected row in the sort
103  // list up one position.
104  void moveUp();
105 
106  // Slot for the "Move Down" button that moves the selected row in the sort
107  // list down one position.
108  void moveDown();
109 
110  // Slot for the button to accept the current sort order and emit the
111  // sortEntered() signal.
112  void acceptButton();
113 };
114 
115 }
116 
117 #endif /* TBSORTER_H_ */
void addAll()
Slot for the &quot;Add All&quot; button that adds all rows in the field list to the bottom of the sort list...
void tableIndexChanged(int row)
Slot for when the currently selected index in the sort list is changed.
Widget to configure a multi-field sort ordering.
Definition: TBSorter.qo.h:50
void add()
Slot for the &quot;Add&quot; button that adds the selected row in the field list to the bottom of the sort list...
void swapRows(int r1, int r2)
Swaps the two indicated rows in the sort list.
void moveDown()
Slot for the &quot;Move Down&quot; button that moves the selected row in the sort list down one position...
void sortEntered(std::vector< std::pair< casacore::String, bool > > &sort)
sortEntered is emitted when the &quot;casacore::Sort&quot; button is clicked.
TBSorter(std::vector< casacore::String > &cols, std::vector< std::pair< casacore::String, bool > > *sort=NULL, QWidget *parent=NULL)
Constructor that takes the list of fields, an optional current sort order to display, and an optional parent.
std::vector< casacore::String > cols
The sortable fields.
Definition: TBSorter.qo.h:70
void acceptButton()
Slot for the button to accept the current sort order and emit the sortEntered() signal.
void moveUp()
Slot for the &quot;Move Up&quot; button that moves the selected row in the sort list up one position...
void removeAll()
Slot for the &quot;Remove All&quot; button that removes all the rows from the sort list and returns them to the...