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