Chris@67
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@67
|
2
|
Chris@67
|
3 /*
|
Chris@67
|
4 EasyMercurial
|
Chris@67
|
5
|
Chris@67
|
6 Based on HgExplorer by Jari Korhonen
|
Chris@67
|
7 Copyright (c) 2010 Jari Korhonen
|
Chris@644
|
8 Copyright (c) 2013 Chris Cannam
|
Chris@644
|
9 Copyright (c) 2013 Queen Mary, University of London
|
Chris@67
|
10
|
Chris@67
|
11 This program is free software; you can redistribute it and/or
|
Chris@67
|
12 modify it under the terms of the GNU General Public License as
|
Chris@67
|
13 published by the Free Software Foundation; either version 2 of the
|
Chris@67
|
14 License, or (at your option) any later version. See the file
|
Chris@67
|
15 COPYING included with this distribution for more information.
|
Chris@67
|
16 */
|
Chris@67
|
17
|
Chris@67
|
18 #ifndef MULTICHOICEDIALOG_H
|
Chris@67
|
19 #define MULTICHOICEDIALOG_H
|
Chris@67
|
20
|
Chris@69
|
21 #include "recentfiles.h"
|
Chris@69
|
22
|
Chris@67
|
23 #include <QDialog>
|
Chris@67
|
24 #include <QString>
|
Chris@69
|
25 #include <QAbstractButton>
|
Chris@68
|
26 #include <QMap>
|
Chris@68
|
27 #include <QLabel>
|
Chris@68
|
28 #include <QLineEdit>
|
Chris@68
|
29 #include <QGridLayout>
|
Chris@69
|
30 #include <QHBoxLayout>
|
Chris@68
|
31 #include <QStackedWidget>
|
Chris@69
|
32 #include <QSharedPointer>
|
Chris@69
|
33 #include <QComboBox>
|
Chris@67
|
34
|
Chris@67
|
35 class MultiChoiceDialog : public QDialog
|
Chris@67
|
36 {
|
Chris@67
|
37 Q_OBJECT
|
Chris@67
|
38 public:
|
Chris@341
|
39 explicit MultiChoiceDialog(QString title,
|
Chris@341
|
40 QString heading,
|
Chris@341
|
41 QString helpUrl = "",
|
Chris@69
|
42 QWidget *parent = 0);
|
Chris@67
|
43
|
Chris@67
|
44 enum ArgType {
|
Chris@67
|
45 NoArg,
|
Chris@67
|
46 FileArg,
|
Chris@69
|
47 DirectoryArg,
|
Chris@67
|
48 UrlArg,
|
Chris@72
|
49 UrlToDirectoryArg
|
Chris@67
|
50 };
|
Chris@67
|
51
|
Chris@67
|
52 void addChoice(QString identifier, QString text,
|
Chris@553
|
53 QString description, ArgType arg,
|
Chris@553
|
54 bool defaultEmpty = false);
|
Chris@67
|
55
|
Chris@69
|
56 void setCurrentChoice(QString);
|
Chris@69
|
57 QString getCurrentChoice();
|
Chris@67
|
58 QString getArgument();
|
Chris@72
|
59 QString getAdditionalArgument();
|
Chris@67
|
60
|
Chris@72
|
61 static void addRecentArgument(QString identifier, QString name,
|
Chris@72
|
62 bool additionalArgument = false);
|
Chris@67
|
63
|
Chris@68
|
64 private slots:
|
Chris@69
|
65 void choiceChanged();
|
Chris@72
|
66 void urlChanged(const QString &);
|
Chris@74
|
67 void fileChanged(const QString &);
|
Chris@341
|
68 void helpRequested();
|
Chris@69
|
69 void browse();
|
Chris@68
|
70
|
Chris@68
|
71 private:
|
Chris@483
|
72 void updateFileComboFromURL();
|
Chris@199
|
73 void updateOkButton();
|
Chris@199
|
74
|
Chris@341
|
75 QString m_helpUrl;
|
Chris@341
|
76
|
Chris@68
|
77 QMap<QString, QString> m_texts;
|
Chris@68
|
78 QMap<QString, QString> m_descriptions;
|
Chris@69
|
79 QMap<QString, ArgType> m_argTypes;
|
Chris@553
|
80 QMap<QString, bool> m_defaultEmpty;
|
Chris@69
|
81 QMap<QString, QSharedPointer<RecentFiles> > m_recentFiles;
|
Chris@68
|
82
|
Chris@68
|
83 QString m_currentChoice;
|
Chris@69
|
84 QMap<QWidget *, QString> m_choiceButtons;
|
Chris@68
|
85
|
Chris@69
|
86 QHBoxLayout *m_choiceLayout;
|
Chris@68
|
87 QLabel *m_descriptionLabel;
|
Chris@72
|
88 QLabel *m_fileLabel;
|
Chris@72
|
89 QComboBox *m_fileCombo;
|
Chris@69
|
90 QAbstractButton *m_browseButton;
|
Chris@72
|
91 QLabel *m_urlLabel;
|
Chris@72
|
92 QComboBox *m_urlCombo;
|
Chris@74
|
93 QAbstractButton *m_okButton;
|
Chris@342
|
94
|
Chris@342
|
95 QString getDefaultPath() const;
|
Chris@604
|
96 bool urlComboNotUrl() const;
|
Chris@67
|
97 };
|
Chris@67
|
98
|
Chris@67
|
99 #endif // MULTICHOICEDIALOG_H
|