aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/advanceddockingsystem/workspaceview.h
blob: 36c86809dc8599f6d68f5d966aedf6a4641c82aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-2.1-or-later OR GPL-3.0-or-later

#pragma once

#include "workspaceinputdialog.h"
#include "workspacemodel.h"

#include <utils/itemviews.h>
#include <utils/result.h>

namespace ADS {

class DockManager;
class WorkspaceDialog;

class WorkspaceView : public Utils::TreeView
{
    Q_OBJECT

public:
    explicit WorkspaceView(DockManager *manager, QWidget *parent = nullptr);

    void createNewWorkspace();
    void cloneCurrentWorkspace();
    void renameCurrentWorkspace();
    void resetCurrentWorkspace();
    void switchToCurrentWorkspace();
    void deleteSelectedWorkspaces();

    void importWorkspace();
    void exportCurrentWorkspace();

    void moveWorkspaceUp();
    void moveWorkspaceDown();

    QString currentWorkspace();
    WorkspaceModel *workspaceModel();
    void selectActiveWorkspace();
    void selectWorkspace(const QString &fileName);

    QStringList selectedWorkspaces() const;

signals:
    void workspaceActivated(const QString &fileName);
    void workspacesSelected(const QStringList &fileNames);
    void workspaceSwitched();

private:
    void showEvent(QShowEvent *event) override;
    void keyPressEvent(QKeyEvent *event) override;
    void dropEvent(QDropEvent *event) override;

    void deleteWorkspaces(const QStringList &fileNames);

    bool confirmWorkspaceDelete(const QStringList &fileNames);

    void runWorkspaceNameInputDialog(
        WorkspaceNameInputDialog *workspaceInputDialog,
        std::function<Utils::Result<QString>(const QString &)> callback);

    DockManager *m_manager;
    WorkspaceModel m_workspaceModel;
};

} // namespace ADS