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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
/*
SPDX-FileCopyrightText: 2009 Andreas Pakulat <apaku@gmx.de>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef KDEVPLATFORM_LAUNCHCONFIGURATIONDIALOG_H
#define KDEVPLATFORM_LAUNCHCONFIGURATIONDIALOG_H
#include <QAbstractItemModel>
#include <QDialog>
#include <QList>
#include <QMap>
#include <QStyledItemDelegate>
#include "ui_launchconfigurationdialog.h"
class QItemSelection;
namespace Ui
{
class LaunchConfigTypePage;
}
namespace KDevelop
{
class ILauncher;
class LaunchConfigurationPageFactory;
class ILaunchMode;
class LaunchConfigurationType;
class LaunchConfiguration;
class LaunchConfigurationPage;
class ILaunchConfiguration;
class IProject;
class LaunchConfigurationModelDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
using QStyledItemDelegate::QStyledItemDelegate;
QWidget* createEditor ( QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index ) const override;
void setEditorData ( QWidget* editor, const QModelIndex& index ) const override;
void setModelData ( QWidget* editor, QAbstractItemModel* model, const QModelIndex& index ) const override;
};
class LaunchConfigurationsModel : public QAbstractItemModel
{
Q_OBJECT
public:
explicit LaunchConfigurationsModel(QObject* parent = nullptr);
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex& child) const override;
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
void createConfiguration( const QModelIndex& );
void deleteConfiguration( const QModelIndex& index );
LaunchConfiguration* configForIndex( const QModelIndex& ) const;
ILaunchMode* modeForIndex( const QModelIndex& idx ) const;
QModelIndex indexForConfig( LaunchConfiguration* ) const;
void addConfiguration(KDevelop::ILaunchConfiguration* launch, const QModelIndex& idx);
KDevelop::IProject* projectForIndex(const QModelIndex& idx);
private:
class TreeItem
{
public:
TreeItem() {}
virtual ~TreeItem() {}
TreeItem* parent = nullptr;
int row;
QList<TreeItem*> children;
};
class ProjectItem : public TreeItem
{
public:
IProject* project;
};
class LaunchItem : public TreeItem
{
public:
LaunchConfiguration* launch;
};
class LaunchModeItem : public TreeItem
{
public:
ILaunchMode* mode;
};
class GenericPageItem : public TreeItem
{
public:
QString text;
};
void addItemForLaunchConfig( LaunchConfiguration* l );
void addLaunchModeItemsForLaunchConfig ( KDevelop::LaunchConfigurationsModel::LaunchItem* l );
QList<TreeItem*> topItems;
public:
ProjectItem* findItemForProject(IProject* p) const;
};
class LaunchConfigPagesContainer : public QWidget
{
Q_OBJECT
public:
explicit LaunchConfigPagesContainer( const QList<LaunchConfigurationPageFactory*> &, QWidget* parent = nullptr );
void setLaunchConfiguration( LaunchConfiguration* );
void save();
Q_SIGNALS:
void changed();
private:
LaunchConfiguration* config;
QList<LaunchConfigurationPage*> pages;
};
class LaunchConfigurationDialog : public QDialog, public Ui::LaunchConfigurationDialog
{
Q_OBJECT
public:
explicit LaunchConfigurationDialog(QWidget* parent = nullptr );
QSize sizeHint() const override;
private Q_SLOTS:
void deleteConfiguration();
void createConfiguration();
void addConfiguration(KDevelop::ILaunchConfiguration*);
void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
void modelChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
void pageChanged();
void saveConfig();
void updateNameLabel( LaunchConfiguration* l );
void createEmptyLauncher();
void launchModeChanged(int index);
void doTreeContextMenu(const QPoint& point);
void renameSelected();
private:
void saveConfig( const QModelIndex& );
LaunchConfigurationsModel* model;
QMap<LaunchConfigurationType*, LaunchConfigPagesContainer*> typeWidgets;
QMap<ILauncher*, LaunchConfigPagesContainer*> launcherWidgets;
bool currentPageChanged = false;
};
}
#endif
|