CEDRIC  Revision_backup-2009-02
ClusterDialog.h
Go to the documentation of this file.
1 #ifndef CLUSTERDIALOG_H
2 #define CLUSTERDIALOG_H
3 
4 #include <QtGui>
5 
6 // #define CLUSTERDIALOG_MODELESS
7 
8 
9 class ClusterDialog: public QDialog
10 {
11  Q_OBJECT
12 
13 #ifdef CLUSTERDIALOG_MODELESS
14 signals:
15  void preview( unsigned int k );
16  void cluster( unsigned int k );
17 #endif
18 
19 public:
20  ClusterDialog( QWidget* parent=0 )
21  : QDialog( parent )
22  {
23  m_clusterSpinBox = new QSpinBox;
24  m_clusterSpinBox->setRange( 2, 23 );
25  m_clusterSpinBox->setValue( 5 );
26 
27  QLabel* clusterLabel = new QLabel( tr("Number of clusters") );
28  clusterLabel->setBuddy( m_clusterSpinBox );
29 
30 #ifdef CLUSTERDIALOG_MODELESS
31  QPushButton* previewBut = new QPushButton( tr("Preview") );
32  QPushButton* applyBut = new QPushButton( tr("Apply") );
33 #else
34  QPushButton* abortBut = new QPushButton( tr("Cancel") );
35 #endif
36  QPushButton* doneBut = new QPushButton( tr("Done") );
37  doneBut->setDefault( true );
38 
39 
40  QHBoxLayout* clusterLayout = new QHBoxLayout;
41  clusterLayout->addWidget( clusterLabel );
42  clusterLayout->addWidget( m_clusterSpinBox );
43 
44 #ifdef CLUSTERDIALOG_MODELESS
45  QVBoxLayout* butLayout = new QVBoxLayout;
46  butLayout->addWidget( previewBut );
47  butLayout->addWidget( applyBut );
48 #endif
49 
50  QHBoxLayout* doneLayout = new QHBoxLayout;
51  doneLayout->addStretch( 3 );
52 #ifndef CLUSTERDIALOG_MODELESS
53  doneLayout->addWidget( abortBut );
54 #endif
55  doneLayout->addWidget( doneBut );
56 
57  QVBoxLayout* layout = new QVBoxLayout;
58  layout->addLayout( clusterLayout );
59 #ifdef CLUSTERDIALOG_MODELESS
60  layout->addLayout( butLayout );
61 #endif
62  layout->addLayout( doneLayout );
63 
64  setLayout( layout );
65  setWindowTitle( tr("Cluster Events") );
66  setFixedSize( sizeHint() );
67 
68 
69 #ifdef CLUSTERDIALOG_MODELESS
70  connect( previewBut, SIGNAL(clicked()), this, SLOT(preview()));
71  connect( applyBut, SIGNAL(clicked()), this, SLOT(apply()) );
72 #else
73  connect( abortBut, SIGNAL(clicked()), this, SLOT(reject()) );
74 #endif
75  connect( doneBut, SIGNAL(clicked()), this, SLOT(accept()) );
76  }
77 
78 #ifdef CLUSTERDIALOG_MODELESS
79 protected slots:
80  void apply()
81  {
82  emit cluster( (unsigned int)m_clusterSpinBox->value() );
83  }
84 
85  void preview()
86  {
87  emit preview( (unsigned int)m_clusterSpinBox->value() );
88  }
89 #else
90 public:
91  unsigned int getNumClusters() const { return (unsigned int)m_clusterSpinBox->value(); }
92 #endif
93 
94 private:
95  QSpinBox* m_clusterSpinBox;
96 };
97 
98 #endif // CLUSTERDIALOG_H
unsigned int getNumClusters() const
Definition: ClusterDialog.h:91
ClusterDialog(QWidget *parent=0)
Definition: ClusterDialog.h:20
Definition: ClusterDialog.h:9