linuxdeviceconfigurations.h 4.11 KB
Newer Older
1
2
3
4
/**************************************************************************
**
** This file is part of Qt Creator
**
hjk's avatar
hjk committed
5
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
6
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
**
**
** GNU Lesser General Public License Usage
**
** 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, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** 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.
**
** If you have questions regarding the use of this file, please contact
29
** Nokia at qt-info@nokia.com.
30
31
**
**************************************************************************/
32
33
#ifndef LINUXDEVICECONFIGURATIONS_H
#define LINUXDEVICECONFIGURATIONS_H
34
35

#include "linuxdeviceconfiguration.h"
36
#include "remotelinux_export.h"
37

38
#include <QAbstractListModel>
39

40
QT_FORWARD_DECLARE_CLASS(QString)
41
42
43

namespace RemoteLinux {
namespace Internal {
44
class LinuxDeviceConfigurationsPrivate;
45
class LinuxDeviceConfigurationsSettingsWidget;
46
} // namespace Internal
47

48
class REMOTELINUX_EXPORT LinuxDeviceConfigurations : public QAbstractListModel
49
50
{
    Q_OBJECT
51
    friend class Internal::LinuxDeviceConfigurationsSettingsWidget;
52
public:
53
54
    ~LinuxDeviceConfigurations();

55
56
    static LinuxDeviceConfigurations *instance(QObject *parent = 0);

57
58
59
60
61
62
    // If you want to edit the list of device configurations programatically
    // (e.g. when doing device auto-detection), call cloneInstance() to get a copy,
    // do the changes there and then call replaceInstance() to write them back.
    // Callers must be prepared to deal with cloneInstance() temporarily returning null,
    // which happens if the settings dialog is currently open.
    // All other callers are required to do the clone/replace operation synchronously!
63
64
65
66
67
    static void replaceInstance(const LinuxDeviceConfigurations *other);
    static LinuxDeviceConfigurations *cloneInstance();

    LinuxDeviceConfiguration::ConstPtr deviceAt(int index) const;
    LinuxDeviceConfiguration::ConstPtr find(LinuxDeviceConfiguration::Id id) const;
68
    LinuxDeviceConfiguration::ConstPtr defaultDeviceConfig(const QString &osType) const;
69
70
71
72
    bool hasConfig(const QString &name) const;
    int indexForInternalId(LinuxDeviceConfiguration::Id internalId) const;
    LinuxDeviceConfiguration::Id internalId(LinuxDeviceConfiguration::ConstPtr devConf) const;

73
74
    void setDefaultSshKeyFilePath(const QString &path);
    QString defaultSshKeyFilePath() const;
75

76
    void addConfiguration(const LinuxDeviceConfiguration::Ptr &devConfig);
77
78
79
    void removeConfiguration(int index);
    void setConfigurationName(int i, const QString &name);
    void setSshParameters(int i, const Utils::SshConnectionParameters &params);
80
    void setFreePorts(int i, const PortList &freePorts);
81
    void setDefaultDevice(int index);
82
    void setAttribute(int index, const QString &name, const QVariant &value);
83
84
85
86
87
88
89

    virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
    virtual QVariant data(const QModelIndex &index,
        int role = Qt::DisplayRole) const;

signals:
    void updated();
90
    void cloningPossible();
91
92
93

private:
    LinuxDeviceConfigurations(QObject *parent);
94

95
96
97
    static void blockCloning();
    static void unblockCloning();

98
99
100
101
    void load();
    void save();
    static void copy(const LinuxDeviceConfigurations *source,
        LinuxDeviceConfigurations *target, bool deep);
102
    void ensureOneDefaultConfigurationPerOsType();
103

104
    Internal::LinuxDeviceConfigurationsPrivate * const d;
105
106
107
108
};

} // namespace RemoteLinux

109
#endif // LINUXDEVICECONFIGURATIONS_H