Merge commit 'origin/0.9.1-beta'

This commit is contained in:
con
2008-12-12 11:09:05 +01:00
71 changed files with 1335 additions and 565 deletions

View File

@@ -122,6 +122,7 @@ int qtGhVersion = QT_VERSION;
# include <QImage>
#endif
#include <list>
#include <string>
#include <vector>
@@ -406,12 +407,13 @@ struct QDumper
QDumper &operator<<(unsigned int i);
QDumper &operator<<(const void *p);
QDumper &operator<<(qulonglong c);
void put(char c);
void addCommaIfNeeded();
void putBase64Encoded(const char *buf, int n);
QDumper &operator<<(const char *str);
QDumper &operator<<(const QByteArray &ba);
QDumper &operator<<(const QString &str);
void put(char c);
void addCommaIfNeeded();
void putBase64Encoded(const char *buf, int n);
void putEllipsis();
void disarm();
void beginHash(); // start of data hash output
@@ -657,6 +659,11 @@ void QDumper::endHash()
put('}');
}
void QDumper::putEllipsis()
{
addCommaIfNeeded();
*this << "{name=\"<incomplete>\",value=\"\",type=\"" << innertype << "\"}";
}
//
// Some helpers to keep the dumper code short
@@ -815,6 +822,27 @@ static void qDumpInnerValue(QDumper &d, const char *type, const void *addr)
}
static void qDumpInnerValueOrPointer(QDumper &d,
const char *type, const char *strippedtype, const void *addr)
{
if (strippedtype) {
if (deref(addr)) {
P(d, "addr", deref(addr));
P(d, "type", strippedtype);
qDumpInnerValueHelper(d, strippedtype, deref(addr));
} else {
P(d, "addr", addr);
P(d, "type", strippedtype);
P(d, "value", "<null>");
P(d, "numchild", "0");
}
} else {
P(d, "addr", addr);
P(d, "type", type);
qDumpInnerValueHelper(d, type, addr);
}
}
//////////////////////////////////////////////////////////////////////////////
static void qDumpQByteArray(QDumper &d)
@@ -1213,7 +1241,6 @@ static void qDumpQList(QDumper &d)
&& isMovableType(d.innertype);
P(d, "internal", (int)isInternal);
P(d, "childtype", d.innertype);
if (n > 1000)
n = 1000;
@@ -1244,11 +1271,8 @@ static void qDumpQList(QDumper &d)
}
d.endHash();
}
if (n < nn) {
d.beginHash();
P(d, "value", "<incomplete>");
d.endHash();
}
if (n < nn)
d.putEllipsis();
d << "]";
}
d.disarm();
@@ -1490,7 +1514,6 @@ static void qDumpQObject(QDumper &d)
d.beginHash();
P(d, "name", "methods");
P(d, "exp", "*(class '"NS"QObject'*)" << d.data);
P(d, "type", NS"QObjectMethodList");
P(d, "value", "<" << mo->methodCount() << " items>");
P(d, "numchild", mo->methodCount());
d.endHash();
@@ -1876,11 +1899,7 @@ static void qDumpQSet(QDumper &d)
d.endHash();
++i;
if (i > 10000) {
d.beginHash();
P(d, "name", "Warning:");
P(d, "value", "<incomplete>");
P(d, "type", "");
d.endHash();
d.putEllipsis();
break;
}
}
@@ -1935,13 +1954,8 @@ static void qDumpQStringList(QDumper &d)
P(d, "valueencoded", "1");
d.endHash();
}
if (n < list.size()) {
d.beginHash();
P(d, "name", "Warning:");
P(d, "value", "<incomplete>");
P(d, "type", "");
d.endHash();
}
if (n < list.size())
d.putEllipsis();
d << "]";
}
d.disarm();
@@ -2065,37 +2079,68 @@ static void qDumpQVector(QDumper &d)
P(d, "valuedisabled", "true");
P(d, "numchild", n);
if (d.dumpChildren) {
bool innerTypeIsPointer = isPointerType(d.innertype);
QByteArray strippedInnerType = stripPointerType(d.innertype);
const char *stripped =
isPointerType(d.innertype) ? strippedInnerType.data() : 0;
if (n > 1000)
n = 1000;
d << ",children=[";
for (int i = 0; i != n; ++i) {
d.beginHash();
P(d, "name", "[" << i << "]");
const void *p = addOffset(v, i * innersize + typeddatasize);
if (innerTypeIsPointer) {
if (deref(p)) {
//P(d, "value","@" << p);
qDumpInnerValue(d, strippedInnerType.data(), deref(p));
} else {
P(d, "type", d.innertype);
P(d, "value", "<null>");
P(d, "numchild", "0");
}
} else {
qDumpInnerValue(d, d.innertype, p);
}
qDumpInnerValueOrPointer(d, d.innertype, stripped,
addOffset(v, i * innersize + typeddatasize));
d.endHash();
}
if (n < nn) {
if (n < nn)
d.putEllipsis();
d << "]";
}
d.disarm();
}
static void qDumpStdList(QDumper &d)
{
const std::list<int> &list = *reinterpret_cast<const std::list<int> *>(d.data);
const void *p = d.data;
qCheckAccess(p);
p = deref(p);
qCheckAccess(p);
p = deref(p);
qCheckAccess(p);
p = deref(addOffset(d.data, sizeof(void*)));
qCheckAccess(p);
p = deref(addOffset(p, sizeof(void*)));
qCheckAccess(p);
p = deref(addOffset(p, sizeof(void*)));
qCheckAccess(p);
int nn = 0;
std::list<int>::const_iterator it = list.begin();
for (; nn < 101 && it != list.end(); ++nn, ++it)
qCheckAccess(it.operator->());
if (nn > 100)
P(d, "value", "<more than 100 items>");
else
P(d, "value", "<" << nn << " items>");
P(d, "numchild", nn);
P(d, "valuedisabled", "true");
if (d.dumpChildren) {
QByteArray strippedInnerType = stripPointerType(d.innertype);
const char *stripped =
isPointerType(d.innertype) ? strippedInnerType.data() : 0;
d << ",children=[";
it = list.begin();
for (int i = 0; i < 1000 && it != list.end(); ++i, ++it) {
d.beginHash();
P(d, "name", "[...]");
P(d, "value", "<incomplete>");
P(d, "type", d.innertype);
P(d, "name", "[" << i << "]");
qDumpInnerValueOrPointer(d, d.innertype, stripped, it.operator->());
d.endHash();
}
if (it != list.end())
d.putEllipsis();
d << "]";
}
d.disarm();
@@ -2167,37 +2212,21 @@ static void qDumpStdVector(QDumper &d)
P(d, "numchild", n);
if (d.dumpChildren) {
unsigned innersize = d.extraInt[0];
bool innerTypeIsPointer = isPointerType(d.innertype);
QByteArray strippedInnerType = stripPointerType(d.innertype);
const char *stripped =
isPointerType(d.innertype) ? strippedInnerType.data() : 0;
if (n > 1000)
n = 1000;
d << ",children=[";
for (int i = 0; i != n; ++i) {
d.beginHash();
P(d, "name", "[" << i << "]");
const void *p = addOffset(v->start, i * innersize);
if (innerTypeIsPointer) {
if (deref(p)) {
//P(d, "value","@" << p);
qDumpInnerValue(d, strippedInnerType.data(), deref(p));
} else {
P(d, "type", d.innertype);
P(d, "value", "<null>");
P(d, "numchild", "0");
}
} else {
qDumpInnerValue(d, d.innertype, p);
}
d.endHash();
}
if (n < nn) {
d.beginHash();
P(d, "name", "[...]");
P(d, "value", "<incomplete>");
P(d, "type", d.innertype);
qDumpInnerValueOrPointer(d, d.innertype, stripped,
addOffset(v->start, i * innersize));
d.endHash();
}
if (n < nn)
d.putEllipsis();
d << "]";
}
d.disarm();
@@ -2325,6 +2354,8 @@ static void handleProtocolVersion2and3(QDumper & d)
qDumpStdVector(d);
else if (isEqual(type, "std::vector::bool"))
qDumpStdVectorBool(d);
else if (isEqual(type, "std::list"))
qDumpStdList(d);
else if (isEqual(type, "string"))
qDumpStdString(d);
else if (isEqual(type, "std::string"))

246
doc/coding-style.qdoc Normal file
View File

@@ -0,0 +1,246 @@
/*!
\contentpage{index.html}{Qt Creator}
\page coding-style.html
\title Qt Creator Coding Rules
THIS IS PRELIMINARY.
\section1 Introduction
The aim of this section is to serve as a guide for the developers, to aid us
to build understandable and maintainable code, to create less confusion and
surprises when working on Qt Creator.
As usual: Rules are not set in stone. If there's a good reason to break one,
do it, preferably after making sure that there are others agreeing.
This document is incomplete.
In general, if you want to contribute to the main source, we expect at least
that you:
\list 1
\o The most important rule first: KISS (keep it simple ...): always
use a simple implementation in favor of a more complicated one.
This eases maintenance a lot.
\o Write good C++ code: Readable, well commented when necessary,
and taking advantage of the OO model. Follow the \l{Formatting} guidelines.
There are also certain \l{Code Constructs} that we try to follow.
\o Adapt the code to the structures already existing in Qt Creator, or in
the case that you have better ideas, discuss them with other developers
before writing the code.
\o Take advantage of Qt. Don't re-invent the wheel. Think about what parts
of your code are generic enough that they might be incorporated into
Qt proper.
\o Document interfaces. Right now we use qdoc, but changing to doxygen
is being considered.
\endlist
\section1 Submitting Code
It is implicitly understood that all patches contributed to The Qt Creator
Project are made under under the Gnu General Public License, version 2 or later
and
If you have a problem with that, don't contribute code.
Also please don't just pop up out of the blue with a huge patch (or
small) that changes something substantial in Qt Creator. Always discuss your
ideas with the other developers on mailing list first.
When you create the patch, please use git or use "diff -up" since we find
that a lot easier to read than the other diff formats. Also please do not
send patches that implements or fixes several different things; several
patches is a much better option.
We also require you to provide a commit message entry with every patch,
this describes in detail what the patch is doing.
\section1 Code Constructs
We have several guidelines on code constructs, some of these exist to
make the code faster, others to make the code clearer. Yet others
exist to allow us to take advantage of the strong type checking
in C++.
\list 1
\o Declaration of variables should wait as long as possible. The rule
is: "Don't declare it until you need it." In C++ there are a lot of
user defined types, and these can very often be expensive to
initialize. This rule connects to the next rule too.
\o Make the scope of a variable as small as possible.
\o Prefer preincrement to postincrement whenever possible.
Preincrement has potential of being faster than postincrement. Just
think about the obvious implementations of pre/post-increment. This
rule applies to decrement too.
\code
++T;
--U;
-NOT-
T++; // not used in Qt Creator
U--; // not used in Qt Creator
\endcode
\o Try to minimize evaluation of the same code over and over. This is
aimed especially at loops.
\code
Container::iterator end = large.end();
for (Container::iterator it = large.begin(); it != end; ++it) {
...;
}
-NOT-
for (Container::iterator it = large.begin();
it != large.end(); ++it) {
...;
}
\endcode
\section1 Formatting
\section2 Declarations
Only one declaration on each line.
\code
int a;
int b;
-NOT-
int a, b; // not used in Qt Creator
\endcode
This is especially important when initialization is done at the same
time.
\code
QString a = "Joe";
QString b = "Foo";
-NOT-
QString a = "Joe", b = "Foo"; // not used in Qt Creator
\endcode
[Note that 'QString a = "Joe"' is formally calling a copy constructor
on a temporary constructed from a string literal and therefore has the
potential of being more expensive then direct construction by
'QString a("joe")'. However the compiler is allowed to elide the copy
(even if it had side effects), and modern compilers typically do so.
Given these equal costs, Qt Creator code favours the '=' idiom as it is in
line with the traditional C-style initialization, _and_ cannot be
mistaken as function declaration, _and_ reduces the level of nested
parantheses in more initializations.]
\section2 Pointers and references
\code
char *p = "flop";
char &c = *p;
-NOT-
char* p = "flop"; // not used in Qt Creator
char & c = *p; // not used in Qt Creator
\endcode
This is simply in line with the official Qt guide lines.
Also note that we will have:
\code
const char *p;
-NOT-
char const * p; // not used in Qt Creator
\endcode
Using a plain 0 for Null pointer constants is always correct and least effort
to type. So:
\code
void *p = 0;
-NOT-
void *p = NULL; // not used in Qt Creator
-NOT-
void *p = '\0'; // not used in Qt Creator
-NOT-
void *p = 42 - 7 * 6; // also not used in Qt Creator
\endcode
Note: As an exception, imported third party code as well as code
interfacing the "native" APIs (src/support/os_*) can use NULL.
\section2 Operator names and parentheses
\code
operator==(type)
-NOT-
operator == (type) // not used in Qt Creator
\endcode
The == is part of the function name, separating it makes the
declaration look like an expression.
\section2 Function names and parentheses
\code
void mangle()
-NOT-
void mangle () // not used in Qt Creator
\endcode
\section2 Naming rules
Simply follow the style of Qt proper. As examples:
\list
\o Use descriptive but simple and short names. Do not abbreviate.
\o Class names are capitalized, and function names lowercased.
Enums are named like Classes, values are in lower-case.
\endlist
\section2 Formatting
Adapt the formatting of your code to the one used in the
other parts of Qt Creator. In case there is different formatting for
the same construct, use the one used more often.
\section2 Declarations
- Use this order for the access sections of your class: public,
protected, private. The public section is interesting for every
user of the class. The private section is only of interest for the
implementors of the class (you). [Obviously not true since this is
for developers, and we do not want one developer only to be able to
read and understand the implementation of class internals. Lgb]
- Avoid declaring global objects in the declaration file of the class.
If the same variable is used for all objects, use a static member.
- Avoid global or static variables.
\section2 File headers
If you create a new file, the top of the file should include a
header comment equal to the one found in other source files of Qt Creator.
\section2 Documentation
The documentation is generated from source and header files.
You document for the other developers, not for yourself.
In the header you should document interfaces, i.e. what the function does,
not the implementation.
In the .cpp files you document the implementation if the implementation
in non-obvious.
*/

View File

@@ -1208,4 +1208,141 @@ int Lexer::classify(const char *s, int n, bool q) {
} // switch
}
static inline int classifyOperator2(const char *s) {
if (s[0] == 'o') {
if (s[1] == 'r') {
return T_OR;
}
}
return T_IDENTIFIER;
}
static inline int classifyOperator3(const char *s) {
if (s[0] == 'a') {
if (s[1] == 'n') {
if (s[2] == 'd') {
return T_AND;
}
}
}
else if (s[0] == 'n') {
if (s[1] == 'o') {
if (s[2] == 't') {
return T_NOT;
}
}
}
else if (s[0] == 'x') {
if (s[1] == 'o') {
if (s[2] == 'r') {
return T_XOR;
}
}
}
return T_IDENTIFIER;
}
static inline int classifyOperator5(const char *s) {
if (s[0] == 'b') {
if (s[1] == 'i') {
if (s[2] == 't') {
if (s[3] == 'o') {
if (s[4] == 'r') {
return T_BITOR;
}
}
}
}
}
else if (s[0] == 'c') {
if (s[1] == 'o') {
if (s[2] == 'm') {
if (s[3] == 'p') {
if (s[4] == 'l') {
return T_COMPL;
}
}
}
}
}
else if (s[0] == 'o') {
if (s[1] == 'r') {
if (s[2] == '_') {
if (s[3] == 'e') {
if (s[4] == 'q') {
return T_OR_EQ;
}
}
}
}
}
return T_IDENTIFIER;
}
static inline int classifyOperator6(const char *s) {
if (s[0] == 'a') {
if (s[1] == 'n') {
if (s[2] == 'd') {
if (s[3] == '_') {
if (s[4] == 'e') {
if (s[5] == 'q') {
return T_AND_EQ;
}
}
}
}
}
}
else if (s[0] == 'b') {
if (s[1] == 'i') {
if (s[2] == 't') {
if (s[3] == 'a') {
if (s[4] == 'n') {
if (s[5] == 'd') {
return T_BITAND;
}
}
}
}
}
}
else if (s[0] == 'n') {
if (s[1] == 'o') {
if (s[2] == 't') {
if (s[3] == '_') {
if (s[4] == 'e') {
if (s[5] == 'q') {
return T_NOT_EQ;
}
}
}
}
}
}
else if (s[0] == 'x') {
if (s[1] == 'o') {
if (s[2] == 'r') {
if (s[3] == '_') {
if (s[4] == 'e') {
if (s[5] == 'q') {
return T_XOR_EQ;
}
}
}
}
}
}
return T_IDENTIFIER;
}
int Lexer::classifyOperator(const char *s, int n) {
switch (n) {
case 2: return classifyOperator2(s);
case 3: return classifyOperator3(s);
case 5: return classifyOperator5(s);
case 6: return classifyOperator6(s);
default: return T_IDENTIFIER;
} // switch
}
CPLUSPLUS_END_NAMESPACE

View File

@@ -589,8 +589,13 @@ void Lexer::scan_helper(Token *tok)
tok->kind = classify(yytext, yylen, _qtMocRunEnabled);
else
tok->kind = T_IDENTIFIER;
if (tok->kind == T_IDENTIFIER && control())
if (tok->kind == T_IDENTIFIER) {
tok->kind = classifyOperator(yytext, yylen);
if (control())
tok->identifier = control()->findOrInsertIdentifier(yytext, yylen);
}
break;
} else if (std::isdigit(ch)) {
const char *yytext = _currentChar - 1;

View File

@@ -112,6 +112,7 @@ private:
void scan_helper(Token *tok);
void setSource(const char *firstChar, const char *lastChar);
static int classify(const char *string, int length, bool q);
static int classifyOperator(const char *string, int length);
inline void yyinp()
{

View File

@@ -209,7 +209,19 @@ enum Kind {
T_LAST_KEYWORD = T_SLOTS,
// ### aliases
// aliases
T_OR = T_PIPE_PIPE,
T_AND = T_AMPER_AMPER,
T_NOT = T_EXCLAIM,
T_XOR = T_CARET,
T_BITOR = T_PIPE,
T_COMPL = T_TILDE,
T_OR_EQ = T_PIPE_EQUAL,
T_AND_EQ = T_AMPER_EQUAL,
T_BITAND = T_AMPER,
T_NOT_EQ = T_EXCLAIM_EQUAL,
T_XOR_EQ = T_CARET_EQUAL,
T___ASM = T_ASM,
T___ASM__ = T_ASM,

View File

@@ -69,7 +69,7 @@ static const char *HELP_OPTION4 = "--help";
static const char *VERSION_OPTION = "-version";
static const char *CLIENT_OPTION = "-client";
typedef QSet<ExtensionSystem::PluginSpec *> PluginSpecSet;
typedef QList<ExtensionSystem::PluginSpec *> PluginSpecSet;
// Helpers for displaying messages. Note that there is no console on Windows.
#ifdef Q_WS_WIN

View File

@@ -33,8 +33,6 @@
#include "CppDocument.h"
#include <utils/qtcassert.h>
#include <Control.h>
#include <TranslationUnit.h>
#include <DiagnosticClient.h>
@@ -133,12 +131,16 @@ QString Document::fileName() const
QStringList Document::includedFiles() const
{
return _includedFiles;
QStringList files;
foreach (const Include &i, _includes)
files.append(i.fileName());
files.removeDuplicates();
return files;
}
void Document::addIncludeFile(const QString &fileName)
void Document::addIncludeFile(const QString &fileName, unsigned line)
{
_includedFiles.append(fileName);
_includes.append(Include(fileName, line));
}
void Document::appendMacro(const Macro &macro)
@@ -273,7 +275,7 @@ bool Document::parse(ParseMode mode)
void Document::check()
{
QTC_ASSERT(!_globalNamespace, return);
Q_ASSERT(!_globalNamespace);
Semantic semantic(_control);

View File

@@ -40,7 +40,7 @@
#include <QByteArray>
#include <QList>
#include <QSet>
#include <QMap>
#include <QSharedPointer>
#include <QString>
#include <QStringList>
@@ -65,7 +65,7 @@ public:
QString fileName() const;
QStringList includedFiles() const;
void addIncludeFile(const QString &fileName);
void addIncludeFile(const QString &fileName, unsigned line);
void appendMacro(const Macro &macro);
void addMacroUse(const Macro &macro, unsigned offset, unsigned length);
@@ -181,6 +181,22 @@ public:
{ return pos >= _begin && pos < _end; }
};
class Include {
QString _fileName;
unsigned _line;
public:
Include(const QString &fileName, unsigned line)
: _fileName(fileName), _line(line)
{ }
QString fileName() const
{ return _fileName; }
unsigned line() const
{ return _line; }
};
class MacroUse: public Block {
Macro _macro;
@@ -196,6 +212,9 @@ public:
{ return _macro; }
};
QList<Include> includes() const
{ return _includes; }
QList<Block> skippedBlocks() const
{ return _skippedBlocks; }
@@ -207,16 +226,26 @@ private:
private:
QString _fileName;
QStringList _includedFiles;
Control *_control;
TranslationUnit *_translationUnit;
Namespace *_globalNamespace;
QList<DiagnosticMessage> _diagnosticMessages;
QList<Include> _includes;
QList<Macro> _definedMacros;
QList<Block> _skippedBlocks;
QList<MacroUse> _macroUses;
};
class CPLUSPLUS_EXPORT Snapshot: public QMap<QString, Document::Ptr>
{
public:
Snapshot()
{ }
~Snapshot()
{ }
};
} // end of namespace CPlusPlus
#endif // CPPDOCUMENT_H

View File

@@ -77,7 +77,7 @@ LookupContext::LookupContext(Control *control)
LookupContext::LookupContext(Symbol *symbol,
Document::Ptr expressionDocument,
Document::Ptr thisDocument,
const QMap<QString, Document::Ptr> &documents)
const Snapshot &documents)
: _symbol(symbol),
_expressionDocument(expressionDocument),
_thisDocument(thisDocument),

View File

@@ -57,7 +57,7 @@ public:
LookupContext(Symbol *symbol,
Document::Ptr expressionDocument,
Document::Ptr thisDocument,
const QMap<QString, Document::Ptr> &documents);
const Snapshot &documents);
LookupContext(Symbol *symbol,
const LookupContext &context);
@@ -87,7 +87,7 @@ public:
QList<Symbol *> resolveClassOrNamespace(Name *name) const
{ return resolveClassOrNamespace(name, visibleScopes()); }
QMap<QString, Document::Ptr> documents() const
Snapshot snapshot() const
{ return _documents; }
enum ResolveMode {
@@ -140,7 +140,7 @@ private:
Document::Ptr _thisDocument;
// All documents.
QMap<QString, Document::Ptr> _documents;
Snapshot _documents;
// Visible scopes.
QList<Scope *> _visibleScopes;

View File

@@ -34,8 +34,6 @@
#include "OverviewModel.h"
#include "Overview.h"
#include <utils/qtcassert.h>
#include <Scope.h>
#include <Semantic.h>
#include <Literals.h>
@@ -83,13 +81,13 @@ QModelIndex OverviewModel::index(int row, int column, const QModelIndex &parent)
return createIndex(row, column, symbol);
} else {
Symbol *parentSymbol = static_cast<Symbol *>(parent.internalPointer());
QTC_ASSERT(parentSymbol, return QModelIndex());
Q_ASSERT(parentSymbol);
ScopedSymbol *scopedSymbol = parentSymbol->asScopedSymbol();
QTC_ASSERT(scopedSymbol, return QModelIndex());
Q_ASSERT(scopedSymbol);
Scope *scope = scopedSymbol->members();
QTC_ASSERT(scope, return QModelIndex());
Q_ASSERT(scope);
return createIndex(row, 0, scope->symbolAt(row));
}
@@ -126,12 +124,12 @@ int OverviewModel::rowCount(const QModelIndex &parent) const
if (!parent.parent().isValid() && parent.row() == 0) // account for no symbol item
return 0;
Symbol *parentSymbol = static_cast<Symbol *>(parent.internalPointer());
QTC_ASSERT(parentSymbol, return 0);
Q_ASSERT(parentSymbol);
if (ScopedSymbol *scopedSymbol = parentSymbol->asScopedSymbol()) {
if (!scopedSymbol->isFunction()) {
Scope *parentScope = scopedSymbol->members();
QTC_ASSERT(parentScope, return 0);
Q_ASSERT(parentScope);
return parentScope->symbolCount();
}

View File

@@ -45,8 +45,6 @@
#include <TypeVisitor.h>
#include <NameVisitor.h>
#include <utils/qtcassert.h>
#include <QtCore/QList>
#include <QtCore/QtDebug>
@@ -100,7 +98,7 @@ protected:
// types
virtual void visit(PointerToMemberType * /*ty*/)
{
QTC_ASSERT(false, /**/);
Q_ASSERT(false);
}
virtual void visit(PointerType *ty)
@@ -152,32 +150,32 @@ protected:
{ /* nothing to do*/ }
virtual void visit(Namespace *)
{ QTC_ASSERT(false, /**/); }
{ Q_ASSERT(false); }
virtual void visit(Class *)
{ QTC_ASSERT(false, /**/); }
{ Q_ASSERT(false); }
virtual void visit(Enum *)
{ QTC_ASSERT(false, /**/); }
{ Q_ASSERT(false); }
// names
virtual void visit(NameId *)
{ QTC_ASSERT(false, /**/); }
{ Q_ASSERT(false); }
virtual void visit(TemplateNameId *)
{ QTC_ASSERT(false, /**/); }
{ Q_ASSERT(false); }
virtual void visit(DestructorNameId *)
{ QTC_ASSERT(false, /**/); }
{ Q_ASSERT(false); }
virtual void visit(OperatorNameId *)
{ QTC_ASSERT(false, /**/); }
{ Q_ASSERT(false); }
virtual void visit(ConversionNameId *)
{ QTC_ASSERT(false, /**/); }
{ Q_ASSERT(false); }
virtual void visit(QualifiedNameId *)
{ QTC_ASSERT(false, /**/); }
{ Q_ASSERT(false); }
};
} // end of anonymous namespace

View File

@@ -37,6 +37,7 @@
#include <TranslationUnit.h>
#include <cplusplus/LookupContext.h>
#include <cplusplus/ResolveExpression.h>
#include <cplusplus/pp.h>
using namespace CPlusPlus;
@@ -45,21 +46,25 @@ TypeOfExpression::TypeOfExpression():
{
}
void TypeOfExpression::setDocuments(const QMap<QString, Document::Ptr> &documents)
void TypeOfExpression::setSnapshot(const Snapshot &documents)
{
m_documents = documents;
m_snapshot = documents;
m_lookupContext = LookupContext();
}
QList<TypeOfExpression::Result> TypeOfExpression::operator()(const QString &expression,
Document::Ptr document,
Symbol *lastVisibleSymbol)
Symbol *lastVisibleSymbol,
PreprocessMode mode)
{
Document::Ptr expressionDoc = documentForExpression(expression);
QString code = expression;
if (mode == Preprocess)
code = preprocessedExpression(expression, m_snapshot, document);
Document::Ptr expressionDoc = documentForExpression(code);
m_ast = extractExpressionAST(expressionDoc);
m_lookupContext = LookupContext(lastVisibleSymbol, expressionDoc,
document, m_documents);
document, m_snapshot);
ResolveExpression resolveExpression(m_lookupContext);
return resolveExpression(m_ast);
@@ -97,3 +102,36 @@ Document::Ptr TypeOfExpression::documentForExpression(const QString &expression)
doc->parse(Document::ParseExpression);
return doc;
}
void TypeOfExpression::processEnvironment(Snapshot documents,
Document::Ptr doc, Environment *env,
QSet<QString> *processed) const
{
if (! doc)
return;
if (processed->contains(doc->fileName()))
return;
processed->insert(doc->fileName());
foreach (const Document::Include &incl, doc->includes()) {
processEnvironment(documents,
documents.value(incl.fileName()),
env, processed);
}
foreach (const Macro &macro, doc->definedMacros())
env->bind(macro);
}
QString TypeOfExpression::preprocessedExpression(const QString &expression,
Snapshot documents,
Document::Ptr thisDocument) const
{
Environment env;
QSet<QString> processed;
processEnvironment(documents, thisDocument,
&env, &processed);
const QByteArray code = expression.toUtf8();
pp preproc(0, env);
QByteArray preprocessedCode;
preproc("<expression>", code, &preprocessedCode);
return QString::fromUtf8(preprocessedCode);
}

View File

@@ -43,6 +43,9 @@
namespace CPlusPlus {
class Environment;
class Macro;
class CPLUSPLUS_EXPORT TypeOfExpression
{
public:
@@ -58,7 +61,12 @@ public:
* Also clears the lookup context, so can be used to make sure references
* to the documents previously used are removed.
*/
void setDocuments(const QMap<QString, Document::Ptr> &documents);
void setSnapshot(const Snapshot &documents);
enum PreprocessMode {
NoPreprocess,
Preprocess
};
/**
* Returns a list of possible fully specified types associated with the
@@ -73,7 +81,8 @@ public:
* @param lastVisibleSymbol The last visible symbol in the document.
*/
QList<Result> operator()(const QString &expression, Document::Ptr document,
Symbol *lastVisibleSymbol);
Symbol *lastVisibleSymbol,
PreprocessMode mode = NoPreprocess);
/**
* Returns the AST of the last evaluated expression.
@@ -91,7 +100,15 @@ private:
ExpressionAST *extractExpressionAST(Document::Ptr doc) const;
Document::Ptr documentForExpression(const QString &expression) const;
QMap<QString, Document::Ptr> m_documents;
void processEnvironment(CPlusPlus::Snapshot documents,
CPlusPlus::Document::Ptr doc, CPlusPlus::Environment *env,
QSet<QString> *processed) const;
QString preprocessedExpression(const QString &expression,
CPlusPlus::Snapshot documents,
CPlusPlus::Document::Ptr thisDocument) const;
Snapshot m_snapshot;
ExpressionAST *m_ast;
LookupContext m_lookupContext;
};

View File

@@ -63,7 +63,8 @@ public:
{ }
virtual void macroAdded(const Macro &macro) = 0;
virtual void sourceNeeded(QString &fileName, IncludeType mode) = 0; // ### FIX the signature.
virtual void sourceNeeded(QString &fileName, IncludeType mode,
unsigned line) = 0; // ### FIX the signature.
virtual void startExpandingMacro(unsigned offset,
const Macro &macro,

View File

@@ -818,7 +818,7 @@ void pp::processInclude(bool skipCurentPath,
QString fn = QString::fromUtf8(path.constData(), path.length());
if (client)
client->sourceNeeded(fn, Client::IncludeGlobal);
client->sourceNeeded(fn, Client::IncludeGlobal, firstToken->lineno);
} else if (tk->is(T_ANGLE_STRING_LITERAL) || tk->is(T_STRING_LITERAL)) {
const QByteArray spell = tokenSpell(*tk);
const char *beginOfPath = spell.constBegin();
@@ -831,7 +831,7 @@ void pp::processInclude(bool skipCurentPath,
QString fn = QString::fromUtf8(path.constData(), path.length());
if (client)
client->sourceNeeded(fn, Client::IncludeLocal);
client->sourceNeeded(fn, Client::IncludeLocal, firstToken->lineno);
}
}
}

View File

@@ -53,8 +53,6 @@
#include "pp-environment.h"
#include "pp.h"
#include <utils/qtcassert.h>
#include <cstring>
using namespace CPlusPlus;
@@ -93,7 +91,7 @@ Macro *Environment::macroAt(unsigned index) const
Macro *Environment::bind(const Macro &__macro)
{
QTC_ASSERT(! __macro.name.isEmpty(), return 0);
Q_ASSERT(! __macro.name.isEmpty());
Macro *m = new Macro (__macro);
m->hashcode = hash_code(m->name);

View File

@@ -129,7 +129,7 @@ bool OptionsParser::checkForNoLoadOption()
"The plugin '%1' does not exist.").arg(m_currentArg);
m_hasError = true;
} else {
m_pmPrivate->pluginSpecs.remove(spec);
m_pmPrivate->pluginSpecs.removeAll(spec);
delete spec;
m_isDependencyRefreshNeeded = true;
}

View File

@@ -48,7 +48,7 @@
#include <QTest>
#endif
typedef QSet<ExtensionSystem::PluginSpec *> PluginSpecSet;
typedef QList<ExtensionSystem::PluginSpec *> PluginSpecSet;
enum { debugLeaks = 0 };
@@ -162,6 +162,11 @@ enum { debugLeaks = 0 };
using namespace ExtensionSystem;
using namespace ExtensionSystem::Internal;
static bool lessThanByPluginName(const PluginSpec *one, const PluginSpec *two)
{
return one->name() < two->name();
}
PluginManager *PluginManager::m_instance = 0;
/*!
@@ -306,7 +311,7 @@ QStringList PluginManager::arguments() const
}
/*!
\fn QSet<PluginSpec *> PluginManager::plugins() const
\fn QList<PluginSpec *> PluginManager::plugins() const
List of all plugin specifications that have been found in the plugin search paths.
This list is valid directly after the setPluginPaths() call.
The plugin specifications contain the information from the plugins' xml description files
@@ -315,7 +320,7 @@ QStringList PluginManager::arguments() const
\sa setPluginPaths()
*/
QSet<PluginSpec *> PluginManager::plugins() const
QList<PluginSpec *> PluginManager::plugins() const
{
return d->pluginSpecs;
}
@@ -703,9 +708,11 @@ void PluginManagerPrivate::readPluginPaths()
foreach (const QString &specFile, specFiles) {
PluginSpec *spec = new PluginSpec;
spec->d->read(specFile);
pluginSpecs.insert(spec);
pluginSpecs.append(spec);
}
resolveDependencies();
// ensure deterministic plugin load order by sorting
qSort(pluginSpecs.begin(), pluginSpecs.end(), lessThanByPluginName);
emit q->pluginsChanged();
}

View File

@@ -101,7 +101,7 @@ public:
void loadPlugins();
QStringList pluginPaths() const;
void setPluginPaths(const QStringList &paths);
QSet<PluginSpec *> plugins() const;
QList<PluginSpec *> plugins() const;
void setFileExtension(const QString &extension);
QString fileExtension() const;

View File

@@ -66,7 +66,7 @@ public:
void loadPlugin(PluginSpec *spec, PluginSpec::State destState);
void resolveDependencies();
QSet<PluginSpec *> pluginSpecs;
QList<PluginSpec *> pluginSpecs;
QList<PluginSpec *> testSpecs;
QStringList pluginPaths;
QString extension;

View File

@@ -693,10 +693,10 @@ int PluginSpecPrivate::versionCompare(const QString &version1, const QString &ve
}
/*!
\fn bool PluginSpecPrivate::resolveDependencies(const QSet<PluginSpec *> &specs)
\fn bool PluginSpecPrivate::resolveDependencies(const QList<PluginSpec *> &specs)
\internal
*/
bool PluginSpecPrivate::resolveDependencies(const QSet<PluginSpec *> &specs)
bool PluginSpecPrivate::resolveDependencies(const QList<PluginSpec *> &specs)
{
if (hasError)
return false;

View File

@@ -56,7 +56,7 @@ public:
bool read(const QString &fileName);
bool provides(const QString &pluginName, const QString &version) const;
bool resolveDependencies(const QSet<PluginSpec *> &specs);
bool resolveDependencies(const QList<PluginSpec *> &specs);
bool loadLibrary();
bool initializePlugin();
bool initializeExtensions();

View File

@@ -46,11 +46,12 @@
#include <QtGui/QHBoxLayout>
#include <QtGui/QLineEdit>
#include <QtGui/QToolButton>
#include <QtGui/QPushButton>
namespace Core {
namespace Utils {
#ifdef Q_OS_OSX
#ifdef Q_OS_MAC
/*static*/ const char * const PathChooser::browseButtonLabel = "Choose...";
#else
/*static*/ const char * const PathChooser::browseButtonLabel = "Browse...";
@@ -112,7 +113,11 @@ PathChooser::PathChooser(QWidget *parent) :
hLayout->addWidget(m_d->m_lineEdit);
hLayout->setSizeConstraint(QLayout::SetMinimumSize);
#ifdef Q_OS_MAC
QPushButton *browseButton = new QPushButton;
#else
QToolButton *browseButton = new QToolButton;
#endif
browseButton->setText(tr(browseButtonLabel));
connect(browseButton, SIGNAL(clicked()), this, SLOT(slotBrowse()));

View File

@@ -201,15 +201,19 @@ void BookmarksPlugin::updateActions(int state)
void BookmarksPlugin::editorOpened(Core::IEditor *editor)
{
if (qobject_cast<ITextEditor *>(editor)) {
connect(editor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)),
this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*)));
}
}
void BookmarksPlugin::editorAboutToClose(Core::IEditor *editor)
{
if (qobject_cast<ITextEditor *>(editor)) {
disconnect(editor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)),
this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*)));
}
}
void BookmarksPlugin::requestContextMenu(TextEditor::ITextEditor *editor,
int lineNumber, QMenu *menu)

View File

@@ -186,6 +186,15 @@ MainWindow::MainWindow() :
QCoreApplication::setOrganizationName(QLatin1String("Nokia"));
QSettings::setDefaultFormat(QSettings::IniFormat);
QString baseName = qApp->style()->objectName();
if (baseName == "windows") {
// Sometimes we get the standard windows 95 style as a fallback
// e.g. if we are running on a KDE4 desktop
QByteArray desktopEnvironment = qgetenv("DESKTOP_SESSION");
if (desktopEnvironment == "kde")
baseName = "plastique";
else
baseName = "cleanlooks";
}
qApp->setStyle(new ManhattanStyle(baseName));
statusBar()->setProperty("p_styled", true);
}

View File

@@ -334,6 +334,10 @@ NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget)
m_navigationComboBox = new NavComboBox(this);
m_navigationWidget = 0;
#ifdef Q_OS_MAC
// this is to avoid ugly tool bar behavior
m_navigationComboBox->setMaximumWidth(130);
#endif
m_toolbar = new QToolBar(this);
m_toolbar->setContentsMargins(0, 0, 0, 0);

View File

@@ -72,7 +72,7 @@ VersionDialog::VersionDialog(QWidget *parent)
"<br/>"
"Built on " __DATE__ " at " __TIME__ "<br />"
#ifdef IDE_REVISION
"Using revision %5<br/>"
"From revision %5<br/>"
#endif
"<br/>"
"<br/>"

View File

@@ -427,7 +427,9 @@ void CPPEditor::switchDeclarationDefinition()
if (!m_modelManager)
return;
Document::Ptr doc = m_modelManager->document(file()->fileName());
const Snapshot snapshot = m_modelManager->snapshot();
Document::Ptr doc = snapshot.value(file()->fileName());
if (!doc)
return;
Symbol *lastSymbol = doc->findSymbolAt(line, column);
@@ -445,7 +447,7 @@ void CPPEditor::switchDeclarationDefinition()
if (f) {
TypeOfExpression typeOfExpression;
typeOfExpression.setDocuments(m_modelManager->documents());
typeOfExpression.setSnapshot(m_modelManager->snapshot());
QList<TypeOfExpression::Result> resolvedSymbols = typeOfExpression(QString(), doc, lastSymbol);
const LookupContext &context = typeOfExpression.lookupContext();
@@ -474,26 +476,38 @@ void CPPEditor::jumpToDefinition()
if (!m_modelManager)
return;
const Snapshot snapshot = m_modelManager->snapshot();
// Find the last symbol up to the cursor position
int line = 0, column = 0;
convertPosition(position(), &line, &column);
Document::Ptr doc = m_modelManager->document(file()->fileName());
Document::Ptr doc = snapshot.value(file()->fileName());
if (!doc)
return;
QTextCursor tc = textCursor();
unsigned lineno = tc.blockNumber() + 1;
foreach (const Document::Include &incl, doc->includes()) {
if (incl.line() == lineno) {
if (openCppEditorAt(incl.fileName(), 0, 0))
return; // done
break;
}
}
Symbol *lastSymbol = doc->findSymbolAt(line, column);
if (!lastSymbol)
return;
// Get the expression under the cursor
const int endOfName = endOfNameUnderCursor();
QTextCursor tc = textCursor();
tc.setPosition(endOfName);
ExpressionUnderCursor expressionUnderCursor;
const QString expression = expressionUnderCursor(tc);
// Evaluate the type of the expression
TypeOfExpression typeOfExpression;
typeOfExpression.setDocuments(m_modelManager->documents());
typeOfExpression.setSnapshot(m_modelManager->snapshot());
QList<TypeOfExpression::Result> resolvedSymbols =
typeOfExpression(expression, doc, lastSymbol);
@@ -515,7 +529,7 @@ void CPPEditor::jumpToDefinition()
QList<Symbol *> candidates = context.resolve(namedType->name());
if (!candidates.isEmpty()) {
Symbol *s = candidates.takeFirst();
openEditorAt(s->fileName(), s->line(), s->column());
openCppEditorAt(s->fileName(), s->line(), s->column());
}
#endif
}
@@ -524,7 +538,7 @@ void CPPEditor::jumpToDefinition()
if (use.contains(endOfName - 1)) {
const Macro &macro = use.macro();
const QString fileName = QString::fromUtf8(macro.fileName);
if (TextEditor::BaseTextEditor::openEditorAt(fileName, macro.line, 0))
if (openCppEditorAt(fileName, macro.line, 0))
return; // done
}
}
@@ -562,7 +576,7 @@ Symbol *CPPEditor::findDefinition(Symbol *lastSymbol)
QualifiedNameId *q = control.qualifiedNameId(&qualifiedName[0], qualifiedName.size());
LookupContext context(&control);
const QMap<QString, Document::Ptr> documents = m_modelManager->documents();
const Snapshot documents = m_modelManager->snapshot();
foreach (Document::Ptr doc, documents) {
QList<Scope *> visibleScopes;
visibleScopes.append(doc->globalSymbols());
@@ -734,7 +748,8 @@ void CPPEditor::unCommentSelection()
QString endText = endBlock.text();
int endPos = end - endBlock.position();
bool hasTrailingCharacters = !endText.mid(endPos).trimmed().isEmpty();
bool hasTrailingCharacters = !endText.left(endPos).remove(QLatin1String("//")).trimmed().isEmpty()
&& !endText.mid(endPos).trimmed().isEmpty();
if ((endPos <= endText.length() - 2
&& endText.at(endPos) == QLatin1Char('*')
&& endText.at(endPos+1) == QLatin1Char('/'))) {
@@ -826,8 +841,15 @@ int CPPEditor::endOfNameUnderCursor()
return pos;
}
TextEditor::ITextEditor *CPPEditor::openCppEditorAt(const QString &fileName,
int line, int column)
{
return TextEditor::BaseTextEditor::openEditorAt(fileName, line, column,
Constants::C_CPPEDITOR);
}
bool CPPEditor::openEditorAt(Symbol *s)
{
const QString fileName = QString::fromUtf8(s->fileName(), s->fileNameLength());
return TextEditor::BaseTextEditor::openEditorAt(fileName, s->line(), s->column());
return openCppEditorAt(fileName, s->line(), s->column());
}

View File

@@ -123,6 +123,9 @@ private:
CPlusPlus::Symbol *findDefinition(CPlusPlus::Symbol *symbol);
virtual void indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar);
TextEditor::ITextEditor *openCppEditorAt(const QString &fileName, int line,
int column = 0);
int previousBlockState(QTextBlock block) const;
QTextCursor moveToPreviousToken(QTextCursor::MoveMode mode) const;
QTextCursor moveToNextToken(QTextCursor::MoveMode mode) const;

View File

@@ -434,12 +434,15 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
//if (! expression.isEmpty())
//qDebug() << "***** expression:" << expression;
if (Document::Ptr thisDocument = m_manager->document(fileName)) {
const Snapshot snapshot = m_manager->snapshot();
if (Document::Ptr thisDocument = snapshot.value(fileName)) {
Symbol *symbol = thisDocument->findSymbolAt(line, column);
typeOfExpression.setDocuments(m_manager->documents());
typeOfExpression.setSnapshot(m_manager->snapshot());
QList<TypeOfExpression::Result> resolvedTypes = typeOfExpression(expression, thisDocument, symbol);
QList<TypeOfExpression::Result> resolvedTypes = typeOfExpression(expression, thisDocument, symbol,
TypeOfExpression::Preprocess);
LookupContext context = typeOfExpression.lookupContext();
if (!typeOfExpression.expressionAST() && (! m_completionOperator ||
@@ -963,8 +966,10 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item)
if (Function *function = symbol->type()->asFunction()) {
// If the member is a function, automatically place the opening parenthesis,
// except when it might take template parameters.
if (!function->returnType().isValid()
&& (function->identity() && !function->identity()->isDestructorNameId())) {
const bool hasReturnType = function->returnType().isValid() ||
function->returnType().isSigned() ||
function->returnType().isUnsigned();
if (! hasReturnType && (function->identity() && !function->identity()->isDestructorNameId())) {
// Don't insert any magic, since the user might have just wanted to select the class
} else if (function->templateParameterCount() != 0) {
@@ -1033,7 +1038,7 @@ void CppCodeCompletion::cleanup()
// Set empty map in order to avoid referencing old versions of the documents
// until the next completion
typeOfExpression.setDocuments(QMap<QString, Document::Ptr>());
typeOfExpression.setSnapshot(Snapshot());
}
int CppCodeCompletion::findStartOfName(const TextEditor::ITextEditor *editor)

View File

@@ -165,9 +165,11 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
QTextCursor tc(edit->document());
tc.setPosition(pos);
const Snapshot documents = m_manager->snapshot();
const int lineNumber = tc.block().blockNumber() + 1;
const QString fileName = editor->file()->fileName();
Document::Ptr doc = m_manager->document(fileName);
Document::Ptr doc = documents.value(fileName);
if (doc) {
foreach (Document::DiagnosticMessage m, doc->diagnosticMessages()) {
if (m.line() == lineNumber) {
@@ -177,6 +179,16 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
}
}
if (m_toolTip.isEmpty()) {
unsigned lineno = tc.blockNumber() + 1;
foreach (const Document::Include &incl, doc->includes()) {
if (lineno == incl.line()) {
m_toolTip = incl.fileName();
break;
}
}
}
if (m_toolTip.isEmpty()) {
// Move to the end of a qualified name
bool stop = false;
@@ -202,7 +214,7 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
Symbol *lastSymbol = doc->findSymbolAt(line, column);
TypeOfExpression typeOfExpression;
typeOfExpression.setDocuments(m_manager->documents());
typeOfExpression.setSnapshot(documents);
QList<TypeOfExpression::Result> types = typeOfExpression(expression, doc, lastSymbol);
if (!types.isEmpty()) {

View File

@@ -138,11 +138,12 @@ protected:
virtual void stopExpandingMacro(unsigned offset, const Macro &macro);
virtual void startSkippingBlocks(unsigned offset);
virtual void stopSkippingBlocks(unsigned offset);
virtual void sourceNeeded(QString &fileName, IncludeType type);
virtual void sourceNeeded(QString &fileName, IncludeType type,
unsigned line);
private:
QPointer<CppModelManager> m_modelManager;
CppModelManager::DocumentTable m_documents;
Snapshot m_snapshot;
Environment env;
pp m_proc;
QStringList m_includePaths;
@@ -159,7 +160,7 @@ private:
CppPreprocessor::CppPreprocessor(QPointer<CppModelManager> modelManager)
: m_modelManager(modelManager),
m_documents(modelManager->documents()),
m_snapshot(modelManager->snapshot()),
m_proc(this, env)
{ }
@@ -176,7 +177,7 @@ void CppPreprocessor::setProjectFiles(const QStringList &files)
{ m_projectFiles = files; }
void CppPreprocessor::run(QString &fileName)
{ sourceNeeded(fileName, IncludeGlobal); }
{ sourceNeeded(fileName, IncludeGlobal, /*line = */ 0); }
void CppPreprocessor::operator()(QString &fileName)
{ run(fileName); }
@@ -339,7 +340,7 @@ void CppPreprocessor::mergeEnvironment(Document::Ptr doc, QSet<QString> *process
processed->insert(fn);
foreach (QString includedFile, doc->includedFiles()) {
mergeEnvironment(m_documents.value(includedFile), processed);
mergeEnvironment(m_snapshot.value(includedFile), processed);
}
foreach (const Macro macro, doc->definedMacros()) {
@@ -361,7 +362,8 @@ void CppPreprocessor::stopSkippingBlocks(unsigned offset)
m_currentDoc->stopSkippingBlocks(offset);
}
void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type)
void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type,
unsigned line)
{
if (fileName.isEmpty())
return;
@@ -369,7 +371,7 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type)
QByteArray contents = tryIncludeFile(fileName, type);
if (m_currentDoc) {
m_currentDoc->addIncludeFile(fileName);
m_currentDoc->addIncludeFile(fileName, line);
if (contents.isEmpty() && ! QFileInfo(fileName).isAbsolute()) {
QString msg;
msg += fileName;
@@ -384,7 +386,7 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type)
}
if (! contents.isEmpty()) {
Document::Ptr cachedDoc = m_documents.value(fileName);
Document::Ptr cachedDoc = m_snapshot.value(fileName);
if (cachedDoc && m_currentDoc) {
mergeEnvironment(cachedDoc);
} else {
@@ -475,11 +477,8 @@ CppModelManager::CppModelManager(QObject *parent) :
CppModelManager::~CppModelManager()
{ }
Document::Ptr CppModelManager::document(const QString &fileName) const
{ return m_documents.value(fileName); }
CppModelManager::DocumentTable CppModelManager::documents() const
{ return m_documents; }
Snapshot CppModelManager::snapshot() const
{ return m_snapshot; }
void CppModelManager::ensureUpdated()
{
@@ -670,7 +669,7 @@ void CppModelManager::emitDocumentUpdated(Document::Ptr doc)
void CppModelManager::onDocumentUpdated(Document::Ptr doc)
{
const QString fileName = doc->fileName();
m_documents[fileName] = doc;
m_snapshot[fileName] = doc;
QList<Core::IEditor *> openedEditors = m_core->editorManager()->openedEditors();
foreach (Core::IEditor *editor, openedEditors) {
if (editor->file()->fileName() == fileName) {
@@ -835,7 +834,7 @@ void CppModelManager::parse(QFutureInterface<void> &future,
void CppModelManager::GC()
{
DocumentTable documents = m_documents;
Snapshot documents = m_snapshot;
QSet<QString> processed;
QStringList todo = projectFiles();
@@ -866,7 +865,7 @@ void CppModelManager::GC()
}
emit aboutToRemoveFiles(removedFiles);
m_documents = documents;
m_snapshot = documents;
}

View File

@@ -76,8 +76,7 @@ public:
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const;
virtual void updateProjectInfo(const ProjectInfo &pinfo);
virtual CPlusPlus::Document::Ptr document(const QString &fileName) const;
virtual DocumentTable documents() const;
virtual CPlusPlus::Snapshot snapshot() const;
virtual void GC();
QFuture<void> refreshSourceFiles(const QStringList &sourceFiles);
@@ -146,7 +145,7 @@ private:
Core::ICore *m_core;
ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer;
CppHoverHandler *m_hoverHandler;
DocumentTable m_documents;
CPlusPlus::Snapshot m_snapshot;
// cache
bool m_dirty;

View File

@@ -46,14 +46,11 @@ namespace ProjectExplorer {
namespace CppTools {
class CPPTOOLS_EXPORT CppModelManagerInterface
: public QObject
class CPPTOOLS_EXPORT CppModelManagerInterface: public QObject
{
Q_OBJECT
public:
typedef QMap<QString, CPlusPlus::Document::Ptr> DocumentTable; // ### remove me
class ProjectInfo
{
public:
@@ -89,8 +86,7 @@ public:
virtual void GC() = 0;
virtual void updateSourceFiles(const QStringList &sourceFiles) = 0;
virtual CPlusPlus::Document::Ptr document(const QString &fileName) const = 0;
virtual DocumentTable documents() const = 0;
virtual CPlusPlus::Snapshot snapshot() const = 0;
virtual QList<ProjectInfo> projectInfos() const = 0;
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const = 0;

View File

@@ -6,7 +6,6 @@ include(cpptools_dependencies.pri)
# DEFINES += QT_NO_CAST_FROM_ASCII
DEFINES += QT_NO_CAST_TO_ASCII
unix:QMAKE_CXXFLAGS_DEBUG += -O3
INCLUDEPATH += .
DEFINES += CPPTOOLS_LIBRARY
CONFIG += help

View File

@@ -43,6 +43,7 @@
#include <QIcon>
#include <QMetaType>
#include <QString>
#include <QSet>
#include <functional>

View File

@@ -58,7 +58,6 @@ SOURCES += attachexternaldialog.cpp \
gdbengine.cpp \
gdbmi.cpp \
gdboptionpage.cpp \
gdbtypemacros.cpp \
gdbengine.h \
moduleshandler.cpp \
moduleswindow.cpp \
@@ -79,7 +78,6 @@ FORMS += attachexternaldialog.ui \
breakcondition.ui \
mode.ui \
gdboptionpage.ui \
gdbtypemacros.ui \
startexternaldialog.ui \
RESOURCES += debugger.qrc

View File

@@ -1033,7 +1033,6 @@ void DebuggerManager::addToWatchWindow()
void DebuggerManager::watchExpression(const QString &expression)
{
watchHandler()->watchExpression(expression);
//engine()->updateWatchModel();
}
void DebuggerManager::setBreakpoint(const QString &fileName, int lineNumber)

View File

@@ -183,7 +183,6 @@ DebuggerPlugin::DebuggerPlugin()
{
m_pm = 0;
m_generalOptionPage = 0;
m_typeMacroPage = 0;
m_locationMark = 0;
m_manager = 0;
}
@@ -202,7 +201,6 @@ void DebuggerPlugin::shutdown()
//qDebug() << "DebuggerPlugin::~DebuggerPlugin";
removeObject(m_debugMode);
removeObject(m_generalOptionPage);
removeObject(m_typeMacroPage);
// FIXME: when using the line below, BreakWindow etc gets deleted twice.
// so better leak for now...
@@ -212,9 +210,6 @@ void DebuggerPlugin::shutdown()
delete m_generalOptionPage;
m_generalOptionPage = 0;
delete m_typeMacroPage;
m_typeMacroPage = 0;
delete m_locationMark;
m_locationMark = 0;
@@ -409,13 +404,10 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *error_mes
mdebug->addAction(cmd);
m_generalOptionPage = 0;
m_typeMacroPage = 0;
// FIXME:
m_generalOptionPage = new GdbOptionPage(&theGdbSettings());
addObject(m_generalOptionPage);
m_typeMacroPage = new TypeMacroPage(&theGdbSettings());
addObject(m_typeMacroPage);
m_locationMark = 0;

View File

@@ -54,7 +54,6 @@ namespace Internal {
class DebuggerManager;
class DebugMode;
class GdbOptionPage;
class TypeMacroPage;
class LocationMark;
class DebuggerPlugin : public ExtensionSystem::IPlugin
@@ -103,7 +102,6 @@ private:
ExtensionSystem::PluginManager *m_pm;
GdbOptionPage *m_generalOptionPage;
TypeMacroPage *m_typeMacroPage;
QString m_previousMode;
LocationMark *m_locationMark;

View File

@@ -2939,6 +2939,8 @@ bool GdbEngine::isCustomValueDumperAvailable(const QString &type) const
if (tmplate == "QSet")
return true;
}
if (tmplate == "std::list")
return true;
if (tmplate == "std::vector" && inner != "bool")
return true;
if (tmplate == "std::basic_string") {

View File

@@ -80,7 +80,7 @@ enum DataDumperState
DataDumperUnavailable,
};
// FIXME: Move to extra file?
class GdbSettings
{
public:

View File

@@ -58,7 +58,11 @@ GdbOptionPage::GdbOptionPage(GdbSettings *settings)
#if defined(Q_OS_WIN32)
defaultCommand.append(".exe");
#endif
QString defaultScript = coreIFace->resourcePath() +
QLatin1String("/gdb/qt4macros");
m_settings->m_gdbCmd = s->value("Location", defaultCommand).toString();
m_settings->m_scriptFile= s->value("ScriptFile", defaultScript).toString();
m_settings->m_gdbEnv = s->value("Environment", "").toString();
m_settings->m_autoRun = s->value("AutoRun", true).toBool();
m_settings->m_autoQuit = s->value("AutoQuit", true).toBool();
@@ -72,36 +76,50 @@ QString GdbOptionPage::name() const
QString GdbOptionPage::category() const
{
return "Debugger|Gdb";
return "Debugger";
}
QString GdbOptionPage::trCategory() const
{
return tr("Debugger|Gdb");
return tr("Debugger");
}
QWidget *GdbOptionPage::createPage(QWidget *parent)
{
QWidget *w = new QWidget(parent);
m_ui.setupUi(w);
m_ui.gdbEdit->setText(m_settings->m_gdbCmd);
m_ui.envEdit->setText(m_settings->m_gdbEnv);
m_ui.gdbLocationChooser->setExpectedKind(Core::Utils::PathChooser::Command);
m_ui.gdbLocationChooser->setPromptDialogTitle(tr("Choose Gdb Location"));
m_ui.gdbLocationChooser->setPath(m_settings->m_gdbCmd);
m_ui.scriptFileChooser->setExpectedKind(Core::Utils::PathChooser::File);
m_ui.scriptFileChooser->setPromptDialogTitle(tr("Choose Location of Startup Script File"));
m_ui.scriptFileChooser->setPath(m_settings->m_scriptFile);
m_ui.environmentEdit->setText(m_settings->m_gdbEnv);
m_ui.autoStartBox->setChecked(m_settings->m_autoRun);
m_ui.autoQuitBox->setChecked(m_settings->m_autoQuit);
connect(m_ui.pushButtonBrowse, SIGNAL(clicked()),
this, SLOT(browse()));
// FIXME
m_ui.autoStartBox->hide();
m_ui.autoQuitBox->hide();
m_ui.environmentEdit->hide();
m_ui.labelEnvironment->hide();
connect(m_ui.gdbLocationChooser, SIGNAL(changed()),
this, SLOT(onGdbLocationChanged()));
connect(m_ui.scriptFileChooser, SIGNAL(changed()),
this, SLOT(onScriptFileChanged()));
return w;
}
void GdbOptionPage::browse()
void GdbOptionPage::onGdbLocationChanged()
{
QString fileName = QFileDialog::getOpenFileName(m_ui.pushButtonBrowse,
"Browse for gdb executable");
if (fileName.isEmpty())
return;
m_settings->m_gdbCmd = fileName;
m_ui.gdbEdit->setText(fileName);
m_settings->m_gdbCmd = m_ui.gdbLocationChooser->path();
}
void GdbOptionPage::onScriptFileChanged()
{
m_settings->m_scriptFile = m_ui.scriptFileChooser->path();
}
void GdbOptionPage::finished(bool accepted)
@@ -109,10 +127,11 @@ void GdbOptionPage::finished(bool accepted)
if (!accepted)
return;
m_settings->m_gdbCmd = m_ui.gdbEdit->text();
m_settings->m_gdbEnv = m_ui.envEdit->text();
m_settings->m_gdbCmd = m_ui.gdbLocationChooser->path();
m_settings->m_gdbEnv = m_ui.environmentEdit->text();
m_settings->m_autoRun = m_ui.autoStartBox->isChecked();
m_settings->m_autoQuit = m_ui.autoQuitBox->isChecked();
m_settings->m_scriptFile = m_ui.scriptFileChooser->path();
Core::ICore *coreIFace = m_pm->getObject<Core::ICore>();
if (!coreIFace || !coreIFace->settings())

View File

@@ -35,7 +35,6 @@
#define GDBOPTIONPAGE_H
#include "ui_gdboptionpage.h"
#include "ui_gdbtypemacros.h"
#include <coreplugin/dialogs/ioptionspage.h>
@@ -63,7 +62,8 @@ public:
void finished(bool accepted);
public slots:
void browse();
void onGdbLocationChanged();
void onScriptFileChanged();
private:
ExtensionSystem::PluginManager *m_pm;
@@ -72,6 +72,7 @@ private:
GdbSettings *m_settings;
};
#if 0
class TypeMacroPage : public Core::IOptionsPage
{
Q_OBJECT
@@ -87,7 +88,6 @@ public:
void finished(bool accepted);
private slots:
void onScriptButton();
void onAddButton();
void onDelButton();
void currentItemChanged(QTreeWidgetItem *item);
@@ -100,6 +100,7 @@ private:
GdbSettings *m_settings;
QWidget *m_widget;
};
#endif
} // namespace Internal
} // namespace Debugger

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>433</width>
<height>216</height>
<height>233</height>
</rect>
</property>
<property name="windowTitle">
@@ -23,7 +23,7 @@
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Gdb Debug Options</string>
<string>Locations</string>
</property>
<layout class="QGridLayout">
<property name="margin">
@@ -32,46 +32,45 @@
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="1">
<widget class="QLineEdit" name="gdbEdit"/>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="envEdit"/>
<item row="1" column="1">
<widget class="QLineEdit" name="environmentEdit"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<widget class="QLabel" name="labelGdbLocaltion">
<property name="toolTip">
<string>This is either a full abolute path leading to the gdb binary you intend to use or the name of a gdb binary that wiull be searched in your PATH.</string>
</property>
<property name="text">
<string>Gdb Location:</string>
</property>
<property name="buddy">
<cstring>gdbEdit</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="labelEnvironment">
<property name="text">
<string>Environment:</string>
</property>
<property name="buddy">
<cstring>envEdit</cstring>
<cstring>environmentEdit</cstring>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButtonBrowse">
<item row="2" column="0">
<widget class="QLabel" name="labelGdbStartupScript">
<property name="toolTip">
<string>This is either empty or points to a file containing gdb commands that will be executed immediately after gdb starts up.</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../coreplugin/core.qrc">
<normaloff>:/qworkbench/images/fileopen.png</normaloff>:/qworkbench/images/fileopen.png</iconset>
</property>
<property name="checkable">
<bool>false</bool>
<string>Gdb Startup Script:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Core::Utils::PathChooser" name="scriptFileChooser" native="true"/>
</item>
<item row="0" column="1">
<widget class="Core::Utils::PathChooser" name="gdbLocationChooser" native="true"/>
</item>
</layout>
</widget>
</item>
@@ -104,6 +103,14 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Core::Utils::PathChooser</class>
<extends>QWidget</extends>
<header location="global">utils/pathchooser.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../coreplugin/core.qrc"/>
</resources>

View File

@@ -109,6 +109,8 @@ QWidget *TypeMacroPage::createPage(QWidget *parent)
m_widget = new QWidget(parent);
m_ui.setupUi(m_widget);
m_ui.scriptFile->setPromptDialogTitle(tr("Select Gdb Script"));
m_ui.scriptFile->setExpectedKind(Core::Utils::PathChooser::File);
connect(m_ui.addButton, SIGNAL(clicked()),
this, SLOT(onAddButton()));
@@ -116,8 +118,8 @@ QWidget *TypeMacroPage::createPage(QWidget *parent)
connect(m_ui.delButton, SIGNAL(clicked()),
this, SLOT(onDelButton()));
connect(m_ui.scriptButton, SIGNAL(clicked()),
this, SLOT(onScriptButton()));
connect(m_ui.scriptFile, SIGNAL(validChanged()),
this, SLOT(updateButtonState()));
connect(m_ui.treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
this, SLOT(currentItemChanged(QTreeWidgetItem *)));
@@ -139,7 +141,7 @@ QWidget *TypeMacroPage::createPage(QWidget *parent)
++i;
}
m_ui.scriptEdit->setText(m_settings->m_scriptFile);
m_ui.scriptFile->setPath(m_settings->m_scriptFile);
updateButtonState();
@@ -152,7 +154,7 @@ void TypeMacroPage::finished(bool accepted)
return;
m_settings->m_typeMacros.clear();
m_settings->m_scriptFile = m_ui.scriptEdit->text();
m_settings->m_scriptFile = m_ui.scriptFile->path();
for (int i = 0; i < m_ui.treeWidget->topLevelItemCount(); ++i) {
QTreeWidgetItem *item = m_ui.treeWidget->topLevelItem(i);
@@ -172,13 +174,6 @@ void TypeMacroPage::finished(bool accepted)
}
}
void TypeMacroPage::onScriptButton()
{
QString fileName = QFileDialog::getOpenFileName(m_widget, tr("Select Gdb Script"));
m_ui.scriptEdit->setText(fileName);
updateButtonState();
}
void TypeMacroPage::onAddButton()
{
if (m_ui.typeEdit->text().isEmpty() || m_ui.macroEdit->text().isEmpty())

View File

@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>TypeMacroPage</class>
<widget class="QWidget" name="TypeMacroPage">
<property name="geometry">
@@ -9,50 +7,19 @@
<x>0</x>
<y>0</y>
<width>519</width>
<height>238</height>
<height>263</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout">
<property name="margin" >
<number>9</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string>Script File</string>
</property>
<layout class="QHBoxLayout" >
<property name="margin">
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLineEdit" name="scriptEdit" />
</item>
<item>
<widget class="QToolButton" name="scriptButton" >
<property name="minimumSize" >
<size>
<width>21</width>
<height>23</height>
</size>
</property>
<property name="text" >
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QGridLayout">
<property name="margin">
@@ -90,7 +57,8 @@
<string>+</string>
</property>
<property name="icon">
<iconset resource="gdbdebugger.qrc" >:/gdbdebugger/images/newitem.png</iconset>
<iconset>
<normaloff>:/gdbdebugger/images/newitem.png</normaloff>:/gdbdebugger/images/newitem.png</iconset>
</property>
</widget>
</item>
@@ -113,10 +81,10 @@
</item>
<item row="0" column="2">
<layout class="QVBoxLayout">
<property name="margin" >
<property name="spacing">
<number>0</number>
</property>
<property name="spacing" >
<property name="margin">
<number>0</number>
</property>
<item>
@@ -131,7 +99,8 @@
<string>-</string>
</property>
<property name="icon">
<iconset resource="gdbdebugger.qrc" >:/gdbdebugger/images/delete.png</iconset>
<iconset>
<normaloff>:/gdbdebugger/images/delete.png</normaloff>:/gdbdebugger/images/delete.png</iconset>
</property>
</widget>
</item>
@@ -140,7 +109,7 @@
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
@@ -178,7 +147,6 @@
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<resources>
<include location="gdbdebugger.qrc"/>
</resources>

View File

@@ -402,18 +402,41 @@ bool WatchHandler::setData(const QModelIndex &idx,
static QString niceType(QString type)
{
if (type.contains("std::")) {
static QRegExp re("std::vector<(.*)\\s*,std::allocator<(.*)>\\s*>");
re.setMinimal(true);
// std::string
type.replace("std::basic_string<char, std::char_traits<char>, "
"std::allocator<char> >", "std::string");
// std::wstring
type.replace("std::basic_string<wchar_t, std::char_traits<wchar_t>, "
"std::allocator<wchar_t> >", "std::wstring");
// std::vector
static QRegExp re1("std::vector<(.*), std::allocator<(.*)>\\s*>");
re1.setMinimal(true);
for (int i = 0; i != 10; ++i) {
if (re.indexIn(type) == -1 || re.cap(1) != re.cap(2))
if (re1.indexIn(type) == -1 || re1.cap(1) != re1.cap(2))
break;
type.replace(re.cap(0), "std::vector<" + re.cap(1) + ">");
type.replace(re1.cap(0), "std::vector<" + re1.cap(1) + ">");
}
// std::list
static QRegExp re2("std::list<(.*), std::allocator<(.*)>\\s*>");
re2.setMinimal(true);
for (int i = 0; i != 10; ++i) {
if (re2.indexIn(type) == -1 || re2.cap(1) != re2.cap(2))
break;
type.replace(re2.cap(0), "std::list<" + re2.cap(1) + ">");
}
// std::map
static QRegExp re3("std::map<(.*), (.*), std::less<(.*)\\s*>, "
"std::allocator<std::pair<const (.*), (.*)\\s*> > >");
re3.setMinimal(true);
for (int i = 0; i != 10; ++i) {
if (re3.indexIn(type) == -1 || re3.cap(1) != re3.cap(3)
|| re3.cap(1) != re3.cap(4) || re3.cap(2) != re3.cap(5))
break;
type.replace(re3.cap(0), "std::map<" + re3.cap(1) + ", " + re3.cap(2) + ">");
}
type.replace(" >", ">");
@@ -865,9 +888,9 @@ void WatchHandler::watchExpression(const QString &exp)
data.name = exp;
data.iname = "watch." + exp;
insertData(data);
emit watchModelUpdateRequested();
}
void WatchHandler::setDisplayedIName(const QString &iname, bool on)
{
WatchData *d = findData(iname);

View File

@@ -95,7 +95,7 @@ static QList<Document::Ptr> findDocumentsIncluding(const QString &fileName, bool
QList<Document::Ptr> docList;
// take all docs
CppTools::CppModelManagerInterface::DocumentTable docTable = cppModelManager->documents();
CPlusPlus::Snapshot docTable = cppModelManager->snapshot();
foreach (Document::Ptr doc, docTable) { // we go through all documents
QStringList includes = doc->includedFiles();
foreach (QString include, includes) {
@@ -286,7 +286,7 @@ static Document::Ptr findDefinition(Function *functionDeclaration, int *line)
QualifiedNameId *q = control.qualifiedNameId(&qualifiedName[0], qualifiedName.size());
LookupContext context(&control);
const QMap<QString, Document::Ptr> documents = cppModelManager->documents();
const Snapshot documents = cppModelManager->snapshot();
foreach (Document::Ptr doc, documents) {
QList<Scope *> visibleScopes;
visibleScopes.append(doc->globalSymbols());

View File

@@ -197,7 +197,7 @@ void GitClient::diff(const QString &workingDirectory, const QStringList &fileNam
const QString title = tr("Git Diff");
VCSBase::VCSBaseEditor *editor = createVCSEditor(kind, title, workingDirectory, true, "originalFileName", workingDirectory);
executeGit(workingDirectory, arguments, m_plugin->outputWindow(), editor);
executeGit(workingDirectory, arguments, editor);
}
@@ -215,14 +215,14 @@ void GitClient::diff(const QString &workingDirectory, const QString &fileName)
const QString sourceFile = source(workingDirectory, fileName);
VCSBase::VCSBaseEditor *editor = createVCSEditor(kind, title, sourceFile, true, "originalFileName", sourceFile);
executeGit(workingDirectory, arguments, m_plugin->outputWindow(), editor);
executeGit(workingDirectory, arguments, editor);
}
void GitClient::status(const QString &workingDirectory)
{
QStringList statusArgs(QLatin1String("status"));
statusArgs << QLatin1String("-u");
executeGit(workingDirectory, statusArgs, m_plugin->outputWindow(), 0,true);
executeGit(workingDirectory, statusArgs, 0, true);
}
void GitClient::log(const QString &workingDirectory, const QString &fileName)
@@ -242,7 +242,7 @@ void GitClient::log(const QString &workingDirectory, const QString &fileName)
const QString kind = QLatin1String(Git::Constants::GIT_LOG_EDITOR_KIND);
const QString sourceFile = source(workingDirectory, fileName);
VCSBase::VCSBaseEditor *editor = createVCSEditor(kind, title, sourceFile, false, "logFileName", sourceFile);
executeGit(workingDirectory, arguments, m_plugin->outputWindow(), editor);
executeGit(workingDirectory, arguments, editor);
}
void GitClient::show(const QString &source, const QString &id)
@@ -258,7 +258,7 @@ void GitClient::show(const QString &source, const QString &id)
const QFileInfo sourceFi(source);
const QString workDir = sourceFi.isDir() ? sourceFi.absoluteFilePath() : sourceFi.absolutePath();
executeGit(workDir, arguments, m_plugin->outputWindow(), editor);
executeGit(workDir, arguments, editor);
}
void GitClient::blame(const QString &workingDirectory, const QString &fileName)
@@ -273,7 +273,7 @@ void GitClient::blame(const QString &workingDirectory, const QString &fileName)
const QString sourceFile = source(workingDirectory, fileName);
VCSBase::VCSBaseEditor *editor = createVCSEditor(kind, title, sourceFile, true, "blameFileName", sourceFile);
executeGit(workingDirectory, arguments, m_plugin->outputWindow(), editor);
executeGit(workingDirectory, arguments, editor);
}
void GitClient::checkout(const QString &workingDirectory, const QString &fileName)
@@ -287,7 +287,7 @@ void GitClient::checkout(const QString &workingDirectory, const QString &fileNam
arguments << QLatin1String("checkout") << QLatin1String("HEAD") << QLatin1String("--")
<< fileName;
executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0,true);
executeGit(workingDirectory, arguments, 0, true);
}
void GitClient::hardReset(const QString &workingDirectory, const QString &commit)
@@ -297,7 +297,7 @@ void GitClient::hardReset(const QString &workingDirectory, const QString &commit
if (!commit.isEmpty())
arguments << commit;
executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0,true);
executeGit(workingDirectory, arguments, 0, true);
}
void GitClient::addFile(const QString &workingDirectory, const QString &fileName)
@@ -305,7 +305,7 @@ void GitClient::addFile(const QString &workingDirectory, const QString &fileName
QStringList arguments;
arguments << QLatin1String("add") << fileName;
executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0,true);
executeGit(workingDirectory, arguments, 0, true);
}
bool GitClient::synchronousAdd(const QString &workingDirectory, const QStringList &files)
@@ -380,13 +380,14 @@ bool GitClient::synchronousCheckout(const QString &workingDirectory,
}
void GitClient::executeGit(const QString &workingDirectory, const QStringList &arguments,
GitOutputWindow *outputWindow, VCSBase::VCSBaseEditor* editor,
VCSBase::VCSBaseEditor* editor,
bool outputToWindow)
{
if (Git::Constants::debug)
qDebug() << "executeGit" << workingDirectory << arguments << editor;
m_plugin->outputWindow()->append(formatCommand(QLatin1String(kGitCommand), arguments));
GitOutputWindow *outputWindow = m_plugin->outputWindow();
outputWindow->append(formatCommand(QLatin1String(kGitCommand), arguments));
QProcess process;
ProjectExplorer::Environment environment = ProjectExplorer::Environment::systemEnvironment();
@@ -396,8 +397,13 @@ void GitClient::executeGit(const QString &workingDirectory, const QStringList &a
GitCommand* command = new GitCommand();
if (outputToWindow) {
if (!editor) { // assume that the commands output is the important thing
connect(command, SIGNAL(outputText(QString)), this, SLOT(appendAndPopup(QString)));
connect(command, SIGNAL(outputData(QByteArray)), this, SLOT(appendDataAndPopup(QByteArray)));
} else {
connect(command, SIGNAL(outputText(QString)), outputWindow, SLOT(append(QString)));
connect(command, SIGNAL(outputData(QByteArray)), outputWindow, SLOT(appendData(QByteArray)));
}
} else {
QTC_ASSERT(editor, /**/);
connect(command, SIGNAL(outputText(QString)), editor, SLOT(setPlainText(QString)));
@@ -405,11 +411,23 @@ void GitClient::executeGit(const QString &workingDirectory, const QStringList &a
}
if (outputWindow)
connect(command, SIGNAL(errorText(QString)), outputWindow, SLOT(append(QString)));
connect(command, SIGNAL(errorText(QString)), this, SLOT(appendAndPopup(QString)));
command->execute(arguments, workingDirectory, environment);
}
void GitClient::appendDataAndPopup(const QByteArray &data)
{
m_plugin->outputWindow()->appendData(data);
m_plugin->outputWindow()->popup(false);
}
void GitClient::appendAndPopup(const QString &text)
{
m_plugin->outputWindow()->append(text);
m_plugin->outputWindow()->popup(false);
}
bool GitClient::synchronousGit(const QString &workingDirectory,
const QStringList &arguments,
QByteArray* outputText,
@@ -810,12 +828,12 @@ void GitClient::revert(const QStringList &files)
void GitClient::pull(const QString &workingDirectory)
{
executeGit(workingDirectory, QStringList(QLatin1String("pull")), m_plugin->outputWindow(), 0, true);
executeGit(workingDirectory, QStringList(QLatin1String("pull")), 0, true);
}
void GitClient::push(const QString &workingDirectory)
{
executeGit(workingDirectory, QStringList(QLatin1String("push")), m_plugin->outputWindow(), 0, true);
executeGit(workingDirectory, QStringList(QLatin1String("push")), 0, true);
}
QString GitClient::msgNoChangedFiles()
@@ -829,7 +847,7 @@ void GitClient::stash(const QString &workingDirectory)
QString errorMessage;
switch (gitStatus(workingDirectory, false, 0, &errorMessage)) {
case StatusChanged:
executeGit(workingDirectory, QStringList(QLatin1String("stash")), m_plugin->outputWindow(), 0, true);
executeGit(workingDirectory, QStringList(QLatin1String("stash")), 0, true);
break;
case StatusUnchanged:
m_plugin->outputWindow()->append(msgNoChangedFiles());
@@ -846,21 +864,21 @@ void GitClient::stashPop(const QString &workingDirectory)
{
QStringList arguments(QLatin1String("stash"));
arguments << QLatin1String("pop");
executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0, true);
executeGit(workingDirectory, arguments, 0, true);
}
void GitClient::branchList(const QString &workingDirectory)
{
QStringList arguments(QLatin1String("branch"));
arguments << QLatin1String("-r");
executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0, true);
executeGit(workingDirectory, arguments, 0, true);
}
void GitClient::stashList(const QString &workingDirectory)
{
QStringList arguments(QLatin1String("stash"));
arguments << QLatin1String("list");
executeGit(workingDirectory, arguments, m_plugin->outputWindow(), 0, true);
executeGit(workingDirectory, arguments, 0, true);
}
QString GitClient::readConfig(const QString &workingDirectory, const QStringList &configVar)

View File

@@ -130,6 +130,10 @@ public:
public slots:
void show(const QString &source, const QString &id);
private slots:
void appendAndPopup(const QString &text);
void appendDataAndPopup(const QByteArray &data);
private:
VCSBase::VCSBaseEditor *createVCSEditor(const QString &kind,
QString title,
@@ -141,7 +145,6 @@ private:
void executeGit(const QString &workingDirectory,
const QStringList &arguments,
GitOutputWindow *outputWindow,
VCSBase::VCSBaseEditor* editor = 0,
bool outputToWindow = false);

View File

@@ -105,7 +105,6 @@ void GitOutputWindow::append(const QString &text)
foreach (const QString &s, lines)
m_outputListWidget->addItem(s);
m_outputListWidget->scrollToBottom();
popup();
}
void GitOutputWindow::setData(const QByteArray &data)

View File

@@ -496,7 +496,7 @@ QString GitPlugin::getWorkingDirectory()
if (workingDirectory.isEmpty()) {
m_outputWindow->clearContents();
m_outputWindow->append(tr("Could not find working directory"));
m_outputWindow->popup();
m_outputWindow->popup(false);
return QString();
}
return workingDirectory;
@@ -612,6 +612,7 @@ void GitPlugin::startCommit()
changeTmpFile->setAutoRemove(true);
if (!changeTmpFile->open()) {
m_outputWindow->append(tr("Cannot create temporary file: %1").arg(changeTmpFile->errorString()));
m_outputWindow->popup(false);
delete changeTmpFile;
return;
}

View File

@@ -6,15 +6,13 @@
<rect>
<x>0</x>
<y>0</y>
<width>436</width>
<height>186</height>
<width>389</width>
<height>183</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="environmentGroupBox">
@@ -104,21 +102,6 @@
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<tabstops>
<tabstop>pathLineEdit</tabstop>

View File

@@ -626,7 +626,7 @@ QList<FolderNode*> DetailedModel::recursiveSubFolders(FolderNode *parentFolder)
FlatModel::FlatModel(SessionNode *rootNode, QObject *parent)
: QAbstractItemModel(parent),
m_filterProjects(true),
m_filterProjects(false),
m_filterGeneratedFiles(true),
m_rootNode(rootNode),
m_startupProject(0),
@@ -914,6 +914,8 @@ QModelIndex FlatModel::indexForNode(const Node *node_)
void FlatModel::setProjectFilterEnabled(bool filter)
{
if (filter == m_filterProjects)
return;
m_filterProjects = filter;
reset();
}

View File

@@ -90,6 +90,20 @@ protected:
if (event->reason() != Qt::PopupFocusReason)
QTreeView::focusOutEvent(event);
}
#ifdef Q_OS_MAC
void keyPressEvent(QKeyEvent *event)
{
if ((event->key() == Qt::Key_Return
|| event->key() == Qt::Key_Enter)
&& event->modifiers() == 0
&& currentIndex().isValid()) {
emit activated(currentIndex());
return;
}
QTreeView::keyPressEvent(event);
}
#endif
};
/*!

View File

@@ -45,6 +45,7 @@
#include <coreplugin/icore.h>
#include <QtCore/QDebug>
#include <QtGui/QApplication>
#include <QtGui/QBoxLayout>
#include <QtGui/QComboBox>
#include <QtGui/QTabWidget>
@@ -190,7 +191,14 @@ void ProjectWindow::updateTreeWidget()
// That one runs fully thorough and deletes all widgets, even that one that we are currently removing
// from m_panelsTabWidget.
// To prevent that, we simply prevent the focus switching....
QWidget *focusWidget = qApp->focusWidget();
while (focusWidget) {
if (focusWidget == this) {
m_treeWidget->setFocus();
break;
}
focusWidget = focusWidget->parentWidget();
}
m_treeWidget->clear();
foreach(Project *project, m_session->projects()) {

View File

@@ -628,8 +628,10 @@ bool SessionManager::loadImpl(const QString &fileName)
if (success) {
// restore the active mode
const QString &modeIdentifier = value(QLatin1String("ActiveMode")).toString();
if (!modeIdentifier.isEmpty())
if (!modeIdentifier.isEmpty()) {
m_core->modeManager()->activateMode(modeIdentifier);
m_core->modeManager()->setFocusToCurrentMode();
}
}
if (debug)

View File

@@ -498,12 +498,8 @@ void Qt4Project::updateCodeModel()
pinfo.sourceFiles = files;
modelmanager->updateProjectInfo(pinfo);
modelmanager->GC();
modelmanager->updateSourceFiles(pinfo.sourceFiles);
}
// update info
}

View File

@@ -54,14 +54,7 @@ QList<FilterEntry> FileSystemFilter::matchesFor(const QString &entry)
QString name = entryInfo.fileName();
QString directory = entryInfo.path();
QString filePath = entryInfo.filePath();
bool isDrive = false;
foreach (const QFileInfo &drive, QDir::drives()) {
if (filePath.startsWith(drive.path())) {
isDrive = true;
break;
}
}
if (!isDrive) {
if (entryInfo.isRelative()) {
if (filePath.startsWith("~/")) {
directory.replace(0, 1, QDir::homePath());
} else {

View File

@@ -54,8 +54,8 @@ class OpenDocumentsFilter : public QuickOpen::IQuickOpenFilter
public:
OpenDocumentsFilter(Core::EditorManager *editorManager);
QString trName() const { return tr("Open document"); }
QString name() const { return "Open document"; }
QString trName() const { return tr("Open documents"); }
QString name() const { return "Open documents"; }
QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::Medium; }
QList<QuickOpen::FilterEntry> matchesFor(const QString &entry);
void accept(QuickOpen::FilterEntry selection) const;

View File

@@ -128,12 +128,13 @@ protected:
ITextEditor *BaseTextEditor::openEditorAt(const QString &fileName,
int line,
int column)
int column,
const QString &editorKind)
{
Core::EditorManager *editorManager =
ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()->editorManager();
editorManager->addCurrentPositionToNavigationHistory(true);
Core::IEditor *editor = editorManager->openEditor(fileName, QString(), true);
Core::IEditor *editor = editorManager->openEditor(fileName, editorKind, true);
TextEditor::ITextEditor *texteditor = qobject_cast<TextEditor::ITextEditor *>(editor);
if (texteditor) {
texteditor->gotoLine(line, column);
@@ -684,6 +685,67 @@ void BaseTextEditor::selectBlockDown()
_q_matchParentheses();
}
void BaseTextEditor::moveLineUp()
{
moveLineUpDown(true);
}
void BaseTextEditor::moveLineDown()
{
moveLineUpDown(false);
}
void BaseTextEditor::moveLineUpDown(bool up)
{
QTextCursor cursor = textCursor();
QTextCursor move = cursor;
move.beginEditBlock();
bool hasSelection = cursor.hasSelection();
if (cursor.hasSelection()) {
move.setPosition(cursor.selectionStart());
move.movePosition(QTextCursor::StartOfBlock);
move.setPosition(cursor.selectionEnd(), QTextCursor::KeepAnchor);
move.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
} else {
move.movePosition(QTextCursor::StartOfBlock);
move.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
}
QString text = move.selectedText();
move.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
move.removeSelectedText();
if (up) {
move.movePosition(QTextCursor::PreviousBlock);
move.insertBlock();
move.movePosition(QTextCursor::Left);
} else {
move.movePosition(QTextCursor::EndOfBlock);
if (move.atBlockStart()) { // empty block
move.movePosition(QTextCursor::NextBlock);
move.insertBlock();
move.movePosition(QTextCursor::Left);
} else {
move.insertBlock();
}
}
int start = move.position();
move.clearSelection();
move.insertText(text);
int end = move.position();
if (hasSelection) {
move.setPosition(start);
move.setPosition(end, QTextCursor::KeepAnchor);
}
indent(document(), move, QChar::Null);
move.endEditBlock();
setTextCursor(move);
}
void BaseTextEditor::cleanWhitespace()
{
@@ -740,9 +802,13 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
QTextCursor cursor = textCursor();
if (d->m_inBlockSelectionMode)
cursor.clearSelection();
cursor.insertBlock();
if (d->m_document->tabSettings().m_autoIndent) {
cursor.beginEditBlock();
cursor.insertBlock();
indent(document(), cursor, QChar::Null);
cursor.endEditBlock();
} else {
cursor.insertBlock();
}
e->accept();
setTextCursor(cursor);
@@ -2451,7 +2517,7 @@ void BaseTextEditor::extraAreaMouseEvent(QMouseEvent *e)
}
} else if (e->button() == Qt::RightButton) {
QMenu * contextMenu = new QMenu(this);
emit d->m_editable->markContextMenuRequested(editableInterface(), cursor.blockNumber(), contextMenu);
emit d->m_editable->markContextMenuRequested(editableInterface(), cursor.blockNumber() + 1, contextMenu);
if (!contextMenu->isEmpty())
contextMenu->exec(e->globalPos());
delete contextMenu;
@@ -2702,6 +2768,8 @@ void BaseTextEditor::handleHomeKey(bool anchor)
while (character == tab || character.category() == QChar::Separator_Space) {
++pos;
if (pos == initpos)
break;
character = characterAt(pos);
}
@@ -2889,12 +2957,13 @@ void BaseTextEditor::markBlocksAsChanged(QList<int> blockNumbers) {
TextBlockUserData::MatchType TextBlockUserData::checkOpenParenthesis(QTextCursor *cursor, QChar c)
{
if (!TextEditDocumentLayout::hasParentheses(cursor->block()))
QTextBlock block = cursor->block();
if (!TextEditDocumentLayout::hasParentheses(block) || TextEditDocumentLayout::ifdefedOut(block))
return NoMatch;
Parentheses parenList = TextEditDocumentLayout::parentheses(cursor->block());
Parentheses parenList = TextEditDocumentLayout::parentheses(block);
Parenthesis openParen, closedParen;
QTextBlock closedParenParag = cursor->block();
QTextBlock closedParenParag = block;
const int cursorPos = cursor->position() - closedParenParag.position();
int i = 0;
@@ -2919,7 +2988,8 @@ TextBlockUserData::MatchType TextBlockUserData::checkOpenParenthesis(QTextCursor
closedParenParag = closedParenParag.next();
if (!closedParenParag.isValid())
return NoMatch;
if (TextEditDocumentLayout::hasParentheses(closedParenParag)) {
if (TextEditDocumentLayout::hasParentheses(closedParenParag)
&& !TextEditDocumentLayout::ifdefedOut(closedParenParag)) {
parenList = TextEditDocumentLayout::parentheses(closedParenParag);
break;
}
@@ -2956,12 +3026,13 @@ TextBlockUserData::MatchType TextBlockUserData::checkOpenParenthesis(QTextCursor
TextBlockUserData::MatchType TextBlockUserData::checkClosedParenthesis(QTextCursor *cursor, QChar c)
{
if (!TextEditDocumentLayout::hasParentheses(cursor->block()))
QTextBlock block = cursor->block();
if (!TextEditDocumentLayout::hasParentheses(block) || TextEditDocumentLayout::ifdefedOut(block))
return NoMatch;
Parentheses parenList = TextEditDocumentLayout::parentheses(cursor->block());
Parentheses parenList = TextEditDocumentLayout::parentheses(block);
Parenthesis openParen, closedParen;
QTextBlock openParenParag = cursor->block();
QTextBlock openParenParag = block;
const int cursorPos = cursor->position() - openParenParag.position();
int i = parenList.count() - 1;
@@ -2987,7 +3058,8 @@ TextBlockUserData::MatchType TextBlockUserData::checkClosedParenthesis(QTextCurs
if (!openParenParag.isValid())
return NoMatch;
if (TextEditDocumentLayout::hasParentheses(openParenParag)) {
if (TextEditDocumentLayout::hasParentheses(openParenParag)
&& !TextEditDocumentLayout::ifdefedOut(openParenParag)) {
parenList = TextEditDocumentLayout::parentheses(openParenParag);
break;
}
@@ -3029,7 +3101,7 @@ bool TextBlockUserData::findPreviousOpenParenthesis(QTextCursor *cursor, bool se
int ignore = 0;
while (block.isValid()) {
Parentheses parenList = TextEditDocumentLayout::parentheses(block);
if (!parenList.isEmpty()) {
if (!parenList.isEmpty() && !TextEditDocumentLayout::ifdefedOut(block)) {
for (int i = parenList.count()-1; i >= 0; --i) {
Parenthesis paren = parenList.at(i);
if (block == cursor->block() && position - block.position() <= paren.pos + 1)
@@ -3056,7 +3128,7 @@ bool TextBlockUserData::findNextClosingParenthesis(QTextCursor *cursor, bool sel
int ignore = 0;
while (block.isValid()) {
Parentheses parenList = TextEditDocumentLayout::parentheses(block);
if (!parenList.isEmpty()) {
if (!parenList.isEmpty() && !TextEditDocumentLayout::ifdefedOut(block)) {
for (int i = 0; i < parenList.count(); ++i) {
Parenthesis paren = parenList.at(i);
if (block == cursor->block() && position - block.position() >= paren.pos)
@@ -3081,7 +3153,7 @@ TextBlockUserData::MatchType TextBlockUserData::matchCursorBackward(QTextCursor
cursor->clearSelection();
const QTextBlock block = cursor->block();
if (!TextEditDocumentLayout::hasParentheses(block))
if (!TextEditDocumentLayout::hasParentheses(block) || TextEditDocumentLayout::ifdefedOut(block))
return NoMatch;
const int relPos = cursor->position() - block.position();
@@ -3103,7 +3175,7 @@ TextBlockUserData::MatchType TextBlockUserData::matchCursorForward(QTextCursor *
cursor->clearSelection();
const QTextBlock block = cursor->block();
if (!TextEditDocumentLayout::hasParentheses(block))
if (!TextEditDocumentLayout::hasParentheses(block) || TextEditDocumentLayout::ifdefedOut(block))
return NoMatch;
const int relPos = cursor->position() - block.position();

View File

@@ -230,7 +230,8 @@ public:
BaseTextEditor(QWidget *parent);
~BaseTextEditor();
static ITextEditor *openEditorAt(const QString &fileName, int line, int column = 0);
static ITextEditor *openEditorAt(const QString &fileName, int line, int column = 0,
const QString &editorKind = QString());
// EditorInterface
Core::IFile * file();
@@ -329,6 +330,9 @@ public slots:
void selectBlockUp();
void selectBlockDown();
void moveLineUp();
void moveLineDown();
void cleanWhitespace();
signals:
@@ -447,6 +451,7 @@ private:
void indentOrUnindent(bool doIndent);
void handleHomeKey(bool anchor);
void handleBackspaceKey();
void moveLineUpDown(bool up);
void toggleBlockVisible(const QTextBlock &block);
QRect collapseBox(const QTextBlock &block);

View File

@@ -66,6 +66,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>20</number>
</property>
@@ -132,6 +135,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>20</number>
</property>

View File

@@ -71,6 +71,7 @@ TextEditorActionHandler::TextEditorActionHandler(Core::ICore *core,
= m_gotoBlockStartAction = m_gotoBlockStartWithSelectionAction
= m_gotoBlockEndAction = m_gotoBlockEndWithSelectionAction
= m_selectBlockUpAction = m_selectBlockDownAction
= m_moveLineUpAction = m_moveLineDownAction
= 0;
m_contextId << m_core->uniqueIDManager()->uniqueIdentifier(context);
@@ -223,6 +224,16 @@ void TextEditorActionHandler::createActions()
command = am->registerAction(m_selectBlockDownAction, Constants::SELECT_BLOCK_DOWN, m_contextId);
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+U")));
connect(m_selectBlockDownAction, SIGNAL(triggered()), this, SLOT(selectBlockDown()));
m_moveLineUpAction= new QAction(tr("Move Line Up"), this);
command = am->registerAction(m_moveLineUpAction, Constants::MOVE_LINE_UP, m_contextId);
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+Up")));
connect(m_moveLineUpAction, SIGNAL(triggered()), this, SLOT(moveLineUp()));
m_moveLineDownAction= new QAction(tr("Move Line Down"), this);
command = am->registerAction(m_moveLineDownAction, Constants::MOVE_LINE_DOWN, m_contextId);
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+Down")));
connect(m_moveLineDownAction, SIGNAL(triggered()), this, SLOT(moveLineDown()));
}
bool TextEditorActionHandler::supportsAction(const QString & /*id */) const
@@ -287,6 +298,8 @@ void TextEditorActionHandler::updateActions(UpdateMode um)
m_gotoBlockEndWithSelectionAction->setEnabled(um != NoEditor);
m_selectBlockUpAction->setEnabled(um != NoEditor);
m_selectBlockDownAction->setEnabled(um != NoEditor);
m_moveLineUpAction->setEnabled(um != NoEditor);
m_moveLineDownAction->setEnabled(um != NoEditor);
m_visualizeWhitespaceAction->setEnabled(um != NoEditor);
if (m_currentEditor)
@@ -390,6 +403,8 @@ FUNCTION(gotoBlockStartWithSelection)
FUNCTION(gotoBlockEndWithSelection)
FUNCTION(selectBlockUp)
FUNCTION(selectBlockDown)
FUNCTION(moveLineUp)
FUNCTION(moveLineDown)
void TextEditorActionHandler::updateCurrentEditor(Core::IContext *object)
{

View File

@@ -116,6 +116,8 @@ private slots:
void gotoBlockEndWithSelection();
void selectBlockUp();
void selectBlockDown();
void moveLineUp();
void moveLineDown();
void updateCurrentEditor(Core::IContext *object);
private:
@@ -145,6 +147,8 @@ private:
QAction *m_gotoBlockEndWithSelectionAction;
QAction *m_selectBlockUpAction;
QAction *m_selectBlockDownAction;
QAction *m_moveLineUpAction;
QAction *m_moveLineDownAction;
uint m_optionalActions;
QPointer<BaseTextEditor> m_currentEditor;

View File

@@ -55,6 +55,8 @@ const char * const GOTO_BLOCK_END = "TextEditor.GotoBlockEnd";
const char * const GOTO_BLOCK_END_WITH_SELECTION = "TextEditor.GotoBlockEndWithSelection";
const char * const SELECT_BLOCK_UP = "TextEditor.SelectBlockUp";
const char * const SELECT_BLOCK_DOWN = "TextEditor.SelectBlockDown";
const char * const MOVE_LINE_UP = "TextEditor.MoveLineUp";
const char * const MOVE_LINE_DOWN = "TextEditor.MoveLineDown";
const char * const DELETE_LINE = "TextEditor.DeleteLine";
const char * const DELETE_WORD = "TextEditor.DeleteWord";
const char * const SELECT_ENCODING = "TextEditor.SelectEncoding";

View File

@@ -53,6 +53,9 @@
#include <QtNetwork/QHostAddress>
#include <iostream>
#include <map>
#include <list>
#include <stack>
#include <string>
#include <vector>
@@ -71,6 +74,9 @@ uint qHash(const double & f)
return int(f);
}
#define X myns
X::QString str;
class Foo
{
public:
@@ -126,8 +132,7 @@ void testArray()
}
}
void testByteArray()
void testQByteArray()
{
QByteArray ba = "Hello";
ba += '"';
@@ -137,8 +142,7 @@ void testByteArray()
ba += 2;
}
void testHash()
void testQHash()
{
QHash<int, float> hgg0;
hgg0[11] = 11.0;
@@ -162,7 +166,7 @@ void testHash()
hash.insert(".", QPointer<QObject>(&ob));
}
void testImage()
void testQImage()
{
QImage im(QSize(200, 200), QImage::Format_RGB32);
im.fill(QColor(200, 100, 130).rgba());
@@ -190,7 +194,7 @@ void testIO()
}
void testList()
void testQList()
{
#if 1
QList<int> li;
@@ -252,7 +256,7 @@ void testList()
v.push_back("dd");
}
void testMap()
void testQMap()
{
QMap<uint, QStringList> ggl;
ggl[11] = QStringList() << "11";
@@ -287,7 +291,7 @@ void testMap()
#endif
}
void testObject(int &argc, char *argv[])
void testQObject(int &argc, char *argv[])
{
QApplication app(argc, argv);
QAction act("xxx", &app);
@@ -315,7 +319,7 @@ void testObject(int &argc, char *argv[])
app.exec();
}
void testPixmap()
void testQPixmap()
{
QImage im(QSize(200, 200), QImage::Format_RGB32);
im.fill(QColor(200, 100, 130).rgba());
@@ -351,7 +355,7 @@ void testPlugin()
}
}
void testSet()
void testQSet()
{
QSet<int> hgg0;
hgg0.insert(11);
@@ -373,65 +377,98 @@ void stringRefTest(const QString &refstring)
Q_UNUSED(refstring);
}
int F(int a, int b)
void testStdList()
{
return a + b;
}
int add(int i) { return i + 2; }
int mul(int i) { return i * 2; }
void testStdVector()
{
int x = F(add(1), mul(2));
Q_UNUSED(x);
std::vector<int *> plist1;
std::list<int *> plist1;
plist1.push_back(new int(1));
plist1.push_back(0);
plist1.push_back(new int(2));
std::vector<int> flist2;
std::list<int> flist2;
flist2.push_back(1);
flist2.push_back(2);
flist2.push_back(3);
flist2.push_back(4);
int a = 1;
int b = 0;
while (0) {
a += 1;
if (b)
break;
}
flist2.push_back(1);
flist2.push_back(2);
flist2.push_back(3);
flist2.push_back(4);
std::vector<Foo *> plist;
std::list<Foo *> plist;
plist.push_back(new Foo(1));
plist.push_back(0);
plist.push_back(new Foo(2));
std::vector<Foo> flist;
std::list<Foo> flist;
flist.push_back(1);
flist.push_back(2);
flist.push_back(3);
flist.push_back(4);
//flist.takeFirst();
//flist.takeFirst();
std::vector<bool> vec;
std::list<bool> vec;
vec.push_back(true);
vec.push_back(false);
}
void testStdMap()
{
std::map<uint, QStringList> ggl;
ggl[11] = QStringList() << "11";
ggl[22] = QStringList() << "22";
typedef std::map<uint, QStringList> T;
T ggt;
ggt[11] = QStringList() << "11";
ggt[22] = QStringList() << "22";
#if 0
std::map<uint, float> gg0;
gg0[11] = 11.0;
gg0[22] = 22.0;
std::map<QString, float> gg1;
gg1["22.0"] = 22.0;
std::map<int, QString> gg2;
gg2[22] = "22.0";
std::map<QString, Foo> gg3;
gg3["22.0"] = Foo(22);
gg3["33.0"] = Foo(33);
QObject ob;
std::map<QString, QPointer<QObject> > map;
map.insert("Hallo", QPointer<QObject>(&ob));
map.insert("Welt", QPointer<QObject>(&ob));
map.insert(".", QPointer<QObject>(&ob));
#endif
}
void testStdStack()
{
std::stack<int *> plist1;
plist1.push(new int(1));
plist1.push(0);
plist1.push(new int(2));
plist1.pop();
plist1.pop();
plist1.pop();
std::stack<int> flist2;
flist2.push(1);
flist2.push(2);
std::stack<Foo *> plist;
plist.push(new Foo(1));
plist.push(new Foo(2));
std::stack<Foo> flist;
flist.push(1);
flist.push(2);
}
void testStdString()
{
QString foo;
@@ -470,7 +507,43 @@ void testStdString()
v.push_back(str);
}
void testString()
void testStdVector()
{
std::vector<int *> plist1;
plist1.push_back(new int(1));
plist1.push_back(0);
plist1.push_back(new int(2));
std::vector<int> flist2;
flist2.push_back(1);
flist2.push_back(2);
flist2.push_back(3);
flist2.push_back(4);
flist2.push_back(1);
flist2.push_back(2);
flist2.push_back(3);
flist2.push_back(4);
std::vector<Foo *> plist;
plist.push_back(new Foo(1));
plist.push_back(0);
plist.push_back(new Foo(2));
std::vector<Foo> flist;
flist.push_back(1);
flist.push_back(2);
flist.push_back(3);
flist.push_back(4);
//flist.takeFirst();
//flist.takeFirst();
std::vector<bool> vec;
vec.push_back(true);
vec.push_back(false);
}
void testQString()
{
QString str = "Hello ";
str += " big, ";
@@ -480,19 +553,9 @@ void testString()
str += " World ";
str += " World ";
str += " World ";
str += " World ";
str += " World ";
str += " World ";
str += " World ";
str += " World ";
str += " World ";
str += " World ";
str += " World ";
str += " World ";
str += " World ";
}
void testString3()
void testQString3()
{
QString str = "Hello ";
str += " big, ";
@@ -508,7 +571,7 @@ void testString3()
delete pstring;
}
void testStringList()
void testQStringList()
{
QStringList l;
l << "Hello ";
@@ -542,7 +605,7 @@ private:
int m_id;
};
void testThreads()
void testQThread()
{
Thread thread1(1);
Thread thread2(2);
@@ -552,7 +615,7 @@ void testThreads()
thread2.wait();
}
void testVariant1()
void testQVariant1()
{
QVariant v;
v = 1;
@@ -561,7 +624,7 @@ void testVariant1()
v = 1;
}
void testVariant2()
void testQVariant2()
{
QVariant var;
#if 0
@@ -586,7 +649,7 @@ void testVariant2()
var.setValue(my);
}
void testVariant3()
void testQVariant3()
{
QList<int> list;
list << 1 << 2 << 3;
@@ -595,8 +658,10 @@ void testVariant3()
list = qVariantValue<QList<int> >(variant);
}
void testVector()
void testQVector()
{
QVector<int> big(10000);
QVector<Foo *> plist;
plist.append(new Foo(1));
plist.append(0);
@@ -616,7 +681,7 @@ void testVector()
vec.append(false);
}
void testVectorOfList()
void testQVectorOfQList()
{
QVector<QList<int> > v;
QVector<QList<int> > *pv = &v;
@@ -729,16 +794,9 @@ void testNamespace()
bar.doit(1);
}
int main(int argc, char *argv[])
void testHidden()
{
testIO();
//QString s;
//s = "hallo";
//QList<QVector<int> *> vi;
//QList<QVector<double> *> vd;
//int n = A::barz();
int n = 1;
n = 2;
n = 3;
@@ -762,34 +820,43 @@ int main(int argc, char *argv[])
}
++n;
++n;
}
int main(int argc, char *argv[])
{
//testIO();
testHidden();
testArray();
testStdVector();
testStdList();
testStdMap();
testStdStack();
testStdString();
testStdVector();
testPlugin();
testList();
testQList();
testNamespace();
//return 0;
testByteArray();
testHash();
testImage();
testMap();
testString();
testSet();
testStringList();
testQByteArray();
testQHash();
testQImage();
testQMap();
testQString();
testQSet();
testQStringList();
testStruct();
//testThreads();
testVariant1();
testVariant2();
testVariant3();
testVector();
testVectorOfList();
testQVariant1();
testQVariant2();
testQVariant3();
testQVector();
testQVectorOfQList();
*(int *)0 = 0;
testObject(argc, argv);
testQObject(argc, argv);
//QColor color(255,128,10);