vcsbaseeditorparameterwidget.h 3.48 KB
Newer Older
1 2 3 4 5 6
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
8 9 10 11
**
**
** GNU Lesser General Public License Usage
**
Tobias Hunger's avatar
Tobias Hunger committed
12 13 14 15 16 17
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 19
**
** In addition, as a special exception, Nokia gives you certain additional
Tobias Hunger's avatar
Tobias Hunger committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
21 22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
Tobias Hunger's avatar
Tobias Hunger committed
23 24 25 26 27
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
28
** If you have questions regarding the use of this file, please contact
29
** Nokia at qt-info@nokia.com.
30 31 32 33 34 35 36 37 38
**
**************************************************************************/

#ifndef VCSBASE_VCSBASEEDITORPARAMETERWIDGET_H
#define VCSBASE_VCSBASEEDITORPARAMETERWIDGET_H

#include "vcsbase_global.h"

#include <QtCore/QStringList>
39
#include <QtCore/QVariant>
hjk's avatar
hjk committed
40
#include <QtGui/QWidget>
41

42
QT_BEGIN_NAMESPACE
43
class QComboBox;
44 45 46
class QToolButton;
QT_END_NAMESPACE

47
namespace VCSBase {
48

hjk's avatar
hjk committed
49
namespace Internal { class VCSBaseEditorParameterWidgetPrivate; }
50 51 52 53 54

// Documentation->inside.
class VCSBASE_EXPORT VCSBaseEditorParameterWidget : public QWidget
{
    Q_OBJECT
hjk's avatar
hjk committed
55

56
public:
hjk's avatar
hjk committed
57 58 59
    explicit VCSBaseEditorParameterWidget(QWidget *parent = 0);
    ~VCSBaseEditorParameterWidget();

Tobias Hunger's avatar
Tobias Hunger committed
60
    struct VCSBASE_EXPORT ComboBoxItem
61
    {
hjk's avatar
hjk committed
62
        ComboBoxItem() {}
63 64 65 66 67
        ComboBoxItem(const QString &text, const QVariant &val);
        QString displayText;
        QVariant value;
    };

68 69 70
    QStringList baseArguments() const;
    void setBaseArguments(const QStringList &);

71 72
    QToolButton *addToggleButton(const QString &option, const QString &label,
                                 const QString &tooltip = QString());
73 74
    QComboBox *addComboBox(const QString &option, const QList<ComboBoxItem> &items);

75 76
    void mapSetting(QToolButton *button, bool *setting);
    void mapSetting(QComboBox *comboBox, QString *setting);
77
    void mapSetting(QComboBox *comboBox, int *setting);
78

79 80
    QStringList comboBoxOptionTemplate() const;
    void setComboBoxOptionTemplate(const QStringList &optTemplate) const;
81 82

    // Return the effective arguments according to setting.
83
    virtual QStringList arguments() const;
84

85 86 87 88
public slots:
    virtual void executeCommand();
    virtual void handleArgumentsChanged();

89 90 91 92
signals:
    // Trigger a re-run to show changed output according to new argument list.
    void argumentsChanged();

93 94 95 96 97 98 99 100 101 102 103
protected:
    struct OptionMapping
    {
        OptionMapping();
        OptionMapping(const QString &optName, QWidget *w);
        QString optionName;
        QWidget *widget;
    };

    const QList<OptionMapping> &optionMappings() const;
    virtual QStringList argumentsForOption(const OptionMapping &mapping) const;
104
    void updateMappedSettings();
105

106
private:
107 108
    friend class Internal::VCSBaseEditorParameterWidgetPrivate;
    Internal::VCSBaseEditorParameterWidgetPrivate *const d;
109 110 111 112 113
};

} // namespace VCSBase

#endif // VCSBASE_VCSBASEEDITORPARAMETERWIDGET_H