Commit 14455083 authored by Marco Bubke's avatar Marco Bubke

QmlDesigner: Add remove functionality to the ImportManager

Change-Id: I7227f84ae808ac449bc92f5a068696295b6814ab
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 662df29e
......@@ -47,6 +47,7 @@ ImportLabel::ImportLabel(QWidget *parent) :
m_removeButton->setMaximumHeight(20);
m_removeButton->setFocusPolicy(Qt::NoFocus);
m_removeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
connect(m_removeButton, SIGNAL(clicked()), this, SLOT(emitRemoveImport()));
layout->addWidget(m_removeButton);
m_importLabel = new QLabel(this);
......@@ -58,8 +59,16 @@ ImportLabel::ImportLabel(QWidget *parent) :
void ImportLabel::setImport(const Import &import)
{
m_importLabel->setText(import.toString(false));
if (import.url() == "QtQuick")
m_removeButton->setDisabled(true);
m_import = import;
}
void ImportLabel::emitRemoveImport()
{
emit removeImport(m_import);
}
} // namespace QmlDesigner
......@@ -45,7 +45,14 @@ public:
void setImport(const Import &import);
signals:
void removeImport(const Import &import);
private slots:
void emitRemoveImport();
private:
Import m_import;
QLabel *m_importLabel;
QPushButton *m_removeButton;
};
......
......@@ -54,6 +54,7 @@ WidgetInfo ImportManagerView::widgetInfo()
{
if (m_importsWidget == 0) {
m_importsWidget = new ImportsWidget;
connect(m_importsWidget, SIGNAL(removeImport(Import)), this, SLOT(removeImport(Import)));
if (model())
m_importsWidget->setImports(model()->imports());
}
......@@ -228,4 +229,10 @@ void ImportManagerView::scriptFunctionsChanged(const ModelNode &/*node*/, const
}
void ImportManagerView::removeImport(const Import &import)
{
if (model())
model()->changeImports(QList<Import>(), QList<Import>() << import);
}
} // namespace QmlDesigner
......@@ -93,6 +93,9 @@ public:
void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
private slots:
void removeImport(const Import &import);
private:
ImportsWidget *m_importsWidget;
};
......
......@@ -84,6 +84,7 @@ void ImportsWidget::setImports(const QList<Import> &imports)
ImportLabel *importLabel = new ImportLabel(this);
importLabel->setImport(import);
m_importLabels.append(importLabel);
connect(importLabel, SIGNAL(removeImport(Import)), this, SIGNAL(removeImport(Import)));
}
updateLayout();
......
......@@ -47,6 +47,9 @@ public:
void setImports(const QList<Import> &imports);
void removeAllImports();
signals:
void removeImport(const Import &import);
protected:
void updateLayout();
......
......@@ -40,6 +40,8 @@ namespace QmlDesigner {
class QMLDESIGNERCORE_EXPORT Import
{
public:
Import();
static Import createLibraryImport(const QString &url, const QString &version = QString(), const QString &alias = QString(), const QStringList &importPaths = QStringList());
static Import createFileImport(const QString &file, const QString &version = QString(), const QString &alias = QString(), const QStringList &importPaths = QStringList());
static Import empty();
......
......@@ -33,6 +33,10 @@
namespace QmlDesigner {
Import::Import()
{
}
Import Import::createLibraryImport(const QString &url, const QString &version, const QString &alias, const QStringList &importPaths)
{
return Import(url, QString(), version, alias, importPaths);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment