diff src/hgignoredialog.cpp @ 416:8df07172d6da ignore

Return ignore type from ignore dialog
author Chris Cannam
date Thu, 16 Jun 2011 14:53:06 +0100
parents 6d7dad48b13c
children 4593555915cf
line wrap: on
line diff
--- a/src/hgignoredialog.cpp	Thu Jun 16 14:32:35 2011 +0100
+++ b/src/hgignoredialog.cpp	Thu Jun 16 14:53:06 2011 +0100
@@ -51,8 +51,12 @@
 	foreach (QString option, options) {
 	    QRadioButton *b = new QRadioButton(option);
 	    layout->addWidget(b, row++, 1);
-	    b->setChecked(first);
-	    first = false;
+	    if (first) {
+		m_option = option;
+		b->setChecked(true);
+		first = false;
+	    }
+	    connect(b, SIGNAL(toggled(bool)), this, SLOT(optionToggled(bool)));
 	}
     }
 
@@ -67,6 +71,16 @@
     connect(bbox, SIGNAL(rejected()), this, SLOT(reject()));
 }
 
+void
+HgIgnoreDialog::optionToggled(bool checked)
+{
+    QObject *s = sender();
+    QRadioButton *rb = qobject_cast<QRadioButton *>(s);
+    if (rb && checked) {
+	m_option = rb->text();
+    }
+}
+
 HgIgnoreDialog::IgnoreType
 HgIgnoreDialog::confirmIgnore(QWidget *parent,
 			      QStringList files, QStringList suffixes)
@@ -104,9 +118,11 @@
 			 options, tr("Ignore"));
 
 	if (d.exec() == QDialog::Accepted) {
-
-	    //...
-
+	    QString option = d.getOption();
+	    DEBUG << "HgIgnoreDialog::confirmIgnore: option = " << option << endl;
+	    if (option == options[0]) return IgnoreGivenFilesOnly;
+	    else if (option == options[1]) return IgnoreAllFilesOfGivenNames;
+	    else return IgnoreAllFilesOfGivenSuffixes;
 	}
     
     } else {
@@ -120,9 +136,10 @@
 			 options, tr("Ignore"));
 
 	if (d.exec() == QDialog::Accepted) {
-
-	    //...
-
+	    QString option = d.getOption();
+	    DEBUG << "HgIgnoreDialog::confirmIgnore: option = " << option << endl;
+	    if (option == options[0]) return IgnoreGivenFilesOnly;
+	    else return IgnoreAllFilesOfGivenNames;
 	}
     }