comparison 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
comparison
equal deleted inserted replaced
415:6d7dad48b13c 416:8df07172d6da
49 layout->setColumnStretch(1, 10); 49 layout->setColumnStretch(1, 10);
50 bool first = true; 50 bool first = true;
51 foreach (QString option, options) { 51 foreach (QString option, options) {
52 QRadioButton *b = new QRadioButton(option); 52 QRadioButton *b = new QRadioButton(option);
53 layout->addWidget(b, row++, 1); 53 layout->addWidget(b, row++, 1);
54 b->setChecked(first); 54 if (first) {
55 first = false; 55 m_option = option;
56 b->setChecked(true);
57 first = false;
58 }
59 connect(b, SIGNAL(toggled(bool)), this, SLOT(optionToggled(bool)));
56 } 60 }
57 } 61 }
58 62
59 QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok | 63 QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok |
60 QDialogButtonBox::Cancel); 64 QDialogButtonBox::Cancel);
63 bbox->button(QDialogButtonBox::Ok)->setText(okButtonText); 67 bbox->button(QDialogButtonBox::Ok)->setText(okButtonText);
64 bbox->button(QDialogButtonBox::Cancel)->setAutoDefault(false); 68 bbox->button(QDialogButtonBox::Cancel)->setAutoDefault(false);
65 69
66 connect(bbox, SIGNAL(accepted()), this, SLOT(accept())); 70 connect(bbox, SIGNAL(accepted()), this, SLOT(accept()));
67 connect(bbox, SIGNAL(rejected()), this, SLOT(reject())); 71 connect(bbox, SIGNAL(rejected()), this, SLOT(reject()));
72 }
73
74 void
75 HgIgnoreDialog::optionToggled(bool checked)
76 {
77 QObject *s = sender();
78 QRadioButton *rb = qobject_cast<QRadioButton *>(s);
79 if (rb && checked) {
80 m_option = rb->text();
81 }
68 } 82 }
69 83
70 HgIgnoreDialog::IgnoreType 84 HgIgnoreDialog::IgnoreType
71 HgIgnoreDialog::confirmIgnore(QWidget *parent, 85 HgIgnoreDialog::confirmIgnore(QWidget *parent,
72 QStringList files, QStringList suffixes) 86 QStringList files, QStringList suffixes)
102 HgIgnoreDialog d(parent, tr("Ignore files"), 116 HgIgnoreDialog d(parent, tr("Ignore files"),
103 intro, tr("<p>Please choose whether to:</p>"), 117 intro, tr("<p>Please choose whether to:</p>"),
104 options, tr("Ignore")); 118 options, tr("Ignore"));
105 119
106 if (d.exec() == QDialog::Accepted) { 120 if (d.exec() == QDialog::Accepted) {
107 121 QString option = d.getOption();
108 //... 122 DEBUG << "HgIgnoreDialog::confirmIgnore: option = " << option << endl;
109 123 if (option == options[0]) return IgnoreGivenFilesOnly;
124 else if (option == options[1]) return IgnoreAllFilesOfGivenNames;
125 else return IgnoreAllFilesOfGivenSuffixes;
110 } 126 }
111 127
112 } else { 128 } else {
113 129
114 QStringList options; 130 QStringList options;
118 HgIgnoreDialog d(parent, tr("Ignore files"), 134 HgIgnoreDialog d(parent, tr("Ignore files"),
119 intro, tr("<p>Please choose whether to:</p>"), 135 intro, tr("<p>Please choose whether to:</p>"),
120 options, tr("Ignore")); 136 options, tr("Ignore"));
121 137
122 if (d.exec() == QDialog::Accepted) { 138 if (d.exec() == QDialog::Accepted) {
123 139 QString option = d.getOption();
124 //... 140 DEBUG << "HgIgnoreDialog::confirmIgnore: option = " << option << endl;
125 141 if (option == options[0]) return IgnoreGivenFilesOnly;
142 else return IgnoreAllFilesOfGivenNames;
126 } 143 }
127 } 144 }
128 145
129 146
130 return IgnoreNothing; 147 return IgnoreNothing;