Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/stable' into dev
Browse files Browse the repository at this point in the history
Conflicts:
	src/plugins/platforms/qnx/qqnxscreen.cpp
	src/plugins/platforms/windows/qwindowsdialoghelpers.cpp

Change-Id: Ib64f21c077b54f2291d19187590bfe869b98477a
  • Loading branch information
gladhorn committed Mar 6, 2013
2 parents b861063 + 31c5b34 commit 49a2ec0
Show file tree
Hide file tree
Showing 34 changed files with 143 additions and 70 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of the Qt Toolkit.
Expand All @@ -26,9 +26,11 @@
****************************************************************************/

/*!
\example customcompleter
\example tools/customcompleter
\title Custom Completer Example

\ingroup examples-widgets-tools

\brief The Custom Completer example shows how to provide string-completion
facilities for an input widget based on data provided by a model. The
completer pops up suggestions for possible words based on the first three
Expand All @@ -43,7 +45,7 @@
that has a list of words to help QCompleter complete words. This file
contains the following:

\quotefile customcompleter/customcompleter.qrc
\quotefile tools/customcompleter/customcompleter.qrc

\section1 TextEdit Class Definition

Expand All @@ -54,7 +56,7 @@
contains a private function \c textUnderCursor() and a private instance
of QCompleter, \c c.

\snippet customcompleter/textedit.h 0
\snippet tools/customcompleter/textedit.h 0

\section1 TextEdit Class Implementation

Expand All @@ -63,19 +65,19 @@
the \c TextEdit object, using the
\l{QTextEdit::setPlainText()}{setPlainText()} function.

\snippet customcompleter/textedit.cpp 0
\snippet tools/customcompleter/textedit.cpp 0

In addition, \c TextEdit also includes a default destructor:

\snippet customcompleter/textedit.cpp 1
\snippet tools/customcompleter/textedit.cpp 1

The \c setCompleter() function accepts a \a completer and sets it up.
We use \c{if (c)} to check if \c c has been initialized. If it has been
initialized, the QObject::disconnect() function is invoked to disconnect
the signal from the slot. This is to ensure that no previous completer
object is still connected to the slot.

\snippet customcompleter/textedit.cpp 2
\snippet tools/customcompleter/textedit.cpp 2

We then instantiate \c c with \a completer and set it as \c{TextEdit}'s
widget. The completion mode and case sensitivity are also set and then
Expand All @@ -84,7 +86,7 @@

The \c completer() function is a getter function that returns \c c.

\snippet customcompleter/textedit.cpp 3
\snippet tools/customcompleter/textedit.cpp 3

The completer pops up the options available, based on the contents of
\e wordlist.txt, but the text cursor is responsible for filling in the
Expand All @@ -99,7 +101,7 @@
completer's widget is \c TextEdit before using \c tc to insert the extra
characters to complete the word.

\snippet customcompleter/textedit.cpp 4
\snippet tools/customcompleter/textedit.cpp 4

The figure below illustrates this process:

Expand All @@ -116,13 +118,13 @@
The \c textUnderCursor() function uses a QTextCursor, \c tc, to select a
word under the cursor and return it.

\snippet customcompleter/textedit.cpp 5
\snippet tools/customcompleter/textedit.cpp 5

The \c TextEdit class reimplements \l{QWidget::focusInEvent()}
{focusInEvent()} function, which is an event handler used to receive
keyboard focus events for the widget.

\snippet customcompleter/textedit.cpp 6
\snippet tools/customcompleter/textedit.cpp 6

The \l{QAbstractScrollArea::keyPressEvent()}{keyPressEvent()} is
reimplemented to ignore key events like Qt::Key_Enter, Qt::Key_Return,
Expand All @@ -131,12 +133,12 @@

If there is an active completer, we cannot process the shortcut, Ctrl+E.

\snippet customcompleter/textedit.cpp 7
\snippet tools/customcompleter/textedit.cpp 7

We also handle other modifiers and shortcuts for which we do not want the
completer to respond to.

\snippet customcompleter/textedit.cpp 8
\snippet tools/customcompleter/textedit.cpp 8

Finally, we pop up the completer.

Expand All @@ -147,7 +149,7 @@
\c createMenu() and \c modelFromFile() as well as private instances of
QCompleter and \c TextEdit.

\snippet customcompleter/mainwindow.h 0
\snippet tools/customcompleter/mainwindow.h 0

\section1 MainWindow Class Implementation

Expand All @@ -157,31 +159,31 @@
to populate the \c completer. The \c{MainWindow}'s central widget is set
to \c TextEdit and its size is set to 500 x 300.

\snippet customcompleter/mainwindow.cpp 0
\snippet tools/customcompleter/mainwindow.cpp 0

The \c createMenu() function creates the necessary QAction objects needed
for the "File" and "Help" menu and their \l{QAction::triggered()}
{triggered()} signals are connected to the \c quit(), \c about(), and
\c aboutQt() slots respectively.

\snippet customcompleter/mainwindow.cpp 1
\snippet tools/customcompleter/mainwindow.cpp 1

The \c modelFromFile() function accepts a \a fileName and attempts to
extract the contents of this file into a QStringListModel. We display the
Qt::WaitCursor when we are populating the QStringList, \c words, and
restore the mouse cursor when we are done.

\snippet customcompleter/mainwindow.cpp 2
\snippet tools/customcompleter/mainwindow.cpp 2

The \c about() function provides a brief description about the Custom
Completer example.

\snippet customcompleter/mainwindow.cpp 3
\snippet tools/customcompleter/mainwindow.cpp 3

\section1 \c main() Function

The \c main() function instantiates \c MainWindow and invokes the
\l{QWidget::show()}{show()} function.

\snippet customcompleter/main.cpp 0
\snippet tools/customcompleter/main.cpp 0
*/
5 changes: 5 additions & 0 deletions qmake/generators/win32/msvc_nmake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ void NmakeMakefileGenerator::init()
project->values("QMAKE_CLEAN").append(project->first("DESTDIR") + project->first("TARGET") + version + ".ilk");
project->values("QMAKE_CLEAN").append("vc*.pdb");
project->values("QMAKE_CLEAN").append("vc*.idb");
project->values("DEFINES").removeAll("NDEBUG");
} else {
ProStringList &defines = project->values("DEFINES");
if (!defines.contains("NDEBUG"))
defines.append("NDEBUG");
}
}

Expand Down
3 changes: 0 additions & 3 deletions qmake/option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ ProFileCache *Option::proFileCache;
QMakeParser *Option::parser;

//convenience
const char *Option::application_argv0 = 0;
QString Option::prf_ext;
QString Option::prl_ext;
QString Option::libtool_ext;
Expand Down Expand Up @@ -318,13 +317,11 @@ Option::parseCommandLine(QStringList &args, QMakeCmdLineParserState &state)
int
Option::init(int argc, char **argv)
{
Option::application_argv0 = 0;
Option::prf_ext = ".prf";
Option::pro_ext = ".pro";
Option::field_sep = ' ';

if(argc && argv) {
Option::application_argv0 = argv[0];
QString argv0 = argv[0];
if(Option::qmake_mode == Option::QMAKE_GENERATE_NOTHING)
Option::qmake_mode = default_mode(argv0);
Expand Down
1 change: 0 additions & 1 deletion qmake/option.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ struct Option
static QString pro_ext;
static QString res_ext;
static char field_sep;
static const char *application_argv0;

enum CmdLineFlags {
QMAKE_CMDLINE_SUCCESS = 0x00,
Expand Down
6 changes: 1 addition & 5 deletions src/corelib/doc/src/objectmodel/object.qdoc
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@
by Qt's own \l{moc}{Meta-Object Compiler (moc)}.

The meta-object system is a C++ extension that makes the language
better suited to true component GUI programming. Although
templates can be used to extend C++, the meta-object system
provides benefits using standard C++ that cannot be achieved with
templates; see \l{Why Doesn't Qt Use Templates for Signals and
Slots?}
better suited to true component GUI programming.

\section1 Important Classes

Expand Down
1 change: 1 addition & 0 deletions src/corelib/global/qcompilerdetection.h
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,7 @@
const bool valueOfExpression = Expr;\
Q_ASSERT_X(valueOfExpression, "Q_ASSUME()", "Assumption in Q_ASSUME(\"" #Expr "\") was not correct");\
Q_ASSUME_IMPL(valueOfExpression);\
Q_UNUSED(valueOfExpression); /* the value may not be used if Q_ASSERT_X and Q_ASSUME_IMPL are noop */\
} while (0)

#endif // QCOMPILERDETECTION_H
4 changes: 2 additions & 2 deletions src/corelib/kernel/qobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4194,7 +4194,7 @@ void qDeleteInEventHandler(QObject *o)
connecting to a static function or a functor
\a slot a pointer only used when using Qt::UniqueConnection
\a type the Qt::ConnctionType passed as argument to connect
\a types an array of integer with the metatype id of the parametter of the signal
\a types an array of integer with the metatype id of the parameter of the signal
to be used with queued connection
must stay valid at least for the whole time of the connection, this function
do not take ownership. typically static data.
Expand All @@ -4209,7 +4209,7 @@ QMetaObject::Connection QObject::connectImpl(const QObject *sender, void **signa
const int *types, const QMetaObject *senderMetaObject)
{
if (!sender || !signal || !slotObj || !senderMetaObject) {
qWarning("QObject::connect: invalid null parametter");
qWarning("QObject::connect: invalid null parameter");
if (slotObj)
slotObj->destroyIfLastRef();
return QMetaObject::Connection();
Expand Down
4 changes: 2 additions & 2 deletions src/corelib/kernel/qobjectdefs_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace QtPrivate {
/*
The following List classes are used to help to handle the list of arguments.
It follow the same principles as the lisp lists.
List_Left<L,N> take a list and a number as a parametter and returns (via the Value typedef,
List_Left<L,N> take a list and a number as a parameter and returns (via the Value typedef,
the list composed of the first N element of the list
*/
#ifndef Q_COMPILER_VARIADIC_TEMPLATES
Expand Down Expand Up @@ -116,7 +116,7 @@ namespace QtPrivate {
- ArgumentCount is the number of argument, or -1 if it is unknown
- the Object typedef is the Object of a pointer to member function
- the Arguments typedef is the list of argument (in a QtPrivate::List)
- the Function typedef is an alias to the template parametter Func
- the Function typedef is an alias to the template parameter Func
- the call<Args, R>(f,o,args) method is used to call that slot
Args is the list of argument of the signal
R is the return type of the signal
Expand Down
2 changes: 1 addition & 1 deletion src/corelib/mimetypes/qmimedatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ QMimeType QMimeDatabase::mimeTypeForFile(const QString &fileName, MatchMode mode
} else {
// Implemented as a wrapper around mimeTypeForFile(QFileInfo), so no mutex.
QFileInfo fileInfo(fileName);
return mimeTypeForFile(fileInfo);
return mimeTypeForFile(fileInfo, mode);
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/corelib/tools/qdatetime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4045,6 +4045,16 @@ static void localToUtc(QDate &date, QTime &time, int isdst)
_tzset();
#endif
time_t secsSince1Jan1970UTC = mktime(&localTM);
#ifdef Q_OS_QNX
//mktime sometimes fails on QNX. Following workaround converts the date and time then manually
if (secsSince1Jan1970UTC == (time_t)-1) {
QDateTime tempTime = QDateTime(date, time, Qt::UTC);;
tempTime = tempTime.addMSecs(timezone * 1000);
date = tempTime.date();
time = tempTime.time();
return;
}
#endif
#endif
tm *brokenDown = 0;
#if defined(Q_OS_WINCE)
Expand Down
2 changes: 2 additions & 0 deletions src/corelib/xml/qxmlstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ QXmlStreamPrivateTagStack::QXmlStreamPrivateTagStack()
NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push();
namespaceDeclaration.prefix = addToStringStorage(QLatin1String("xml"));
namespaceDeclaration.namespaceUri = addToStringStorage(QLatin1String("http://www.w3.org/XML/1998/namespace"));
initialTagStackStringStorageSize = tagStackStringStorageSize;
}

#ifndef QT_NO_XMLSTREAMREADER
Expand Down Expand Up @@ -854,6 +855,7 @@ void QXmlStreamReaderPrivate::init()
rawReadBuffer.clear();
dataBuffer.clear();
readBuffer.clear();
tagStackStringStorageSize = initialTagStackStringStorageSize;

type = QXmlStreamReader::NoToken;
error = QXmlStreamReader::NoError;
Expand Down
1 change: 1 addition & 0 deletions src/corelib/xml/qxmlstream_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ class QXmlStreamPrivateTagStack {
QXmlStreamSimpleStack<NamespaceDeclaration> namespaceDeclarations;
QString tagStackStringStorage;
int tagStackStringStorageSize;
int initialTagStackStringStorageSize;
bool tagsDone;

inline QStringRef addToStringStorage(const QStringRef &s) {
Expand Down
4 changes: 2 additions & 2 deletions src/dbus/dbus.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ MODULE_CONFIG = dbusadaptors dbusinterfaces
!isEmpty(DBUS_PATH) {
INCLUDEPATH += $$DBUS_PATH/include
QMAKE_LIBDIR += $$DBUS_PATH/lib
win32:CONFIG(debug, debug|release):QT_LIBS_DBUS += -ldbus-1d
else:QT_LIBS_DBUS += -ldbus-1
}

DEFINES += DBUS_API_SUBJECT_TO_CHANGE
Expand All @@ -21,8 +23,6 @@ win32 {
-ladvapi32 \
-lnetapi32 \
-luser32
CONFIG(debug, debug|release):LIBS_PRIVATE += -ldbus-1d
else:LIBS_PRIVATE += -ldbus-1
}

QMAKE_DOCS = $$PWD/doc/qtdbus.qdocconf
Expand Down
10 changes: 5 additions & 5 deletions src/network/socket/qnativesocketengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,8 @@ int QNativeSocketEngine::accept()
{
Q_D(QNativeSocketEngine);
Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::accept(), -1);
Q_CHECK_STATE(QNativeSocketEngine::accept(), QAbstractSocket::ListeningState, false);
Q_CHECK_TYPE(QNativeSocketEngine::accept(), QAbstractSocket::TcpSocket, false);
Q_CHECK_STATE(QNativeSocketEngine::accept(), QAbstractSocket::ListeningState, -1);
Q_CHECK_TYPE(QNativeSocketEngine::accept(), QAbstractSocket::TcpSocket, -1);

return d->nativeAccept();
}
Expand Down Expand Up @@ -702,7 +702,7 @@ qint64 QNativeSocketEngine::bytesAvailable() const
{
Q_D(const QNativeSocketEngine);
Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::bytesAvailable(), -1);
Q_CHECK_NOT_STATE(QNativeSocketEngine::bytesAvailable(), QAbstractSocket::UnconnectedState, false);
Q_CHECK_NOT_STATE(QNativeSocketEngine::bytesAvailable(), QAbstractSocket::UnconnectedState, -1);

return d->nativeBytesAvailable();
}
Expand Down Expand Up @@ -732,7 +732,7 @@ qint64 QNativeSocketEngine::pendingDatagramSize() const
{
Q_D(const QNativeSocketEngine);
Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::pendingDatagramSize(), -1);
Q_CHECK_TYPE(QNativeSocketEngine::pendingDatagramSize(), QAbstractSocket::UdpSocket, false);
Q_CHECK_TYPE(QNativeSocketEngine::pendingDatagramSize(), QAbstractSocket::UdpSocket, -1);

return d->nativePendingDatagramSize();
}
Expand All @@ -757,7 +757,7 @@ qint64 QNativeSocketEngine::readDatagram(char *data, qint64 maxSize, QHostAddres
{
Q_D(QNativeSocketEngine);
Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::readDatagram(), -1);
Q_CHECK_TYPE(QNativeSocketEngine::readDatagram(), QAbstractSocket::UdpSocket, false);
Q_CHECK_TYPE(QNativeSocketEngine::readDatagram(), QAbstractSocket::UdpSocket, -1);

return d->nativeReceiveDatagram(data, maxSize, address, port);
}
Expand Down
14 changes: 8 additions & 6 deletions src/platformsupport/linuxaccessibility/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ bool QSpiApplicationAdaptor::eventFilter(QObject *target, QEvent *event)
SLOT(notifyKeyboardListenerError(QDBusError, QDBusMessage)), timeout);
if (sent) {
//queue the event and send it after callback
keyEvents.enqueue(QPair<QObject*, QKeyEvent*> (target, copyKeyEvent(keyEvent)));
keyEvents.enqueue(QPair<QPointer<QObject>, QKeyEvent*> (QPointer<QObject>(target), copyKeyEvent(keyEvent)));
#ifdef KEYBOARD_DEBUG
qDebug() << QStringLiteral("Sent key: ") << de.text;
#endif
Expand All @@ -200,20 +200,22 @@ void QSpiApplicationAdaptor::notifyKeyboardListenerCallback(const QDBusMessage&
}
Q_ASSERT(message.arguments().length() == 1);
if (message.arguments().at(0).toBool() == true) {
QPair<QObject*, QKeyEvent*> event = keyEvents.dequeue();
QPair<QPointer<QObject>, QKeyEvent*> event = keyEvents.dequeue();
delete event.second;
} else {
QPair<QObject*, QKeyEvent*> event = keyEvents.dequeue();
QCoreApplication::postEvent(event.first, event.second);
QPair<QPointer<QObject>, QKeyEvent*> event = keyEvents.dequeue();
if (event.first)
QCoreApplication::postEvent(event.first.data(), event.second);
}
}

void QSpiApplicationAdaptor::notifyKeyboardListenerError(const QDBusError& error, const QDBusMessage& /*message*/)
{
qWarning() << QStringLiteral("QSpiApplication::keyEventError ") << error.name() << error.message();
while (!keyEvents.isEmpty()) {
QPair<QObject*, QKeyEvent*> event = keyEvents.dequeue();
QCoreApplication::postEvent(event.first, event.second);
QPair<QPointer<QObject>, QKeyEvent*> event = keyEvents.dequeue();
if (event.first)
QCoreApplication::postEvent(event.first.data(), event.second);
}
}

Expand Down
Loading

0 comments on commit 49a2ec0

Please sign in to comment.