Commit 5321950d authored by dt's avatar dt
Browse files

Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline

parents 5df4f930 38baf276
......@@ -29,12 +29,6 @@
#include <qglobal.h>
// this relies on contents copied from qobject_p.h
#define PRIVATE_OBJECT_ALLOWED 1
#ifdef HAS_QOBJECT_P_H // Detected by qmake
# include <QtCore/private/qobject_p.h>
#endif
#include <QtCore/QDateTime>
#include <QtCore/QDebug>
#include <QtCore/QDir>
......@@ -149,68 +143,76 @@ int qtGhVersion = QT_VERSION;
# define NSY ""
#endif
#if PRIVATE_OBJECT_ALLOWED && !defined(HAS_QOBJECT_P_H)
#if defined(QT_BEGIN_NAMESPACE)
QT_BEGIN_NAMESPACE
#endif
class QVariant;
class QThreadData;
class QObjectConnectionListVector;
struct Sender { QObject *sender; int signal; int ref; };
class QObjectPrivate : public QObjectData
{
Q_DECLARE_PUBLIC(QObject)
public:
QObjectPrivate() {}
virtual ~QObjectPrivate() {}
#if QT_VERSION < 0x040600
struct Connection
{
QObject *receiver;
int method;
uint connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking
QBasicAtomicPointer<int> argumentTypes;
};
// preserve binary compatibility with code compiled without Qt 3 support
QList<QObject *> pendingChildInsertedEvents; // unused
typedef QList<Connection> ConnectionList;
typedef QList<Sender> SenderList;
// id of the thread that owns the object
QThreadData *threadData;
const Connection &connectionAt(const ConnectionList &l, int i) { return l.at(i); }
const QObject *senderAt(const SenderList &l, int i) { return l.at(i).sender; }
int signalAt(const SenderList &l, int i) { return l.at(i).signal; }
#endif
struct Sender
#if QT_VERSION >= 0x040600
struct Connection
{
QObject *sender;
int signal;
int ref;
QObject *receiver;
int method;
uint connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking
QBasicAtomicPointer<int> argumentTypes;
};
Sender *currentSender; // object currently activating the object
QObject *currentChildBeingDeleted;
typedef QList<Connection *> ConnectionList;
typedef ConnectionList SenderList;
const Connection &connectionAt(const ConnectionList &l, int i) { return *l.at(i); }
const QObject *senderAt(const SenderList &l, int i) { return l.at(i)->sender; }
// FIXME: 'method' is wrong
int signalAt(const SenderList &l, int i) { return l.at(i)->method; }
#endif
class QObjectPrivate : public QObjectData
{
public:
QObjectPrivate() {}
virtual ~QObjectPrivate() {}
QList<QObject *> pendingChildInsertedEvents;
void *threadData;
void *currentSender;
void *currentChildBeingDeleted;
QList<QPointer<QObject> > eventFilters;
struct ExtraData;
ExtraData *extraData;
void *extraData;
mutable quint32 connectedSignals;
QString objectName;
struct Connection
{
QObject *receiver;
int method;
uint connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking
QBasicAtomicPointer<int> argumentTypes;
};
typedef QList<Connection> ConnectionList;
QObjectConnectionListVector *connectionLists;
QList<Sender> senders;
void *connectionLists;
SenderList senders;
int *deleteWatch;
};
#if defined(QT_BEGIN_NAMESPACE)
QT_END_NAMESPACE
#endif
#endif // PRIVATE_OBJECT_ALLOWED
// This can be mangled typenames of nested templates, each char-by-char
// comma-separated integer list...
......@@ -1547,13 +1549,6 @@ static void qDumpQObject(QDumper &d)
const QObject *ob = reinterpret_cast<const QObject *>(d.data);
const QMetaObject *mo = ob->metaObject();
unsigned childrenOffset = d.extraInt[0];
#ifdef HAS_QOBJECT_P_H
// QObject child offset if known
if (!childrenOffset) {
QObjectPrivate qop;
childrenOffset = (char*)&qop.children - (char*)&qop;
}
#endif
P(d, "value", ob->objectName());
P(d, "valueencoded", "2");
P(d, "type", NS"QObject");
......@@ -1594,7 +1589,6 @@ static void qDumpQObject(QDumper &d)
P(d, "type", NS"QList<"NS"QObjectPrivateSender>");
d.endHash();
#endif
#if PRIVATE_OBJECT_ALLOWED
d.beginHash();
P(d, "name", "signals");
P(d, "exp", "*(class '"NS"QObject'*)" << d.data);
......@@ -1609,7 +1603,6 @@ static void qDumpQObject(QDumper &d)
P(d, "value", "<" << slotCount << " items>");
P(d, "numchild", slotCount);
d.endHash();
#endif
if (childrenOffset) {
d.beginHash();
P(d, "name", "children");
......@@ -1624,24 +1617,6 @@ static void qDumpQObject(QDumper &d)
P(d, "numchild", children.size());
d.endHash();
}
#if 0
// Unneeded (and not working): Connections are listes as childen
// of the signal or slot they are connected to.
// d.beginHash();
// P(d, "name", "connections");
// P(d, "exp", "*(*(class "NS"QObjectPrivate*)" << dfunc(ob) << ")->connectionLists");
// P(d, "type", NS"QVector<"NS"QList<"NS"QObjectPrivate::Connection> >");
// d.endHash();
#endif
#if 0
d.beginHash();
P(d, "name", "objectprivate");
P(d, "type", NS"QObjectPrivate");
P(d, "addr", dfunc(ob));
P(d, "value", "");
P(d, "numchild", "1");
d.endHash();
#endif
d.beginHash();
P(d, "name", "parent");
qDumpInnerValueHelper(d, NS"QObject *", ob->parent());
......@@ -1720,7 +1695,6 @@ static void qDumpQObjectMethodList(QDumper &d)
d.disarm();
}
#if PRIVATE_OBJECT_ALLOWED
const char * qConnectionTypes[] ={
"auto",
"direct",
......@@ -1730,13 +1704,13 @@ const char * qConnectionTypes[] ={
};
#if QT_VERSION >= 0x040400
static const QObjectPrivate::ConnectionList &qConnectionList(const QObject *ob, int signalNumber)
static const ConnectionList &qConnectionList(const QObject *ob, int signalNumber)
{
static const QObjectPrivate::ConnectionList emptyList;
static const ConnectionList emptyList;
const QObjectPrivate *p = reinterpret_cast<const QObjectPrivate *>(dfunc(ob));
if (!p->connectionLists)
return emptyList;
typedef QVector<QObjectPrivate::ConnectionList> ConnLists;
typedef QVector<ConnectionList> ConnLists;
const ConnLists *lists = reinterpret_cast<const ConnLists *>(p->connectionLists);
// there's an optimization making the lists only large enough to hold the
// last non-empty item
......@@ -1758,9 +1732,9 @@ static void qDumpQObjectSignal(QDumper &d)
if (d.dumpChildren) {
const QObject *ob = reinterpret_cast<const QObject *>(d.data);
d << ",children=[";
const QObjectPrivate::ConnectionList &connList = qConnectionList(ob, signalNumber);
const ConnectionList &connList = qConnectionList(ob, signalNumber);
for (int i = 0; i != connList.size(); ++i) {
const QObjectPrivate::Connection &conn = connList.at(i);
const Connection &conn = connectionAt(connList, i);
d.beginHash();
P(d, "name", i << " receiver");
qDumpInnerValueHelper(d, NS"QObject *", conn.receiver);
......@@ -1804,7 +1778,7 @@ static void qDumpQObjectSignalList(QDumper &d)
const QMetaMethod & method = mo->method(i);
if (method.methodType() == QMetaMethod::Signal) {
int k = mo->indexOfSignal(method.signature());
const QObjectPrivate::ConnectionList &connList = qConnectionList(ob, k);
const ConnectionList &connList = qConnectionList(ob, k);
d.beginHash();
P(d, "name", k);
P(d, "value", method.signature());
......@@ -1836,18 +1810,17 @@ static void qDumpQObjectSlot(QDumper &d)
const QObject *ob = reinterpret_cast<const QObject *>(d.data);
const QObjectPrivate *p = reinterpret_cast<const QObjectPrivate *>(dfunc(ob));
for (int s = 0; s != p->senders.size(); ++s) {
const QObjectPrivate::Sender &sender = p->senders.at(s);
const QObjectPrivate::ConnectionList &connList
= qConnectionList(sender.sender, sender.signal);
const QObject *sender = senderAt(p->senders, s);
int signal = signalAt(p->senders, s);
const ConnectionList &connList = qConnectionList(sender, signal);
for (int i = 0; i != connList.size(); ++i) {
const QObjectPrivate::Connection &conn = connList.at(i);
const Connection &conn = connectionAt(connList, i);
if (conn.receiver == ob && conn.method == slotNumber) {
++numchild;
const QMetaMethod & method =
sender.sender->metaObject()->method(sender.signal);
const QMetaMethod &method = sender->metaObject()->method(signal);
d.beginHash();
P(d, "name", s << " sender");
qDumpInnerValueHelper(d, NS"QObject *", sender.sender);
qDumpInnerValueHelper(d, NS"QObject *", sender);
d.endHash();
d.beginHash();
P(d, "name", s << " signal");
......@@ -1899,11 +1872,11 @@ static void qDumpQObjectSlotList(QDumper &d)
// count senders. expensive...
int numchild = 0;
for (int s = 0; s != p->senders.size(); ++s) {
const QObjectPrivate::Sender & sender = p->senders.at(s);
const QObjectPrivate::ConnectionList &connList
= qConnectionList(sender.sender, sender.signal);
const QObject *sender = senderAt(p->senders, s);
int signal = signalAt(p->senders, s);
const ConnectionList &connList = qConnectionList(sender, signal);
for (int c = 0; c != connList.size(); ++c) {
const QObjectPrivate::Connection &conn = connList.at(c);
const Connection &conn = connectionAt(connList, c);
if (conn.receiver == ob && conn.method == k)
++numchild;
}
......@@ -1919,7 +1892,6 @@ static void qDumpQObjectSlotList(QDumper &d)
#endif
d.disarm();
}
#endif // PRIVATE_OBJECT_ALLOWED
static void qDumpQPixmap(QDumper &d)
......@@ -2609,7 +2581,6 @@ static void handleProtocolVersion2and3(QDumper & d)
qDumpQObjectPropertyList(d);
else if (isEqual(type, "QObjectMethodList"))
qDumpQObjectMethodList(d);
#if PRIVATE_OBJECT_ALLOWED
else if (isEqual(type, "QObjectSignal"))
qDumpQObjectSignal(d);
else if (isEqual(type, "QObjectSignalList"))
......@@ -2618,7 +2589,6 @@ static void handleProtocolVersion2and3(QDumper & d)
qDumpQObjectSlot(d);
else if (isEqual(type, "QObjectSlotList"))
qDumpQObjectSlotList(d);
#endif
break;
case 'P':
if (isEqual(type, "QPixmap"))
......@@ -2728,12 +2698,10 @@ void *qDumpObjectData440(
"\""NS"QObject\","
"\""NS"QObjectMethodList\"," // hack to get nested properties display
"\""NS"QObjectPropertyList\","
#if PRIVATE_OBJECT_ALLOWED
"\""NS"QObjectSignal\","
"\""NS"QObjectSignalList\","
"\""NS"QObjectSlot\","
"\""NS"QObjectSlotList\","
#endif // PRIVATE_OBJECT_ALLOWED
// << "\""NS"QRegion\","
"\""NS"QSet\","
"\""NS"QSharedPointer\","
......
......@@ -590,6 +590,24 @@ void Preprocessor::expand(const char *first, const char *last, QByteArray *resul
return expand(source, result);
}
void Preprocessor::out(const QByteArray &text)
{
if (_result)
_result->append(text);
}
void Preprocessor::out(char ch)
{
if (_result)
_result->append(ch);
}
void Preprocessor::out(const char *s)
{
if (_result)
_result->append(s);
}
Preprocessor::State Preprocessor::createStateFromSource(const QByteArray &source) const
{
State state;
......@@ -611,16 +629,16 @@ void Preprocessor::processNewline(bool force)
return;
if (force || env->currentLine > _dot->lineno) {
_result->append("\n# ");
_result->append(QByteArray::number(_dot->lineno));
_result->append(' ');
_result->append('"');
_result->append(env->currentFile);
_result->append('"');
_result->append('\n');
out("\n# ");
out(QByteArray::number(_dot->lineno));
out(' ');
out('"');
out(env->currentFile);
out('"');
out('\n');
} else {
for (unsigned i = env->currentLine; i < _dot->lineno; ++i)
_result->append('\n');
out('\n');
}
env->currentLine = _dot->lineno;
......@@ -661,9 +679,9 @@ bool Preprocessor::markGeneratedTokens(bool markGeneratedTokens,
dot = _dot;
if (_markGeneratedTokens)
_result->append("\n#gen true");
out("\n#gen true");
else
_result->append("\n#gen false");
out("\n#gen false");
processNewline(/*force = */ true);
......@@ -684,10 +702,10 @@ bool Preprocessor::markGeneratedTokens(bool markGeneratedTokens,
for (; it != end; ++it) {
if (! std::isspace(*it))
_result->append(' ');
out(' ');
else
_result->append(*it);
out(*it);
}
}
......@@ -737,7 +755,7 @@ void Preprocessor::preprocess(const QByteArray &fileName, const QByteArray &sour
} else {
if (_dot->joined)
_result->append("\\\n");
out("\\\n");
else if (_dot->whitespace) {
const unsigned endOfPreviousToken = (_dot - 1)->end();
......@@ -755,15 +773,15 @@ void Preprocessor::preprocess(const QByteArray &fileName, const QByteArray &sour
for (; it != end; ++it) {
if (std::isspace(*it))
_result->append(*it);
out(*it);
else
_result->append(' ');
out(' ');
}
}
if (_dot->isNot(T_IDENTIFIER)) {
_result->append(tokenSpell(*_dot));
out(tokenSpell(*_dot));
++_dot;
} else {
......@@ -798,7 +816,7 @@ void Preprocessor::preprocess(const QByteArray &fileName, const QByteArray &sour
}
// it's not a function or object-like macro.
_result->append(spell);
out(spell);
}
}
}
......@@ -893,7 +911,7 @@ Macro *Preprocessor::processObjectLikeMacro(TokenIterator identifierToken,
}
const bool was = markGeneratedTokens(true, identifierToken);
_result->append(tmp);
out(tmp);
(void) markGeneratedTokens(was);
return 0;
}
......
......@@ -70,6 +70,10 @@ public:
QByteArray operator()(const QByteArray &filename,
const QByteArray &source);
void preprocess(const QByteArray &filename,
const QByteArray &source,
QByteArray *result);
private:
enum { MAX_LEVEL = 512 };
......@@ -99,10 +103,6 @@ private:
bool markGeneratedTokens(bool markGeneratedTokens, TokenIterator dot = 0);
void preprocess(const QByteArray &filename,
const QByteArray &source,
QByteArray *result);
QByteArray expand(const QByteArray &source);
void expand(const QByteArray &source, QByteArray *result);
void expand(const char *first, const char *last, QByteArray *result);
......@@ -165,6 +165,10 @@ private:
State createStateFromSource(const QByteArray &source) const;
void out(const QByteArray &text);
void out(char ch);
void out(const char *s);
private:
Client *client;
Environment *env;
......
......@@ -30,6 +30,7 @@
#include "reloadpromptutils.h"
#include <QtGui/QMessageBox>
#include <QtCore/QCoreApplication>
using namespace Core;
using namespace Core::Utils;
......@@ -37,9 +38,10 @@ using namespace Core::Utils;
QTCREATOR_UTILS_EXPORT Core::Utils::ReloadPromptAnswer
Core::Utils::reloadPrompt(const QString &fileName, QWidget *parent)
{
return reloadPrompt(QObject::tr("File Changed"),
QObject::tr("The file %1 has changed outside Qt Creator. Do you want to reload it?").arg(fileName),
parent);
const QString title = QCoreApplication::translate("Core::Utils::reloadPrompt", "File Changed");
const QString msg = QCoreApplication::translate("Core::Utils::reloadPrompt",
"The file %1 has changed outside Qt Creator. Do you want to reload it?").arg(fileName);
return reloadPrompt(title, msg, parent);
}
QTCREATOR_UTILS_EXPORT Core::Utils::ReloadPromptAnswer
......
......@@ -1241,19 +1241,19 @@ EditorManager::ReadOnlyAction
QWidget *parent,
bool displaySaveAsButton)
{
QMessageBox msgBox(QMessageBox::Question, QObject::tr("File is Read Only"),
QObject::tr("The file %1 is read only.").arg(fileName),
QMessageBox msgBox(QMessageBox::Question, tr("File is Read Only"),
tr("The file %1 is read only.").arg(fileName),
QMessageBox::Cancel, parent);
QPushButton *sccButton = 0;
if (versionControl && versionControl->supportsOperation(IVersionControl::OpenOperation))
sccButton = msgBox.addButton(QObject::tr("Open with VCS (%1)").arg(versionControl->name()), QMessageBox::AcceptRole);
sccButton = msgBox.addButton(tr("Open with VCS (%1)").arg(versionControl->name()), QMessageBox::AcceptRole);
QPushButton *makeWritableButton = msgBox.addButton(QObject::tr("Make writable"), QMessageBox::AcceptRole);
QPushButton *makeWritableButton = msgBox.addButton(tr("Make writable"), QMessageBox::AcceptRole);
QPushButton *saveAsButton = 0;
if (displaySaveAsButton)
saveAsButton = msgBox.addButton(QObject::tr("Save as ..."), QMessageBox::ActionRole);
saveAsButton = msgBox.addButton(tr("Save as ..."), QMessageBox::ActionRole);
msgBox.setDefaultButton(sccButton ? sccButton : makeWritableButton);
msgBox.exec();
......
......@@ -647,7 +647,7 @@ static bool parseNumber(const QString &n, int *target, QString *errorMessage)
bool ok;
*target = n.toInt(&ok);
if (!ok) {
*errorMessage = QCoreApplication::translate("MimeDatabase", "Not a number '%1'.").arg(n);
*errorMessage = QString::fromLatin1("Not a number '%1'.").arg(n);
return false;
}
return true;
......@@ -667,7 +667,7 @@ static bool addMagicMatchRule(const QXmlStreamAttributes &atts,
}
const QString value = atts.value(QLatin1String(matchValueAttributeC)).toString();
if (value.isEmpty()) {
*errorMessage = QCoreApplication::translate("MimeDatabase", "Empty match value detected.");
*errorMessage = QString::fromLatin1("Empty match value detected.");
return false;
}
// Parse for offset as "1" or "1:10"
......@@ -699,7 +699,7 @@ bool BaseMimeTypeParser::parse(QIODevice *dev, const QString &fileName, QString
case ParseMimeType: { // start parsing a type
const QString type = reader.attributes().value(QLatin1String(mimeTypeAttributeC)).toString();
if (type.isEmpty()) {
reader.raiseError(QCoreApplication::translate("MimeDatabase", "Missing 'type'-attribute"));
reader.raiseError(QString::fromLatin1("Missing 'type'-attribute"));
} else {
data.type = type;
}
......@@ -748,7 +748,7 @@ bool BaseMimeTypeParser::parse(QIODevice *dev, const QString &fileName, QString
return false;
break;
case ParseError:
reader.raiseError(QCoreApplication::translate("MimeDatabase", "Unexpected element <%1>").arg(reader.name().toString()));
reader.raiseError(QString::fromLatin1("Unexpected element <%1>").arg(reader.name().toString()));
break;
default:
break;
......@@ -775,7 +775,7 @@ bool BaseMimeTypeParser::parse(QIODevice *dev, const QString &fileName, QString
}
if (reader.hasError()) {
*errorMessage = QCoreApplication::translate("MimeDatabase", "An error has been encountered at line %1 of %2: %3:").arg(reader.lineNumber()).arg(fileName, reader.errorString());
*errorMessage = QString::fromLatin1("An error has been encountered at line %1 of %2: %3:").arg(reader.lineNumber()).arg(fileName, reader.errorString());
return false;
}
return true;
......@@ -890,7 +890,7 @@ bool MimeDatabasePrivate::addMimeTypes(const QString &fileName, QString *errorMe
{
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) {
*errorMessage = QCoreApplication::translate("MimeDatabase", "Cannot open %1: %2").arg(fileName, file.errorString());
*errorMessage = QString::fromLatin1("Cannot open %1: %2").arg(fileName, file.errorString());
return false;
}
return addMimeTypes(&file, fileName, errorMessage);
......
......@@ -189,6 +189,7 @@ CPPEditorEditable::CPPEditorEditable(CPPEditor *editor)
CPPEditor::CPPEditor(QWidget *parent)
: TextEditor::BaseTextEditor(parent)
, m_mouseNavigationEnabled(true)
, m_showingLink(false)
{
setParenthesesMatchingEnabled(true);
......@@ -901,7 +902,7 @@ void CPPEditor::mouseMoveEvent(QMouseEvent *e)
{
bool linkFound = false;
if (e->modifiers() & Qt::ControlModifier) {
if (m_mouseNavigationEnabled && e->modifiers() & Qt::ControlModifier) {
// Link emulation behaviour for 'go to definition'
const QTextCursor cursor = cursorForPosition(e->pos());
......@@ -1027,6 +1028,11 @@ void CPPEditor::setFontSettings(const TextEditor::FontSettings &fs)
m_linkFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_LINK));
}
void CPPEditor::setDisplaySettings(const TextEditor::DisplaySettings &ds)
{
TextEditor::BaseTextEditor::setDisplaySettings(ds);
m_mouseNavigationEnabled = ds.m_mouseNavigation;
}
void CPPEditor::unCommentSelection()
{
......
......@@ -87,6 +87,7 @@ public:
public slots:
virtual void setFontSettings(const TextEditor::FontSettings &);
virtual void setDisplaySettings(const TextEditor::DisplaySettings &);
void setSortedMethodOverview(bool sort);
void switchDeclarationDefinition();
void jumpToDefinition();
......@@ -153,11 +154,13 @@ private:
void showLink(const Link &);
void clearLink();
bool m_showingLink;
Link findLinkAt(const QTextCursor &, bool lookupDefinition = true);