44
44
#include <coreplugin/icore.h>
45
45
#include <projectexplorer/iprojectproperties.h>
46
46
#include <projectexplorer/projectwindow.h>
47
#include <projectexplorer/task.h>
48
#include <projectexplorer/taskhub.h>
47
49
#include <texteditor/plaintexteditor.h>
48
#include <texteditor/texteditoractionhandler.h>
49
50
#include <texteditor/texteditorsettings.h>
50
51
#include <texteditor/texteditorconstants.h>
52
#include <utils/qtcassert.h>
52
54
using namespace Qnx;
53
55
using namespace Qnx::Internal;
55
BarDescriptorEditorWidget::BarDescriptorEditorWidget(
56
QWidget *parent, TextEditor::TextEditorActionHandler *handler)
57
BarDescriptorEditorWidget::BarDescriptorEditorWidget(BarDescriptorEditor *editor, QWidget *parent)
57
58
: QStackedWidget(parent)
62
61
Core::IContext *myContext = new Core::IContext(this);
63
62
myContext->setWidget(this);
72
71
setCurrentIndex(0);
73
connect(m_entryPointWidget, SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), barDescriptorDocument(), SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
74
connect(m_packageInformationWidget, SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), barDescriptorDocument(), SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
75
connect(m_authorInformationWidget, SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), barDescriptorDocument(), SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
76
connect(m_generalWidget, SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), barDescriptorDocument(), SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
77
connect(m_permissionsWidget, SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), barDescriptorDocument(), SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
78
connect(m_environmentWidget, SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), barDescriptorDocument(), SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
79
connect(m_assetsWidget, SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), barDescriptorDocument(), SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
81
connect(barDescriptorDocument(), SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), m_entryPointWidget, SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
82
connect(barDescriptorDocument(), SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), m_packageInformationWidget, SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
83
connect(barDescriptorDocument(), SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), m_authorInformationWidget, SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
84
connect(barDescriptorDocument(), SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), m_generalWidget, SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
85
connect(barDescriptorDocument(), SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), m_permissionsWidget, SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
86
connect(barDescriptorDocument(), SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), m_environmentWidget, SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
87
connect(barDescriptorDocument(), SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), m_assetsWidget, SLOT(setValue(BarDescriptorDocument::Tag,QVariant)));
89
connect(m_xmlSourceWidget, SIGNAL(textChanged()), this, SLOT(updateDocumentContent()));
90
connect(barDescriptorDocument(), SIGNAL(changed()), this, SLOT(updateSourceView()));
75
93
void BarDescriptorEditorWidget::initGeneralPage()
98
116
authorInformationPanel->setDisplayName(tr("Author Information"));
99
117
authorInformationPanel->setWidget(m_authorInformationWidget);
100
118
generalPanel->addPropertiesPanel(authorInformationPanel);
102
connect(m_entryPointWidget, SIGNAL(changed()), this, SLOT(setDirty()));
103
connect(m_packageInformationWidget, SIGNAL(changed()), this, SLOT(setDirty()));
104
connect(m_authorInformationWidget, SIGNAL(changed()), this, SLOT(setDirty()));
107
121
void BarDescriptorEditorWidget::initApplicationPage()
130
144
environmentPanel->setDisplayName(tr("Environment"));
131
145
environmentPanel->setWidget(m_environmentWidget);
132
146
applicationPanel->addPropertiesPanel(environmentPanel);
134
connect(m_generalWidget, SIGNAL(changed()), this, SLOT(setDirty()));
135
connect(m_permissionsWidget, SIGNAL(changed()), this, SLOT(setDirty()));
136
connect(m_environmentWidget, SIGNAL(changed()), this, SLOT(setDirty()));
139
149
void BarDescriptorEditorWidget::initAssetsPage()
148
158
assetsPropertiesPanel->setWidget(m_assetsWidget);
149
159
assetsPanel->addPropertiesPanel(assetsPropertiesPanel);
151
connect(m_assetsWidget, SIGNAL(changed()), this, SLOT(setDirty()));
153
161
m_entryPointWidget->setAssetsModel(m_assetsWidget->assetsModel());
154
162
connect(m_entryPointWidget, SIGNAL(imageAdded(QString)), m_assetsWidget, SLOT(addAsset(QString)));
155
163
connect(m_entryPointWidget, SIGNAL(imageRemoved(QString)), m_assetsWidget, SLOT(removeAsset(QString)));
172
178
panelsWidget->widget()->setMinimumWidth(0);
175
Core::IEditor *BarDescriptorEditorWidget::editor() const
178
m_editor = const_cast<BarDescriptorEditorWidget *>(this)->createEditor();
179
connect(this, SIGNAL(changed()), m_editor->document(), SIGNAL(changed()));
185
BarDescriptorEditorPackageInformationWidget *BarDescriptorEditorWidget::packageInformationWidget() const
187
return m_packageInformationWidget;
190
BarDescriptorEditorAuthorInformationWidget *BarDescriptorEditorWidget::authorInformationWidget() const
192
return m_authorInformationWidget;
195
BarDescriptorEditorEntryPointWidget *BarDescriptorEditorWidget::entryPointWidget() const
197
return m_entryPointWidget;
200
BarDescriptorEditorGeneralWidget *BarDescriptorEditorWidget::generalWidget() const
202
return m_generalWidget;
205
BarDescriptorEditorPermissionsWidget *BarDescriptorEditorWidget::permissionsWidget() const
207
return m_permissionsWidget;
210
BarDescriptorEditorEnvironmentWidget *BarDescriptorEditorWidget::environmentWidget() const
212
return m_environmentWidget;
215
BarDescriptorEditorAssetsWidget *BarDescriptorEditorWidget::assetsWidget() const
217
return m_assetsWidget;
220
181
TextEditor::BaseTextEditorWidget *BarDescriptorEditorWidget::sourceWidget() const
222
183
return m_xmlSourceWidget;
225
186
void BarDescriptorEditorWidget::setFilePath(const QString &filePath)
227
Core::IDocument *doc = m_xmlSourceWidget->editorDocument();
188
Core::IDocument *doc = m_xmlSourceWidget->baseTextDocument();
229
190
doc->setFilePath(filePath);
230
// setFilePath() call leads to a textChanged() signal emitted
231
// and therefore having this editor-widget to become dirty
232
// therefore we have to explicitly unset the dirty flag
193
void BarDescriptorEditorWidget::updateDocumentContent()
195
ProjectExplorer::TaskHub::clearTasks(Constants::QNX_TASK_CATEGORY_BARDESCRIPTOR);
199
disconnect(barDescriptorDocument(), SIGNAL(changed()), this, SLOT(updateSourceView()));
200
bool result = barDescriptorDocument()->loadContent(m_xmlSourceWidget->toPlainText(), true, &errorMsg, &errorLine);
201
connect(barDescriptorDocument(), SIGNAL(changed()), this, SLOT(updateSourceView()));
204
ProjectExplorer::TaskHub::addTask(ProjectExplorer::Task::Error, errorMsg, Constants::QNX_TASK_CATEGORY_BARDESCRIPTOR,
205
Utils::FileName::fromString(barDescriptorDocument()->filePath()), errorLine);
206
ProjectExplorer::TaskHub::requestPopup();
237
QString BarDescriptorEditorWidget::xmlSource() const
239
return m_xmlSourceWidget->toPlainText();
242
void BarDescriptorEditorWidget::setXmlSource(const QString &xmlSource)
244
bool blocked = m_xmlSourceWidget->blockSignals(true);
245
m_xmlSourceWidget->setPlainText(xmlSource);
246
m_xmlSourceWidget->blockSignals(blocked);
249
bool BarDescriptorEditorWidget::isDirty() const
254
void BarDescriptorEditorWidget::clear()
256
m_entryPointWidget->clear();
257
m_packageInformationWidget->clear();
258
m_authorInformationWidget->clear();
260
m_generalWidget->clear();
261
m_permissionsWidget->clear();
262
m_environmentWidget->clear();
264
m_assetsWidget->clear();
266
bool blocked = m_xmlSourceWidget->blockSignals(true);
267
m_xmlSourceWidget->clear();
268
m_xmlSourceWidget->blockSignals(blocked);
271
void BarDescriptorEditorWidget::setDirty(bool dirty)
277
BarDescriptorEditor *BarDescriptorEditorWidget::createEditor()
279
return new BarDescriptorEditor(this);
210
void BarDescriptorEditorWidget::updateSourceView()
212
bool blocked = m_xmlSourceWidget->blockSignals(true);
216
int position = m_xmlSourceWidget->position();
217
m_xmlSourceWidget->convertPosition(position, &line, &column);
219
m_xmlSourceWidget->setPlainText(barDescriptorDocument()->xmlSource());
221
m_xmlSourceWidget->gotoLine(line, column);
223
m_xmlSourceWidget->blockSignals(blocked);
226
BarDescriptorDocument *BarDescriptorEditorWidget::barDescriptorDocument() const
228
return qobject_cast<BarDescriptorDocument*>(m_editor->document());