scidavis  2.3.0
About: SciDAVis is a free application for Scientific Data Analysis and Visualization (a fork off of QtiPlot).
  Fossies Dox: scidavis-2.3.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

future_SortDialog.cpp
Go to the documentation of this file.
1 
11 
30 
31 #include <QPushButton>
32 #include <QLabel>
33 #include <QComboBox>
34 #include <QGroupBox>
35 #include <QLayout>
36 #include <QApplication>
37 
38 namespace future{
39 
40 SortDialog::SortDialog( QWidget* parent, Qt::WindowFlags fl )
41  : QDialog( parent, fl )
42 {
43  setWindowIcon(qApp->windowIcon());
44  setWindowTitle(tr("Sorting Options"));
45  setSizeGripEnabled(true);
46 
47  QGroupBox *group_box1 = new QGroupBox();
48  QGridLayout * top_layout = new QGridLayout(group_box1);
49  QHBoxLayout * hl = new QHBoxLayout();
50  hl->addStretch();
51 
52  top_layout->addWidget( new QLabel(tr("Sort columns")), 0, 0 );
53  ui.box_type = new QComboBox();
54  ui.box_type->addItem(tr("Separately"));
55  ui.box_type->addItem(tr("Together"));
56  top_layout->addWidget(ui.box_type, 0, 1 );
57  ui.box_type->setCurrentIndex(Together);
58 
59  top_layout->addWidget( new QLabel( tr("Order")), 1, 0 );
60  ui.box_order = new QComboBox();
61  ui.box_order->addItem(tr("Ascending"));
62  ui.box_order->addItem(tr("Descending"));
63  top_layout->addWidget(ui.box_order, 1, 1 );
64 
65  top_layout->addWidget( new QLabel(tr("Leading column")), 2, 0 );
66  ui.columns_list = new QComboBox();
67  top_layout->addWidget(ui.columns_list, 2, 1);
68  top_layout->setRowStretch(3, 1);
69 
70  ui.button_ok = new QPushButton(tr("&Sort"));
71  ui.button_ok->setDefault( true );
72  hl->addWidget(ui.button_ok);
73 
74  ui.button_close = new QPushButton(tr("&Close"));
75  hl->addWidget(ui.button_close);
76 
77  QVBoxLayout * mainlayout = new QVBoxLayout(this);
78  mainlayout->addWidget(group_box1);
79  mainlayout->addLayout(hl);
80 
81  connect( ui.button_ok, SIGNAL( clicked() ), this, SLOT( accept() ) );
82  connect( ui.button_close, SIGNAL( clicked() ), this, SLOT( close() ) );
83  connect( ui.box_type, SIGNAL( currentIndexChanged(int) ), this, SLOT(changeType(int)));
84 }
85 
87 {
88  Column* leading;
89  if(ui.box_type->currentIndex() == Together)
90  leading = d_columns_list.at(ui.columns_list->currentIndex());
91  else
92  leading = 0;
93  emit sort(leading, d_columns_list, ui.box_order->currentIndex() == Ascending );
94 }
95 
96 void SortDialog::setColumnsList(QList<Column*> list)
97 {
98  d_columns_list = list;
99 
100  for(int i=0; i<list.size(); i++)
101  ui.columns_list->addItem( list.at(i)->name() );
102  ui.columns_list->setCurrentIndex(0);
103 }
104 
106 {
107  if(Type == Together)
108  ui.columns_list->setEnabled(true);
109  else
110  ui.columns_list->setEnabled(false);
111 }
112 
113 } //namespace
future
Definition: AbstractAspect.h:43
future::SortDialog::Ascending
@ Ascending
Definition: future_SortDialog.h:50
Column
Aspect that manages a column.
Definition: Column.h:59
future::SortDialog::SortDialog
SortDialog(QWidget *parent=0, Qt::WindowFlags fl=0)
Definition: future_SortDialog.cpp:40
future::SortDialog::sort
void sort(Column *leading, QList< Column * > cols, bool ascending)
future::SortDialog::Together
@ Together
Definition: future_SortDialog.h:49
future::SortDialog::d_columns_list
QList< Column * > d_columns_list
Definition: future_SortDialog.h:60
future::SortDialog::ui
struct future::SortDialog::@2 ui
future::SortDialog::accept
void accept()
Definition: future_SortDialog.cpp:86
future::SortDialog::changeType
void changeType(int index)
Definition: future_SortDialog.cpp:105
future_SortDialog.h
future::SortDialog::setColumnsList
void setColumnsList(QList< Column * > list)
Definition: future_SortDialog.cpp:96