forked from qt-creator/qt-creator
Merge branch 'origin/2.0' (early part)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -39,7 +39,7 @@ using namespace CPlusPlus;
|
||||
|
||||
enum { MAX_NUM_LINES = 20 };
|
||||
|
||||
static bool shouldOverrideChar(const QChar &ch)
|
||||
static bool shouldOverrideChar(QChar ch)
|
||||
{
|
||||
switch (ch.unicode()) {
|
||||
case ')': case ']': case ';': case '"': case '\'':
|
||||
@@ -86,7 +86,7 @@ bool MatchingText::shouldInsertMatchingText(const QTextCursor &tc)
|
||||
return shouldInsertMatchingText(doc->characterAt(tc.selectionEnd()));
|
||||
}
|
||||
|
||||
bool MatchingText::shouldInsertMatchingText(const QChar &lookAhead)
|
||||
bool MatchingText::shouldInsertMatchingText(QChar lookAhead)
|
||||
{
|
||||
switch (lookAhead.unicode()) {
|
||||
case '{': case '}':
|
||||
@@ -103,7 +103,7 @@ bool MatchingText::shouldInsertMatchingText(const QChar &lookAhead)
|
||||
}
|
||||
|
||||
QString MatchingText::insertMatchingBrace(const QTextCursor &cursor, const QString &textToProcess,
|
||||
const QChar &la, int *skippedChars) const
|
||||
QChar la, int *skippedChars) const
|
||||
{
|
||||
QTextCursor tc = cursor;
|
||||
QTextDocument *doc = tc.document();
|
||||
|
@@ -43,10 +43,10 @@ public:
|
||||
MatchingText(TokenCache *tokenCache);
|
||||
|
||||
static bool shouldInsertMatchingText(const QTextCursor &tc);
|
||||
static bool shouldInsertMatchingText(const QChar &lookAhead);
|
||||
static bool shouldInsertMatchingText(QChar lookAhead);
|
||||
|
||||
QString insertMatchingBrace(const QTextCursor &tc, const QString &text,
|
||||
const QChar &la, int *skippedChars) const;
|
||||
QChar la, int *skippedChars) const;
|
||||
QString insertParagraphSeparator(const QTextCursor &tc) const;
|
||||
|
||||
private:
|
||||
|
@@ -1380,7 +1380,7 @@ SemanticInfo CPPEditor::semanticInfo() const
|
||||
return m_lastSemanticInfo;
|
||||
}
|
||||
|
||||
bool CPPEditor::isElectricCharacter(const QChar &ch) const
|
||||
bool CPPEditor::isElectricCharacter(QChar ch) const
|
||||
{
|
||||
if (ch == QLatin1Char('{') ||
|
||||
ch == QLatin1Char('}') ||
|
||||
@@ -1392,7 +1392,7 @@ bool CPPEditor::isElectricCharacter(const QChar &ch) const
|
||||
}
|
||||
|
||||
QString CPPEditor::insertMatchingBrace(const QTextCursor &tc, const QString &text,
|
||||
const QChar &la, int *skippedChars) const
|
||||
QChar la, int *skippedChars) const
|
||||
{
|
||||
MatchingText m(tokenCache());
|
||||
return m.insertMatchingBrace(tc, text, la, skippedChars);
|
||||
|
@@ -222,10 +222,10 @@ protected:
|
||||
TextEditor::BaseTextEditorEditable *createEditableInterface();
|
||||
|
||||
// These override BaseTextEditor
|
||||
virtual bool isElectricCharacter(const QChar &ch) const;
|
||||
virtual bool isElectricCharacter(QChar ch) const;
|
||||
|
||||
virtual QString insertMatchingBrace(const QTextCursor &tc, const QString &text,
|
||||
const QChar &la, int *skippedChars) const;
|
||||
QChar la, int *skippedChars) const;
|
||||
|
||||
virtual QString insertParagraphSeparator(const QTextCursor &tc) const;
|
||||
|
||||
|
@@ -120,7 +120,7 @@ void FilterSettingsPage::updateFilterPage()
|
||||
foreach (const QString &attribute, attributes)
|
||||
new QTreeWidgetItem(m_ui.attributeWidget, QStringList(attribute));
|
||||
|
||||
if (m_filterMap.keys().isEmpty()) {
|
||||
if (!m_filterMap.keys().isEmpty()) {
|
||||
m_ui.filterWidget->setCurrentRow(0);
|
||||
updateAttributes(m_ui.filterWidget->currentItem());
|
||||
}
|
||||
|
@@ -819,16 +819,8 @@ void HelpPlugin::handleHelpRequest(const QUrl &url)
|
||||
if (HelpViewer::launchWithExternalApp(url))
|
||||
return;
|
||||
|
||||
if (Core::HelpManager::instance()->findFile(url).isValid()) {
|
||||
if (url.queryItemValue(QLatin1String("view")) == QLatin1String("split")) {
|
||||
if (HelpViewer* viewer = viewerForContextMode())
|
||||
viewer->setSource(url);
|
||||
} else {
|
||||
activateHelpMode();
|
||||
m_centralWidget->setSource(url);
|
||||
}
|
||||
} else {
|
||||
QString address = url.toString();
|
||||
if (!Core::HelpManager::instance()->findFile(url).isValid()) {
|
||||
if (address.startsWith(HelpViewer::NsNokia)
|
||||
|| address.startsWith(HelpViewer::NsTrolltech)) {
|
||||
// local help not installed, resort to external web help
|
||||
@@ -840,7 +832,15 @@ void HelpPlugin::handleHelpRequest(const QUrl &url)
|
||||
}
|
||||
address = urlPrefix + address.mid(address.lastIndexOf(QLatin1Char('/')));
|
||||
}
|
||||
QDesktopServices::openUrl(address);
|
||||
}
|
||||
|
||||
const QUrl newUrl(address);
|
||||
if (newUrl.queryItemValue(QLatin1String("view")) == QLatin1String("split")) {
|
||||
if (HelpViewer* viewer = viewerForContextMode())
|
||||
viewer->setSource(newUrl);
|
||||
} else {
|
||||
activateHelpMode();
|
||||
m_centralWidget->setSource(newUrl);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -147,8 +147,6 @@ bool HelpViewer::launchWithExternalApp(const QUrl &url)
|
||||
actualTmpFile.close();
|
||||
return QDesktopServices::openUrl(QUrl(actualTmpFile.fileName()));
|
||||
}
|
||||
} else if (url.scheme() == QLatin1String("http")) {
|
||||
return QDesktopServices::openUrl(url);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -41,7 +41,7 @@
|
||||
#include <QtGui/QKeyEvent>
|
||||
#include <QtGui/QMenu>
|
||||
|
||||
#include <QtHelp/QHelpEngineCore>
|
||||
#include <QtHelp/QHelpEngine>
|
||||
|
||||
using namespace Find;
|
||||
using namespace Help;
|
||||
@@ -78,7 +78,7 @@ HelpViewer::~HelpViewer()
|
||||
|
||||
QFont HelpViewer::viewerFont() const
|
||||
{
|
||||
const QHelpEngineCore &engine = HelpManager::helpEngineCore();
|
||||
const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
|
||||
return qVariantValue<QFont>(engine.customValue(QLatin1String("font"),
|
||||
qApp->font()));
|
||||
}
|
||||
@@ -149,8 +149,15 @@ void HelpViewer::setSource(const QUrl &url)
|
||||
if (launchWithExternalApp(url))
|
||||
return;
|
||||
|
||||
const QHelpEngineCore &engine = HelpManager::instance().helpEngineCore();
|
||||
const QUrl &resolvedUrl = engine.findFile(url);
|
||||
QUrl resolvedUrl;
|
||||
if (url.scheme() == QLatin1String("http"))
|
||||
resolvedUrl = url;
|
||||
|
||||
if (!resolvedUrl.isValid()) {
|
||||
const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
|
||||
resolvedUrl = engine.findFile(url);
|
||||
}
|
||||
|
||||
if (resolvedUrl.isValid()) {
|
||||
QTextBrowser::setSource(resolvedUrl);
|
||||
emit loadFinished(true);
|
||||
@@ -345,7 +352,7 @@ QVariant HelpViewer::loadResource(int type, const QUrl &name)
|
||||
{
|
||||
QByteArray ba;
|
||||
if (type < 4) {
|
||||
const QHelpEngineCore &engine = HelpManager::instance().helpEngineCore();
|
||||
const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
|
||||
ba = engine.fileData(name);
|
||||
if (name.toString().endsWith(QLatin1String(".svg"), Qt::CaseInsensitive)) {
|
||||
QImage image;
|
||||
|
@@ -121,9 +121,14 @@ HelpNetworkAccessManager::HelpNetworkAccessManager(QObject *parent)
|
||||
{
|
||||
}
|
||||
|
||||
QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/,
|
||||
const QNetworkRequest &request, QIODevice* /*outgoingData*/)
|
||||
QNetworkReply *HelpNetworkAccessManager::createRequest(Operation op,
|
||||
const QNetworkRequest &request, QIODevice* outgoingData)
|
||||
{
|
||||
if (!HelpViewer::isLocalUrl(request.url())
|
||||
&& request.url().scheme() == QLatin1String("http")) {
|
||||
return QNetworkAccessManager::createRequest(op, request, outgoingData);
|
||||
}
|
||||
|
||||
QString url = request.url().toString();
|
||||
const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
|
||||
// TODO: For some reason the url to load is already wrong (passed from webkit)
|
||||
|
@@ -36,8 +36,25 @@ InvalidIdException::InvalidIdException(int line,
|
||||
const QString &function,
|
||||
const QString &file,
|
||||
const QString &id,
|
||||
bool duplicate) :
|
||||
InvalidArgumentException(line, function, file, "id"), m_id(id), m_duplicate(duplicate)
|
||||
Reason reason) :
|
||||
InvalidArgumentException(line, function, file, "id"),
|
||||
m_id(id)
|
||||
{
|
||||
if (reason == InvalidCharacters) {
|
||||
m_description = QCoreApplication::translate("InvalidIdException", "Only alphanumeric characters and underscore allowed.\nIds must begin with a lowercase letter.");
|
||||
} else {
|
||||
m_description = QCoreApplication::translate("InvalidIdException", "Ids have to be unique.");
|
||||
}
|
||||
}
|
||||
|
||||
InvalidIdException::InvalidIdException(int line,
|
||||
const QString &function,
|
||||
const QString &file,
|
||||
const QString &id,
|
||||
const QString &description) :
|
||||
InvalidArgumentException(line, function, file, "id"),
|
||||
m_id(id),
|
||||
m_description(description)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -48,22 +65,7 @@ QString InvalidIdException::type() const
|
||||
|
||||
QString InvalidIdException::description() const
|
||||
{
|
||||
if (m_duplicate)
|
||||
return duplicateErrorMessage(m_id);
|
||||
|
||||
return invalidErrorMessage(m_id);
|
||||
}
|
||||
|
||||
QString InvalidIdException::duplicateErrorMessage(const QString &id)
|
||||
{
|
||||
return QCoreApplication::translate("InvalidIdException", "Ids have to be unique: ") + id;
|
||||
}
|
||||
|
||||
QString InvalidIdException::invalidErrorMessage(const QString &id)
|
||||
{
|
||||
return QCoreApplication::translate("InvalidIdException", "Invalid Id: ") +
|
||||
id + QCoreApplication::translate("InvalidIdException",
|
||||
"\nOnly alphanumeric characters and underscore allowed.\nIds must begin with a lowercase letter.");
|
||||
return QCoreApplication::translate("InvalidIdException", "Invalid Id: %1\n%2").arg(m_id, m_description);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -37,22 +37,26 @@ namespace QmlDesigner {
|
||||
class CORESHARED_EXPORT InvalidIdException : public InvalidArgumentException
|
||||
{
|
||||
public:
|
||||
enum Reason { InvalidCharacters, DuplicateId };
|
||||
|
||||
InvalidIdException(int line,
|
||||
const QString &function,
|
||||
const QString &file,
|
||||
const QString &id,
|
||||
bool duplicate = false);
|
||||
Reason reason);
|
||||
|
||||
InvalidIdException(int line,
|
||||
const QString &function,
|
||||
const QString &file,
|
||||
const QString &id,
|
||||
const QString &description);
|
||||
|
||||
QString type() const;
|
||||
QString description() const;
|
||||
|
||||
static QString duplicateErrorMessage(const QString &id);
|
||||
static QString invalidErrorMessage(const QString &id);
|
||||
|
||||
private:
|
||||
QString m_id;
|
||||
bool m_duplicate;
|
||||
|
||||
QString m_description;
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -65,6 +65,7 @@
|
||||
#include "rewritertransaction.h"
|
||||
#include "rewriterview.h"
|
||||
#include "rewritingexception.h"
|
||||
#include "invalididexception.h"
|
||||
|
||||
/*!
|
||||
\defgroup CoreModel
|
||||
@@ -259,7 +260,12 @@ void ModelPrivate::changeNodeId(const InternalNode::Pointer& internalNodePointer
|
||||
m_idNodeHash.remove(oldId);
|
||||
if (!id.isEmpty())
|
||||
m_idNodeHash.insert(id, internalNodePointer);
|
||||
|
||||
try {
|
||||
notifyNodeIdChanged(internalNodePointer, id, oldId);
|
||||
} catch (RewritingException &e) {
|
||||
throw InvalidIdException(__LINE__, __FUNCTION__, __FILE__, id, e.description());
|
||||
}
|
||||
}
|
||||
|
||||
void ModelPrivate::checkPropertyName(const QString &propertyName)
|
||||
|
@@ -180,13 +180,13 @@ void ModelNode::setId(const QString& id)
|
||||
}
|
||||
|
||||
if (!isValidId(id))
|
||||
throw InvalidIdException(__LINE__, __FUNCTION__, __FILE__, id);
|
||||
throw InvalidIdException(__LINE__, __FUNCTION__, __FILE__, id, InvalidIdException::InvalidCharacters);
|
||||
|
||||
if (id == ModelNode::id())
|
||||
return;
|
||||
|
||||
if (view()->hasId(id))
|
||||
throw InvalidIdException(__LINE__, __FUNCTION__, __FILE__, id, true);
|
||||
throw InvalidIdException(__LINE__, __FUNCTION__, __FILE__, id, InvalidIdException::DuplicateId);
|
||||
|
||||
m_model.data()->m_d->changeNodeId(internalNode(), id);
|
||||
}
|
||||
|
@@ -577,7 +577,7 @@ bool CodeCompletion::maybeTriggersCompletion(TextEditor::ITextEditable *editor)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CodeCompletion::isDelimiter(const QChar &ch) const
|
||||
bool CodeCompletion::isDelimiter(QChar ch) const
|
||||
{
|
||||
switch (ch.unicode()) {
|
||||
case '{':
|
||||
|
@@ -78,7 +78,7 @@ private:
|
||||
void updateSnippets();
|
||||
|
||||
bool maybeTriggersCompletion(TextEditor::ITextEditable *editor);
|
||||
bool isDelimiter(const QChar &ch) const;
|
||||
bool isDelimiter(QChar ch) const;
|
||||
|
||||
void addCompletions(const QHash<QString, const QmlJS::Interpreter::Value *> &newCompletions,
|
||||
const QIcon &icon, int relevance);
|
||||
|
@@ -82,9 +82,7 @@ using namespace QmlJS;
|
||||
using namespace QmlJS::AST;
|
||||
using namespace QmlJSEditor::Internal;
|
||||
|
||||
namespace {
|
||||
|
||||
int blockBraceDepth(const QTextBlock &block)
|
||||
static int blockBraceDepth(const QTextBlock &block)
|
||||
{
|
||||
int state = block.userState();
|
||||
if (state == -1)
|
||||
@@ -93,7 +91,7 @@ int blockBraceDepth(const QTextBlock &block)
|
||||
return (state >> 8) & 0xFF;
|
||||
}
|
||||
|
||||
int blockStartState(const QTextBlock &block)
|
||||
static int blockStartState(const QTextBlock &block)
|
||||
{
|
||||
int state = block.userState();
|
||||
|
||||
@@ -103,7 +101,7 @@ int blockStartState(const QTextBlock &block)
|
||||
return state & 0xff;
|
||||
}
|
||||
|
||||
bool shouldInsertMatchingText(const QChar &lookAhead)
|
||||
static bool shouldInsertMatchingText(QChar lookAhead)
|
||||
{
|
||||
switch (lookAhead.unicode()) {
|
||||
case '{': case '}':
|
||||
@@ -120,12 +118,14 @@ bool shouldInsertMatchingText(const QChar &lookAhead)
|
||||
} // switch
|
||||
}
|
||||
|
||||
bool shouldInsertMatchingText(const QTextCursor &tc)
|
||||
static bool shouldInsertMatchingText(const QTextCursor &tc)
|
||||
{
|
||||
QTextDocument *doc = tc.document();
|
||||
return shouldInsertMatchingText(doc->characterAt(tc.selectionEnd()));
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class FindIdDeclarations: protected Visitor
|
||||
{
|
||||
public:
|
||||
@@ -945,7 +945,7 @@ QString QmlJSTextEditor::wordUnderCursor() const
|
||||
return word;
|
||||
}
|
||||
|
||||
bool QmlJSTextEditor::isElectricCharacter(const QChar &ch) const
|
||||
bool QmlJSTextEditor::isElectricCharacter(QChar ch) const
|
||||
{
|
||||
if (ch == QLatin1Char('}')
|
||||
|| ch == QLatin1Char(']')
|
||||
@@ -1184,7 +1184,7 @@ bool QmlJSTextEditor::isInComment(const QTextCursor &) const
|
||||
return false;
|
||||
}
|
||||
|
||||
QString QmlJSTextEditor::insertMatchingBrace(const QTextCursor &tc, const QString &text, const QChar &, int *skippedChars) const
|
||||
QString QmlJSTextEditor::insertMatchingBrace(const QTextCursor &tc, const QString &text, QChar, int *skippedChars) const
|
||||
{
|
||||
if (text.length() != 1)
|
||||
return QString();
|
||||
|
@@ -249,11 +249,11 @@ protected:
|
||||
//// brace matching
|
||||
virtual bool contextAllowsAutoParentheses(const QTextCursor &cursor, const QString &textToInsert = QString()) const;
|
||||
virtual bool isInComment(const QTextCursor &cursor) const;
|
||||
virtual QString insertMatchingBrace(const QTextCursor &tc, const QString &text, const QChar &la, int *skippedChars) const;
|
||||
virtual QString insertMatchingBrace(const QTextCursor &tc, const QString &text, QChar la, int *skippedChars) const;
|
||||
virtual QString insertParagraphSeparator(const QTextCursor &tc) const;
|
||||
|
||||
private:
|
||||
virtual bool isElectricCharacter(const QChar &ch) const;
|
||||
virtual bool isElectricCharacter(QChar ch) const;
|
||||
virtual void indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar);
|
||||
bool isClosingBrace(const QList<QmlJS::Token> &tokens) const;
|
||||
|
||||
|
@@ -3774,7 +3774,7 @@ void BaseTextEditor::zoomReset()
|
||||
emit requestZoomReset();
|
||||
}
|
||||
|
||||
bool BaseTextEditor::isElectricCharacter(const QChar &) const
|
||||
bool BaseTextEditor::isElectricCharacter(QChar) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -3831,7 +3831,7 @@ bool BaseTextEditor::isInComment(const QTextCursor &cursor) const
|
||||
}
|
||||
|
||||
QString BaseTextEditor::insertMatchingBrace(const QTextCursor &tc, const QString &text,
|
||||
const QChar &la, int *skippedChars) const
|
||||
QChar la, int *skippedChars) const
|
||||
{
|
||||
Q_UNUSED(tc);
|
||||
Q_UNUSED(text);
|
||||
|
@@ -389,7 +389,7 @@ protected:
|
||||
|
||||
public:
|
||||
// Returns true if key triggers an indent.
|
||||
virtual bool isElectricCharacter(const QChar &ch) const;
|
||||
virtual bool isElectricCharacter(QChar ch) const;
|
||||
|
||||
void indentInsertedText(const QTextCursor &tc);
|
||||
|
||||
@@ -411,7 +411,7 @@ public:
|
||||
// Returns true if the cursor is inside a comment.
|
||||
virtual bool isInComment(const QTextCursor &cursor) const;
|
||||
|
||||
virtual QString insertMatchingBrace(const QTextCursor &tc, const QString &text, const QChar &la, int *skippedChars) const;
|
||||
virtual QString insertMatchingBrace(const QTextCursor &tc, const QString &text, QChar la, int *skippedChars) const;
|
||||
|
||||
// Returns the text that needs to be inserted
|
||||
virtual QString insertParagraphSeparator(const QTextCursor &tc) const;
|
||||
|
@@ -176,7 +176,7 @@ QString IoUtils::shellQuote(const QString &arg)
|
||||
|
||||
#else // Q_OS_WIN
|
||||
|
||||
inline static bool isSpecial(const QChar &cUnicode)
|
||||
inline static bool isSpecial(QChar cUnicode)
|
||||
{
|
||||
static const uchar iqm[] = {
|
||||
0xff, 0xff, 0xff, 0xff, 0xdf, 0x07, 0x00, 0xd8,
|
||||
|
Reference in New Issue
Block a user