Chris@414
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@414
|
2
|
Chris@414
|
3 /*
|
Chris@414
|
4 EasyMercurial
|
Chris@414
|
5
|
Chris@414
|
6 Based on hgExplorer by Jari Korhonen
|
Chris@414
|
7 Copyright (c) 2010 Jari Korhonen
|
Chris@414
|
8 Copyright (c) 2011 Chris Cannam
|
Chris@414
|
9 Copyright (c) 2011 Queen Mary, University of London
|
Chris@414
|
10
|
Chris@414
|
11 This program is free software; you can redistribute it and/or
|
Chris@414
|
12 modify it under the terms of the GNU General Public License as
|
Chris@414
|
13 published by the Free Software Foundation; either version 2 of the
|
Chris@414
|
14 License, or (at your option) any later version. See the file
|
Chris@414
|
15 COPYING included with this distribution for more information.
|
Chris@414
|
16 */
|
Chris@414
|
17
|
Chris@414
|
18 #include "hgignoredialog.h"
|
Chris@414
|
19 #include "common.h"
|
Chris@414
|
20 #include "debug.h"
|
Chris@414
|
21
|
Chris@415
|
22 #include <QGridLayout>
|
Chris@415
|
23 #include <QRadioButton>
|
Chris@415
|
24 #include <QLabel>
|
Chris@415
|
25 #include <QDialogButtonBox>
|
Chris@415
|
26 #include <QPushButton>
|
Chris@415
|
27
|
Chris@415
|
28 HgIgnoreDialog::HgIgnoreDialog(QWidget *parent,
|
Chris@415
|
29 QString title,
|
Chris@415
|
30 QString introText,
|
Chris@415
|
31 QString question,
|
Chris@415
|
32 QStringList options,
|
Chris@415
|
33 QString okButtonText) :
|
Chris@415
|
34 QDialog(parent)
|
Chris@415
|
35 {
|
Chris@415
|
36 setWindowTitle(title);
|
Chris@415
|
37
|
Chris@415
|
38 QGridLayout *layout = new QGridLayout;
|
Chris@415
|
39 setLayout(layout);
|
Chris@415
|
40
|
Chris@415
|
41 int row = 0;
|
Chris@415
|
42
|
Chris@415
|
43 QLabel *label = new QLabel(QString("%1%2").arg(introText).arg(question));
|
Chris@415
|
44 label->setWordWrap(true);
|
Chris@415
|
45 layout->addWidget(label, row++, 0, 1, 2);
|
Chris@415
|
46
|
Chris@415
|
47 if (!options.empty()) {
|
Chris@415
|
48 layout->addWidget(new QLabel(" "), row, 0);
|
Chris@415
|
49 layout->setColumnStretch(1, 10);
|
Chris@415
|
50 bool first = true;
|
Chris@415
|
51 foreach (QString option, options) {
|
Chris@415
|
52 QRadioButton *b = new QRadioButton(option);
|
Chris@415
|
53 layout->addWidget(b, row++, 1);
|
Chris@415
|
54 b->setChecked(first);
|
Chris@415
|
55 first = false;
|
Chris@415
|
56 }
|
Chris@415
|
57 }
|
Chris@415
|
58
|
Chris@415
|
59 QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok |
|
Chris@415
|
60 QDialogButtonBox::Cancel);
|
Chris@415
|
61 layout->addWidget(bbox, row++, 0, 1, 2);
|
Chris@415
|
62 bbox->button(QDialogButtonBox::Ok)->setDefault(true);
|
Chris@415
|
63 bbox->button(QDialogButtonBox::Ok)->setText(okButtonText);
|
Chris@415
|
64 bbox->button(QDialogButtonBox::Cancel)->setAutoDefault(false);
|
Chris@415
|
65
|
Chris@415
|
66 connect(bbox, SIGNAL(accepted()), this, SLOT(accept()));
|
Chris@415
|
67 connect(bbox, SIGNAL(rejected()), this, SLOT(reject()));
|
Chris@415
|
68 }
|
Chris@415
|
69
|
Chris@414
|
70 HgIgnoreDialog::IgnoreType
|
Chris@415
|
71 HgIgnoreDialog::confirmIgnore(QWidget *parent,
|
Chris@415
|
72 QStringList files, QStringList suffixes)
|
Chris@414
|
73 {
|
Chris@415
|
74 QString intro = "<qt><h3>";
|
Chris@415
|
75 intro += tr("Ignore files");
|
Chris@415
|
76 intro += "</h3><p>";
|
Chris@414
|
77
|
Chris@414
|
78 if (files.size() < 10) {
|
Chris@415
|
79 intro += tr("You have asked to ignore the following files:</p><p>");
|
Chris@415
|
80 intro += "<code> "
|
Chris@415
|
81 + files.join("<br> ") + "</code>";
|
Chris@414
|
82 } else {
|
Chris@415
|
83 intro += tr("You have asked to ignore %n file(s).", "", files.size());
|
Chris@414
|
84 }
|
Chris@414
|
85
|
Chris@415
|
86 intro += "</p></qt>";
|
Chris@415
|
87
|
Chris@414
|
88 if (suffixes.size() > 0) {
|
Chris@414
|
89
|
Chris@415
|
90 QStringList options;
|
Chris@415
|
91 options << tr("Ignore these files only");
|
Chris@415
|
92 options << tr("Ignore files with these names in any subdirectory");
|
Chris@414
|
93
|
Chris@415
|
94 if (suffixes.size() > 1) {
|
Chris@415
|
95 options << tr("Ignore all files with these extensions:\n%1")
|
Chris@415
|
96 .arg(suffixes.join(", "));
|
Chris@415
|
97 } else {
|
Chris@415
|
98 options << tr("Ignore all files with the extension \"%1\"")
|
Chris@415
|
99 .arg(suffixes[0]);
|
Chris@415
|
100 }
|
Chris@414
|
101
|
Chris@415
|
102 HgIgnoreDialog d(parent, tr("Ignore files"),
|
Chris@415
|
103 intro, tr("<p>Please choose whether to:</p>"),
|
Chris@415
|
104 options, tr("Ignore"));
|
Chris@415
|
105
|
Chris@415
|
106 if (d.exec() == QDialog::Accepted) {
|
Chris@415
|
107
|
Chris@415
|
108 //...
|
Chris@415
|
109
|
Chris@415
|
110 }
|
Chris@414
|
111
|
Chris@415
|
112 } else {
|
Chris@415
|
113
|
Chris@415
|
114 QStringList options;
|
Chris@415
|
115 options << tr("Ignore these files only");
|
Chris@415
|
116 options << tr("Ignore files with these names in any subdirectory");
|
Chris@415
|
117
|
Chris@415
|
118 HgIgnoreDialog d(parent, tr("Ignore files"),
|
Chris@415
|
119 intro, tr("<p>Please choose whether to:</p>"),
|
Chris@415
|
120 options, tr("Ignore"));
|
Chris@415
|
121
|
Chris@415
|
122 if (d.exec() == QDialog::Accepted) {
|
Chris@415
|
123
|
Chris@415
|
124 //...
|
Chris@415
|
125
|
Chris@415
|
126 }
|
Chris@415
|
127 }
|
Chris@414
|
128
|
Chris@414
|
129
|
Chris@414
|
130 return IgnoreNothing;
|
Chris@414
|
131 }
|
Chris@414
|
132
|