changeset 68:b918e57c7bea

* Flesh out multi-choice dialog a big
author Chris Cannam
date Wed, 17 Nov 2010 22:13:34 +0000
parents be627aeceaed
children 6d5a5571caec
files multichoicedialog.cpp multichoicedialog.h
diffstat 2 files changed, 58 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/multichoicedialog.cpp	Wed Nov 17 21:37:16 2010 +0000
+++ b/multichoicedialog.cpp	Wed Nov 17 22:13:34 2010 +0000
@@ -17,7 +17,40 @@
 
 #include "multichoicedialog.h"
 
-MultiChoiceDialog::MultiChoiceDialog(QWidget *parent) :
+#include <QDialogButtonBox>
+
+MultiChoiceDialog::MultiChoiceDialog(QString title, QString heading, QWidget *parent) :
     QDialog(parent)
 {
+    setModal(true);
+    setWindowTitle(title);
+
+    QGridLayout *outer = new QGridLayout;
+    setLayout(outer);
+
+    outer->addWidget(new QLabel(heading), 0, 0, 1, 3);
+
+    QWidget *innerWidget = new QWidget;
+    outer->addWidget(innerWidget, 1, 0, 1, 2);
+    m_choiceLayout = new QGridLayout;
+    innerWidget->setLayout(m_choiceLayout);
+
+    m_descriptionLabel = new QLabel;
+    outer->addWidget(m_descriptionLabel, 2, 0, 1, 3);
+
+    m_argLabel = new QLabel();
+    outer->addWidget(m_argLabel, 3, 0);
+
+    m_argEdit = new QLineEdit();
+    outer->addWidget(m_argEdit, 3, 1);
+
+    m_browseButton = new QPushButton(tr("Browse..."));
+    outer->addWidget(m_browseButton, 3, 2);
+
+    QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok |
+                                                  QDialogButtonBox::Cancel);
+    connect(bbox, SIGNAL(accepted()), this, SLOT(accept()));
+    connect(bbox, SIGNAL(rejected()), this, SLOT(reject()));
+    outer->addWidget(bbox, 4, 0, 1, 3);
 }
+
--- a/multichoicedialog.h	Wed Nov 17 21:37:16 2010 +0000
+++ b/multichoicedialog.h	Wed Nov 17 22:13:34 2010 +0000
@@ -20,12 +20,18 @@
 
 #include <QDialog>
 #include <QString>
+#include <QPushButton>
+#include <QMap>
+#include <QLabel>
+#include <QLineEdit>
+#include <QGridLayout>
+#include <QStackedWidget>
 
 class MultiChoiceDialog : public QDialog
 {
     Q_OBJECT
 public:
-    explicit MultiChoiceDialog(QWidget *parent = 0);
+    explicit MultiChoiceDialog(QString title, QString heading, QWidget *parent = 0);
 
     enum ArgType {
         NoArg,
@@ -42,7 +48,23 @@
 
 signals:
 
-public slots:
+private slots:
+
+
+private:
+    void updateArgWidgets(); // when choice changes
+
+    QMap<QString, QString> m_texts;
+    QMap<QString, QString> m_descriptions;
+
+    QString m_currentChoice;
+    QMap<QString, QPushButton *> m_choiceButtons;
+
+    QGridLayout *m_choiceLayout;
+    QLabel *m_descriptionLabel;
+    QLabel *m_argLabel;
+    QLineEdit *m_argEdit;
+    QPushButton *m_browseButton;
 
 };