cppfilesettingspage.h 3.4 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
2
**
3
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
7
**
hjk's avatar
hjk committed
8 9 10 11 12 13 14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15 16
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17 18 19 20 21 22 23 24 25
** Alternatively, 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26 27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
29

30 31
#ifndef CPPFILESETTINGSPAGE_H
#define CPPFILESETTINGSPAGE_H
32 33

#include <coreplugin/dialogs/ioptionspage.h>
hjk's avatar
hjk committed
34

35 36 37
#include <QPointer>
#include <QSharedPointer>
#include <QWidget>
38 39 40 41 42 43 44 45

QT_BEGIN_NAMESPACE
class QSettings;
QT_END_NAMESPACE

namespace CppTools {
namespace Internal {

hjk's avatar
hjk committed
46 47
namespace Ui { class CppFileSettingsPage; }

48 49
struct CppFileSettings
{
50 51
    CppFileSettings();

52
    QStringList headerPrefixes;
53
    QString headerSuffix;
54
    QStringList headerSearchPaths;
55
    QStringList sourcePrefixes;
56
    QString sourceSuffix;
57
    QStringList sourceSearchPaths;
58
    bool lowerCaseFiles;
59
    QString licenseTemplatePath;
60 61 62

    void toSettings(QSettings *) const;
    void fromSettings(QSettings *);
63
    bool applySuffixesToMimeDB();
64 65 66

    // Convenience to return a license template completely formatted.
    // Currently made public in
67
    static QString licenseTemplate(const QString &file = QString(), const QString &className = QString());
68

69
    bool equals(const CppFileSettings &rhs) const;
hjk's avatar
hjk committed
70 71
    bool operator==(const CppFileSettings &s) const { return equals(s); }
    bool operator!=(const CppFileSettings &s) const { return !equals(s); }
72 73
};

74 75
class CppFileSettingsWidget : public QWidget
{
76
    Q_OBJECT
77

78 79 80 81 82 83 84
public:
    explicit CppFileSettingsWidget(QWidget *parent = 0);
    virtual ~CppFileSettingsWidget();

    CppFileSettings settings() const;
    void setSettings(const CppFileSettings &s);

85
private slots:
86 87
    void slotEdit();

88
private:
89 90 91
    inline QString licenseTemplatePath() const;
    inline void setLicenseTemplatePath(const QString &);

hjk's avatar
hjk committed
92
    Ui::CppFileSettingsPage *m_ui;
93 94 95 96 97
};

class CppFileSettingsPage : public Core::IOptionsPage
{
public:
98 99
    explicit CppFileSettingsPage(QSharedPointer<CppFileSettings> &settings,
                                 QObject *parent = 0);
100

101
    QWidget *widget();
102
    void apply();
103
    void finish();
104 105

private:
106
    const QSharedPointer<CppFileSettings> m_settings;
107 108 109 110 111 112
    QPointer<CppFileSettingsWidget> m_widget;
};

} // namespace Internal
} // namespace CppTools

113
#endif // CPPFILESETTINGSPAGE_H