Commit 882e78a7 authored by Tobias Nätterlund's avatar Tobias Nätterlund Committed by Nicolas Arnaud-Cormos

QNX: Fixed BAR editor not being marked as dirty when modifying assets

setDirty() wasn't called when inserting/removing rows from the assets model

Change-Id: I553d9db13caaff1a80d021dea9c202bd1b607fbf
Reviewed-by: default avatarMehdi Fekari <mfekari@rim.com>
Reviewed-by: Nicolas Arnaud-Cormos's avatarNicolas Arnaud-Cormos <nicolas@kdab.com>
parent 86d3e075
......@@ -214,14 +214,15 @@ void BarDescriptorEditorWidget::initAssetsPage()
connect(m_ui->addAsset, SIGNAL(clicked()), this, SLOT(addNewAsset()));
connect(m_ui->removeAsset, SIGNAL(clicked()), this, SLOT(removeSelectedAsset()));
connect(m_assetsModel, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(updateEntryCheckState(QStandardItem*)));
connect(m_assetsModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(setDirty()));
connectAssetsModel();
}
void BarDescriptorEditorWidget::clearAssetsPage()
{
disconnect(m_assetsModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(setDirty()));
// We can't just block signals, as the view depends on them
disconnectAssetsModel();
m_assetsModel->removeRows(0, m_assetsModel->rowCount());
connect(m_assetsModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(setDirty()));
connectAssetsModel();
}
void BarDescriptorEditorWidget::initSourcePage()
......@@ -237,6 +238,20 @@ void BarDescriptorEditorWidget::clearSourcePage()
connect(m_ui->xmlSourceView, SIGNAL(textChanged()), this, SLOT(setDirty()));
}
void BarDescriptorEditorWidget::disconnectAssetsModel()
{
disconnect(m_assetsModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(setDirty()));
disconnect(m_assetsModel, SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(setDirty()));
disconnect(m_assetsModel, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(setDirty()));
}
void BarDescriptorEditorWidget::connectAssetsModel()
{
connect(m_assetsModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(setDirty()));
connect(m_assetsModel, SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(setDirty()));
connect(m_assetsModel, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(setDirty()));
}
Core::IEditor *BarDescriptorEditorWidget::editor() const
{
if (!m_editor) {
......@@ -521,6 +536,13 @@ void BarDescriptorEditorWidget::handleSplashScreenSelectionChanged(const QItemSe
}
void BarDescriptorEditorWidget::addAsset(const BarDescriptorAsset &asset)
{
disconnectAssetsModel();
addAssetInternal(asset);
connectAssetsModel();
}
void BarDescriptorEditorWidget::addAssetInternal(const BarDescriptorAsset &asset)
{
const QString path = asset.source;
const QString dest = asset.destination;
......@@ -530,8 +552,6 @@ void BarDescriptorEditorWidget::addAsset(const BarDescriptorAsset &asset)
if (hasAsset(asset))
return;
disconnect(m_assetsModel, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(updateEntryCheckState(QStandardItem*)));
QList<QStandardItem *> items;
items << new QStandardItem(path);
items << new QStandardItem(dest);
......@@ -542,7 +562,6 @@ void BarDescriptorEditorWidget::addAsset(const BarDescriptorAsset &asset)
items << entryItem;
m_assetsModel->appendRow(items);
connect(m_assetsModel, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(updateEntryCheckState(QStandardItem*)));
}
bool BarDescriptorEditorWidget::hasAsset(const BarDescriptorAsset &asset)
......@@ -631,7 +650,7 @@ void BarDescriptorEditorWidget::addNewAsset()
asset.source = fileName;
asset.destination = fi.fileName();
asset.entry = false; // TODO
addAsset(asset);
addAssetInternal(asset);
}
void BarDescriptorEditorWidget::removeSelectedAsset()
......@@ -670,5 +689,5 @@ void BarDescriptorEditorWidget::addImageAsAsset(const QString &path)
asset.source = path;
asset.destination = QFileInfo(path).fileName();
asset.entry = false;
addAsset(asset);
addAssetInternal(asset);
}
......@@ -162,6 +162,10 @@ private:
void initSourcePage();
void clearSourcePage();
void disconnectAssetsModel();
void connectAssetsModel();
void addAssetInternal(const BarDescriptorAsset &asset);
bool hasAsset(const BarDescriptorAsset &asset);
QString localAssetPathFromDestination(const QString &path);
......
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