projectwelcomepage.h 3.35 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 32

#ifndef PROJECTWELCOMEPAGE_H
#define PROJECTWELCOMEPAGE_H

33
#include <QAbstractListModel>
34

35
#include <utils/iwelcomepage.h>
36

37
QT_BEGIN_NAMESPACE
38
class QQmlEngine;
39
QT_END_NAMESPACE
40

41 42 43
namespace ProjectExplorer {
namespace Internal {

44 45 46 47
class SessionModel : public QAbstractListModel
{
    Q_OBJECT
public:
48
    enum { DefaultSessionRole = Qt::UserRole+1, LastSessionRole, ActiveSessionRole, ProjectsPathRole, ProjectsDisplayRole };
49

hjk's avatar
hjk committed
50
    explicit SessionModel(QObject *parent = 0);
51 52
    int rowCount(const QModelIndex &parent) const;
    QVariant data(const QModelIndex &index, int role) const;
53
    QHash<int, QByteArray> roleNames() const;
54

55 56
    Q_SCRIPTABLE bool isDefaultVirgin() const;

57 58
public slots:
    void resetSessions();
59 60 61
    void cloneSession(const QString &session);
    void deleteSession(const QString &session);
    void renameSession(const QString &session);
62 63 64 65 66 67 68 69 70
};


class ProjectModel : public QAbstractListModel
{
    Q_OBJECT
public:
    enum { FilePathRole = Qt::UserRole+1, PrettyFilePathRole };

71
    ProjectModel(QObject *parent = 0);
72 73
    int rowCount(const QModelIndex &parent) const;
    QVariant data(const QModelIndex &index, int role) const;
74
    QHash<int, QByteArray> roleNames() const;
75 76 77 78 79

public slots:
    void resetProjects();
};

80
class ProjectWelcomePage : public Utils::IWelcomePage
81 82 83 84 85
{
    Q_OBJECT
public:
    ProjectWelcomePage();

86
    void facilitateQml(QQmlEngine *engine);
87
    QUrl pageLocation() const;
88
    QWidget *page() { return 0; }
89
    QString title() const { return tr("Projects"); }
90
    int priority() const { return 20; }
91
    Id id() const;
92

93
    void reloadWelcomeScreenData();
94

95 96 97 98
public slots:
    void newProject();
    void openProject();

99 100 101 102
signals:
    void requestProject(const QString &project);
    void requestSession(const QString &session);
    void manageSessions();
103

104
private:
105 106
    SessionModel *m_sessionModel;
    ProjectModel *m_projectModel;
107 108 109 110 111 112
};

} // namespace Internal
} // namespace ProjectExplorer

#endif // PROJECTWELCOMEPAGE_H