casa
$Rev:20696$
|
00001 //# TBSorter.qo.h: Widget to configure a multi-field sort ordering. 00002 //# Copyright (C) 2005 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 TBSORTER_H_ 00028 #define TBSORTER_H_ 00029 00030 #include <casaqt/QtBrowser/TBSorter.ui.h> 00031 00032 #include <QtGui> 00033 00034 #include <casa/BasicSL/String.h> 00035 00036 #include <casa/namespace.h> 00037 using namespace std; 00038 00039 namespace casa { 00040 00041 // <summary> 00042 // Widget to configure a multi-field sort ordering. 00043 // </summary> 00044 // 00045 // <synopsis> 00046 // TBSorter allows the user to create an ordered list of fields for sorting. 00047 // Each field in the list also has a checkbox to indicate whether the sort 00048 // on that field should be ascending or not. Once a sort order has been 00049 // entered a signal is emitted; it is the parent's/caller's responsibility 00050 // to connect the signal and implement the sort. 00051 // </synopsis> 00052 00053 class TBSorter : public QDialog, Ui::Sorter { 00054 Q_OBJECT 00055 00056 public: 00057 // Constructor that takes the list of fields, an optional current sort 00058 // order to display, and an optional parent. If parent is NULL, the 00059 // widget is displayed as a dialog; otherwise it is displayed in the 00060 // parent. 00061 TBSorter(vector<String>& cols, vector<pair<String, bool> >* sort = NULL, 00062 QWidget* parent = NULL); 00063 00064 ~TBSorter(); 00065 00066 signals: 00067 // sortEntered is emitted when the "Sort" button is clicked. The sort 00068 // parameter contains the ordered list of fields and ascending bools. 00069 void sortEntered(vector<pair<String, bool> >& sort); 00070 00071 private: 00072 // The sortable fields. 00073 vector<String> cols; 00074 00075 00076 // Adds the specified field from the field list to the sort list. 00077 void add(int row, bool asc = true); 00078 00079 // Removes the specified field from the sort list. 00080 void remove(int row); 00081 00082 // Swaps the two indicated rows in the sort list. 00083 void swapRows(int r1, int r2); 00084 00085 private slots: 00086 // Slot for the "Add" button that adds the selected row in the field list 00087 // to the bottom of the sort list. 00088 void add(); 00089 00090 // Slot for the "Add All" button that adds all rows in the field list to 00091 // the bottom of the sort list. 00092 void addAll(); 00093 00094 // Slot for the "Remove" button that removes the selected row from the 00095 // sort list and returns it to its previous position in the field list. 00096 void remove(); 00097 00098 // Slot for the "Remove All" button that removes all the rows from the 00099 // sort list and returns them to the field list. 00100 void removeAll(); 00101 00102 // Slot for when the currently selected index in the sort list is changed. 00103 void tableIndexChanged(int row); 00104 00105 // Slot for the "Move Up" button that moves the selected row in the sort 00106 // list up one position. 00107 void moveUp(); 00108 00109 // Slot for the "Move Down" button that moves the selected row in the sort 00110 // list down one position. 00111 void moveDown(); 00112 00113 // Slot for the button to accept the current sort order and emit the 00114 // sortEntered() signal. 00115 void acceptButton(); 00116 }; 00117 00118 } 00119 00120 #endif /* TBSORTER_H_ */