forked from qt-creator/qt-creator
Merge branch 'master' of ssh://codereview.qt-project.org/qt-creator/qt-creator
This commit is contained in:
@@ -45,6 +45,8 @@ AndroidManifestDocument::AndroidManifestDocument(AndroidManifestEditorWidget *ed
|
||||
m_editorWidget(editorWidget)
|
||||
{
|
||||
setMimeType(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE));
|
||||
connect(editorWidget, SIGNAL(guiChanged()),
|
||||
this, SIGNAL(changed()));
|
||||
}
|
||||
|
||||
bool AndroidManifestDocument::save(QString *errorString, const QString &fileName, bool autoSave)
|
||||
|
||||
@@ -36,36 +36,32 @@
|
||||
|
||||
#include <QActionGroup>
|
||||
#include <QToolBar>
|
||||
#include <QTextBlock>
|
||||
|
||||
using namespace Android;
|
||||
using namespace Internal;
|
||||
|
||||
Android::Internal::AndroidManifestEditor::AndroidManifestEditor(AndroidManifestEditorWidget *editorWidget)
|
||||
: BaseTextEditor(editorWidget),
|
||||
m_document(new AndroidManifestDocument(editorWidget))
|
||||
: Core::IEditor(editorWidget), m_toolBar(0)
|
||||
{
|
||||
QToolBar *toolBar = new QToolBar;
|
||||
|
||||
m_toolBar = new QToolBar(editorWidget);
|
||||
m_actionGroup = new QActionGroup(this);
|
||||
connect(m_actionGroup, SIGNAL(triggered(QAction*)), this, SLOT(changeEditorPage(QAction*)));
|
||||
|
||||
QAction *generalAction = toolBar->addAction(tr("General"));
|
||||
QAction *generalAction = m_toolBar->addAction(tr("General"));
|
||||
generalAction->setData(AndroidManifestEditorWidget::General);
|
||||
generalAction->setCheckable(true);
|
||||
m_actionGroup->addAction(generalAction);
|
||||
|
||||
QAction *sourceAction = toolBar->addAction(tr("XML Source"));
|
||||
QAction *sourceAction = m_toolBar->addAction(tr("XML Source"));
|
||||
sourceAction->setData(AndroidManifestEditorWidget::Source);
|
||||
sourceAction->setCheckable(true);
|
||||
m_actionGroup->addAction(sourceAction);
|
||||
|
||||
generalAction->setChecked(true);
|
||||
|
||||
insertExtraToolBarWidget(BaseTextEditor::Left, toolBar);
|
||||
|
||||
|
||||
setContext(Core::Context(Constants::ANDROID_MANIFEST_EDITOR_CONTEXT,
|
||||
TextEditor::Constants::C_TEXTEDITOR));
|
||||
setContext(Core::Context(Constants::ANDROID_MANIFEST_EDITOR_CONTEXT));
|
||||
setWidget(editorWidget);
|
||||
}
|
||||
|
||||
Core::Id AndroidManifestEditor::id() const
|
||||
@@ -73,12 +69,47 @@ Core::Id AndroidManifestEditor::id() const
|
||||
return Constants::ANDROID_MANIFEST_EDITOR_ID;
|
||||
}
|
||||
|
||||
bool AndroidManifestEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
|
||||
{
|
||||
return widget()->open(errorString, fileName, realFileName);
|
||||
}
|
||||
|
||||
QWidget *AndroidManifestEditor::toolBar()
|
||||
{
|
||||
return m_toolBar;
|
||||
}
|
||||
|
||||
AndroidManifestEditorWidget *AndroidManifestEditor::widget() const
|
||||
{
|
||||
return static_cast<AndroidManifestEditorWidget *>(Core::IEditor::widget());
|
||||
}
|
||||
|
||||
Core::IDocument *AndroidManifestEditor::document()
|
||||
{
|
||||
return textEditor()->baseTextDocument();
|
||||
}
|
||||
|
||||
TextEditor::BaseTextEditorWidget *AndroidManifestEditor::textEditor() const
|
||||
{
|
||||
return widget()->textEditorWidget();
|
||||
}
|
||||
|
||||
int AndroidManifestEditor::currentLine() const
|
||||
{
|
||||
return textEditor()->textCursor().blockNumber() + 1;
|
||||
}
|
||||
|
||||
int AndroidManifestEditor::currentColumn() const
|
||||
{
|
||||
QTextCursor cursor = textEditor()->textCursor();
|
||||
return cursor.position() - cursor.block().position() + 1;
|
||||
}
|
||||
|
||||
void AndroidManifestEditor::changeEditorPage(QAction *action)
|
||||
{
|
||||
AndroidManifestEditorWidget *editorWidget = static_cast<AndroidManifestEditorWidget *>(widget());
|
||||
if (!editorWidget->setActivePage(static_cast<AndroidManifestEditorWidget::EditorPage>(action->data().toInt()))) {
|
||||
if (!widget()->setActivePage(static_cast<AndroidManifestEditorWidget::EditorPage>(action->data().toInt()))) {
|
||||
foreach (QAction *action, m_actionGroup->actions()) {
|
||||
if (action->data().toInt() == editorWidget->activePage()) {
|
||||
if (action->data().toInt() == widget()->activePage()) {
|
||||
action->setChecked(true);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#define ANDROIDMANIFESTEDITOR_H
|
||||
|
||||
#include "androidmanifestdocument.h"
|
||||
#include "androidmanifesteditorwidget.h"
|
||||
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <texteditor/basetexteditor.h>
|
||||
@@ -41,9 +42,8 @@ QT_END_NAMESPACE
|
||||
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
class AndroidManifestEditorWidget;
|
||||
|
||||
class AndroidManifestEditor : public TextEditor::BaseTextEditor
|
||||
class AndroidManifestEditor : public Core::IEditor
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -51,13 +51,22 @@ public:
|
||||
explicit AndroidManifestEditor(AndroidManifestEditorWidget *editorWidget);
|
||||
|
||||
Core::Id id() const;
|
||||
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
||||
QWidget *toolBar();
|
||||
AndroidManifestEditorWidget *widget() const;
|
||||
Core::IDocument *document();
|
||||
TextEditor::BaseTextEditorWidget *textEditor() const;
|
||||
|
||||
int currentLine() const;
|
||||
int currentColumn() const;
|
||||
void gotoLine(int line, int column = 0) { textEditor()->gotoLine(line, column); }
|
||||
|
||||
private slots:
|
||||
void changeEditorPage(QAction *action);
|
||||
|
||||
private:
|
||||
AndroidManifestDocument *m_document;
|
||||
QString m_displayName;
|
||||
QToolBar *m_toolBar;
|
||||
QActionGroup *m_actionGroup;
|
||||
};
|
||||
|
||||
|
||||
@@ -39,6 +39,19 @@
|
||||
using namespace Android;
|
||||
using namespace Android::Internal;
|
||||
|
||||
class AndroidTextEditorActionHandler : public TextEditor::TextEditorActionHandler
|
||||
{
|
||||
public:
|
||||
explicit AndroidTextEditorActionHandler(QObject *parent)
|
||||
: TextEditorActionHandler(parent, Constants::ANDROID_MANIFEST_EDITOR_CONTEXT)
|
||||
{}
|
||||
private:
|
||||
TextEditor::BaseTextEditorWidget *resolveTextEditorWidget(Core::IEditor *editor) const
|
||||
{
|
||||
AndroidManifestEditor *androidManifestEditor = static_cast<AndroidManifestEditor *>(editor);
|
||||
return androidManifestEditor->textEditor();
|
||||
}
|
||||
};
|
||||
|
||||
AndroidManifestEditorFactory::AndroidManifestEditorFactory(QObject *parent)
|
||||
: Core::IEditorFactory(parent)
|
||||
@@ -46,12 +59,11 @@ AndroidManifestEditorFactory::AndroidManifestEditorFactory(QObject *parent)
|
||||
setId(Constants::ANDROID_MANIFEST_EDITOR_ID);
|
||||
setDisplayName(tr("Android Manifest editor"));
|
||||
addMimeType(Constants::ANDROID_MANIFEST_MIME_TYPE);
|
||||
new TextEditor::TextEditorActionHandler(this, Constants::ANDROID_MANIFEST_EDITOR_CONTEXT);
|
||||
new AndroidTextEditorActionHandler(this);
|
||||
}
|
||||
|
||||
Core::IEditor *AndroidManifestEditorFactory::createEditor()
|
||||
{
|
||||
AndroidManifestEditorWidget *editor = new AndroidManifestEditorWidget();
|
||||
TextEditor::TextEditorSettings::initializeEditor(editor);
|
||||
return editor->editor();
|
||||
AndroidManifestEditorWidget *androidManifestEditorWidget = new AndroidManifestEditorWidget();
|
||||
return androidManifestEditorWidget->editor();
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/infobar.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <texteditor/plaintexteditor.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectwindow.h>
|
||||
@@ -44,6 +45,7 @@
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <texteditor/texteditoractionhandler.h>
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
#include <qmakeprojectmanager/qmakeproject.h>
|
||||
|
||||
#include <QLineEdit>
|
||||
@@ -95,49 +97,44 @@ Project *androidProject(const QString &file)
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
AndroidManifestEditorWidget::AndroidManifestEditorWidget(QWidget *parent)
|
||||
: TextEditor::PlainTextEditorWidget(new AndroidManifestDocument(this), parent),
|
||||
AndroidManifestEditorWidget::AndroidManifestEditorWidget()
|
||||
: QWidget(),
|
||||
m_dirty(false),
|
||||
m_stayClean(false),
|
||||
m_setAppName(false),
|
||||
m_appNameInStringsXml(false)
|
||||
{
|
||||
configure(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE));
|
||||
m_textEditorWidget = new AndroidManifestTextEditorWidget(this);
|
||||
TextEditor::TextEditorSettings::initializeEditor(m_textEditorWidget);
|
||||
|
||||
initializePage();
|
||||
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
|
||||
m_timerParseCheck.setInterval(800);
|
||||
m_timerParseCheck.setSingleShot(true);
|
||||
|
||||
m_editor = new AndroidManifestEditor(this);
|
||||
|
||||
connect(&m_timerParseCheck, SIGNAL(timeout()),
|
||||
this, SLOT(delayedParseCheck()));
|
||||
|
||||
connect(document(), SIGNAL(contentsChanged()),
|
||||
connect(m_textEditorWidget->document(), SIGNAL(contentsChanged()),
|
||||
this, SLOT(startParseCheck()));
|
||||
}
|
||||
|
||||
TextEditor::BaseTextEditor *AndroidManifestEditorWidget::createEditor()
|
||||
{
|
||||
return new AndroidManifestEditor(this);
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::initializePage()
|
||||
{
|
||||
QWidget *mainWidget = new QWidget(this);
|
||||
mainWidget->setAutoFillBackground(true);
|
||||
// If the user clicks on the mainwidget it gets focus, even though that's not visible
|
||||
// This is to prevent the parent, the actual basetexteditorwidget from getting focus
|
||||
mainWidget->setFocusPolicy(Qt::WheelFocus);
|
||||
mainWidget->installEventFilter(this);
|
||||
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||
layout->setMargin(0);
|
||||
m_stackedWidget = new QStackedWidget(this); // simplfy make AndroidManifestEditorWidget a stacked widget
|
||||
layout->addWidget(m_stackedWidget);
|
||||
|
||||
Core::IContext *myContext = new Core::IContext(this);
|
||||
myContext->setWidget(mainWidget);
|
||||
myContext->setContext(Core::Context(androidManifestEditorGeneralPaneContextId));
|
||||
myContext->setWidget(m_stackedWidget);
|
||||
myContext->setContext(Core::Context(androidManifestEditorGeneralPaneContextId)); // where is the context used?
|
||||
Core::ICore::addContextObject(myContext);
|
||||
|
||||
QWidget *mainWidget = new QWidget; // different name
|
||||
|
||||
QVBoxLayout *topLayout = new QVBoxLayout(mainWidget);
|
||||
|
||||
QGroupBox *packageGroupBox = new QGroupBox(mainWidget);
|
||||
@@ -444,7 +441,8 @@ void AndroidManifestEditorWidget::initializePage()
|
||||
|
||||
topLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding));
|
||||
|
||||
m_overlayWidget = mainWidget;
|
||||
m_stackedWidget->insertWidget(General, mainWidget);
|
||||
m_stackedWidget->insertWidget(Source, m_textEditorWidget);
|
||||
}
|
||||
|
||||
bool AndroidManifestEditorWidget::eventFilter(QObject *obj, QEvent *event)
|
||||
@@ -454,18 +452,12 @@ bool AndroidManifestEditorWidget::eventFilter(QObject *obj, QEvent *event)
|
||||
QTimer::singleShot(0, this, SLOT(updateTargetComboBox()));
|
||||
}
|
||||
|
||||
if (obj == m_overlayWidget)
|
||||
if (event->type() == QEvent::KeyPress
|
||||
|| event->type() == QEvent::KeyRelease) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return TextEditor::PlainTextEditorWidget::eventFilter(obj, event);
|
||||
return QWidget::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::updateTargetComboBox()
|
||||
{
|
||||
const QString docPath(baseTextDocument()->filePath());
|
||||
const QString docPath(m_textEditorWidget->baseTextDocument()->filePath());
|
||||
ProjectExplorer::Project *project = androidProject(docPath);
|
||||
QStringList items;
|
||||
if (project) {
|
||||
@@ -487,28 +479,20 @@ void AndroidManifestEditorWidget::updateTargetComboBox()
|
||||
m_targetLineEdit->addItems(items);
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
PlainTextEditorWidget::resizeEvent(event);
|
||||
QSize s = QSize(rect().width(), rect().height());
|
||||
m_overlayWidget->resize(s);
|
||||
}
|
||||
|
||||
bool AndroidManifestEditorWidget::open(QString *errorString, const QString &fileName, const QString &realFileName)
|
||||
{
|
||||
bool result = PlainTextEditorWidget::open(errorString, fileName, realFileName);
|
||||
bool result = m_textEditorWidget->open(errorString, fileName, realFileName);
|
||||
|
||||
updateSdkVersions();
|
||||
|
||||
if (!result)
|
||||
return result;
|
||||
|
||||
Q_UNUSED(errorString);
|
||||
QString error;
|
||||
int errorLine;
|
||||
int errorColumn;
|
||||
QDomDocument doc;
|
||||
if (doc.setContent(toPlainText(), &error, &errorLine, &errorColumn)) {
|
||||
if (doc.setContent(m_textEditorWidget->toPlainText(), &error, &errorLine, &errorColumn)) {
|
||||
if (checkDocument(doc, &error, &errorLine, &errorColumn)) {
|
||||
if (activePage() != Source)
|
||||
syncToWidgets(doc);
|
||||
@@ -518,7 +502,6 @@ bool AndroidManifestEditorWidget::open(QString *errorString, const QString &file
|
||||
// some error occured
|
||||
updateInfoBar(error, errorLine, errorColumn);
|
||||
setActivePage(Source);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -527,7 +510,7 @@ void AndroidManifestEditorWidget::setDirty(bool dirty)
|
||||
if (m_stayClean)
|
||||
return;
|
||||
m_dirty = dirty;
|
||||
emit changed();
|
||||
emit guiChanged();
|
||||
}
|
||||
|
||||
bool AndroidManifestEditorWidget::isModified() const
|
||||
@@ -541,7 +524,7 @@ bool AndroidManifestEditorWidget::isModified() const
|
||||
|
||||
AndroidManifestEditorWidget::EditorPage AndroidManifestEditorWidget::activePage() const
|
||||
{
|
||||
return m_overlayWidget->isVisibleTo(const_cast<AndroidManifestEditorWidget *>(this)) ? General : Source;
|
||||
return AndroidManifestEditorWidget::EditorPage(m_stackedWidget->currentIndex());
|
||||
}
|
||||
|
||||
bool AndroidManifestEditorWidget::setActivePage(EditorPage page)
|
||||
@@ -557,22 +540,15 @@ bool AndroidManifestEditorWidget::setActivePage(EditorPage page)
|
||||
} else {
|
||||
if (!syncToWidgets())
|
||||
return false;
|
||||
|
||||
QWidget *fw = m_overlayWidget->focusWidget();
|
||||
if (fw && fw != m_overlayWidget)
|
||||
fw->setFocus();
|
||||
else
|
||||
m_packageNameLineEdit->setFocus();
|
||||
// TODO?
|
||||
// QWidget *fw = m_overlayWidget->focusWidget();
|
||||
// if (fw && fw != m_overlayWidget)
|
||||
// fw->setFocus();
|
||||
// else
|
||||
// m_packageNameLineEdit->setFocus();
|
||||
}
|
||||
|
||||
m_overlayWidget->setVisible(page == General);
|
||||
if (page == General) {
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
} else {
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
}
|
||||
m_stackedWidget->setCurrentIndex(page);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -582,7 +558,7 @@ void AndroidManifestEditorWidget::preSave()
|
||||
syncToEditor();
|
||||
|
||||
if (m_setAppName && m_appNameInStringsXml) {
|
||||
QString baseDir = QFileInfo(baseTextDocument()->filePath()).absolutePath();
|
||||
QString baseDir = QFileInfo(m_textEditorWidget->baseTextDocument()->filePath()).absolutePath();
|
||||
QString fileName = baseDir + QLatin1String("/res/values/strings.xml");
|
||||
QFile f(fileName);
|
||||
if (f.open(QIODevice::ReadOnly)) {
|
||||
@@ -606,7 +582,7 @@ void AndroidManifestEditorWidget::preSave()
|
||||
m_setAppName = false;
|
||||
}
|
||||
|
||||
QString baseDir = QFileInfo(baseTextDocument()->filePath()).absolutePath();
|
||||
QString baseDir = QFileInfo(m_textEditorWidget->baseTextDocument()->filePath()).absolutePath();
|
||||
if (!m_lIconPath.isEmpty()) {
|
||||
copyIcon(LowDPI, baseDir, m_lIconPath);
|
||||
m_lIconPath.clear();
|
||||
@@ -624,12 +600,22 @@ void AndroidManifestEditorWidget::preSave()
|
||||
updateInfoBar();
|
||||
}
|
||||
|
||||
Core::IEditor *AndroidManifestEditorWidget::editor() const
|
||||
{
|
||||
return m_editor;
|
||||
}
|
||||
|
||||
TextEditor::PlainTextEditorWidget *AndroidManifestEditorWidget::textEditorWidget() const
|
||||
{
|
||||
return m_textEditorWidget;
|
||||
}
|
||||
|
||||
bool AndroidManifestEditorWidget::syncToWidgets()
|
||||
{
|
||||
QDomDocument doc;
|
||||
QString errorMessage;
|
||||
int errorLine, errorColumn;
|
||||
if (doc.setContent(toPlainText(), &errorMessage, &errorLine, &errorColumn)) {
|
||||
if (doc.setContent(m_textEditorWidget->toPlainText(), &errorMessage, &errorLine, &errorColumn)) {
|
||||
if (checkDocument(doc, &errorMessage, &errorLine, &errorColumn)) {
|
||||
hideInfoBar();
|
||||
syncToWidgets(doc);
|
||||
@@ -678,7 +664,7 @@ void AndroidManifestEditorWidget::updateInfoBar()
|
||||
QDomDocument doc;
|
||||
int errorLine, errorColumn;
|
||||
QString errorMessage;
|
||||
if (doc.setContent(toPlainText(), &errorMessage, &errorLine, &errorColumn)) {
|
||||
if (doc.setContent(m_textEditorWidget->toPlainText(), &errorMessage, &errorLine, &errorColumn)) {
|
||||
if (checkDocument(doc, &errorMessage, &errorLine, &errorColumn)) {
|
||||
hideInfoBar();
|
||||
return;
|
||||
@@ -690,7 +676,7 @@ void AndroidManifestEditorWidget::updateInfoBar()
|
||||
|
||||
void AndroidManifestEditorWidget::updateSdkVersions()
|
||||
{
|
||||
const QString docPath(baseTextDocument()->filePath());
|
||||
const QString docPath(m_textEditorWidget->baseTextDocument()->filePath());
|
||||
Project *project = androidProject(docPath);
|
||||
QPair<int, int> apiLevels = AndroidManager::apiLevelRange(project ? project->activeTarget() : 0);
|
||||
for (int i = apiLevels.first; i < apiLevels.second + 1; ++i)
|
||||
@@ -708,7 +694,7 @@ void AndroidManifestEditorWidget::updateSdkVersions()
|
||||
|
||||
void AndroidManifestEditorWidget::updateInfoBar(const QString &errorMessage, int line, int column)
|
||||
{
|
||||
Core::InfoBar *infoBar = baseTextDocument()->infoBar();
|
||||
Core::InfoBar *infoBar = m_textEditorWidget->baseTextDocument()->infoBar();
|
||||
QString text;
|
||||
if (line < 0)
|
||||
text = tr("Could not parse file: '%1'.").arg(errorMessage);
|
||||
@@ -726,14 +712,14 @@ void AndroidManifestEditorWidget::updateInfoBar(const QString &errorMessage, int
|
||||
|
||||
void AndroidManifestEditorWidget::hideInfoBar()
|
||||
{
|
||||
Core::InfoBar *infoBar = baseTextDocument()->infoBar();
|
||||
infoBar->removeInfo(infoBarId);
|
||||
Core::InfoBar *infoBar = m_textEditorWidget->baseTextDocument()->infoBar();
|
||||
infoBar->removeInfo(infoBarId);
|
||||
m_timerParseCheck.stop();
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::gotoError()
|
||||
{
|
||||
gotoLine(m_errorLine, m_errorColumn);
|
||||
m_textEditorWidget->gotoLine(m_errorLine, m_errorColumn);
|
||||
}
|
||||
|
||||
void setApiLevel(QComboBox *box, const QDomElement &element, const QString &attribute)
|
||||
@@ -765,7 +751,7 @@ void AndroidManifestEditorWidget::syncToWidgets(const QDomDocument &doc)
|
||||
setApiLevel(m_androidMinSdkVersion, usesSdkElement, QLatin1String("android:minSdkVersion"));
|
||||
setApiLevel(m_androidTargetSdkVersion, usesSdkElement, QLatin1String("android:targetSdkVersion"));
|
||||
|
||||
QString baseDir = QFileInfo(baseTextDocument()->filePath()).absolutePath();
|
||||
QString baseDir = QFileInfo(m_textEditorWidget->baseTextDocument()->filePath()).absolutePath();
|
||||
QString fileName = baseDir + QLatin1String("/res/values/strings.xml");
|
||||
|
||||
QDomElement applicationElement = manifest.firstChildElement(QLatin1String("application"));
|
||||
@@ -883,7 +869,7 @@ int extractVersion(const QString &string)
|
||||
void AndroidManifestEditorWidget::syncToEditor()
|
||||
{
|
||||
QDomDocument doc;
|
||||
if (!doc.setContent(toPlainText())) {
|
||||
if (!doc.setContent(m_textEditorWidget->toPlainText())) {
|
||||
// This should not happen
|
||||
updateInfoBar();
|
||||
return;
|
||||
@@ -930,11 +916,11 @@ void AndroidManifestEditorWidget::syncToEditor()
|
||||
|
||||
|
||||
QString newText = doc.toString(4);
|
||||
if (newText == toPlainText())
|
||||
if (newText == m_textEditorWidget->toPlainText())
|
||||
return;
|
||||
|
||||
setPlainText(newText);
|
||||
document()->setModified(true); // Why is this necessary?
|
||||
m_textEditorWidget->setPlainText(newText);
|
||||
m_textEditorWidget->document()->setModified(true);
|
||||
|
||||
m_dirty = false;
|
||||
}
|
||||
@@ -1062,7 +1048,7 @@ void AndroidManifestEditorWidget::removePermission()
|
||||
void AndroidManifestEditorWidget::setAppName()
|
||||
{
|
||||
m_setAppName = true;
|
||||
emit changed();
|
||||
setDirty(true);
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::setPackageName()
|
||||
@@ -1154,3 +1140,12 @@ int PermissionsModel::rowCount(const QModelIndex &parent) const
|
||||
Q_UNUSED(parent)
|
||||
return m_permissions.count();
|
||||
}
|
||||
|
||||
|
||||
AndroidManifestTextEditorWidget::AndroidManifestTextEditorWidget(AndroidManifestEditorWidget *parent)
|
||||
: TextEditor::PlainTextEditorWidget(new AndroidManifestDocument(parent), parent),
|
||||
m_parent(parent)
|
||||
{
|
||||
baseTextDocument()->setMimeType(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE));
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace Core { class IEditor; }
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
class AndroidManifestEditor;
|
||||
class AndroidManifestEditorWidget;
|
||||
|
||||
|
||||
class PermissionsModel: public QAbstractListModel
|
||||
@@ -75,16 +76,24 @@ private:
|
||||
QStringList m_permissions;
|
||||
};
|
||||
|
||||
class AndroidManifestEditorWidget : public TextEditor::PlainTextEditorWidget
|
||||
class AndroidManifestTextEditorWidget : public TextEditor::PlainTextEditorWidget
|
||||
{
|
||||
public:
|
||||
AndroidManifestTextEditorWidget(AndroidManifestEditorWidget *parent = 0);
|
||||
protected:
|
||||
AndroidManifestEditorWidget *m_parent;
|
||||
};
|
||||
|
||||
class AndroidManifestEditorWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum EditorPage {
|
||||
General,
|
||||
Source
|
||||
General = 0,
|
||||
Source = 1
|
||||
};
|
||||
|
||||
explicit AndroidManifestEditorWidget(QWidget *parent = 0);
|
||||
explicit AndroidManifestEditorWidget();
|
||||
|
||||
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
||||
|
||||
@@ -95,12 +104,16 @@ public:
|
||||
|
||||
void preSave();
|
||||
|
||||
Core::IEditor *editor() const;
|
||||
TextEditor::PlainTextEditorWidget *textEditorWidget() const;
|
||||
|
||||
public slots:
|
||||
void setDirty(bool dirty = true);
|
||||
|
||||
signals:
|
||||
void guiChanged();
|
||||
|
||||
protected:
|
||||
TextEditor::BaseTextEditor *createEditor();
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
private slots:
|
||||
void setLDPIIcon();
|
||||
@@ -165,8 +178,10 @@ private:
|
||||
QPushButton *m_removePermissionButton;
|
||||
QComboBox *m_permissionsComboBox;
|
||||
|
||||
QWidget *m_overlayWidget;
|
||||
QTimer m_timerParseCheck;
|
||||
TextEditor::PlainTextEditorWidget *m_textEditorWidget;
|
||||
QStackedWidget *m_stackedWidget;
|
||||
AndroidManifestEditor *m_editor;
|
||||
};
|
||||
} // namespace Internal
|
||||
} // namespace Android
|
||||
|
||||
@@ -70,7 +70,7 @@ QList<LocatorFilterEntry> LineNumberFilter::matchesFor(QFutureInterface<Core::Lo
|
||||
column = lineAndColumn.at(1).toInt(&ok);
|
||||
if (!ok)
|
||||
return value;
|
||||
if (currentTextEditor() && (line > 0 || column > 0)) {
|
||||
if (EditorManager::currentEditor() && (line > 0 || column > 0)) {
|
||||
LineColumn data;
|
||||
data.first = line;
|
||||
data.second = column - 1; // column API is 0-based
|
||||
@@ -88,21 +88,13 @@ QList<LocatorFilterEntry> LineNumberFilter::matchesFor(QFutureInterface<Core::Lo
|
||||
|
||||
void LineNumberFilter::accept(LocatorFilterEntry selection) const
|
||||
{
|
||||
ITextEditor *editor = currentTextEditor();
|
||||
IEditor *editor = EditorManager::currentEditor();
|
||||
if (editor) {
|
||||
EditorManager::addCurrentPositionToNavigationHistory();
|
||||
LineColumn data = selection.internalData.value<LineColumn>();
|
||||
if (data.first < 1) { // jump to column in same line
|
||||
int currLine, currColumn;
|
||||
editor->convertPosition(editor->position(), &currLine, &currColumn);
|
||||
data.first = currLine;
|
||||
}
|
||||
if (data.first < 1) // jump to column in same line
|
||||
data.first = editor->currentLine();
|
||||
editor->gotoLine(data.first, data.second);
|
||||
EditorManager::activateEditor(editor);
|
||||
}
|
||||
}
|
||||
|
||||
ITextEditor *LineNumberFilter::currentTextEditor() const
|
||||
{
|
||||
return qobject_cast<TextEditor::ITextEditor *>(EditorManager::currentEditor());
|
||||
}
|
||||
|
||||
@@ -36,10 +36,11 @@
|
||||
#include <QList>
|
||||
#include <QFutureInterface>
|
||||
|
||||
namespace Core {
|
||||
class IEditor;
|
||||
}
|
||||
|
||||
namespace TextEditor {
|
||||
|
||||
class ITextEditor;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class LineNumberFilter : public Core::ILocatorFilter
|
||||
@@ -52,9 +53,6 @@ public:
|
||||
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry);
|
||||
void accept(Core::LocatorFilterEntry selection) const;
|
||||
void refresh(QFutureInterface<void> &) {}
|
||||
|
||||
private:
|
||||
ITextEditor *currentTextEditor() const;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user