Merge branch '0.9.1-beta' of git@scm.dev.nokia.troll.no:creator/mainline into 0.9.1-beta

This commit is contained in:
mae
2008-12-10 18:02:16 +01:00
33 changed files with 627 additions and 320 deletions

View File

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

View File

@@ -1208,4 +1208,141 @@ int Lexer::classify(const char *s, int n, bool q) {
} // switch } // 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 CPLUSPLUS_END_NAMESPACE

View File

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

View File

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

View File

@@ -209,7 +209,19 @@ enum Kind {
T_LAST_KEYWORD = T_SLOTS, 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,
T___ASM__ = T_ASM, T___ASM__ = T_ASM,

View File

@@ -33,8 +33,6 @@
#include "CppDocument.h" #include "CppDocument.h"
#include <utils/qtcassert.h>
#include <Control.h> #include <Control.h>
#include <TranslationUnit.h> #include <TranslationUnit.h>
#include <DiagnosticClient.h> #include <DiagnosticClient.h>
@@ -133,12 +131,16 @@ QString Document::fileName() const
QStringList Document::includedFiles() 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) void Document::appendMacro(const Macro &macro)
@@ -273,7 +275,7 @@ bool Document::parse(ParseMode mode)
void Document::check() void Document::check()
{ {
QTC_ASSERT(!_globalNamespace, return); Q_ASSERT(!_globalNamespace);
Semantic semantic(_control); Semantic semantic(_control);

View File

@@ -65,7 +65,7 @@ public:
QString fileName() const; QString fileName() const;
QStringList includedFiles() const; QStringList includedFiles() const;
void addIncludeFile(const QString &fileName); void addIncludeFile(const QString &fileName, unsigned line);
void appendMacro(const Macro &macro); void appendMacro(const Macro &macro);
void addMacroUse(const Macro &macro, unsigned offset, unsigned length); void addMacroUse(const Macro &macro, unsigned offset, unsigned length);
@@ -181,6 +181,22 @@ public:
{ return pos >= _begin && pos < _end; } { 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 { class MacroUse: public Block {
Macro _macro; Macro _macro;
@@ -196,6 +212,9 @@ public:
{ return _macro; } { return _macro; }
}; };
QList<Include> includes() const
{ return _includes; }
QList<Block> skippedBlocks() const QList<Block> skippedBlocks() const
{ return _skippedBlocks; } { return _skippedBlocks; }
@@ -207,11 +226,11 @@ private:
private: private:
QString _fileName; QString _fileName;
QStringList _includedFiles;
Control *_control; Control *_control;
TranslationUnit *_translationUnit; TranslationUnit *_translationUnit;
Namespace *_globalNamespace; Namespace *_globalNamespace;
QList<DiagnosticMessage> _diagnosticMessages; QList<DiagnosticMessage> _diagnosticMessages;
QList<Include> _includes;
QList<Macro> _definedMacros; QList<Macro> _definedMacros;
QList<Block> _skippedBlocks; QList<Block> _skippedBlocks;
QList<MacroUse> _macroUses; QList<MacroUse> _macroUses;

View File

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

View File

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

View File

@@ -63,7 +63,8 @@ public:
{ } { }
virtual void macroAdded(const Macro &macro) = 0; 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, virtual void startExpandingMacro(unsigned offset,
const Macro &macro, const Macro &macro,

View File

@@ -818,7 +818,7 @@ void pp::processInclude(bool skipCurentPath,
QString fn = QString::fromUtf8(path.constData(), path.length()); QString fn = QString::fromUtf8(path.constData(), path.length());
if (client) 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)) { } else if (tk->is(T_ANGLE_STRING_LITERAL) || tk->is(T_STRING_LITERAL)) {
const QByteArray spell = tokenSpell(*tk); const QByteArray spell = tokenSpell(*tk);
const char *beginOfPath = spell.constBegin(); const char *beginOfPath = spell.constBegin();
@@ -831,7 +831,7 @@ void pp::processInclude(bool skipCurentPath,
QString fn = QString::fromUtf8(path.constData(), path.length()); QString fn = QString::fromUtf8(path.constData(), path.length());
if (client) 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-environment.h"
#include "pp.h" #include "pp.h"
#include <utils/qtcassert.h>
#include <cstring> #include <cstring>
using namespace CPlusPlus; using namespace CPlusPlus;
@@ -93,7 +91,7 @@ Macro *Environment::macroAt(unsigned index) const
Macro *Environment::bind(const Macro &__macro) Macro *Environment::bind(const Macro &__macro)
{ {
QTC_ASSERT(! __macro.name.isEmpty(), return 0); Q_ASSERT(! __macro.name.isEmpty());
Macro *m = new Macro (__macro); Macro *m = new Macro (__macro);
m->hashcode = hash_code(m->name); m->hashcode = hash_code(m->name);

View File

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

View File

@@ -47,6 +47,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &initialCategory,
setupUi(this); setupUi(this);
buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
splitter->setCollapsible(1, false);
pageTree->header()->setVisible(false); pageTree->header()->setVisible(false);
connect(pageTree, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), connect(pageTree, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
@@ -59,7 +60,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &initialCategory,
int index = 0; int index = 0;
foreach (IOptionsPage *page, pages) { foreach (IOptionsPage *page, pages) {
QTreeWidgetItem *item = new QTreeWidgetItem(); QTreeWidgetItem *item = new QTreeWidgetItem;
item->setText(0, page->name()); item->setText(0, page->name());
item->setData(0, Qt::UserRole, index); item->setData(0, Qt::UserRole, index);

View File

@@ -186,6 +186,15 @@ MainWindow::MainWindow() :
QCoreApplication::setOrganizationName(QLatin1String("Nokia")); QCoreApplication::setOrganizationName(QLatin1String("Nokia"));
QSettings::setDefaultFormat(QSettings::IniFormat); QSettings::setDefaultFormat(QSettings::IniFormat);
QString baseName = qApp->style()->objectName(); 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)); qApp->setStyle(new ManhattanStyle(baseName));
statusBar()->setProperty("p_styled", true); statusBar()->setProperty("p_styled", true);
} }

View File

@@ -480,13 +480,23 @@ void CPPEditor::jumpToDefinition()
Document::Ptr doc = m_modelManager->document(file()->fileName()); Document::Ptr doc = m_modelManager->document(file()->fileName());
if (!doc) if (!doc)
return; return;
QTextCursor tc = textCursor();
unsigned lineno = tc.blockNumber() + 1;
foreach (const Document::Include &incl, doc->includes()) {
if (incl.line() == lineno) {
if (TextEditor::BaseTextEditor::openEditorAt(incl.fileName(), 0, 0))
return; // done
break;
}
}
Symbol *lastSymbol = doc->findSymbolAt(line, column); Symbol *lastSymbol = doc->findSymbolAt(line, column);
if (!lastSymbol) if (!lastSymbol)
return; return;
// Get the expression under the cursor // Get the expression under the cursor
const int endOfName = endOfNameUnderCursor(); const int endOfName = endOfNameUnderCursor();
QTextCursor tc = textCursor();
tc.setPosition(endOfName); tc.setPosition(endOfName);
ExpressionUnderCursor expressionUnderCursor; ExpressionUnderCursor expressionUnderCursor;
const QString expression = expressionUnderCursor(tc); const QString expression = expressionUnderCursor(tc);

View File

@@ -177,6 +177,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()) { if (m_toolTip.isEmpty()) {
// Move to the end of a qualified name // Move to the end of a qualified name
bool stop = false; bool stop = false;

View File

@@ -138,7 +138,8 @@ protected:
virtual void stopExpandingMacro(unsigned offset, const Macro &macro); virtual void stopExpandingMacro(unsigned offset, const Macro &macro);
virtual void startSkippingBlocks(unsigned offset); virtual void startSkippingBlocks(unsigned offset);
virtual void stopSkippingBlocks(unsigned offset); virtual void stopSkippingBlocks(unsigned offset);
virtual void sourceNeeded(QString &fileName, IncludeType type); virtual void sourceNeeded(QString &fileName, IncludeType type,
unsigned line);
private: private:
QPointer<CppModelManager> m_modelManager; QPointer<CppModelManager> m_modelManager;
@@ -176,7 +177,7 @@ void CppPreprocessor::setProjectFiles(const QStringList &files)
{ m_projectFiles = files; } { m_projectFiles = files; }
void CppPreprocessor::run(QString &fileName) void CppPreprocessor::run(QString &fileName)
{ sourceNeeded(fileName, IncludeGlobal); } { sourceNeeded(fileName, IncludeGlobal, /*line = */ 0); }
void CppPreprocessor::operator()(QString &fileName) void CppPreprocessor::operator()(QString &fileName)
{ run(fileName); } { run(fileName); }
@@ -361,7 +362,8 @@ void CppPreprocessor::stopSkippingBlocks(unsigned offset)
m_currentDoc->stopSkippingBlocks(offset); m_currentDoc->stopSkippingBlocks(offset);
} }
void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type) void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type,
unsigned line)
{ {
if (fileName.isEmpty()) if (fileName.isEmpty())
return; return;
@@ -369,7 +371,7 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type)
QByteArray contents = tryIncludeFile(fileName, type); QByteArray contents = tryIncludeFile(fileName, type);
if (m_currentDoc) { if (m_currentDoc) {
m_currentDoc->addIncludeFile(fileName); m_currentDoc->addIncludeFile(fileName, line);
if (contents.isEmpty() && ! QFileInfo(fileName).isAbsolute()) { if (contents.isEmpty() && ! QFileInfo(fileName).isAbsolute()) {
QString msg; QString msg;
msg += fileName; msg += fileName;

View File

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

View File

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

View File

@@ -402,18 +402,30 @@ bool WatchHandler::setData(const QModelIndex &idx,
static QString niceType(QString type) static QString niceType(QString type)
{ {
if (type.contains("std::")) { if (type.contains("std::")) {
static QRegExp re("std::vector<(.*)\\s*,std::allocator<(.*)>\\s*>"); // std::string
re.setMinimal(true);
type.replace("std::basic_string<char, std::char_traits<char>, " type.replace("std::basic_string<char, std::char_traits<char>, "
"std::allocator<char> >", "std::string"); "std::allocator<char> >", "std::string");
// std::wstring
type.replace("std::basic_string<wchar_t, std::char_traits<wchar_t>, " type.replace("std::basic_string<wchar_t, std::char_traits<wchar_t>, "
"std::allocator<wchar_t> >", "std::wstring"); "std::allocator<wchar_t> >", "std::wstring");
// std::vector
static QRegExp re1("std::vector<(.*)\\s*,std::allocator<(.*)>\\s*>");
re1.setMinimal(true);
for (int i = 0; i != 10; ++i) { 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; 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<(.*)\\s*,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) + ">");
} }
type.replace(" >", ">"); type.replace(" >", ">");
@@ -865,9 +877,9 @@ void WatchHandler::watchExpression(const QString &exp)
data.name = exp; data.name = exp;
data.iname = "watch." + exp; data.iname = "watch." + exp;
insertData(data); insertData(data);
emit watchModelUpdateRequested();
} }
void WatchHandler::setDisplayedIName(const QString &iname, bool on) void WatchHandler::setDisplayedIName(const QString &iname, bool on)
{ {
WatchData *d = findData(iname); WatchData *d = findData(iname);

View File

@@ -43,6 +43,7 @@ ChangeSelectionDialog::ChangeSelectionDialog(QWidget *parent)
{ {
m_ui.setupUi(this); m_ui.setupUi(this);
connect(m_ui.repositoryButton, SIGNAL(clicked()), this, SLOT(selectWorkingDirectory())); connect(m_ui.repositoryButton, SIGNAL(clicked()), this, SLOT(selectWorkingDirectory()));
setWindowTitle(tr("Select a Git commit"));
} }
void ChangeSelectionDialog::selectWorkingDirectory() void ChangeSelectionDialog::selectWorkingDirectory()
@@ -59,7 +60,7 @@ void ChangeSelectionDialog::selectWorkingDirectory()
// the head directory of the repository. // the head directory of the repository.
QDir repository(location); QDir repository(location);
do { do {
if (repository.entryList(QDir::AllDirs).contains(QLatin1String(".git"))) { if (repository.entryList(QDir::AllDirs|QDir::Hidden).contains(QLatin1String(".git"))) {
m_ui.repositoryEdit->setText(repository.absolutePath()); m_ui.repositoryEdit->setText(repository.absolutePath());
return; return;
} }

View File

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

View File

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

View File

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

View File

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

View File

@@ -6,114 +6,97 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>436</width> <width>389</width>
<height>186</height> <height>183</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"> <widget class="QGroupBox" name="environmentGroupBox">
<item> <property name="enabled">
<widget class="QGroupBox" name="environmentGroupBox"> <bool>true</bool>
<property name="enabled"> </property>
<bool>true</bool> <property name="title">
</property> <string>Environment variables</string>
<property name="title"> </property>
<string>Environment variables</string> <property name="checkable">
</property> <bool>true</bool>
<property name="checkable"> </property>
<bool>true</bool> <layout class="QFormLayout" name="formLayout">
</property> <item row="0" column="0">
<layout class="QFormLayout" name="formLayout"> <widget class="QLabel" name="pathlabel">
<item row="0" column="0"> <property name="text">
<widget class="QLabel" name="pathlabel"> <string>PATH:</string>
<property name="text"> </property>
<string>PATH:</string> </widget>
</property> </item>
</widget> <item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="pathLineEdit"/>
</item> </item>
<item row="0" column="1"> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <widget class="QPushButton" name="adoptButton">
<item>
<widget class="QLineEdit" name="pathLineEdit"/>
</item>
<item>
<widget class="QPushButton" name="adoptButton">
<property name="text">
<string>From system</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="noteLabel">
<property name="text"> <property name="text">
<string>&lt;b&gt;Note:&lt;/b&gt;</string> <string>From system</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="noteFieldlabel">
<property name="text">
<string>Git needs to find Perl in the environment as well.</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="noteLabel">
<property name="text">
<string>&lt;b&gt;Note:&lt;/b&gt;</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="noteFieldlabel">
<property name="text">
<string>Git needs to find Perl in the environment as well.</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QFormLayout" name="logFormLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="1">
<widget class="QSpinBox" name="logCountSpinBox">
<property name="toolTip">
<string>Note that huge amount of commits might take some time.</string>
</property>
<property name="maximum">
<number>1000</number>
</property>
</widget> </widget>
</item> </item>
<item> <item row="0" column="0">
<layout class="QFormLayout" name="logFormLayout"> <widget class="QLabel" name="logCountLabel">
<property name="fieldGrowthPolicy"> <property name="text">
<enum>QFormLayout::ExpandingFieldsGrow</enum> <string>Log commit display count:</string>
</property> </property>
<item row="0" column="1"> </widget>
<widget class="QSpinBox" name="logCountSpinBox">
<property name="toolTip">
<string>Note that huge amount of commits might take some time.</string>
</property>
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="logCountLabel">
<property name="text">
<string>Log commit display count:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>40</width> <width>20</width>
<height>20</height> <height>40</height>
</size> </size>
</property> </property>
</spacer> </spacer>

View File

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

View File

@@ -90,6 +90,20 @@ protected:
if (event->reason() != Qt::PopupFocusReason) if (event->reason() != Qt::PopupFocusReason)
QTreeView::focusOutEvent(event); 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 <coreplugin/icore.h>
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtGui/QApplication>
#include <QtGui/QBoxLayout> #include <QtGui/QBoxLayout>
#include <QtGui/QComboBox> #include <QtGui/QComboBox>
#include <QtGui/QTabWidget> #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 // That one runs fully thorough and deletes all widgets, even that one that we are currently removing
// from m_panelsTabWidget. // from m_panelsTabWidget.
// To prevent that, we simply prevent the focus switching.... // To prevent that, we simply prevent the focus switching....
m_treeWidget->setFocus(); QWidget *focusWidget = qApp->focusWidget();
while (focusWidget) {
if (focusWidget == this) {
m_treeWidget->setFocus();
break;
}
focusWidget = focusWidget->parentWidget();
}
m_treeWidget->clear(); m_treeWidget->clear();
foreach(Project *project, m_session->projects()) { foreach(Project *project, m_session->projects()) {

View File

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

View File

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

View File

@@ -53,6 +53,8 @@
#include <QtNetwork/QHostAddress> #include <QtNetwork/QHostAddress>
#include <iostream> #include <iostream>
#include <list>
#include <stack>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -71,6 +73,9 @@ uint qHash(const double & f)
return int(f); return int(f);
} }
#define X myns
X::QString str;
class Foo class Foo
{ {
public: public:
@@ -127,7 +132,7 @@ void testArray()
} }
void testByteArray() void testQByteArray()
{ {
QByteArray ba = "Hello"; QByteArray ba = "Hello";
ba += '"'; ba += '"';
@@ -138,7 +143,7 @@ void testByteArray()
} }
void testHash() void testQHash()
{ {
QHash<int, float> hgg0; QHash<int, float> hgg0;
hgg0[11] = 11.0; hgg0[11] = 11.0;
@@ -162,7 +167,7 @@ void testHash()
hash.insert(".", QPointer<QObject>(&ob)); hash.insert(".", QPointer<QObject>(&ob));
} }
void testImage() void testQImage()
{ {
QImage im(QSize(200, 200), QImage::Format_RGB32); QImage im(QSize(200, 200), QImage::Format_RGB32);
im.fill(QColor(200, 100, 130).rgba()); im.fill(QColor(200, 100, 130).rgba());
@@ -190,7 +195,7 @@ void testIO()
} }
void testList() void testQList()
{ {
#if 1 #if 1
QList<int> li; QList<int> li;
@@ -252,7 +257,7 @@ void testList()
v.push_back("dd"); v.push_back("dd");
} }
void testMap() void testQMap()
{ {
QMap<uint, QStringList> ggl; QMap<uint, QStringList> ggl;
ggl[11] = QStringList() << "11"; ggl[11] = QStringList() << "11";
@@ -287,7 +292,7 @@ void testMap()
#endif #endif
} }
void testObject(int &argc, char *argv[]) void testQObject(int &argc, char *argv[])
{ {
QApplication app(argc, argv); QApplication app(argc, argv);
QAction act("xxx", &app); QAction act("xxx", &app);
@@ -315,7 +320,7 @@ void testObject(int &argc, char *argv[])
app.exec(); app.exec();
} }
void testPixmap() void testQPixmap()
{ {
QImage im(QSize(200, 200), QImage::Format_RGB32); QImage im(QSize(200, 200), QImage::Format_RGB32);
im.fill(QColor(200, 100, 130).rgba()); im.fill(QColor(200, 100, 130).rgba());
@@ -351,7 +356,7 @@ void testPlugin()
} }
} }
void testSet() void testQSet()
{ {
QSet<int> hgg0; QSet<int> hgg0;
hgg0.insert(11); hgg0.insert(11);
@@ -373,65 +378,63 @@ void stringRefTest(const QString &refstring)
Q_UNUSED(refstring); Q_UNUSED(refstring);
} }
void testStdList()
int F(int a, int b)
{ {
return a + b; std::list<int *> plist1;
}
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;
plist1.push_back(new int(1)); plist1.push_back(new int(1));
plist1.push_back(0); plist1.push_back(0);
plist1.push_back(new int(2)); plist1.push_back(new int(2));
std::vector<int> flist2; std::list<int> flist2;
flist2.push_back(1); flist2.push_back(1);
flist2.push_back(2); flist2.push_back(2);
flist2.push_back(3); flist2.push_back(3);
flist2.push_back(4); flist2.push_back(4);
int a = 1;
int b = 0;
while (0) {
a += 1;
if (b)
break;
}
flist2.push_back(1); flist2.push_back(1);
flist2.push_back(2); flist2.push_back(2);
flist2.push_back(3); flist2.push_back(3);
flist2.push_back(4); flist2.push_back(4);
std::vector<Foo *> plist; std::list<Foo *> plist;
plist.push_back(new Foo(1)); plist.push_back(new Foo(1));
plist.push_back(0); plist.push_back(0);
plist.push_back(new Foo(2)); plist.push_back(new Foo(2));
std::vector<Foo> flist; std::list<Foo> flist;
flist.push_back(1); flist.push_back(1);
flist.push_back(2); flist.push_back(2);
flist.push_back(3); flist.push_back(3);
flist.push_back(4); flist.push_back(4);
//flist.takeFirst();
//flist.takeFirst();
std::vector<bool> vec; std::list<bool> vec;
vec.push_back(true); vec.push_back(true);
vec.push_back(false); vec.push_back(false);
} }
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() void testStdString()
{ {
QString foo; QString foo;
@@ -470,7 +473,43 @@ void testStdString()
v.push_back(str); 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 "; QString str = "Hello ";
str += " big, "; str += " big, ";
@@ -480,19 +519,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 ";
str += " World ";
str += " World ";
str += " World ";
} }
void testString3() void testQString3()
{ {
QString str = "Hello "; QString str = "Hello ";
str += " big, "; str += " big, ";
@@ -508,7 +537,7 @@ void testString3()
delete pstring; delete pstring;
} }
void testStringList() void testQStringList()
{ {
QStringList l; QStringList l;
l << "Hello "; l << "Hello ";
@@ -542,7 +571,7 @@ private:
int m_id; int m_id;
}; };
void testThreads() void testQThread()
{ {
Thread thread1(1); Thread thread1(1);
Thread thread2(2); Thread thread2(2);
@@ -552,7 +581,7 @@ void testThreads()
thread2.wait(); thread2.wait();
} }
void testVariant1() void testQVariant1()
{ {
QVariant v; QVariant v;
v = 1; v = 1;
@@ -561,7 +590,7 @@ void testVariant1()
v = 1; v = 1;
} }
void testVariant2() void testQVariant2()
{ {
QVariant var; QVariant var;
#if 0 #if 0
@@ -586,7 +615,7 @@ void testVariant2()
var.setValue(my); var.setValue(my);
} }
void testVariant3() void testQVariant3()
{ {
QList<int> list; QList<int> list;
list << 1 << 2 << 3; list << 1 << 2 << 3;
@@ -595,8 +624,10 @@ void testVariant3()
list = qVariantValue<QList<int> >(variant); list = qVariantValue<QList<int> >(variant);
} }
void testVector() void testQVector()
{ {
QVector<int> big(10000);
QVector<Foo *> plist; QVector<Foo *> plist;
plist.append(new Foo(1)); plist.append(new Foo(1));
plist.append(0); plist.append(0);
@@ -616,7 +647,7 @@ void testVector()
vec.append(false); vec.append(false);
} }
void testVectorOfList() void testQVectorOfQList()
{ {
QVector<QList<int> > v; QVector<QList<int> > v;
QVector<QList<int> > *pv = &v; QVector<QList<int> > *pv = &v;
@@ -729,16 +760,9 @@ void testNamespace()
bar.doit(1); 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; int n = 1;
n = 2; n = 2;
n = 3; n = 3;
@@ -762,34 +786,42 @@ int main(int argc, char *argv[])
} }
++n; ++n;
++n; ++n;
}
int main(int argc, char *argv[])
{
//testIO();
testHidden();
testArray(); testArray();
testStdVector();
testStdList();
testStdStack();
testStdString(); testStdString();
testStdVector();
testPlugin(); testPlugin();
testList(); testQList();
testNamespace(); testNamespace();
//return 0; //return 0;
testByteArray(); testQByteArray();
testHash(); testQHash();
testImage(); testQImage();
testMap(); testQMap();
testString(); testQString();
testSet(); testQSet();
testStringList(); testQStringList();
testStruct(); testStruct();
//testThreads(); //testThreads();
testVariant1(); testQVariant1();
testVariant2(); testQVariant2();
testVariant3(); testQVariant3();
testVector(); testQVector();
testVectorOfList(); testQVectorOfQList();
*(int *)0 = 0; *(int *)0 = 0;
testObject(argc, argv); testQObject(argc, argv);
//QColor color(255,128,10); //QColor color(255,128,10);