~ubuntu-sdk-team/qtcreator-plugin-remotelinux/trunk

« back to all changes in this revision

Viewing changes to src/qnx/bardescriptoreditorassetswidget.cpp

  • Committer: CI bot
  • Author(s): Benjamin Zeller
  • Date: 2014-06-16 10:28:43 UTC
  • mfrom: (4.2.4 remotelinux)
  • Revision ID: ps-jenkins@lists.canonical.com-20140616102843-8juvmjvzwlzsboyw
Migrating to Qt5.3 and QtC 3.1 

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
    connect(m_ui->addAsset, SIGNAL(clicked()), this, SLOT(addNewAsset()));
58
58
    connect(m_ui->removeAsset, SIGNAL(clicked()), this, SLOT(removeSelectedAsset()));
59
59
    connect(m_assetsModel, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(updateEntryCheckState(QStandardItem*)));
60
 
    connectAssetsModel();
 
60
 
 
61
    addSignalMapping(BarDescriptorDocument::asset, m_assetsModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)));
 
62
    addSignalMapping(BarDescriptorDocument::asset, m_assetsModel, SIGNAL(rowsInserted(QModelIndex,int,int)));
 
63
    addSignalMapping(BarDescriptorDocument::asset, m_assetsModel, SIGNAL(rowsRemoved(QModelIndex,int,int)));
61
64
}
62
65
 
63
66
BarDescriptorEditorAssetsWidget::~BarDescriptorEditorAssetsWidget()
67
70
 
68
71
void BarDescriptorEditorAssetsWidget::clear()
69
72
{
70
 
    // We can't just block signals, as the view depends on them
71
 
    disconnectAssetsModel();
 
73
    blockSignalMapping(BarDescriptorDocument::asset);
72
74
    m_assetsModel->removeRows(0, m_assetsModel->rowCount());
73
 
    connectAssetsModel();
74
 
}
75
 
 
76
 
void BarDescriptorEditorAssetsWidget::addAsset(const BarDescriptorAsset &asset)
77
 
{
78
 
    disconnectAssetsModel();
79
 
    addAssetInternal(asset);
80
 
    connectAssetsModel();
81
 
}
82
 
 
83
 
QList<BarDescriptorAsset> BarDescriptorEditorAssetsWidget::assets() const
84
 
{
85
 
    QList<BarDescriptorAsset> result;
86
 
 
87
 
    for (int i = 0; i < m_assetsModel->rowCount(); ++i) {
88
 
        BarDescriptorAsset asset;
89
 
        asset.source = m_assetsModel->item(i, 0)->text();
90
 
        asset.destination = m_assetsModel->item(i, 1)->text();
91
 
        asset.entry = m_assetsModel->item(i, 2)->checkState() == Qt::Checked;
92
 
        result << asset;
93
 
    }
94
 
 
95
 
    return result;
 
75
    unblockSignalMapping(BarDescriptorDocument::asset);
96
76
}
97
77
 
98
78
QStandardItemModel *BarDescriptorEditorAssetsWidget::assetsModel() const
100
80
    return m_assetsModel;
101
81
}
102
82
 
 
83
void BarDescriptorEditorAssetsWidget::updateWidgetValue(BarDescriptorDocument::Tag tag, const QVariant &value)
 
84
{
 
85
    if (tag != BarDescriptorDocument::asset) {
 
86
        BarDescriptorEditorAbstractPanelWidget::updateWidgetValue(tag, value);
 
87
        return;
 
88
    }
 
89
 
 
90
    clear();
 
91
    BarDescriptorAssetList assets = value.value<BarDescriptorAssetList>();
 
92
    foreach (const BarDescriptorAsset asset, assets)
 
93
        addAsset(asset);
 
94
}
 
95
 
103
96
void BarDescriptorEditorAssetsWidget::addAsset(const QString &fullPath)
104
97
{
105
98
    if (fullPath.isEmpty())
109
102
    asset.source = fullPath;
110
103
    asset.destination = QFileInfo(fullPath).fileName();
111
104
    asset.entry = false;
112
 
    addAssetInternal(asset);
 
105
    addAsset(asset);
113
106
}
114
107
 
115
108
void BarDescriptorEditorAssetsWidget::removeAsset(const QString &fullPath)
157
150
    connect(m_assetsModel, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(updateEntryCheckState(QStandardItem*)));
158
151
}
159
152
 
160
 
void BarDescriptorEditorAssetsWidget::connectAssetsModel()
161
 
{
162
 
    connect(m_assetsModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SIGNAL(changed()));
163
 
    connect(m_assetsModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SIGNAL(changed()));
164
 
    connect(m_assetsModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SIGNAL(changed()));
165
 
}
166
 
 
167
 
void BarDescriptorEditorAssetsWidget::disconnectAssetsModel()
168
 
{
169
 
    disconnect(m_assetsModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SIGNAL(changed()));
170
 
    disconnect(m_assetsModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SIGNAL(changed()));
171
 
    disconnect(m_assetsModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SIGNAL(changed()));
172
 
}
173
 
 
174
 
void BarDescriptorEditorAssetsWidget::addAssetInternal(const BarDescriptorAsset &asset)
 
153
void BarDescriptorEditorAssetsWidget::emitChanged(BarDescriptorDocument::Tag tag)
 
154
{
 
155
    if (tag != BarDescriptorDocument::asset) {
 
156
        BarDescriptorEditorAbstractPanelWidget::emitChanged(tag);
 
157
        return;
 
158
    }
 
159
 
 
160
    BarDescriptorAssetList result;
 
161
    for (int i = 0; i < m_assetsModel->rowCount(); ++i) {
 
162
        BarDescriptorAsset asset;
 
163
        asset.source = m_assetsModel->item(i, 0)->text();
 
164
        asset.destination = m_assetsModel->item(i, 1)->text();
 
165
        asset.entry = m_assetsModel->item(i, 2)->checkState() == Qt::Checked;
 
166
        result.append(asset);
 
167
    }
 
168
 
 
169
    QVariant var;
 
170
    var.setValue(result);
 
171
    emit changed(tag, var);
 
172
}
 
173
 
 
174
void BarDescriptorEditorAssetsWidget::addAsset(const BarDescriptorAsset &asset)
175
175
{
176
176
    const QString path = asset.source;
177
177
    const QString dest = asset.destination;