Whitespace cleanup: remove trailing whitespace
Remove all trailing whitespace from the following list of files: *.cpp *.h *.conf *.qdoc *.pro *.pri *.mm *.rc *.pl *.qps *.xpm *.txt *README excluding 3rdparty, test-data and auto generated code. Note A): the only non 3rdparty c++-files that still have trailing whitespace after this change are: * src/corelib/codecs/cp949codetbl_p.h * src/corelib/codecs/qjpunicode.cpp * src/corelib/codecs/qbig5codec.cpp * src/corelib/xml/qxmlstream_p.h * src/tools/qdoc/qmlparser/qqmljsgrammar.cpp * src/tools/uic/ui4.cpp * tests/auto/other/qtokenautomaton/tokenizers/* * tests/benchmarks/corelib/tools/qstring/data.cpp * util/lexgen/tokenizer.cpp Note B): in about 30 files some overlapping 'leading tab' and 'TAB character in non-leading whitespace' issues have been fixed to make the sanity bot happy. Plus some general ws-fixes here and there as asked for during review. Change-Id: Ia713113c34d82442d6ce4d93d8b1cf545075d11d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
This commit is contained in:
parent
72367a94a7
commit
b11317a643
@ -50,7 +50,7 @@ int main(int, char **)
|
|||||||
#else
|
#else
|
||||||
# error "Feature _POSIX_MONOTONIC_CLOCK not available"
|
# error "Feature _POSIX_MONOTONIC_CLOCK not available"
|
||||||
// MIPSpro doesn't understand #error, so force a compiler error
|
// MIPSpro doesn't understand #error, so force a compiler error
|
||||||
force_compiler_error = true;
|
force_compiler_error = true;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,6 @@ int main()
|
|||||||
if (getaddrinfo("foo", 0, 0, &res) == 0)
|
if (getaddrinfo("foo", 0, 0, &res) == 0)
|
||||||
freeaddrinfo(res);
|
freeaddrinfo(res);
|
||||||
gai_strerror(0);
|
gai_strerror(0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
message to be sent.
|
message to be sent.
|
||||||
|
|
||||||
The \c Message class is defined in the following way:
|
The \c Message class is defined in the following way:
|
||||||
|
|
||||||
\snippet examples/tools/customtypesending/message.h custom type definition
|
\snippet examples/tools/customtypesending/message.h custom type definition
|
||||||
|
|
||||||
The type is declared to the meta-type system with the Q_DECLARE_METATYPE()
|
The type is declared to the meta-type system with the Q_DECLARE_METATYPE()
|
||||||
|
@ -82,7 +82,7 @@ void Ping::start(const QString &name, const QString &oldValue, const QString &ne
|
|||||||
if (!reply.isNull())
|
if (!reply.isNull())
|
||||||
printf("value = %s\n", qPrintable(reply.toString()));
|
printf("value = %s\n", qPrintable(reply.toString()));
|
||||||
} else if (line.startsWith("value=")) {
|
} else if (line.startsWith("value=")) {
|
||||||
iface->setProperty("value", line.mid(6));
|
iface->setProperty("value", line.mid(6));
|
||||||
} else {
|
} else {
|
||||||
QDBusReply<QDBusVariant> reply = iface->call("query", line);
|
QDBusReply<QDBusVariant> reply = iface->call("query", line);
|
||||||
if (reply.isValid())
|
if (reply.isValid())
|
||||||
@ -92,7 +92,7 @@ void Ping::start(const QString &name, const QString &oldValue, const QString &ne
|
|||||||
if (iface->lastError().isValid())
|
if (iface->lastError().isValid())
|
||||||
fprintf(stderr, "Call failed: %s\n", qPrintable(iface->lastError().message()));
|
fprintf(stderr, "Call failed: %s\n", qPrintable(iface->lastError().message()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
@ -94,10 +94,10 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (!QDBusConnection::sessionBus().registerService(SERVICE_NAME)) {
|
if (!QDBusConnection::sessionBus().registerService(SERVICE_NAME)) {
|
||||||
fprintf(stderr, "%s\n",
|
fprintf(stderr, "%s\n",
|
||||||
qPrintable(QDBusConnection::sessionBus().lastError().message()));
|
qPrintable(QDBusConnection::sessionBus().lastError().message()));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.exec();
|
app.exec();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -67,13 +67,13 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (!QDBusConnection::sessionBus().registerService(SERVICE_NAME)) {
|
if (!QDBusConnection::sessionBus().registerService(SERVICE_NAME)) {
|
||||||
fprintf(stderr, "%s\n",
|
fprintf(stderr, "%s\n",
|
||||||
qPrintable(QDBusConnection::sessionBus().lastError().message()));
|
qPrintable(QDBusConnection::sessionBus().lastError().message()));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Pong pong;
|
Pong pong;
|
||||||
QDBusConnection::sessionBus().registerObject("/", &pong, QDBusConnection::ExportAllSlots);
|
QDBusConnection::sessionBus().registerObject("/", &pong, QDBusConnection::ExportAllSlots);
|
||||||
|
|
||||||
app.exec();
|
app.exec();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ void Dialog::loadFromMemory()
|
|||||||
*/
|
*/
|
||||||
void Dialog::detach()
|
void Dialog::detach()
|
||||||
{
|
{
|
||||||
if (!sharedMemory.detach())
|
if (!sharedMemory.detach())
|
||||||
ui.label->setText(tr("Unable to detach from shared memory."));
|
ui.label->setText(tr("Unable to detach from shared memory."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
QTcpSocket::connectToHost() returns immediately, and when the connection
|
QTcpSocket::connectToHost() returns immediately, and when the connection
|
||||||
has been established, QTcpSocket emits
|
has been established, QTcpSocket emits
|
||||||
\l{QTcpSocket::connected()}{connected()}.
|
\l{QTcpSocket::connected()}{connected()}.
|
||||||
|
|
||||||
\li \e{The synchronous (blocking) approach.} In non-GUI and multithreaded
|
\li \e{The synchronous (blocking) approach.} In non-GUI and multithreaded
|
||||||
applications, you can call the \c waitFor...() functions (e.g.,
|
applications, you can call the \c waitFor...() functions (e.g.,
|
||||||
QTcpSocket::waitForConnected()) to suspend the calling thread until the
|
QTcpSocket::waitForConnected()) to suspend the calling thread until the
|
||||||
@ -208,7 +208,7 @@
|
|||||||
\snippet blockingfortuneclient/blockingclient.cpp 3
|
\snippet blockingfortuneclient/blockingclient.cpp 3
|
||||||
\codeline
|
\codeline
|
||||||
\snippet blockingfortuneclient/blockingclient.cpp 4
|
\snippet blockingfortuneclient/blockingclient.cpp 4
|
||||||
|
|
||||||
Here, we simply display the fortune we received as the argument.
|
Here, we simply display the fortune we received as the argument.
|
||||||
|
|
||||||
\sa {Fortune Client Example}, {Fortune Server Example}
|
\sa {Fortune Client Example}, {Fortune Server Example}
|
||||||
|
@ -48,8 +48,8 @@
|
|||||||
|
|
||||||
FortuneServer inherits QTcpServer and reimplements
|
FortuneServer inherits QTcpServer and reimplements
|
||||||
QTcpServer::incomingConnection(). We also use it for storing the list of
|
QTcpServer::incomingConnection(). We also use it for storing the list of
|
||||||
random fortunes.
|
random fortunes.
|
||||||
|
|
||||||
\snippet threadedfortuneserver/fortuneserver.cpp 0
|
\snippet threadedfortuneserver/fortuneserver.cpp 0
|
||||||
|
|
||||||
We use FortuneServer's constructor to simply generate the list of
|
We use FortuneServer's constructor to simply generate the list of
|
||||||
@ -71,7 +71,7 @@
|
|||||||
QThread::run(), and it has a signal for reporting errors.
|
QThread::run(), and it has a signal for reporting errors.
|
||||||
|
|
||||||
\snippet threadedfortuneserver/fortunethread.cpp 0
|
\snippet threadedfortuneserver/fortunethread.cpp 0
|
||||||
|
|
||||||
FortuneThread's constructor simply stores the socket descriptor and
|
FortuneThread's constructor simply stores the socket descriptor and
|
||||||
fortune text, so that they are available for run() later on.
|
fortune text, so that they are available for run() later on.
|
||||||
|
|
||||||
@ -101,7 +101,7 @@
|
|||||||
But unlike the previous example, we finish off by calling
|
But unlike the previous example, we finish off by calling
|
||||||
QTcpSocket::waitForDisconnected(), which blocks the calling thread until
|
QTcpSocket::waitForDisconnected(), which blocks the calling thread until
|
||||||
the socket has disconnected. Because we are running in a separate thread,
|
the socket has disconnected. Because we are running in a separate thread,
|
||||||
the GUI will remain responsive.
|
the GUI will remain responsive.
|
||||||
|
|
||||||
\sa {Fortune Server Example}, {Fortune Client Example}, {Blocking Fortune
|
\sa {Fortune Server Example}, {Fortune Client Example}, {Blocking Fortune
|
||||||
Client Example}
|
Client Example}
|
||||||
|
@ -180,7 +180,7 @@ void HttpWindow::httpFinished()
|
|||||||
tr("Download failed: %1.")
|
tr("Download failed: %1.")
|
||||||
.arg(reply->errorString()));
|
.arg(reply->errorString()));
|
||||||
downloadButton->setEnabled(true);
|
downloadButton->setEnabled(true);
|
||||||
} else if (!redirectionTarget.isNull()) {
|
} else if (!redirectionTarget.isNull()) {
|
||||||
QUrl newUrl = url.resolved(redirectionTarget.toUrl());
|
QUrl newUrl = url.resolved(redirectionTarget.toUrl());
|
||||||
if (QMessageBox::question(this, tr("HTTP"),
|
if (QMessageBox::question(this, tr("HTTP"),
|
||||||
tr("Redirect to %1 ?").arg(newUrl.toString()),
|
tr("Redirect to %1 ?").arg(newUrl.toString()),
|
||||||
@ -256,7 +256,7 @@ void HttpWindow::sslErrors(QNetworkReply*,const QList<QSslError> &errors)
|
|||||||
errorString += ", ";
|
errorString += ", ";
|
||||||
errorString += error.errorString();
|
errorString += error.errorString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QMessageBox::warning(this, tr("HTTP"),
|
if (QMessageBox::warning(this, tr("HTTP"),
|
||||||
tr("One or more SSL errors has occurred: %1").arg(errorString),
|
tr("One or more SSL errors has occurred: %1").arg(errorString),
|
||||||
QMessageBox::Ignore | QMessageBox::Abort) == QMessageBox::Ignore) {
|
QMessageBox::Ignore | QMessageBox::Abort) == QMessageBox::Ignore) {
|
||||||
|
@ -57,7 +57,7 @@ class SslClient : public QWidget
|
|||||||
public:
|
public:
|
||||||
SslClient(QWidget *parent = 0);
|
SslClient(QWidget *parent = 0);
|
||||||
~SslClient();
|
~SslClient();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateEnabledState();
|
void updateEnabledState();
|
||||||
void secureConnect();
|
void secureConnect();
|
||||||
|
@ -117,14 +117,14 @@ void AddTorrentDialog::setTorrent(const QString &torrentFile)
|
|||||||
|
|
||||||
if (lastDestinationDirectory.isEmpty())
|
if (lastDestinationDirectory.isEmpty())
|
||||||
lastDestinationDirectory = lastDirectory;
|
lastDestinationDirectory = lastDirectory;
|
||||||
|
|
||||||
MetaInfo metaInfo;
|
MetaInfo metaInfo;
|
||||||
QFile torrent(torrentFile);
|
QFile torrent(torrentFile);
|
||||||
if (!torrent.open(QFile::ReadOnly) || !metaInfo.parse(torrent.readAll())) {
|
if (!torrent.open(QFile::ReadOnly) || !metaInfo.parse(torrent.readAll())) {
|
||||||
enableOkButton();
|
enableOkButton();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.torrentFile->setText(torrentFile);
|
ui.torrentFile->setText(torrentFile);
|
||||||
ui.announceUrl->setText(metaInfo.announceUrl());
|
ui.announceUrl->setText(metaInfo.announceUrl());
|
||||||
if (metaInfo.comment().isEmpty())
|
if (metaInfo.comment().isEmpty())
|
||||||
|
@ -81,26 +81,26 @@ bool BencodeParser::getByteString(QByteArray *byteString)
|
|||||||
const int contentSize = content.size();
|
const int contentSize = content.size();
|
||||||
int size = -1;
|
int size = -1;
|
||||||
do {
|
do {
|
||||||
char c = content.at(index);
|
char c = content.at(index);
|
||||||
if (c < '0' || c > '9') {
|
if (c < '0' || c > '9') {
|
||||||
if (size == -1)
|
if (size == -1)
|
||||||
return false;
|
return false;
|
||||||
if (c != ':') {
|
if (c != ':') {
|
||||||
errString = QString("Unexpected character at pos %1: %2")
|
errString = QString("Unexpected character at pos %1: %2")
|
||||||
.arg(index).arg(c);
|
.arg(index).arg(c);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
++index;
|
++index;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (size == -1)
|
if (size == -1)
|
||||||
size = 0;
|
size = 0;
|
||||||
size *= 10;
|
size *= 10;
|
||||||
size += c - '0';
|
size += c - '0';
|
||||||
} while (++index < contentSize);
|
} while (++index < contentSize);
|
||||||
|
|
||||||
if (byteString)
|
if (byteString)
|
||||||
*byteString = content.mid(index, size);
|
*byteString = content.mid(index, size);
|
||||||
index += size;
|
index += size;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -109,38 +109,38 @@ bool BencodeParser::getInteger(qint64 *integer)
|
|||||||
{
|
{
|
||||||
const int contentSize = content.size();
|
const int contentSize = content.size();
|
||||||
if (content.at(index) != 'i')
|
if (content.at(index) != 'i')
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
++index;
|
++index;
|
||||||
qint64 num = -1;
|
qint64 num = -1;
|
||||||
bool negative = false;
|
bool negative = false;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
char c = content.at(index);
|
char c = content.at(index);
|
||||||
if (c < '0' || c > '9') {
|
if (c < '0' || c > '9') {
|
||||||
if (num == -1) {
|
if (num == -1) {
|
||||||
if (c != '-' || negative)
|
if (c != '-' || negative)
|
||||||
return false;
|
return false;
|
||||||
negative = true;
|
negative = true;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
if (c != 'e') {
|
if (c != 'e') {
|
||||||
errString = QString("Unexpected character at pos %1: %2")
|
errString = QString("Unexpected character at pos %1: %2")
|
||||||
.arg(index).arg(c);
|
.arg(index).arg(c);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
++index;
|
++index;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (num == -1)
|
if (num == -1)
|
||||||
num = 0;
|
num = 0;
|
||||||
num *= 10;
|
num *= 10;
|
||||||
num += c - '0';
|
num += c - '0';
|
||||||
} while (++index < contentSize);
|
} while (++index < contentSize);
|
||||||
|
|
||||||
if (integer)
|
if (integer)
|
||||||
*integer = negative ? -num : num;
|
*integer = negative ? -num : num;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,38 +148,38 @@ bool BencodeParser::getList(QList<QVariant> *list)
|
|||||||
{
|
{
|
||||||
const int contentSize = content.size();
|
const int contentSize = content.size();
|
||||||
if (content.at(index) != 'l')
|
if (content.at(index) != 'l')
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QList<QVariant> tmp;
|
QList<QVariant> tmp;
|
||||||
++index;
|
++index;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (content.at(index) == 'e') {
|
if (content.at(index) == 'e') {
|
||||||
++index;
|
++index;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 number;
|
qint64 number;
|
||||||
QByteArray byteString;
|
QByteArray byteString;
|
||||||
QList<QVariant> tmpList;
|
QList<QVariant> tmpList;
|
||||||
QMap<QByteArray, QVariant> dictionary;
|
QMap<QByteArray, QVariant> dictionary;
|
||||||
|
|
||||||
if (getInteger(&number))
|
if (getInteger(&number))
|
||||||
tmp << number;
|
tmp << number;
|
||||||
else if (getByteString(&byteString))
|
else if (getByteString(&byteString))
|
||||||
tmp << byteString;
|
tmp << byteString;
|
||||||
else if (getList(&tmpList))
|
else if (getList(&tmpList))
|
||||||
tmp << tmpList;
|
tmp << tmpList;
|
||||||
else if (getDictionary(&dictionary))
|
else if (getDictionary(&dictionary))
|
||||||
tmp << QVariant::fromValue<QMap<QByteArray, QVariant> >(dictionary);
|
tmp << QVariant::fromValue<QMap<QByteArray, QVariant> >(dictionary);
|
||||||
else {
|
else {
|
||||||
errString = QString("error at index %1").arg(index);
|
errString = QString("error at index %1").arg(index);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} while (index < contentSize);
|
} while (index < contentSize);
|
||||||
|
|
||||||
if (list)
|
if (list)
|
||||||
*list = tmp;
|
*list = tmp;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,48 +187,48 @@ bool BencodeParser::getDictionary(QMap<QByteArray, QVariant> *dictionary)
|
|||||||
{
|
{
|
||||||
const int contentSize = content.size();
|
const int contentSize = content.size();
|
||||||
if (content.at(index) != 'd')
|
if (content.at(index) != 'd')
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QMap<QByteArray, QVariant> tmp;
|
QMap<QByteArray, QVariant> tmp;
|
||||||
++index;
|
++index;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (content.at(index) == 'e') {
|
if (content.at(index) == 'e') {
|
||||||
++index;
|
++index;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray key;
|
QByteArray key;
|
||||||
if (!getByteString(&key))
|
if (!getByteString(&key))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (key == "info")
|
if (key == "info")
|
||||||
infoStart = index;
|
infoStart = index;
|
||||||
|
|
||||||
qint64 number;
|
qint64 number;
|
||||||
QByteArray byteString;
|
QByteArray byteString;
|
||||||
QList<QVariant> tmpList;
|
QList<QVariant> tmpList;
|
||||||
QMap<QByteArray, QVariant> dictionary;
|
QMap<QByteArray, QVariant> dictionary;
|
||||||
|
|
||||||
if (getInteger(&number))
|
if (getInteger(&number))
|
||||||
tmp.insert(key, number);
|
tmp.insert(key, number);
|
||||||
else if (getByteString(&byteString))
|
else if (getByteString(&byteString))
|
||||||
tmp.insert(key, byteString);
|
tmp.insert(key, byteString);
|
||||||
else if (getList(&tmpList))
|
else if (getList(&tmpList))
|
||||||
tmp.insert(key, tmpList);
|
tmp.insert(key, tmpList);
|
||||||
else if (getDictionary(&dictionary))
|
else if (getDictionary(&dictionary))
|
||||||
tmp.insert(key, QVariant::fromValue<QMap<QByteArray, QVariant> >(dictionary));
|
tmp.insert(key, QVariant::fromValue<QMap<QByteArray, QVariant> >(dictionary));
|
||||||
else {
|
else {
|
||||||
errString = QString("error at index %1").arg(index);
|
errString = QString("error at index %1").arg(index);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == "info")
|
if (key == "info")
|
||||||
infoLength = index - infoStart;
|
infoLength = index - infoStart;
|
||||||
|
|
||||||
} while (index < contentSize);
|
} while (index < contentSize);
|
||||||
|
|
||||||
if (dictionary)
|
if (dictionary)
|
||||||
*dictionary = tmp;
|
*dictionary = tmp;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ class BencodeParser
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BencodeParser();
|
BencodeParser();
|
||||||
|
|
||||||
bool parse(const QByteArray &content);
|
bool parse(const QByteArray &content);
|
||||||
QString errorString() const;
|
QString errorString() const;
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ public:
|
|||||||
|
|
||||||
inline void setMetaInfo(const MetaInfo &info) { metaInfo = info; }
|
inline void setMetaInfo(const MetaInfo &info) { metaInfo = info; }
|
||||||
inline void setDestinationFolder(const QString &directory) { destinationPath = directory; }
|
inline void setDestinationFolder(const QString &directory) { destinationPath = directory; }
|
||||||
|
|
||||||
int read(int pieceIndex, int offset, int length);
|
int read(int pieceIndex, int offset, int length);
|
||||||
void write(int pieceIndex, int offset, const QByteArray &data);
|
void write(int pieceIndex, int offset, const QByteArray &data);
|
||||||
void verifyPiece(int pieceIndex);
|
void verifyPiece(int pieceIndex);
|
||||||
|
@ -130,7 +130,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
QAction *newTorrentAction = new QAction(QIcon(":/icons/bottom.png"), tr("Add &new torrent"), this);
|
QAction *newTorrentAction = new QAction(QIcon(":/icons/bottom.png"), tr("Add &new torrent"), this);
|
||||||
pauseTorrentAction = new QAction(QIcon(":/icons/player_pause.png"), tr("&Pause torrent"), this);
|
pauseTorrentAction = new QAction(QIcon(":/icons/player_pause.png"), tr("&Pause torrent"), this);
|
||||||
removeTorrentAction = new QAction(QIcon(":/icons/player_stop.png"), tr("&Remove torrent"), this);
|
removeTorrentAction = new QAction(QIcon(":/icons/player_stop.png"), tr("&Remove torrent"), this);
|
||||||
|
|
||||||
// File menu
|
// File menu
|
||||||
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
|
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
|
||||||
fileMenu->addAction(newTorrentAction);
|
fileMenu->addAction(newTorrentAction);
|
||||||
|
@ -65,7 +65,7 @@ public:
|
|||||||
|
|
||||||
QSize sizeHint() const;
|
QSize sizeHint() const;
|
||||||
const TorrentClient *clientForRow(int row) const;
|
const TorrentClient *clientForRow(int row) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
@ -94,12 +94,12 @@ private slots:
|
|||||||
void about();
|
void about();
|
||||||
void setActionsEnabled();
|
void setActionsEnabled();
|
||||||
void acceptFileDrop(const QString &fileName);
|
void acceptFileDrop(const QString &fileName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int rowOfClient(TorrentClient *client) const;
|
int rowOfClient(TorrentClient *client) const;
|
||||||
bool addTorrent(const QString &fileName, const QString &destinationFolder,
|
bool addTorrent(const QString &fileName, const QString &destinationFolder,
|
||||||
const QByteArray &resumeState = QByteArray());
|
const QByteArray &resumeState = QByteArray());
|
||||||
|
|
||||||
TorrentView *torrentView;
|
TorrentView *torrentView;
|
||||||
QAction *pauseTorrentAction;
|
QAction *pauseTorrentAction;
|
||||||
QAction *removeTorrentAction;
|
QAction *removeTorrentAction;
|
||||||
|
@ -100,7 +100,7 @@ public:
|
|||||||
// Total size
|
// Total size
|
||||||
qint64 totalSize() const;
|
qint64 totalSize() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString errString;
|
QString errString;
|
||||||
QByteArray content;
|
QByteArray content;
|
||||||
QByteArray infoData;
|
QByteArray infoData;
|
||||||
|
@ -63,7 +63,7 @@ struct TorrentBlock
|
|||||||
&& offset == other.offset
|
&& offset == other.offset
|
||||||
&& length == other.length;
|
&& length == other.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pieceIndex;
|
int pieceIndex;
|
||||||
int offset;
|
int offset;
|
||||||
int length;
|
int length;
|
||||||
|
@ -1020,7 +1020,7 @@ void TorrentClient::blockReceived(int pieceIndex, int begin, const QByteArray &d
|
|||||||
if (blocksLeftForPiece(piece) == 0) {
|
if (blocksLeftForPiece(piece) == 0) {
|
||||||
// Ask the file manager to verify the newly downloaded piece
|
// Ask the file manager to verify the newly downloaded piece
|
||||||
d->fileManager.verifyPiece(piece->index);
|
d->fileManager.verifyPiece(piece->index);
|
||||||
|
|
||||||
// Remove this piece from all payloads
|
// Remove this piece from all payloads
|
||||||
QMultiMap<PeerWireClient *, TorrentPiece *>::Iterator it = d->payloads.begin();
|
QMultiMap<PeerWireClient *, TorrentPiece *>::Iterator it = d->payloads.begin();
|
||||||
while (it != d->payloads.end()) {
|
while (it != d->payloads.end()) {
|
||||||
@ -1103,7 +1103,7 @@ void TorrentClient::scheduleUploads()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((client->peerWireState() & PeerWireClient::ChokingPeer) == 0) {
|
if ((client->peerWireState() & PeerWireClient::ChokingPeer) == 0) {
|
||||||
if ((qrand() % 10) == 0)
|
if ((qrand() % 10) == 0)
|
||||||
client->abort();
|
client->abort();
|
||||||
else
|
else
|
||||||
client->chokePeer();
|
client->chokePeer();
|
||||||
@ -1245,7 +1245,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
|
|||||||
if (d->state == WarmingUp || (qrand() & 4) == 0) {
|
if (d->state == WarmingUp || (qrand() & 4) == 0) {
|
||||||
int *occurrences = new int[d->pieceCount];
|
int *occurrences = new int[d->pieceCount];
|
||||||
memset(occurrences, 0, d->pieceCount * sizeof(int));
|
memset(occurrences, 0, d->pieceCount * sizeof(int));
|
||||||
|
|
||||||
// Count how many of each piece are available.
|
// Count how many of each piece are available.
|
||||||
foreach (PeerWireClient *peer, d->connections) {
|
foreach (PeerWireClient *peer, d->connections) {
|
||||||
QBitArray peerPieces = peer->availablePieces();
|
QBitArray peerPieces = peer->availablePieces();
|
||||||
@ -1342,7 +1342,7 @@ void TorrentClient::requestMore(PeerWireClient *client)
|
|||||||
? MaxBlocksInMultiMode : MaxBlocksInProgress);
|
? MaxBlocksInMultiMode : MaxBlocksInProgress);
|
||||||
if (numBlocksInProgress == maxInProgress)
|
if (numBlocksInProgress == maxInProgress)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Starting with the first piece that we're waiting for, request
|
// Starting with the first piece that we're waiting for, request
|
||||||
// blocks until the quota is filled up.
|
// blocks until the quota is filled up.
|
||||||
foreach (TorrentPiece *piece, piecesInProgress) {
|
foreach (TorrentPiece *piece, piecesInProgress) {
|
||||||
@ -1446,7 +1446,7 @@ void TorrentClient::addToPeerList(const QList<TorrentPeer> &peerList)
|
|||||||
// Skip our own server.
|
// Skip our own server.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool known = false;
|
bool known = false;
|
||||||
foreach (TorrentPeer *knownPeer, d->peers) {
|
foreach (TorrentPeer *knownPeer, d->peers) {
|
||||||
if (knownPeer->port == peer.port
|
if (knownPeer->port == peer.port
|
||||||
|
@ -124,7 +124,7 @@ public:
|
|||||||
qint64 uploadedBytes() const;
|
qint64 uploadedBytes() const;
|
||||||
int connectedPeerCount() const;
|
int connectedPeerCount() const;
|
||||||
int seedCount() const;
|
int seedCount() const;
|
||||||
|
|
||||||
// Accessors for the tracker
|
// Accessors for the tracker
|
||||||
QByteArray peerId() const;
|
QByteArray peerId() const;
|
||||||
QByteArray infoHash() const;
|
QByteArray infoHash() const;
|
||||||
@ -142,7 +142,7 @@ signals:
|
|||||||
|
|
||||||
void downloadCompleted();
|
void downloadCompleted();
|
||||||
void peerInfoUpdated();
|
void peerInfoUpdated();
|
||||||
|
|
||||||
void dataSent(int uploadedBytes);
|
void dataSent(int uploadedBytes);
|
||||||
void dataReceived(int downloadedBytes);
|
void dataReceived(int downloadedBytes);
|
||||||
void progressUpdated(int percentProgress);
|
void progressUpdated(int percentProgress);
|
||||||
|
@ -74,7 +74,7 @@ signals:
|
|||||||
|
|
||||||
void uploadCountUpdated(qint64 newUploadCount);
|
void uploadCountUpdated(qint64 newUploadCount);
|
||||||
void downloadCountUpdated(qint64 newDownloadCount);
|
void downloadCountUpdated(qint64 newDownloadCount);
|
||||||
|
|
||||||
void stopped();
|
void stopped();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -99,7 +99,7 @@ private:
|
|||||||
qint64 length;
|
qint64 length;
|
||||||
QString uname;
|
QString uname;
|
||||||
QString pwd;
|
QString pwd;
|
||||||
|
|
||||||
bool firstTrackerRequest;
|
bool firstTrackerRequest;
|
||||||
bool lastTrackerRequest;
|
bool lastTrackerRequest;
|
||||||
bool firstSeeding;
|
bool firstSeeding;
|
||||||
|
@ -50,7 +50,7 @@ struct VertexData
|
|||||||
};
|
};
|
||||||
|
|
||||||
GeometryEngine::GeometryEngine()
|
GeometryEngine::GeometryEngine()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
GeometryEngine::~GeometryEngine()
|
GeometryEngine::~GeometryEngine()
|
||||||
|
@ -68,7 +68,7 @@ void MainWidget::mouseReleaseEvent(QMouseEvent *e)
|
|||||||
// Mouse release position - mouse press position
|
// Mouse release position - mouse press position
|
||||||
QVector2D diff = QVector2D(e->localPos()) - mousePressPosition;
|
QVector2D diff = QVector2D(e->localPos()) - mousePressPosition;
|
||||||
|
|
||||||
// Rotation axis is perpendicular to the mouse position difference
|
// Rotation axis is perpendicular to the mouse position difference
|
||||||
// vector
|
// vector
|
||||||
QVector3D n = QVector3D(diff.y(), diff.x(), 0.0).normalized();
|
QVector3D n = QVector3D(diff.y(), diff.x(), 0.0).normalized();
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ void GLWidget::initializeGL()
|
|||||||
gear3 = makeGear(reflectance3, 1.3, 2.0, 0.5, 0.7, 10);
|
gear3 = makeGear(reflectance3, 1.3, 2.0, 0.5, 0.7, 10);
|
||||||
|
|
||||||
glEnable(GL_NORMALIZE);
|
glEnable(GL_NORMALIZE);
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLWidget::paintGL()
|
void GLWidget::paintGL()
|
||||||
|
@ -90,7 +90,7 @@ private:
|
|||||||
int yRot;
|
int yRot;
|
||||||
int zRot;
|
int zRot;
|
||||||
int gear1Rot;
|
int gear1Rot;
|
||||||
|
|
||||||
QPoint lastPos;
|
QPoint lastPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ void Bubble::move(const QRect &bbox)
|
|||||||
qreal rightOverflow = position.x() + radius - bbox.right();
|
qreal rightOverflow = position.x() + radius - bbox.right();
|
||||||
qreal topOverflow = position.y() - radius - bbox.top();
|
qreal topOverflow = position.y() - radius - bbox.top();
|
||||||
qreal bottomOverflow = position.y() + radius - bbox.bottom();
|
qreal bottomOverflow = position.y() + radius - bbox.bottom();
|
||||||
|
|
||||||
if (leftOverflow < 0.0) {
|
if (leftOverflow < 0.0) {
|
||||||
position.setX(position.x() - 2 * leftOverflow);
|
position.setX(position.x() - 2 * leftOverflow);
|
||||||
vel.setX(-vel.x());
|
vel.setX(-vel.x());
|
||||||
|
@ -70,7 +70,7 @@ void GLWidget::setScaling(int scale) {
|
|||||||
m_fScale = 1 + qreal(scale -50) / 50 * 0.5;
|
m_fScale = 1 + qreal(scale -50) / 50 * 0.5;
|
||||||
else if (scale < 50)
|
else if (scale < 50)
|
||||||
m_fScale = 1- (qreal(50 - scale) / 50 * 1/2);
|
m_fScale = 1- (qreal(50 - scale) / 50 * 1/2);
|
||||||
else
|
else
|
||||||
m_fScale = 1;
|
m_fScale = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,7 +316,7 @@ void GLWidget::paintGL()
|
|||||||
painter.drawText(20, 40, framesPerSecond + " fps");
|
painter.drawText(20, 40, framesPerSecond + " fps");
|
||||||
|
|
||||||
painter.end();
|
painter.end();
|
||||||
|
|
||||||
swapBuffers();
|
swapBuffers();
|
||||||
|
|
||||||
QMutableListIterator<Bubble*> iter(bubbles);
|
QMutableListIterator<Bubble*> iter(bubbles);
|
||||||
|
@ -55,7 +55,7 @@ class GLWidget : public QGLWidget {
|
|||||||
public:
|
public:
|
||||||
GLWidget(QWidget *parent = 0);
|
GLWidget(QWidget *parent = 0);
|
||||||
~GLWidget();
|
~GLWidget();
|
||||||
public slots:
|
public slots:
|
||||||
void setScaling(int scale);
|
void setScaling(int scale);
|
||||||
void setLogo();
|
void setLogo();
|
||||||
void setTexture();
|
void setTexture();
|
||||||
|
@ -57,7 +57,7 @@ MainWindow::MainWindow()
|
|||||||
QTimer *timer = new QTimer(this);
|
QTimer *timer = new QTimer(this);
|
||||||
QSlider *slider = new QSlider(this);
|
QSlider *slider = new QSlider(this);
|
||||||
slider->setOrientation(Qt::Horizontal);
|
slider->setOrientation(Qt::Horizontal);
|
||||||
|
|
||||||
slider->setRange(0, 100);
|
slider->setRange(0, 100);
|
||||||
slider->setSliderPosition(50);
|
slider->setSliderPosition(50);
|
||||||
timer->setInterval(10);
|
timer->setInterval(10);
|
||||||
|
@ -85,7 +85,7 @@ void Bubble::move(const QRect &bbox)
|
|||||||
qreal rightOverflow = position.x() + radius - bbox.right();
|
qreal rightOverflow = position.x() + radius - bbox.right();
|
||||||
qreal topOverflow = position.y() - radius - bbox.top();
|
qreal topOverflow = position.y() - radius - bbox.top();
|
||||||
qreal bottomOverflow = position.y() + radius - bbox.bottom();
|
qreal bottomOverflow = position.y() + radius - bbox.bottom();
|
||||||
|
|
||||||
if (leftOverflow < 0.0) {
|
if (leftOverflow < 0.0) {
|
||||||
position.setX(position.x() - 2 * leftOverflow);
|
position.setX(position.x() - 2 * leftOverflow);
|
||||||
vel.setX(-vel.x());
|
vel.setX(-vel.x());
|
||||||
|
@ -50,8 +50,8 @@ QImage scale(const QString &imageFileName)
|
|||||||
return image.scaled(QSize(imageSize, imageSize), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
return image.scaled(QSize(imageSize, imageSize), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
}
|
}
|
||||||
|
|
||||||
Images::Images(QWidget *parent)
|
Images::Images(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Image loading and scaling example"));
|
setWindowTitle(tr("Image loading and scaling example"));
|
||||||
resize(800, 600);
|
resize(800, 600);
|
||||||
@ -66,11 +66,11 @@ Images::Images(QWidget *parent)
|
|||||||
cancelButton = new QPushButton(tr("Cancel"));
|
cancelButton = new QPushButton(tr("Cancel"));
|
||||||
cancelButton->setEnabled(false);
|
cancelButton->setEnabled(false);
|
||||||
connect(cancelButton, SIGNAL(clicked()), imageScaling, SLOT(cancel()));
|
connect(cancelButton, SIGNAL(clicked()), imageScaling, SLOT(cancel()));
|
||||||
|
|
||||||
pauseButton = new QPushButton(tr("Pause/Resume"));
|
pauseButton = new QPushButton(tr("Pause/Resume"));
|
||||||
pauseButton->setEnabled(false);
|
pauseButton->setEnabled(false);
|
||||||
connect(pauseButton, SIGNAL(clicked()), imageScaling, SLOT(togglePaused()));
|
connect(pauseButton, SIGNAL(clicked()), imageScaling, SLOT(togglePaused()));
|
||||||
|
|
||||||
QHBoxLayout *buttonLayout = new QHBoxLayout();
|
QHBoxLayout *buttonLayout = new QHBoxLayout();
|
||||||
buttonLayout->addWidget(openButton);
|
buttonLayout->addWidget(openButton);
|
||||||
buttonLayout->addWidget(cancelButton);
|
buttonLayout->addWidget(cancelButton);
|
||||||
@ -101,7 +101,7 @@ void Images::open()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show a file open dialog at QStandardPaths::PicturesLocation.
|
// Show a file open dialog at QStandardPaths::PicturesLocation.
|
||||||
QStringList files = QFileDialog::getOpenFileNames(this, tr("Select Images"),
|
QStringList files = QFileDialog::getOpenFileNames(this, tr("Select Images"),
|
||||||
QStandardPaths::writableLocation(QStandardPaths::PicturesLocation),
|
QStandardPaths::writableLocation(QStandardPaths::PicturesLocation),
|
||||||
"*.jpg *.png");
|
"*.jpg *.png");
|
||||||
|
|
||||||
@ -143,4 +143,3 @@ void Images::finished()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // QT_NO_CONCURRENT
|
#endif // QT_NO_CONCURRENT
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ int main(int argc, char **argv)
|
|||||||
// Create a progress dialog.
|
// Create a progress dialog.
|
||||||
QProgressDialog dialog;
|
QProgressDialog dialog;
|
||||||
dialog.setLabelText(QString("Progressing using %1 thread(s)...").arg(QThread::idealThreadCount()));
|
dialog.setLabelText(QString("Progressing using %1 thread(s)...").arg(QThread::idealThreadCount()));
|
||||||
|
|
||||||
// Create a QFutureWatcher and connect signals and slots.
|
// Create a QFutureWatcher and connect signals and slots.
|
||||||
QFutureWatcher<void> futureWatcher;
|
QFutureWatcher<void> futureWatcher;
|
||||||
QObject::connect(&futureWatcher, SIGNAL(finished()), &dialog, SLOT(reset()));
|
QObject::connect(&futureWatcher, SIGNAL(finished()), &dialog, SLOT(reset()));
|
||||||
@ -82,7 +82,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
// Display the dialog and start the event loop.
|
// Display the dialog and start the event loop.
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
|
|
||||||
futureWatcher.waitForFinished();
|
futureWatcher.waitForFinished();
|
||||||
|
|
||||||
// Query the future to check if was canceled.
|
// Query the future to check if was canceled.
|
||||||
|
@ -81,7 +81,7 @@ void TestBenchmark::multiple()
|
|||||||
QFETCH(bool, useLocaleCompare);
|
QFETCH(bool, useLocaleCompare);
|
||||||
QString str1 = QLatin1String("This is a test string");
|
QString str1 = QLatin1String("This is a test string");
|
||||||
QString str2 = QLatin1String("This is a test string");
|
QString str2 = QLatin1String("This is a test string");
|
||||||
|
|
||||||
int result;
|
int result;
|
||||||
if (useLocaleCompare) {
|
if (useLocaleCompare) {
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
@ -101,7 +101,7 @@ void TestBenchmark::series_data()
|
|||||||
{
|
{
|
||||||
QTest::addColumn<bool>("useLocaleCompare");
|
QTest::addColumn<bool>("useLocaleCompare");
|
||||||
QTest::addColumn<int>("stringSize");
|
QTest::addColumn<int>("stringSize");
|
||||||
|
|
||||||
for (int i = 1; i < 10000; i += 2000) {
|
for (int i = 1; i < 10000; i += 2000) {
|
||||||
QByteArray size = QByteArray::number(i);
|
QByteArray size = QByteArray::number(i);
|
||||||
QTest::newRow(("locale aware compare--" + size).constData()) << true << i;
|
QTest::newRow(("locale aware compare--" + size).constData()) << true << i;
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
\brief The Query Model example shows how to make customized versions of
|
\brief The Query Model example shows how to make customized versions of
|
||||||
data obtained from a SQL query, using a model that encapsulates
|
data obtained from a SQL query, using a model that encapsulates
|
||||||
the query and table views to display the results.
|
the query and table views to display the results.
|
||||||
|
|
||||||
\image querymodel-example.png
|
\image querymodel-example.png
|
||||||
*/
|
*/
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\example relationaltablemodel
|
\example relationaltablemodel
|
||||||
\title Relational Table Model Example
|
\title Relational Table Model Example
|
||||||
\ingroup sql_examples
|
\ingroup sql_examples
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\example tablemodel
|
\example tablemodel
|
||||||
\title Table Model Example
|
\title Table Model Example
|
||||||
\ingroup sql_examples
|
\ingroup sql_examples
|
||||||
|
@ -81,7 +81,7 @@ QImage createImage(int width, int height)
|
|||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
int starWidth = image.width()/3;
|
int starWidth = image.width()/3;
|
||||||
int starHeight = image.height()/3;
|
int starHeight = image.height()/3;
|
||||||
|
|
||||||
QRect rect(x, y, starWidth, starHeight);
|
QRect rect(x, y, starWidth, starHeight);
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
|
|
||||||
And thats it. A perfectly reasonable cache, using minimal memory for a very large
|
And thats it. A perfectly reasonable cache, using minimal memory for a very large
|
||||||
list. In this case the accessor for getting the words into the cache
|
list. In this case the accessor for getting the words into the cache
|
||||||
generates random information rather than fixed information. This allows you
|
generates random information rather than fixed information. This allows you
|
||||||
to see how the cache range is kept for a local number of rows when running the
|
to see how the cache range is kept for a local number of rows when running the
|
||||||
example.
|
example.
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@
|
|||||||
With the type fully defined, implemented, and integrated with the
|
With the type fully defined, implemented, and integrated with the
|
||||||
meta-object system, we can now use it.
|
meta-object system, we can now use it.
|
||||||
|
|
||||||
\section1 Using the Message
|
\section1 Using the Message
|
||||||
|
|
||||||
In the example's \c{main()} function, we show how a \c Message object can
|
In the example's \c{main()} function, we show how a \c Message object can
|
||||||
be printed to the console by sending it to the debug stream:
|
be printed to the console by sending it to the debug stream:
|
||||||
|
@ -158,7 +158,7 @@ void Mouse::timerEvent(QTimerEvent *)
|
|||||||
foreach (QGraphicsItem *item, dangerMice) {
|
foreach (QGraphicsItem *item, dangerMice) {
|
||||||
if (item == this)
|
if (item == this)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QLineF lineToMouse(QPointF(0, 0), mapFromItem(item, 0, 0));
|
QLineF lineToMouse(QPointF(0, 0), mapFromItem(item, 0, 0));
|
||||||
qreal angleToMouse = ::acos(lineToMouse.dx() / lineToMouse.length());
|
qreal angleToMouse = ::acos(lineToMouse.dx() / lineToMouse.length());
|
||||||
if (lineToMouse.dy() < 0)
|
if (lineToMouse.dy() < 0)
|
||||||
|
@ -108,7 +108,7 @@ void createStates(const QObjectList &objects,
|
|||||||
void createAnimations(const QObjectList &objects, QStateMachine *machine)
|
void createAnimations(const QObjectList &objects, QStateMachine *machine)
|
||||||
{
|
{
|
||||||
for (int i=0; i<objects.size(); ++i)
|
for (int i=0; i<objects.size(); ++i)
|
||||||
machine->addDefaultAnimation(new QPropertyAnimation(objects.at(i), "geometry"));
|
machine->addDefaultAnimation(new QPropertyAnimation(objects.at(i), "geometry"));
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
@ -63,11 +63,11 @@ private slots:
|
|||||||
void periodChanged(double);
|
void periodChanged(double);
|
||||||
void amplitudeChanged(double);
|
void amplitudeChanged(double);
|
||||||
void overshootChanged(double);
|
void overshootChanged(double);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createCurveIcons();
|
void createCurveIcons();
|
||||||
void startAnimation();
|
void startAnimation();
|
||||||
|
|
||||||
Ui::Form m_ui;
|
Ui::Form m_ui;
|
||||||
QGraphicsScene m_scene;
|
QGraphicsScene m_scene;
|
||||||
PixmapItem *m_item;
|
PixmapItem *m_item;
|
||||||
|
@ -45,13 +45,13 @@
|
|||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
|
|
||||||
class Frame
|
class Frame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Frame() {
|
Frame() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int nodeCount() const
|
int nodeCount() const
|
||||||
{
|
{
|
||||||
return m_nodePositions.size();
|
return m_nodePositions.size();
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ public:
|
|||||||
{
|
{
|
||||||
m_nodePositions[idx] = pos;
|
m_nodePositions[idx] = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVector<QPointF> m_nodePositions;
|
QVector<QPointF> m_nodePositions;
|
||||||
};
|
};
|
||||||
@ -81,7 +81,7 @@ Animation::Animation()
|
|||||||
m_frames.append(new Frame);
|
m_frames.append(new Frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
Animation::~Animation()
|
Animation::~Animation()
|
||||||
{
|
{
|
||||||
qDeleteAll(m_frames);
|
qDeleteAll(m_frames);
|
||||||
}
|
}
|
||||||
@ -89,10 +89,10 @@ Animation::~Animation()
|
|||||||
void Animation::setTotalFrames(int totalFrames)
|
void Animation::setTotalFrames(int totalFrames)
|
||||||
{
|
{
|
||||||
while (m_frames.size() < totalFrames)
|
while (m_frames.size() < totalFrames)
|
||||||
m_frames.append(new Frame);
|
m_frames.append(new Frame);
|
||||||
|
|
||||||
while (totalFrames < m_frames.size())
|
while (totalFrames < m_frames.size())
|
||||||
delete m_frames.takeLast();
|
delete m_frames.takeLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Animation::totalFrames() const
|
int Animation::totalFrames() const
|
||||||
@ -165,15 +165,15 @@ void Animation::load(QIODevice *device)
|
|||||||
|
|
||||||
QDataStream stream(device);
|
QDataStream stream(device);
|
||||||
stream >> m_name;
|
stream >> m_name;
|
||||||
|
|
||||||
int frameCount;
|
int frameCount;
|
||||||
stream >> frameCount;
|
stream >> frameCount;
|
||||||
|
|
||||||
for (int i=0; i<frameCount; ++i) {
|
for (int i=0; i<frameCount; ++i) {
|
||||||
|
|
||||||
int nodeCount;
|
int nodeCount;
|
||||||
stream >> nodeCount;
|
stream >> nodeCount;
|
||||||
|
|
||||||
Frame *frame = new Frame;
|
Frame *frame = new Frame;
|
||||||
frame->setNodeCount(nodeCount);
|
frame->setNodeCount(nodeCount);
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ public:
|
|||||||
if (QSignalTransition::eventTest(e)) {
|
if (QSignalTransition::eventTest(e)) {
|
||||||
QVariant key = static_cast<QStateMachine::SignalEvent*>(e)->arguments().at(0);
|
QVariant key = static_cast<QStateMachine::SignalEvent*>(e)->arguments().at(0);
|
||||||
return (key.toInt() == int(m_key));
|
return (key.toInt() == int(m_key));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ LifeCycle::LifeCycle(StickMan *stickMan, GraphicsView *keyReceiver)
|
|||||||
const int stickManNodeCount = m_stickMan->nodeCount();
|
const int stickManNodeCount = m_stickMan->nodeCount();
|
||||||
for (int i=0; i<stickManNodeCount; ++i) {
|
for (int i=0; i<stickManNodeCount; ++i) {
|
||||||
QPropertyAnimation *pa = new QPropertyAnimation(m_stickMan->node(i), "pos");
|
QPropertyAnimation *pa = new QPropertyAnimation(m_stickMan->node(i), "pos");
|
||||||
m_animationGroup->addAnimation(pa);
|
m_animationGroup->addAnimation(pa);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up initial state graph
|
// Set up initial state graph
|
||||||
@ -111,14 +111,14 @@ LifeCycle::LifeCycle(StickMan *stickMan, GraphicsView *keyReceiver)
|
|||||||
|
|
||||||
m_alive = new QState(m_machine);
|
m_alive = new QState(m_machine);
|
||||||
m_alive->setObjectName("alive");
|
m_alive->setObjectName("alive");
|
||||||
|
|
||||||
// Make it blink when lightning strikes before entering dead animation
|
// Make it blink when lightning strikes before entering dead animation
|
||||||
QState *lightningBlink = new QState(m_machine);
|
QState *lightningBlink = new QState(m_machine);
|
||||||
lightningBlink->assignProperty(m_stickMan->scene(), "backgroundBrush", QColor(Qt::white));
|
lightningBlink->assignProperty(m_stickMan->scene(), "backgroundBrush", QColor(Qt::white));
|
||||||
lightningBlink->assignProperty(m_stickMan, "penColor", QColor(Qt::black));
|
lightningBlink->assignProperty(m_stickMan, "penColor", QColor(Qt::black));
|
||||||
lightningBlink->assignProperty(m_stickMan, "fillColor", QColor(Qt::white));
|
lightningBlink->assignProperty(m_stickMan, "fillColor", QColor(Qt::white));
|
||||||
lightningBlink->assignProperty(m_stickMan, "isDead", true);
|
lightningBlink->assignProperty(m_stickMan, "isDead", true);
|
||||||
|
|
||||||
//! [5]
|
//! [5]
|
||||||
QTimer *timer = new QTimer(lightningBlink);
|
QTimer *timer = new QTimer(lightningBlink);
|
||||||
timer->setSingleShot(true);
|
timer->setSingleShot(true);
|
||||||
@ -126,13 +126,13 @@ LifeCycle::LifeCycle(StickMan *stickMan, GraphicsView *keyReceiver)
|
|||||||
QObject::connect(lightningBlink, SIGNAL(entered()), timer, SLOT(start()));
|
QObject::connect(lightningBlink, SIGNAL(entered()), timer, SLOT(start()));
|
||||||
QObject::connect(lightningBlink, SIGNAL(exited()), timer, SLOT(stop()));
|
QObject::connect(lightningBlink, SIGNAL(exited()), timer, SLOT(stop()));
|
||||||
//! [5]
|
//! [5]
|
||||||
|
|
||||||
m_dead = new QState(m_machine);
|
m_dead = new QState(m_machine);
|
||||||
m_dead->assignProperty(m_stickMan->scene(), "backgroundBrush", QColor(Qt::black));
|
m_dead->assignProperty(m_stickMan->scene(), "backgroundBrush", QColor(Qt::black));
|
||||||
m_dead->assignProperty(m_stickMan, "penColor", QColor(Qt::white));
|
m_dead->assignProperty(m_stickMan, "penColor", QColor(Qt::white));
|
||||||
m_dead->assignProperty(m_stickMan, "fillColor", QColor(Qt::black));
|
m_dead->assignProperty(m_stickMan, "fillColor", QColor(Qt::black));
|
||||||
m_dead->setObjectName("dead");
|
m_dead->setObjectName("dead");
|
||||||
|
|
||||||
// Idle state (sets no properties)
|
// Idle state (sets no properties)
|
||||||
m_idle = new QState(m_alive);
|
m_idle = new QState(m_alive);
|
||||||
m_idle->setObjectName("idle");
|
m_idle->setObjectName("idle");
|
||||||
@ -172,7 +172,7 @@ void LifeCycle::addActivity(const QString &fileName, Qt::Key key, QObject *sende
|
|||||||
QState *LifeCycle::makeState(QState *parentState, const QString &animationFileName)
|
QState *LifeCycle::makeState(QState *parentState, const QString &animationFileName)
|
||||||
{
|
{
|
||||||
QState *topLevel = new QState(parentState);
|
QState *topLevel = new QState(parentState);
|
||||||
|
|
||||||
Animation animation;
|
Animation animation;
|
||||||
{
|
{
|
||||||
QFile file(animationFileName);
|
QFile file(animationFileName);
|
||||||
@ -186,7 +186,7 @@ QState *LifeCycle::makeState(QState *parentState, const QString &animationFileNa
|
|||||||
animation.setCurrentFrame(i);
|
animation.setCurrentFrame(i);
|
||||||
|
|
||||||
//! [1]
|
//! [1]
|
||||||
QState *frameState = new QState(topLevel);
|
QState *frameState = new QState(topLevel);
|
||||||
const int nodeCount = animation.nodeCount();
|
const int nodeCount = animation.nodeCount();
|
||||||
for (int j=0; j<nodeCount; ++j)
|
for (int j=0; j<nodeCount; ++j)
|
||||||
frameState->assignProperty(m_stickMan->node(j), "pos", animation.nodePos(j));
|
frameState->assignProperty(m_stickMan->node(j), "pos", animation.nodePos(j));
|
||||||
@ -199,7 +199,7 @@ QState *LifeCycle::makeState(QState *parentState, const QString &animationFileNa
|
|||||||
//! [2]
|
//! [2]
|
||||||
previousState->addTransition(previousState, SIGNAL(propertiesAssigned()), frameState);
|
previousState->addTransition(previousState, SIGNAL(propertiesAssigned()), frameState);
|
||||||
//! [2]
|
//! [2]
|
||||||
|
|
||||||
previousState = frameState;
|
previousState = frameState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ QRectF Node::boundingRect() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
|
void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
|
||||||
{
|
{
|
||||||
painter->setPen(Qt::white);
|
painter->setPen(Qt::white);
|
||||||
painter->drawEllipse(QPointF(0.0, 0.0), 5.0, 5.0);
|
painter->drawEllipse(QPointF(0.0, 0.0), 5.0, 5.0);
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ void Node::mousePressEvent(QGraphicsSceneMouseEvent *)
|
|||||||
void Node::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
void Node::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (m_dragging)
|
if (m_dragging)
|
||||||
setPos(mapToParent(event->pos()));
|
setPos(mapToParent(event->pos()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *)
|
void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *)
|
||||||
|
@ -62,7 +62,7 @@ public:
|
|||||||
virtual QRectF boundingRect() const;
|
virtual QRectF boundingRect() const;
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
int nodeCount() const;
|
int nodeCount() const;
|
||||||
Node *node(int idx) const;
|
Node *node(int idx) const;
|
||||||
|
|
||||||
void setDrawSticks(bool on);
|
void setDrawSticks(bool on);
|
||||||
@ -90,7 +90,7 @@ private:
|
|||||||
|
|
||||||
Node *m_nodes[NodeCount];
|
Node *m_nodes[NodeCount];
|
||||||
qreal m_perfectBoneLengths[BoneCount];
|
qreal m_perfectBoneLengths[BoneCount];
|
||||||
|
|
||||||
uint m_sticks : 1;
|
uint m_sticks : 1;
|
||||||
uint m_isDead : 1;
|
uint m_isDead : 1;
|
||||||
uint m_reserved : 30;
|
uint m_reserved : 30;
|
||||||
|
@ -124,7 +124,7 @@ class OutputFilesPage : public QWizardPage
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OutputFilesPage(QWidget *parent = 0);
|
OutputFilesPage(QWidget *parent = 0);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
Q_INIT_RESOURCE(classwizard);
|
Q_INIT_RESOURCE(classwizard);
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
#ifndef QT_NO_TRANSLATION
|
#ifndef QT_NO_TRANSLATION
|
||||||
|
@ -91,7 +91,7 @@ Dialog::Dialog()
|
|||||||
//! [Dialog constructor part5]
|
//! [Dialog constructor part5]
|
||||||
connect(button, SIGNAL(clicked()),
|
connect(button, SIGNAL(clicked()),
|
||||||
qApp, SLOT(closeAllWindows()));
|
qApp, SLOT(closeAllWindows()));
|
||||||
connect(QApplication::desktop(), SIGNAL(workAreaResized(int)),
|
connect(QApplication::desktop(), SIGNAL(workAreaResized(int)),
|
||||||
this, SLOT(desktopResized(int)));
|
this, SLOT(desktopResized(int)));
|
||||||
}
|
}
|
||||||
//! [Dialog constructor part5]
|
//! [Dialog constructor part5]
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
\image addressbook-tutorial-screenshot.png
|
\image addressbook-tutorial-screenshot.png
|
||||||
|
|
||||||
Ce tutoriel va nous amener à découvrir quelques technologies fondamentales fournies
|
Ce tutoriel va nous amener à découvrir quelques technologies fondamentales fournies
|
||||||
par Qt, tel que:
|
par Qt, tel que:
|
||||||
|
|
||||||
\list
|
\list
|
||||||
@ -124,7 +124,7 @@
|
|||||||
réutilisé dans d'autres projets
|
réutilisé dans d'autres projets
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
Comme Qt ne fournit pas de widget standard pour un carnet d'adresses, nous
|
Comme Qt ne fournit pas de widget standard pour un carnet d'adresses, nous
|
||||||
partirons d'une classe de widget Qt standard et y ajouterons des fonctionnalités.
|
partirons d'une classe de widget Qt standard et y ajouterons des fonctionnalités.
|
||||||
La classe \c AddressBook crée dans ce tutoriel peut être réutilisée si on a besoin d'un
|
La classe \c AddressBook crée dans ce tutoriel peut être réutilisée si on a besoin d'un
|
||||||
widget carnet d'adresses basique.
|
widget carnet d'adresses basique.
|
||||||
@ -148,12 +148,12 @@
|
|||||||
dans \c nameLine et \c addressText sont nécessaires à de nombreuses méthodes
|
dans \c nameLine et \c addressText sont nécessaires à de nombreuses méthodes
|
||||||
du carnet d'adresses.
|
du carnet d'adresses.
|
||||||
|
|
||||||
Il n'est pas nécessaire de déclarer les objets QLabel que nous allons utiliser
|
Il n'est pas nécessaire de déclarer les objets QLabel que nous allons utiliser
|
||||||
puisque nous n'aurons pas besoin d'y faire référence après leur création.
|
puisque nous n'aurons pas besoin d'y faire référence après leur création.
|
||||||
La façon dont Qt gère la parenté des objets est traitée dans la section suivante.
|
La façon dont Qt gère la parenté des objets est traitée dans la section suivante.
|
||||||
|
|
||||||
La macro Q_OBJECT implémente des fonctionnalités parmi les plus avancées de Qt.
|
La macro Q_OBJECT implémente des fonctionnalités parmi les plus avancées de Qt.
|
||||||
Pour le moment, il est bon de voir la macro Q_OBJECT comme un raccourci nous
|
Pour le moment, il est bon de voir la macro Q_OBJECT comme un raccourci nous
|
||||||
permettant d'utiliser les méthodes \l{QObject::}{tr()} et \l{QObject::}{connect()}.
|
permettant d'utiliser les méthodes \l{QObject::}{tr()} et \l{QObject::}{connect()}.
|
||||||
|
|
||||||
Nous en avons maintenant terminé avec le fichier \c addressbook.h et allons
|
Nous en avons maintenant terminé avec le fichier \c addressbook.h et allons
|
||||||
@ -295,13 +295,13 @@
|
|||||||
|
|
||||||
Le bouton \c addButton est affiché en invoquant la méthode \l{QPushButton::show()}
|
Le bouton \c addButton est affiché en invoquant la méthode \l{QPushButton::show()}
|
||||||
{show()}, tandis que \c submitButton et \c cancelButton sont cachés en invoquant
|
{show()}, tandis que \c submitButton et \c cancelButton sont cachés en invoquant
|
||||||
\l{QPushButton::hide()}{hide()}. Ces deux boutons ne seront affichés que lorsque
|
\l{QPushButton::hide()}{hide()}. Ces deux boutons ne seront affichés que lorsque
|
||||||
l'utilisateur cliquera sur "Add", et ceci est géré par la méthode \c addContact()
|
l'utilisateur cliquera sur "Add", et ceci est géré par la méthode \c addContact()
|
||||||
décrite plus loin.
|
décrite plus loin.
|
||||||
|
|
||||||
\snippet tutorials/addressbook/part2/addressbook.cpp connecting signals and slots
|
\snippet tutorials/addressbook/part2/addressbook.cpp connecting signals and slots
|
||||||
|
|
||||||
Nous connectons le signal \l{QPushButton::clicked()}{clicked()} de chaque bouton
|
Nous connectons le signal \l{QPushButton::clicked()}{clicked()} de chaque bouton
|
||||||
au slot qui gèrera l'action.
|
au slot qui gèrera l'action.
|
||||||
L'image ci-dessous illustre ceci:
|
L'image ci-dessous illustre ceci:
|
||||||
|
|
||||||
@ -379,8 +379,8 @@
|
|||||||
|
|
||||||
\snippet tutorials/addressbook/part2/addressbook.cpp cancel
|
\snippet tutorials/addressbook/part2/addressbook.cpp cancel
|
||||||
|
|
||||||
L'idée générale pour augmenter la flexibilité lors de l'ajout d'un
|
L'idée générale pour augmenter la flexibilité lors de l'ajout d'un
|
||||||
contact est de donner la possiblité de cliquer sur "Add"
|
contact est de donner la possiblité de cliquer sur "Add"
|
||||||
ou "Cancel" à n'importe quel moment.
|
ou "Cancel" à n'importe quel moment.
|
||||||
L'organigramme ci-dessous reprend l'ensemble des interactions dévelopées
|
L'organigramme ci-dessous reprend l'ensemble des interactions dévelopées
|
||||||
jusqu'ici:
|
jusqu'ici:
|
||||||
@ -458,15 +458,15 @@
|
|||||||
\c mainLayout.
|
\c mainLayout.
|
||||||
\image addressbook-tutorial-part3-labeled-layout.png
|
\image addressbook-tutorial-part3-labeled-layout.png
|
||||||
|
|
||||||
Dans notre méthode \c addContact(), nous avons desactivé ces boutons
|
Dans notre méthode \c addContact(), nous avons desactivé ces boutons
|
||||||
pour être sûr que l'utilisateur n'utilise pas la navigation lors de
|
pour être sûr que l'utilisateur n'utilise pas la navigation lors de
|
||||||
l'ajout d'un contact.
|
l'ajout d'un contact.
|
||||||
|
|
||||||
\snippet tutorials/addressbook/part3/addressbook.cpp disabling navigation
|
\snippet tutorials/addressbook/part3/addressbook.cpp disabling navigation
|
||||||
|
|
||||||
Dans notre méthode \c submitContact(), nous activons les boutons de
|
Dans notre méthode \c submitContact(), nous activons les boutons de
|
||||||
navigation, \c nextButton et \c previousButton, en fonction de la
|
navigation, \c nextButton et \c previousButton, en fonction de la
|
||||||
taille de \c contacts. Commen mentionné plus tôt, la navigation n'est
|
taille de \c contacts. Commen mentionné plus tôt, la navigation n'est
|
||||||
activée que si il y a plus d'un contact dans le carnet d'adresses.
|
activée que si il y a plus d'un contact dans le carnet d'adresses.
|
||||||
Les lignes suivantes montrent comment faire cela:
|
Les lignes suivantes montrent comment faire cela:
|
||||||
|
|
||||||
@ -475,13 +475,13 @@
|
|||||||
Nous incluons aussi ces lignes de code dans le bouton \c cancel().
|
Nous incluons aussi ces lignes de code dans le bouton \c cancel().
|
||||||
|
|
||||||
Souvenez vous que nous voulons émuler une liste-liée ciruculaire à
|
Souvenez vous que nous voulons émuler une liste-liée ciruculaire à
|
||||||
l'aide de l'objet QMap, \c contacts. Pour faire cela, nous obtenons un itérateur
|
l'aide de l'objet QMap, \c contacts. Pour faire cela, nous obtenons un itérateur
|
||||||
sur \c contact dans la méthode \c next(), et ensuite:
|
sur \c contact dans la méthode \c next(), et ensuite:
|
||||||
|
|
||||||
\list
|
\list
|
||||||
\li Si l'itérateur n'est pas à la fin de \c contacts, nous l'incrémentons
|
\li Si l'itérateur n'est pas à la fin de \c contacts, nous l'incrémentons
|
||||||
\li Si l'itérateur est à la fin de \c contacts, nous changeons sa position
|
\li Si l'itérateur est à la fin de \c contacts, nous changeons sa position
|
||||||
jusqu'au début de \c contacts. Cela donne l'illusion que notre QMap
|
jusqu'au début de \c contacts. Cela donne l'illusion que notre QMap
|
||||||
fonctionne comme une liste circulaire.
|
fonctionne comme une liste circulaire.
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
@ -490,7 +490,7 @@
|
|||||||
Une fois que nous avons itéré jusqu'à l'objet recherché dans \c contacts,
|
Une fois que nous avons itéré jusqu'à l'objet recherché dans \c contacts,
|
||||||
nous affichons son contenu sur \c nameLine et \c addressText.
|
nous affichons son contenu sur \c nameLine et \c addressText.
|
||||||
|
|
||||||
De la même façon, pour la méthode \c previous(), nous obtenons un
|
De la même façon, pour la méthode \c previous(), nous obtenons un
|
||||||
itérateur sur \c contacts et ensuite:
|
itérateur sur \c contacts et ensuite:
|
||||||
|
|
||||||
\list
|
\list
|
||||||
@ -522,7 +522,7 @@
|
|||||||
\image addressbook-tutorial-screenshot.png
|
\image addressbook-tutorial-screenshot.png
|
||||||
|
|
||||||
Nous avons maintenant un carnet d'adresses qui ne se contente pas de
|
Nous avons maintenant un carnet d'adresses qui ne se contente pas de
|
||||||
lister des contacts de façon ordonnée, mais permet également la
|
lister des contacts de façon ordonnée, mais permet également la
|
||||||
navigation. Il serait pratique d'inclure des fonctions telles qu'éditer et
|
navigation. Il serait pratique d'inclure des fonctions telles qu'éditer et
|
||||||
supprimer, afin que les détails associés à un contact puissent être
|
supprimer, afin que les détails associés à un contact puissent être
|
||||||
modifiés lorsque c'est nécessaire. Cependant, cela requiert une légère
|
modifiés lorsque c'est nécessaire. Cependant, cela requiert une légère
|
||||||
@ -563,7 +563,7 @@
|
|||||||
\dots
|
\dots
|
||||||
\snippet tutorials/addressbook/part4/addressbook.h mode declaration
|
\snippet tutorials/addressbook/part4/addressbook.h mode declaration
|
||||||
|
|
||||||
Enfin, on déclare \c currentMode pour garder une trace du mode
|
Enfin, on déclare \c currentMode pour garder une trace du mode
|
||||||
actuellement utilisé.
|
actuellement utilisé.
|
||||||
|
|
||||||
\section1 Implémentation de la classe AddressBook
|
\section1 Implémentation de la classe AddressBook
|
||||||
@ -637,7 +637,7 @@
|
|||||||
avant de tester sa valeur.
|
avant de tester sa valeur.
|
||||||
|
|
||||||
Chacun des boutons est ensuite activé ou désactivé, en fonction du mode.
|
Chacun des boutons est ensuite activé ou désactivé, en fonction du mode.
|
||||||
Le code source pour les cas \c AddingMode et \c EditingMode est visible
|
Le code source pour les cas \c AddingMode et \c EditingMode est visible
|
||||||
ci-dessous:
|
ci-dessous:
|
||||||
|
|
||||||
\snippet tutorials/addressbook/part4/addressbook.cpp update interface() part 1
|
\snippet tutorials/addressbook/part4/addressbook.cpp update interface() part 1
|
||||||
@ -840,7 +840,7 @@
|
|||||||
|
|
||||||
\section1 Définition de la classe AddressBook
|
\section1 Définition de la classe AddressBook
|
||||||
|
|
||||||
On déclare deux slots publics, \c saveToFile() et \c loadFromFile(),
|
On déclare deux slots publics, \c saveToFile() et \c loadFromFile(),
|
||||||
ainsi que deux objets QPushButton, \c loadButton et \c saveButton.
|
ainsi que deux objets QPushButton, \c loadButton et \c saveButton.
|
||||||
|
|
||||||
\snippet tutorials/addressbook/part6/addressbook.h save and load functions declaration
|
\snippet tutorials/addressbook/part6/addressbook.h save and load functions declaration
|
||||||
@ -863,11 +863,11 @@
|
|||||||
\snippet tutorials/addressbook/part6/addressbook.cpp tooltip 2
|
\snippet tutorials/addressbook/part6/addressbook.cpp tooltip 2
|
||||||
|
|
||||||
Bien qu'on ne cite pas le code correspondant ici, nous ajoutons ces deux boutons au
|
Bien qu'on ne cite pas le code correspondant ici, nous ajoutons ces deux boutons au
|
||||||
layout de droite, \c button1Layout, comme pour les fonctionnalités précédentes, et
|
layout de droite, \c button1Layout, comme pour les fonctionnalités précédentes, et
|
||||||
nous connectons leurs signaux
|
nous connectons leurs signaux
|
||||||
\l{QPushButton::clicked()}{clicked()} à leurs slots respectifs.
|
\l{QPushButton::clicked()}{clicked()} à leurs slots respectifs.
|
||||||
|
|
||||||
Pour la sauvegarde, on commence par récupérer le nom de fichier
|
Pour la sauvegarde, on commence par récupérer le nom de fichier
|
||||||
\c fileName, en utilisant QFileDialog::getSaveFileName(). C'est une
|
\c fileName, en utilisant QFileDialog::getSaveFileName(). C'est une
|
||||||
méthode pratique fournie par QFileDialog, qui ouvre une boîte de
|
méthode pratique fournie par QFileDialog, qui ouvre une boîte de
|
||||||
dialogue modale et permet à l'utilisateur d'entrer un nom de fichier ou
|
dialogue modale et permet à l'utilisateur d'entrer un nom de fichier ou
|
||||||
@ -966,7 +966,7 @@
|
|||||||
\section1 Définition de la classe AddressBook
|
\section1 Définition de la classe AddressBook
|
||||||
|
|
||||||
Nous ajoutons un objet QPushButton, \c exportButton, et un slot
|
Nous ajoutons un objet QPushButton, \c exportButton, et un slot
|
||||||
public correspondant, \c exportAsVCard(), à notre classe \c AddressBook
|
public correspondant, \c exportAsVCard(), à notre classe \c AddressBook
|
||||||
dans le fichier \c addressbook.h.
|
dans le fichier \c addressbook.h.
|
||||||
|
|
||||||
\snippet tutorials/addressbook/part7/addressbook.h exportAsVCard() declaration
|
\snippet tutorials/addressbook/part7/addressbook.h exportAsVCard() declaration
|
||||||
@ -1001,7 +1001,7 @@
|
|||||||
cela échoue, nous affichons un QMessageBox pour informer l'utilisateur
|
cela échoue, nous affichons un QMessageBox pour informer l'utilisateur
|
||||||
à propos de l'origine du problème et nous quittons la méthode. Sinon, nous passons le
|
à propos de l'origine du problème et nous quittons la méthode. Sinon, nous passons le
|
||||||
fichier comme paramètre pour créer un objet QTextStream, \c out. De la même façon que
|
fichier comme paramètre pour créer un objet QTextStream, \c out. De la même façon que
|
||||||
QDataStream, la classe QTextStream fournit les fonctionnalités pour
|
QDataStream, la classe QTextStream fournit les fonctionnalités pour
|
||||||
lire et écrire des fichiers de texte. Grâce à celà, le fichier \c{.vcf}
|
lire et écrire des fichiers de texte. Grâce à celà, le fichier \c{.vcf}
|
||||||
généré pourra être ouvert et édité à l'aide d'un simple éditeur de texte.
|
généré pourra être ouvert et édité à l'aide d'un simple éditeur de texte.
|
||||||
|
|
||||||
@ -1014,7 +1014,7 @@
|
|||||||
à un nom de famille défini ou non. Si oui, nous utilions les détails de
|
à un nom de famille défini ou non. Si oui, nous utilions les détails de
|
||||||
\c nameList pour remplir le champ, dans le cas contraire on écrit uniquement le contenu
|
\c nameList pour remplir le champ, dans le cas contraire on écrit uniquement le contenu
|
||||||
de \c firstName.
|
de \c firstName.
|
||||||
|
|
||||||
\snippet tutorials/addressbook/part7/addressbook.cpp export function part3
|
\snippet tutorials/addressbook/part7/addressbook.cpp export function part3
|
||||||
|
|
||||||
Nous continuons en écrivant l'adresse du contact. Les points-virgules
|
Nous continuons en écrivant l'adresse du contact. Les points-virgules
|
||||||
@ -1026,7 +1026,7 @@
|
|||||||
\snippet tutorials/addressbook/part7/addressbook.cpp export function part4
|
\snippet tutorials/addressbook/part7/addressbook.cpp export function part4
|
||||||
|
|
||||||
À la fin de la méthode, un QMessageBox est affiché pour informer l'utilisateur
|
À la fin de la méthode, un QMessageBox est affiché pour informer l'utilisateur
|
||||||
que la vCard a été exportée avec succès.
|
que la vCard a été exportée avec succès.
|
||||||
|
|
||||||
\e{vCard est une marque déposée de \l{http://www.imc.org}
|
\e{vCard est une marque déposée de \l{http://www.imc.org}
|
||||||
{Internet Mail Consortium}}.
|
{Internet Mail Consortium}}.
|
||||||
|
@ -73,7 +73,7 @@
|
|||||||
have worked through this tutorial, we recommend reading the
|
have worked through this tutorial, we recommend reading the
|
||||||
\l{mainwindows/application}{Application} example, which presents a
|
\l{mainwindows/application}{Application} example, which presents a
|
||||||
small GUI application, with menus, toolbars, a status bar, and so
|
small GUI application, with menus, toolbars, a status bar, and so
|
||||||
on.
|
on.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -199,7 +199,7 @@
|
|||||||
|
|
||||||
Notice that \c addressLabel is positioned using Qt::AlignTop as an
|
Notice that \c addressLabel is positioned using Qt::AlignTop as an
|
||||||
additional argument. This is to make sure it is not vertically centered in
|
additional argument. This is to make sure it is not vertically centered in
|
||||||
cell (1,0). For a basic overview on Qt Layouts, refer to the
|
cell (1,0). For a basic overview on Qt Layouts, refer to the
|
||||||
\l{Layout Management} documentation.
|
\l{Layout Management} documentation.
|
||||||
|
|
||||||
In order to install the layout object onto the widget, we have to invoke
|
In order to install the layout object onto the widget, we have to invoke
|
||||||
@ -431,7 +431,7 @@
|
|||||||
|
|
||||||
\snippet tutorials/addressbook/part3/addressbook.cpp connecting navigation signals
|
\snippet tutorials/addressbook/part3/addressbook.cpp connecting navigation signals
|
||||||
|
|
||||||
The image below is the expected graphical user interface.
|
The image below is the expected graphical user interface.
|
||||||
|
|
||||||
\image addressbook-tutorial-part3-screenshot.png
|
\image addressbook-tutorial-part3-screenshot.png
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@
|
|||||||
|
|
||||||
\snippet itemviews/addressbook/addresswidget.cpp 4a
|
\snippet itemviews/addressbook/addresswidget.cpp 4a
|
||||||
|
|
||||||
Next we extract data from the row the user intends to
|
Next we extract data from the row the user intends to
|
||||||
edit. This data is displayed in an instance of \c AddDialog
|
edit. This data is displayed in an instance of \c AddDialog
|
||||||
with a different window title. The \c table is only
|
with a different window title. The \c table is only
|
||||||
updated if changes have been made to data in \c aDialog.
|
updated if changes have been made to data in \c aDialog.
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
|
|
||||||
We will now move on to the definitions and implementations of \c
|
We will now move on to the definitions and implementations of \c
|
||||||
CodeEditor and \c LineNumberArea. Let's start with the \c
|
CodeEditor and \c LineNumberArea. Let's start with the \c
|
||||||
LineNumberArea class.
|
LineNumberArea class.
|
||||||
|
|
||||||
\section1 The LineNumberArea Class
|
\section1 The LineNumberArea Class
|
||||||
|
|
||||||
@ -130,7 +130,7 @@
|
|||||||
\snippet widgets/codeeditor/codeeditor.cpp resizeEvent
|
\snippet widgets/codeeditor/codeeditor.cpp resizeEvent
|
||||||
|
|
||||||
When the size of the editor changes, we also need to resize the
|
When the size of the editor changes, we also need to resize the
|
||||||
line number area.
|
line number area.
|
||||||
|
|
||||||
\snippet widgets/codeeditor/codeeditor.cpp cursorPositionChanged
|
\snippet widgets/codeeditor/codeeditor.cpp cursorPositionChanged
|
||||||
|
|
||||||
@ -155,7 +155,7 @@
|
|||||||
|
|
||||||
The \c lineNumberAreaPaintEvent() is called from \c LineNumberArea
|
The \c lineNumberAreaPaintEvent() is called from \c LineNumberArea
|
||||||
whenever it receives a paint event. We start off by painting the
|
whenever it receives a paint event. We start off by painting the
|
||||||
widget's background.
|
widget's background.
|
||||||
|
|
||||||
\snippet widgets/codeeditor/codeeditor.cpp extraAreaPaintEvent_1
|
\snippet widgets/codeeditor/codeeditor.cpp extraAreaPaintEvent_1
|
||||||
|
|
||||||
@ -163,11 +163,11 @@
|
|||||||
numbers in the extra area for each line. Notice that in a plain
|
numbers in the extra area for each line. Notice that in a plain
|
||||||
text edit each line will consist of one QTextBlock; though, if
|
text edit each line will consist of one QTextBlock; though, if
|
||||||
line wrapping is enabled, a line may span several rows in the text
|
line wrapping is enabled, a line may span several rows in the text
|
||||||
edit's viewport.
|
edit's viewport.
|
||||||
|
|
||||||
We get the top and bottom y-coordinate of the first text block,
|
We get the top and bottom y-coordinate of the first text block,
|
||||||
and adjust these values by the height of the current text block in
|
and adjust these values by the height of the current text block in
|
||||||
each iteration in the loop.
|
each iteration in the loop.
|
||||||
|
|
||||||
\snippet widgets/codeeditor/codeeditor.cpp extraAreaPaintEvent_2
|
\snippet widgets/codeeditor/codeeditor.cpp extraAreaPaintEvent_2
|
||||||
|
|
||||||
@ -183,7 +183,7 @@
|
|||||||
|
|
||||||
In addition to line numbers, you can add more to the extra area,
|
In addition to line numbers, you can add more to the extra area,
|
||||||
for instance, break points.
|
for instance, break points.
|
||||||
|
|
||||||
QSyntaxHighlighter gives the possibility to add user data to each
|
QSyntaxHighlighter gives the possibility to add user data to each
|
||||||
text block with
|
text block with
|
||||||
\l{QSyntaxHighlighter::}{setCurrentBlockUserData()}. This can be
|
\l{QSyntaxHighlighter::}{setCurrentBlockUserData()}. This can be
|
||||||
|
@ -78,7 +78,7 @@
|
|||||||
|
|
||||||
After the new factory has been set, all standard item delegates
|
After the new factory has been set, all standard item delegates
|
||||||
will use it (i.e, also delegates that were created before the new
|
will use it (i.e, also delegates that were created before the new
|
||||||
default factory was set).
|
default factory was set).
|
||||||
|
|
||||||
The \c createGUI() function sets up the table and fills it
|
The \c createGUI() function sets up the table and fills it
|
||||||
with data.
|
with data.
|
||||||
@ -135,17 +135,17 @@
|
|||||||
|
|
||||||
\list
|
\list
|
||||||
\li If the editor widget has no user property defined, the delegate
|
\li If the editor widget has no user property defined, the delegate
|
||||||
asks the factory for the property name, which it in turn
|
asks the factory for the property name, which it in turn
|
||||||
asks the item editor creator for. In this case, you can use
|
asks the item editor creator for. In this case, you can use
|
||||||
the QItemEditorCreator class, which takes the property
|
the QItemEditorCreator class, which takes the property
|
||||||
name to use for editing as a constructor argument.
|
name to use for editing as a constructor argument.
|
||||||
\li If the editor requires other constructors or other
|
\li If the editor requires other constructors or other
|
||||||
initialization than provided by QItemEditorCreatorBase, you
|
initialization than provided by QItemEditorCreatorBase, you
|
||||||
must reimplement
|
must reimplement
|
||||||
QItemEditorCreatorBase::createWidget().
|
QItemEditorCreatorBase::createWidget().
|
||||||
\li You could also subclass QItemEditorFactory if you only want
|
\li You could also subclass QItemEditorFactory if you only want
|
||||||
to provide editors for certain kinds of data or use another
|
to provide editors for certain kinds of data or use another
|
||||||
method of creating the editors than using creator bases.
|
method of creating the editors than using creator bases.
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
In this example, we use a standard QVariant data type. You can
|
In this example, we use a standard QVariant data type. You can
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
|
|
||||||
In this example we show how to create such custom graphics
|
In this example we show how to create such custom graphics
|
||||||
scenes and items by implementing classes that inherit
|
scenes and items by implementing classes that inherit
|
||||||
QGraphicsScene and QGraphicsItem.
|
QGraphicsScene and QGraphicsItem.
|
||||||
|
|
||||||
In particular we show how to:
|
In particular we show how to:
|
||||||
|
|
||||||
@ -65,21 +65,21 @@
|
|||||||
The example consists of the following classes:
|
The example consists of the following classes:
|
||||||
\list
|
\list
|
||||||
\li \c MainWindow creates the widgets and display
|
\li \c MainWindow creates the widgets and display
|
||||||
them in a QMainWindow. It also manages the interaction
|
them in a QMainWindow. It also manages the interaction
|
||||||
between the widgets and the graphics scene, view and
|
between the widgets and the graphics scene, view and
|
||||||
items.
|
items.
|
||||||
\li \c DiagramItem inherits QGraphicsPolygonItem and
|
\li \c DiagramItem inherits QGraphicsPolygonItem and
|
||||||
represents a flowchart shape.
|
represents a flowchart shape.
|
||||||
\li \c TextDiagramItem inherits QGraphicsTextItem and
|
\li \c TextDiagramItem inherits QGraphicsTextItem and
|
||||||
represents text items in the diagram. The class adds
|
represents text items in the diagram. The class adds
|
||||||
support for moving the item with the mouse, which is not
|
support for moving the item with the mouse, which is not
|
||||||
supported by QGraphicsTextItem.
|
supported by QGraphicsTextItem.
|
||||||
\li \c Arrow inherits QGraphicsLineItem and is an arrow
|
\li \c Arrow inherits QGraphicsLineItem and is an arrow
|
||||||
that connect two DiagramItems.
|
that connect two DiagramItems.
|
||||||
\li \c DiagramScene inherits QGraphicsDiagramScene and
|
\li \c DiagramScene inherits QGraphicsDiagramScene and
|
||||||
provides support for \c DiagramItem, \c Arrow and
|
provides support for \c DiagramItem, \c Arrow and
|
||||||
\c DiagramTextItem (In addition to the support already
|
\c DiagramTextItem (In addition to the support already
|
||||||
handled by QGraphicsScene).
|
handled by QGraphicsScene).
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
\section1 MainWindow Class Definition
|
\section1 MainWindow Class Definition
|
||||||
@ -88,7 +88,7 @@
|
|||||||
|
|
||||||
The \c MainWindow class creates and lays out the widgets in a
|
The \c MainWindow class creates and lays out the widgets in a
|
||||||
QMainWindow. The class forwards input from the widgets to the
|
QMainWindow. The class forwards input from the widgets to the
|
||||||
DiagramScene. It also updates its widgets when the diagram
|
DiagramScene. It also updates its widgets when the diagram
|
||||||
scene's text item changes, or a diagram item or a diagram text item
|
scene's text item changes, or a diagram item or a diagram text item
|
||||||
is inserted into the scene.
|
is inserted into the scene.
|
||||||
|
|
||||||
@ -104,8 +104,8 @@
|
|||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 0
|
\snippet graphicsview/diagramscene/mainwindow.cpp 0
|
||||||
|
|
||||||
In the constructor we call methods to create the widgets and
|
In the constructor we call methods to create the widgets and
|
||||||
layouts of the example before we create the diagram scene.
|
layouts of the example before we create the diagram scene.
|
||||||
The toolbars must be created after the scene as they connect
|
The toolbars must be created after the scene as they connect
|
||||||
to its signals. We then lay the widgets out in the window.
|
to its signals. We then lay the widgets out in the window.
|
||||||
|
|
||||||
We connect to the \c itemInserted() and \c textInserted() slots of
|
We connect to the \c itemInserted() and \c textInserted() slots of
|
||||||
@ -115,20 +115,20 @@
|
|||||||
update the widgets that display font properties if the item
|
update the widgets that display font properties if the item
|
||||||
selected is a \c DiagramTextItem.
|
selected is a \c DiagramTextItem.
|
||||||
|
|
||||||
The \c createToolBox() function creates and lays out the widgets
|
The \c createToolBox() function creates and lays out the widgets
|
||||||
of the \c toolBox QToolBox. We will not examine it with a
|
of the \c toolBox QToolBox. We will not examine it with a
|
||||||
high level of detail as it does not deal with graphics framework
|
high level of detail as it does not deal with graphics framework
|
||||||
specific functionality. Here is its implementation:
|
specific functionality. Here is its implementation:
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 21
|
\snippet graphicsview/diagramscene/mainwindow.cpp 21
|
||||||
|
|
||||||
This part of the function sets up the tabbed widget item that
|
This part of the function sets up the tabbed widget item that
|
||||||
contains the flowchart shapes. An exclusive QButtonGroup always
|
contains the flowchart shapes. An exclusive QButtonGroup always
|
||||||
keeps one button checked; we want the group to allow all buttons
|
keeps one button checked; we want the group to allow all buttons
|
||||||
to be unchecked.
|
to be unchecked.
|
||||||
We still use a button group since we can associate user
|
We still use a button group since we can associate user
|
||||||
data, which we use to store the diagram type, with each button.
|
data, which we use to store the diagram type, with each button.
|
||||||
The \c createCellWidget() function sets up the buttons in the
|
The \c createCellWidget() function sets up the buttons in the
|
||||||
tabbed widget item and is examined later.
|
tabbed widget item and is examined later.
|
||||||
|
|
||||||
The buttons of the background tabbed widget item is set up in the
|
The buttons of the background tabbed widget item is set up in the
|
||||||
@ -137,7 +137,7 @@
|
|||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 22
|
\snippet graphicsview/diagramscene/mainwindow.cpp 22
|
||||||
|
|
||||||
We set the preferred size of the toolbox as its maximum. This
|
We set the preferred size of the toolbox as its maximum. This
|
||||||
way, more space is given to the graphics view.
|
way, more space is given to the graphics view.
|
||||||
|
|
||||||
Here is the \c createActions() function:
|
Here is the \c createActions() function:
|
||||||
|
|
||||||
@ -202,7 +202,7 @@
|
|||||||
with this function is used in the tool box.
|
with this function is used in the tool box.
|
||||||
|
|
||||||
Here is the \c createColorMenu() function:
|
Here is the \c createColorMenu() function:
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 30
|
\snippet graphicsview/diagramscene/mainwindow.cpp 30
|
||||||
|
|
||||||
This function creates a color menu that is used as the
|
This function creates a color menu that is used as the
|
||||||
@ -224,7 +224,7 @@
|
|||||||
|
|
||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 32
|
\snippet graphicsview/diagramscene/mainwindow.cpp 32
|
||||||
|
|
||||||
This function creates an icon with a filled rectangle in the
|
This function creates an icon with a filled rectangle in the
|
||||||
color of \a color. It is used for creating icons for the color
|
color of \a color. It is used for creating icons for the color
|
||||||
menus in the \c fillColorToolButton, \c fontColorToolButton, and
|
menus in the \c fillColorToolButton, \c fontColorToolButton, and
|
||||||
\c lineColorToolButton.
|
\c lineColorToolButton.
|
||||||
@ -240,8 +240,8 @@
|
|||||||
with.
|
with.
|
||||||
|
|
||||||
When one of the buttons in the background tabbed widget item is
|
When one of the buttons in the background tabbed widget item is
|
||||||
clicked we change the brush; we find out which button it is by
|
clicked we change the brush; we find out which button it is by
|
||||||
checking its text.
|
checking its text.
|
||||||
|
|
||||||
Here is the implementation of \c buttonGroupClicked():
|
Here is the implementation of \c buttonGroupClicked():
|
||||||
|
|
||||||
@ -255,37 +255,37 @@
|
|||||||
checked at a time.
|
checked at a time.
|
||||||
|
|
||||||
\c QButtonGroup assigns an id to each button. We have set the id
|
\c QButtonGroup assigns an id to each button. We have set the id
|
||||||
of each button to the diagram type, as given by DiagramItem::DiagramType
|
of each button to the diagram type, as given by DiagramItem::DiagramType
|
||||||
that will be inserted into the scene when it is clicked. We can
|
that will be inserted into the scene when it is clicked. We can
|
||||||
then use the button id when we set the diagram type with
|
then use the button id when we set the diagram type with
|
||||||
\c setItemType(). In the case of text we assigned an id that has a
|
\c setItemType(). In the case of text we assigned an id that has a
|
||||||
value that is not in the DiagramType enum.
|
value that is not in the DiagramType enum.
|
||||||
|
|
||||||
Here is the implementation of \c deleteItem():
|
Here is the implementation of \c deleteItem():
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 3
|
\snippet graphicsview/diagramscene/mainwindow.cpp 3
|
||||||
|
|
||||||
This slot deletes the selected item, if any, from the scene. It
|
This slot deletes the selected item, if any, from the scene. It
|
||||||
deletes the arrows first in order to avoid to delete them twice. If
|
deletes the arrows first in order to avoid to delete them twice. If
|
||||||
the item to be deleted is a \c DiagramItem, we also need to delete
|
the item to be deleted is a \c DiagramItem, we also need to delete
|
||||||
arrows connected to it; we don't want arrows in the scene that
|
arrows connected to it; we don't want arrows in the scene that
|
||||||
aren't connected to items in both ends.
|
aren't connected to items in both ends.
|
||||||
|
|
||||||
This is the implementation of pointerGroupClicked():
|
This is the implementation of pointerGroupClicked():
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 4
|
\snippet graphicsview/diagramscene/mainwindow.cpp 4
|
||||||
|
|
||||||
The \c pointerTypeGroup decides whether the scene is in ItemMove
|
The \c pointerTypeGroup decides whether the scene is in ItemMove
|
||||||
or InsertLine mode. This button group is exclusive, i.e., only
|
or InsertLine mode. This button group is exclusive, i.e., only
|
||||||
one button is checked at any time. As with the \c buttonGroup above
|
one button is checked at any time. As with the \c buttonGroup above
|
||||||
we have assigned an id to the buttons that matches values of the
|
we have assigned an id to the buttons that matches values of the
|
||||||
DiagramScene::Mode enum, so that we can use the id to set the
|
DiagramScene::Mode enum, so that we can use the id to set the
|
||||||
correct mode.
|
correct mode.
|
||||||
|
|
||||||
Here is the \c bringToFront() slot:
|
Here is the \c bringToFront() slot:
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 5
|
\snippet graphicsview/diagramscene/mainwindow.cpp 5
|
||||||
|
|
||||||
Several items may collide, i.e., overlap, with each other in
|
Several items may collide, i.e., overlap, with each other in
|
||||||
the scene. This slot is called when the user requests that an
|
the scene. This slot is called when the user requests that an
|
||||||
item should be placed on top of the items it collides with.
|
item should be placed on top of the items it collides with.
|
||||||
@ -296,169 +296,169 @@
|
|||||||
lower values. When we bring an item to the front we can loop
|
lower values. When we bring an item to the front we can loop
|
||||||
through the items it collides with and set a z-value that is
|
through the items it collides with and set a z-value that is
|
||||||
higher than all of them.
|
higher than all of them.
|
||||||
|
|
||||||
Here is the \c sendToBack() slot:
|
Here is the \c sendToBack() slot:
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 6
|
\snippet graphicsview/diagramscene/mainwindow.cpp 6
|
||||||
|
|
||||||
This slot works in the same way as \c bringToFront() described
|
This slot works in the same way as \c bringToFront() described
|
||||||
above, but sets a z-value that is lower than items the item that
|
above, but sets a z-value that is lower than items the item that
|
||||||
should be send to the back collides with.
|
should be send to the back collides with.
|
||||||
|
|
||||||
This is the implementation of \c itemInserted():
|
This is the implementation of \c itemInserted():
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 7
|
\snippet graphicsview/diagramscene/mainwindow.cpp 7
|
||||||
|
|
||||||
This slot is called from the \c DiagramScene when an item has been
|
This slot is called from the \c DiagramScene when an item has been
|
||||||
added to the scene. We set the mode of the scene back to the mode
|
added to the scene. We set the mode of the scene back to the mode
|
||||||
before the item was inserted, which is ItemMove or InsertText
|
before the item was inserted, which is ItemMove or InsertText
|
||||||
depending on which button is checked in the \c pointerTypeGroup.
|
depending on which button is checked in the \c pointerTypeGroup.
|
||||||
We must also uncheck the button in the in the \c buttonGroup.
|
We must also uncheck the button in the in the \c buttonGroup.
|
||||||
|
|
||||||
Here is the implementation of \c textInserted():
|
Here is the implementation of \c textInserted():
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 8
|
\snippet graphicsview/diagramscene/mainwindow.cpp 8
|
||||||
|
|
||||||
We simply set the mode of the scene back to the mode it had before
|
We simply set the mode of the scene back to the mode it had before
|
||||||
the text was inserted.
|
the text was inserted.
|
||||||
|
|
||||||
Here is the \c currentFontChanged() slot:
|
Here is the \c currentFontChanged() slot:
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 9
|
\snippet graphicsview/diagramscene/mainwindow.cpp 9
|
||||||
|
|
||||||
When the user requests a font change, by using one of the
|
When the user requests a font change, by using one of the
|
||||||
widgets in the \c fontToolBar, we create a new QFont object and
|
widgets in the \c fontToolBar, we create a new QFont object and
|
||||||
set its properties to match the state of the widgets. This is done
|
set its properties to match the state of the widgets. This is done
|
||||||
in \c handleFontChange(), so we simply call that slot.
|
in \c handleFontChange(), so we simply call that slot.
|
||||||
|
|
||||||
Here is the \c fontSizeChanged() slot:
|
Here is the \c fontSizeChanged() slot:
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 10
|
\snippet graphicsview/diagramscene/mainwindow.cpp 10
|
||||||
|
|
||||||
When the user requests a font change, by using one of the
|
When the user requests a font change, by using one of the
|
||||||
widgets in the \c fontToolBar, we create a new QFont object and
|
widgets in the \c fontToolBar, we create a new QFont object and
|
||||||
set its properties to match the state of the widgets. This is done
|
set its properties to match the state of the widgets. This is done
|
||||||
in \c handleFontChange(), so we simply call that slot.
|
in \c handleFontChange(), so we simply call that slot.
|
||||||
|
|
||||||
Here is the implementation of \c sceneScaleChanged():
|
Here is the implementation of \c sceneScaleChanged():
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 11
|
\snippet graphicsview/diagramscene/mainwindow.cpp 11
|
||||||
|
|
||||||
The user can increase or decrease the scale, with the \c
|
The user can increase or decrease the scale, with the \c
|
||||||
sceneScaleCombo, the scene is drawn in.
|
sceneScaleCombo, the scene is drawn in.
|
||||||
It is not the scene itself that changes its scale, but only the
|
It is not the scene itself that changes its scale, but only the
|
||||||
view.
|
view.
|
||||||
|
|
||||||
Here is the \c textColorChanged() slot:
|
Here is the \c textColorChanged() slot:
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 12
|
\snippet graphicsview/diagramscene/mainwindow.cpp 12
|
||||||
|
|
||||||
This slot is called when an item in the drop-down menu of the \c
|
This slot is called when an item in the drop-down menu of the \c
|
||||||
fontColorToolButton is pressed. We need to change the icon on
|
fontColorToolButton is pressed. We need to change the icon on
|
||||||
the button to the color of the selected QAction. We keep a pointer
|
the button to the color of the selected QAction. We keep a pointer
|
||||||
to the selected action in \c textAction. It is in \c
|
to the selected action in \c textAction. It is in \c
|
||||||
textButtonTriggered() we change the text color to the color of \c
|
textButtonTriggered() we change the text color to the color of \c
|
||||||
textAction, so we call that slot.
|
textAction, so we call that slot.
|
||||||
|
|
||||||
Here is the \c itemColorChanged() implementation:
|
Here is the \c itemColorChanged() implementation:
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 13
|
\snippet graphicsview/diagramscene/mainwindow.cpp 13
|
||||||
|
|
||||||
This slot handles requests for changing the color of \c
|
This slot handles requests for changing the color of \c
|
||||||
DiagramItems in the same manner as \c textColorChanged() does for
|
DiagramItems in the same manner as \c textColorChanged() does for
|
||||||
\c DiagramTextItems.
|
\c DiagramTextItems.
|
||||||
|
|
||||||
Here is the implementation of \c lineColorChanged():
|
Here is the implementation of \c lineColorChanged():
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 14
|
\snippet graphicsview/diagramscene/mainwindow.cpp 14
|
||||||
|
|
||||||
This slot handles requests for changing the color of \c Arrows in
|
This slot handles requests for changing the color of \c Arrows in
|
||||||
the same manner that \c textColorChanged() does it for \c
|
the same manner that \c textColorChanged() does it for \c
|
||||||
DiagramTextItems.
|
DiagramTextItems.
|
||||||
|
|
||||||
Here is the \c textButtonTriggered() slot:
|
Here is the \c textButtonTriggered() slot:
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 15
|
\snippet graphicsview/diagramscene/mainwindow.cpp 15
|
||||||
|
|
||||||
\c textAction points to the QAction of the currently selected menu item
|
\c textAction points to the QAction of the currently selected menu item
|
||||||
in the \c fontColorToolButton's color drop-down menu. We have set
|
in the \c fontColorToolButton's color drop-down menu. We have set
|
||||||
the data of the action to the QColor the action represents, so we
|
the data of the action to the QColor the action represents, so we
|
||||||
can simply fetch this when we set the color of text with \c
|
can simply fetch this when we set the color of text with \c
|
||||||
setTextColor().
|
setTextColor().
|
||||||
|
|
||||||
Here is the \c fillButtonTriggered() slot:
|
Here is the \c fillButtonTriggered() slot:
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 16
|
\snippet graphicsview/diagramscene/mainwindow.cpp 16
|
||||||
|
|
||||||
\c fillAction points to the selected menu item in the drop-down
|
\c fillAction points to the selected menu item in the drop-down
|
||||||
menu of \c fillColorToolButton(). We can therefore use the data of
|
menu of \c fillColorToolButton(). We can therefore use the data of
|
||||||
this action when we set the item color with \c setItemColor().
|
this action when we set the item color with \c setItemColor().
|
||||||
|
|
||||||
Here is the \c lineButtonTriggered() slot:
|
Here is the \c lineButtonTriggered() slot:
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 17
|
\snippet graphicsview/diagramscene/mainwindow.cpp 17
|
||||||
|
|
||||||
\c lineAction point to the selected item in the drop-down menu of
|
\c lineAction point to the selected item in the drop-down menu of
|
||||||
\c lineColorToolButton. We use its data when we set the arrow
|
\c lineColorToolButton. We use its data when we set the arrow
|
||||||
color with \c setLineColor().
|
color with \c setLineColor().
|
||||||
|
|
||||||
Here is the \c handleFontChange() function:
|
Here is the \c handleFontChange() function:
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 18
|
\snippet graphicsview/diagramscene/mainwindow.cpp 18
|
||||||
|
|
||||||
\c handleFontChange() is called when any of the widgets that show
|
\c handleFontChange() is called when any of the widgets that show
|
||||||
font properties changes. We create a new QFont object and set its
|
font properties changes. We create a new QFont object and set its
|
||||||
properties based on the widgets. We then call the \c setFont()
|
properties based on the widgets. We then call the \c setFont()
|
||||||
function of \c DiagramScene; it is the scene that set the font of
|
function of \c DiagramScene; it is the scene that set the font of
|
||||||
the \c DiagramTextItems it manages.
|
the \c DiagramTextItems it manages.
|
||||||
|
|
||||||
Here is the \c itemSelected() slot:
|
Here is the \c itemSelected() slot:
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 19
|
\snippet graphicsview/diagramscene/mainwindow.cpp 19
|
||||||
|
|
||||||
This slot is called when an item in the \c DiagramScene is
|
This slot is called when an item in the \c DiagramScene is
|
||||||
selected. In the case of this example it is only text items that
|
selected. In the case of this example it is only text items that
|
||||||
emit signals when they are selected, so we do not need to check
|
emit signals when they are selected, so we do not need to check
|
||||||
what kind of graphics \a item is.
|
what kind of graphics \a item is.
|
||||||
|
|
||||||
We set the state of the widgets to match the properties of the
|
We set the state of the widgets to match the properties of the
|
||||||
font of the selected text item.
|
font of the selected text item.
|
||||||
|
|
||||||
This is the \c about() slot:
|
This is the \c about() slot:
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/mainwindow.cpp 20
|
\snippet graphicsview/diagramscene/mainwindow.cpp 20
|
||||||
|
|
||||||
This slot displays an about box for the example when the user
|
This slot displays an about box for the example when the user
|
||||||
selects the about menu item from the help menu.
|
selects the about menu item from the help menu.
|
||||||
|
|
||||||
\section1 DiagramScene Class Definition
|
\section1 DiagramScene Class Definition
|
||||||
|
|
||||||
The \c DiagramScene class inherits QGraphicsScene and adds
|
The \c DiagramScene class inherits QGraphicsScene and adds
|
||||||
functionality to handle \c DiagramItems, \c Arrows, and \c
|
functionality to handle \c DiagramItems, \c Arrows, and \c
|
||||||
DiagramTextItems in addition to the items handled by its super
|
DiagramTextItems in addition to the items handled by its super
|
||||||
class.
|
class.
|
||||||
|
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/diagramscene.h 0
|
\snippet graphicsview/diagramscene/diagramscene.h 0
|
||||||
|
|
||||||
In the \c DiagramScene a mouse click can give three different
|
In the \c DiagramScene a mouse click can give three different
|
||||||
actions: the item under the mouse can be moved, an item may be
|
actions: the item under the mouse can be moved, an item may be
|
||||||
inserted, or an arrow may be connected between to diagram items.
|
inserted, or an arrow may be connected between to diagram items.
|
||||||
Which action a mouse click has depends on the mode, given by the
|
Which action a mouse click has depends on the mode, given by the
|
||||||
Mode enum, the scene is in. The mode is set with the \c setMode()
|
Mode enum, the scene is in. The mode is set with the \c setMode()
|
||||||
function.
|
function.
|
||||||
|
|
||||||
The scene also sets the color of its items and the font of its
|
The scene also sets the color of its items and the font of its
|
||||||
text items. The colors and font used by the scene can be set with
|
text items. The colors and font used by the scene can be set with
|
||||||
the \c setLineColor(), \c setTextColor(), \c setItemColor() and \c
|
the \c setLineColor(), \c setTextColor(), \c setItemColor() and \c
|
||||||
setFont() functions. The type of \c DiagramItem, given by the
|
setFont() functions. The type of \c DiagramItem, given by the
|
||||||
DiagramItem::DiagramType function, to be created when an item is
|
DiagramItem::DiagramType function, to be created when an item is
|
||||||
inserted is set with the \c setItemType() slot.
|
inserted is set with the \c setItemType() slot.
|
||||||
|
|
||||||
The \c MainWindow and \c DiagramScene share responsibility for
|
The \c MainWindow and \c DiagramScene share responsibility for
|
||||||
the examples functionality. \c MainWindow handles the following
|
the examples functionality. \c MainWindow handles the following
|
||||||
tasks: the deletion of items, text, and arrows; moving diagram
|
tasks: the deletion of items, text, and arrows; moving diagram
|
||||||
items to the back and front; and setting the scale of the scene.
|
items to the back and front; and setting the scale of the scene.
|
||||||
|
|
||||||
\section1 DiagramScene Class Implementation
|
\section1 DiagramScene Class Implementation
|
||||||
|
|
||||||
@ -492,12 +492,12 @@
|
|||||||
|
|
||||||
\snippet graphicsview/diagramscene/diagramscene.cpp 3
|
\snippet graphicsview/diagramscene/diagramscene.cpp 3
|
||||||
|
|
||||||
This function sets the color the scene will use when creating
|
This function sets the color the scene will use when creating
|
||||||
\c DiagramItems. It also changes the color of a selected \c
|
\c DiagramItems. It also changes the color of a selected \c
|
||||||
DiagramItem.
|
DiagramItem.
|
||||||
|
|
||||||
This is the implementation of \c setFont():
|
This is the implementation of \c setFont():
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/diagramscene.cpp 4
|
\snippet graphicsview/diagramscene/diagramscene.cpp 4
|
||||||
|
|
||||||
Set the font to use for new and selected, if a text item is
|
Set the font to use for new and selected, if a text item is
|
||||||
@ -511,15 +511,15 @@
|
|||||||
connected to this slot. We remove the item if it has no text.
|
connected to this slot. We remove the item if it has no text.
|
||||||
If not, we would leak memory and confuse the user as the items
|
If not, we would leak memory and confuse the user as the items
|
||||||
will be edited when pressed on by the mouse.
|
will be edited when pressed on by the mouse.
|
||||||
|
|
||||||
The \c mousePressEvent() function handles mouse press event's
|
The \c mousePressEvent() function handles mouse press event's
|
||||||
different depending on which mode the \c DiagramScene is in. We
|
different depending on which mode the \c DiagramScene is in. We
|
||||||
examine its implementation for each mode:
|
examine its implementation for each mode:
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/diagramscene.cpp 6
|
\snippet graphicsview/diagramscene/diagramscene.cpp 6
|
||||||
|
|
||||||
We simply create a new \c DiagramItem and add it to the scene at
|
We simply create a new \c DiagramItem and add it to the scene at
|
||||||
the position the mouse was pressed. Note that the origin of its
|
the position the mouse was pressed. Note that the origin of its
|
||||||
local coordinate system will be under the mouse pointer position.
|
local coordinate system will be under the mouse pointer position.
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/diagramscene.cpp 7
|
\snippet graphicsview/diagramscene/diagramscene.cpp 7
|
||||||
@ -534,7 +534,7 @@
|
|||||||
line.
|
line.
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/diagramscene.cpp 8
|
\snippet graphicsview/diagramscene/diagramscene.cpp 8
|
||||||
|
|
||||||
The \c DiagramTextItem is editable when the
|
The \c DiagramTextItem is editable when the
|
||||||
Qt::TextEditorInteraction flag is set, else it is movable by the
|
Qt::TextEditorInteraction flag is set, else it is movable by the
|
||||||
mouse. We always want the text to be drawn on top of the other
|
mouse. We always want the text to be drawn on top of the other
|
||||||
@ -547,12 +547,12 @@
|
|||||||
can then call the QGraphicsScene implementation, which
|
can then call the QGraphicsScene implementation, which
|
||||||
handles movement of items with the mouse. We make this call even
|
handles movement of items with the mouse. We make this call even
|
||||||
if we are in another mode making it possible to add an item and
|
if we are in another mode making it possible to add an item and
|
||||||
then keep the mouse button pressed down and start moving
|
then keep the mouse button pressed down and start moving
|
||||||
the item. In the case of text items, this is not possible as they
|
the item. In the case of text items, this is not possible as they
|
||||||
do not propagate mouse events when they are editable.
|
do not propagate mouse events when they are editable.
|
||||||
|
|
||||||
This is the \c mouseMoveEvent() function:
|
This is the \c mouseMoveEvent() function:
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/diagramscene.cpp 10
|
\snippet graphicsview/diagramscene/diagramscene.cpp 10
|
||||||
|
|
||||||
We must draw the line if we are in InsertMode and the mouse button
|
We must draw the line if we are in InsertMode and the mouse button
|
||||||
@ -567,7 +567,7 @@
|
|||||||
should be added to the scene:
|
should be added to the scene:
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/diagramscene.cpp 11
|
\snippet graphicsview/diagramscene/diagramscene.cpp 11
|
||||||
|
|
||||||
First we need to get the items (if any) under the line's start
|
First we need to get the items (if any) under the line's start
|
||||||
and end points. The line itself is the first item at these points,
|
and end points. The line itself is the first item at these points,
|
||||||
so we remove it from the lists. As a precaution, we check if the
|
so we remove it from the lists. As a precaution, we check if the
|
||||||
@ -603,7 +603,7 @@
|
|||||||
DiagramScene. It inherits QGraphicsPolygonItem and has a polygon
|
DiagramScene. It inherits QGraphicsPolygonItem and has a polygon
|
||||||
for each shape. The enum DiagramType has a value for each of the
|
for each shape. The enum DiagramType has a value for each of the
|
||||||
flowchart shapes.
|
flowchart shapes.
|
||||||
|
|
||||||
The class has a list of the arrows that are connected to it.
|
The class has a list of the arrows that are connected to it.
|
||||||
This is necessary because only the item knows when it is being
|
This is necessary because only the item knows when it is being
|
||||||
moved (with the \c itemChanged() function) at which time the
|
moved (with the \c itemChanged() function) at which time the
|
||||||
@ -612,7 +612,7 @@
|
|||||||
buttons in \c MainWindow, see \c createColorToolButtonIcon() in
|
buttons in \c MainWindow, see \c createColorToolButtonIcon() in
|
||||||
\c MainWindow.
|
\c MainWindow.
|
||||||
|
|
||||||
The Type enum is a unique identifier of the class. It is used by
|
The Type enum is a unique identifier of the class. It is used by
|
||||||
\c qgraphicsitem_cast(), which does dynamic casts of graphics
|
\c qgraphicsitem_cast(), which does dynamic casts of graphics
|
||||||
items. The UserType constant is the minimum value a custom
|
items. The UserType constant is the minimum value a custom
|
||||||
graphics item type can be.
|
graphics item type can be.
|
||||||
@ -646,7 +646,7 @@
|
|||||||
item.
|
item.
|
||||||
|
|
||||||
Here is the \c addArrow() function:
|
Here is the \c addArrow() function:
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/diagramitem.cpp 3
|
\snippet graphicsview/diagramscene/diagramitem.cpp 3
|
||||||
|
|
||||||
This function simply adds the \a arrow to the items \c arrows list.
|
This function simply adds the \a arrow to the items \c arrows list.
|
||||||
@ -695,7 +695,7 @@
|
|||||||
possible to alter the mouse behavior of QGraphicsTextItem.
|
possible to alter the mouse behavior of QGraphicsTextItem.
|
||||||
|
|
||||||
\section1 DiagramTextItem Implementation
|
\section1 DiagramTextItem Implementation
|
||||||
|
|
||||||
We start with the constructor:
|
We start with the constructor:
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/diagramtextitem.cpp 0
|
\snippet graphicsview/diagramscene/diagramtextitem.cpp 0
|
||||||
@ -717,7 +717,7 @@
|
|||||||
|
|
||||||
\c DiagramScene uses the signal emitted when the text item looses
|
\c DiagramScene uses the signal emitted when the text item looses
|
||||||
focus to remove the item if it is empty, i.e., it contains no
|
focus to remove the item if it is empty, i.e., it contains no
|
||||||
text.
|
text.
|
||||||
|
|
||||||
This is the implementation of \c mouseDoubleClickEvent():
|
This is the implementation of \c mouseDoubleClickEvent():
|
||||||
|
|
||||||
@ -740,7 +740,7 @@
|
|||||||
|
|
||||||
The item's color can be set with \c setColor().
|
The item's color can be set with \c setColor().
|
||||||
|
|
||||||
\c boundingRect() and \c shape() are reimplemented
|
\c boundingRect() and \c shape() are reimplemented
|
||||||
from QGraphicsLineItem and are used by the scene
|
from QGraphicsLineItem and are used by the scene
|
||||||
to check for collisions and selections.
|
to check for collisions and selections.
|
||||||
|
|
||||||
@ -769,7 +769,7 @@
|
|||||||
We need to reimplement this function because the arrow is
|
We need to reimplement this function because the arrow is
|
||||||
larger than the bounding rectangle of the QGraphicsLineItem. The
|
larger than the bounding rectangle of the QGraphicsLineItem. The
|
||||||
graphics scene uses the bounding rectangle to know which regions
|
graphics scene uses the bounding rectangle to know which regions
|
||||||
of the scene to update.
|
of the scene to update.
|
||||||
|
|
||||||
Here is the \c shape() function:
|
Here is the \c shape() function:
|
||||||
|
|
||||||
@ -779,14 +779,14 @@
|
|||||||
shape of the item. The QGraphicsLineItem::shape() returns a path
|
shape of the item. The QGraphicsLineItem::shape() returns a path
|
||||||
with a line drawn with the current pen, so we only need to add
|
with a line drawn with the current pen, so we only need to add
|
||||||
the arrow head. This function is used to check for collisions and
|
the arrow head. This function is used to check for collisions and
|
||||||
selections with the mouse.
|
selections with the mouse.
|
||||||
|
|
||||||
Here is the \c updatePosition() slot:
|
Here is the \c updatePosition() slot:
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/arrow.cpp 3
|
\snippet graphicsview/diagramscene/arrow.cpp 3
|
||||||
|
|
||||||
This slot updates the arrow by setting the start and end
|
This slot updates the arrow by setting the start and end
|
||||||
points of its line to the center of the items it connects.
|
points of its line to the center of the items it connects.
|
||||||
|
|
||||||
Here is the \c paint() function:
|
Here is the \c paint() function:
|
||||||
|
|
||||||
@ -809,7 +809,7 @@
|
|||||||
one of the lines of the polygon. Note that the points in the
|
one of the lines of the polygon. Note that the points in the
|
||||||
polygon are relative to the local coordinate system of the item.
|
polygon are relative to the local coordinate system of the item.
|
||||||
We must therefore add the position of the end item to make the
|
We must therefore add the position of the end item to make the
|
||||||
coordinates relative to the scene.
|
coordinates relative to the scene.
|
||||||
|
|
||||||
\snippet graphicsview/diagramscene/arrow.cpp 6
|
\snippet graphicsview/diagramscene/arrow.cpp 6
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@
|
|||||||
that the entire name and address insertion is treated as a single
|
that the entire name and address insertion is treated as a single
|
||||||
operation by the QTextEdit, so a single undo will revert all the
|
operation by the QTextEdit, so a single undo will revert all the
|
||||||
insertions.
|
insertions.
|
||||||
|
|
||||||
\snippet mainwindows/dockwidgets/mainwindow.cpp 7
|
\snippet mainwindows/dockwidgets/mainwindow.cpp 7
|
||||||
|
|
||||||
This function works in a similar way to \c insertCustomer(). First
|
This function works in a similar way to \c insertCustomer(). First
|
||||||
@ -141,7 +141,7 @@
|
|||||||
replace it with the standard paragraph that the user clicked. Again
|
replace it with the standard paragraph that the user clicked. Again
|
||||||
we use a \c beginEditBlock() ... \c endEditBlock() pair so that the
|
we use a \c beginEditBlock() ... \c endEditBlock() pair so that the
|
||||||
insertion can be undone as a single operation.
|
insertion can be undone as a single operation.
|
||||||
|
|
||||||
\snippet mainwindows/dockwidgets/mainwindow.cpp 3
|
\snippet mainwindows/dockwidgets/mainwindow.cpp 3
|
||||||
|
|
||||||
Qt's QTextDocument class makes printing documents easy. We simply
|
Qt's QTextDocument class makes printing documents easy. We simply
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
\brief The Easing Curves example shows how to use easing curves to
|
\brief The Easing Curves example shows how to use easing curves to
|
||||||
control the speed of an animation.
|
control the speed of an animation.
|
||||||
|
|
||||||
\image easing-example.png
|
\image easing-example.png
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
System}{meta-object system}. The plugin \l{How to Create Qt
|
System}{meta-object system}. The plugin \l{How to Create Qt
|
||||||
Plugins}{overview document} gives a high-level introduction to
|
Plugins}{overview document} gives a high-level introduction to
|
||||||
plugins.
|
plugins.
|
||||||
|
|
||||||
We have implemented a plugin, the \c EchoPlugin, which implements
|
We have implemented a plugin, the \c EchoPlugin, which implements
|
||||||
the \c EchoInterface. The interface consists of \c echo(), which
|
the \c EchoInterface. The interface consists of \c echo(), which
|
||||||
takes a QString as argument. The \c EchoPlugin returns the string
|
takes a QString as argument. The \c EchoPlugin returns the string
|
||||||
@ -68,8 +68,8 @@
|
|||||||
\snippet tools/echoplugin/echowindow/echowindow.h 0
|
\snippet tools/echoplugin/echowindow/echowindow.h 0
|
||||||
|
|
||||||
We load the plugin in \c loadPlugin() and cast it to \c
|
We load the plugin in \c loadPlugin() and cast it to \c
|
||||||
EchoInterface. When the user clicks the \c button we take the
|
EchoInterface. When the user clicks the \c button we take the
|
||||||
text in \c lineEdit and call the interface's \c echo() with it.
|
text in \c lineEdit and call the interface's \c echo() with it.
|
||||||
|
|
||||||
|
|
||||||
\section1 EchoWindow Class Implementation
|
\section1 EchoWindow Class Implementation
|
||||||
@ -136,15 +136,15 @@
|
|||||||
System}{Qt's meta object system} aware of the interface. We do
|
System}{Qt's meta object system} aware of the interface. We do
|
||||||
this so that it will be possible to identify plugins that
|
this so that it will be possible to identify plugins that
|
||||||
implements the interface at run-time. The second argument is a
|
implements the interface at run-time. The second argument is a
|
||||||
string that must identify the interface in a unique way.
|
string that must identify the interface in a unique way.
|
||||||
|
|
||||||
|
|
||||||
\section1 EchoPlugin Class Definition
|
\section1 EchoPlugin Class Definition
|
||||||
|
|
||||||
We inherit both QObject and \c EchoInterface to make this class a
|
We inherit both QObject and \c EchoInterface to make this class a
|
||||||
plugin. The Q_INTERFACES macro tells Qt which interfaces the class
|
plugin. The Q_INTERFACES macro tells Qt which interfaces the class
|
||||||
implements. In our case we only implement the \c EchoInterface.
|
implements. In our case we only implement the \c EchoInterface.
|
||||||
If a class implements more than one interface, they are given as
|
If a class implements more than one interface, they are given as
|
||||||
a comma separated list. The Q_PLUGIN_METADATA macro is included next
|
a comma separated list. The Q_PLUGIN_METADATA macro is included next
|
||||||
to the Q_OBJECT macro. It contains the plugins IID and a filename
|
to the Q_OBJECT macro. It contains the plugins IID and a filename
|
||||||
pointing to a json file containing the metadata for the plugin.
|
pointing to a json file containing the metadata for the plugin.
|
||||||
@ -158,7 +158,7 @@
|
|||||||
|
|
||||||
\snippet tools/echoplugin/plugin/echoplugin.cpp 0
|
\snippet tools/echoplugin/plugin/echoplugin.cpp 0
|
||||||
|
|
||||||
We simply return the functions parameter.
|
We simply return the functions parameter.
|
||||||
|
|
||||||
\section1 The \c main() function
|
\section1 The \c main() function
|
||||||
|
|
||||||
@ -169,7 +169,7 @@
|
|||||||
\section1 The Profiles
|
\section1 The Profiles
|
||||||
|
|
||||||
When creating plugins the profiles need to be adjusted.
|
When creating plugins the profiles need to be adjusted.
|
||||||
We show here what changes need to be done.
|
We show here what changes need to be done.
|
||||||
|
|
||||||
The profile in the echoplugin directory uses the \c subdirs
|
The profile in the echoplugin directory uses the \c subdirs
|
||||||
template and simply includes includes to directories in which
|
template and simply includes includes to directories in which
|
||||||
@ -196,7 +196,7 @@
|
|||||||
|
|
||||||
You can find an overview of the macros needed to create plugins
|
You can find an overview of the macros needed to create plugins
|
||||||
\l{Macros for Defining Plugins}{here}.
|
\l{Macros for Defining Plugins}{here}.
|
||||||
|
|
||||||
We give an example of a plugin that extend Qt in the \l{Style
|
We give an example of a plugin that extend Qt in the \l{Style
|
||||||
Plugin Example}{style plugin} example. The \l{Plug & Paint
|
Plugin Example}{style plugin} example. The \l{Plug & Paint
|
||||||
Example}{plug and paint} example shows how to create static
|
Example}{plug and paint} example shows how to create static
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
\l{QAbstractItemModel::}{fetchMore()} and
|
\l{QAbstractItemModel::}{fetchMore()} and
|
||||||
\l{QAbstractItemModel::}{canFetchMore()} from QAbstractItemModel.
|
\l{QAbstractItemModel::}{canFetchMore()} from QAbstractItemModel.
|
||||||
These functions are called by the item view when it needs more
|
These functions are called by the item view when it needs more
|
||||||
items.
|
items.
|
||||||
|
|
||||||
The \c setDirPath() function sets the directory the model will
|
The \c setDirPath() function sets the directory the model will
|
||||||
work on. We emit \c numberPopulated() each time we add a batch of
|
work on. We emit \c numberPopulated() each time we add a batch of
|
||||||
|
@ -35,27 +35,27 @@
|
|||||||
\image flowlayout-example.png Screenshot of the Flow Layout example
|
\image flowlayout-example.png Screenshot of the Flow Layout example
|
||||||
|
|
||||||
The items are first laid out horizontally and then vertically when each line
|
The items are first laid out horizontally and then vertically when each line
|
||||||
in the layout runs out of space.
|
in the layout runs out of space.
|
||||||
|
|
||||||
The Flowlayout class mainly uses QLayout and QWidgetItem, while the
|
The Flowlayout class mainly uses QLayout and QWidgetItem, while the
|
||||||
Window uses QWidget and QLabel. We will only document the definition
|
Window uses QWidget and QLabel. We will only document the definition
|
||||||
and implementation of \c FlowLayout below.
|
and implementation of \c FlowLayout below.
|
||||||
|
|
||||||
\section1 FlowLayout Class Definition
|
\section1 FlowLayout Class Definition
|
||||||
|
|
||||||
The \c FlowLayout class inherits QLayout. It is a custom layout class
|
The \c FlowLayout class inherits QLayout. It is a custom layout class
|
||||||
that arranges its child widgets horizontally and vertically.
|
that arranges its child widgets horizontally and vertically.
|
||||||
|
|
||||||
\snippet layouts/flowlayout/flowlayout.h 0
|
\snippet layouts/flowlayout/flowlayout.h 0
|
||||||
|
|
||||||
We reimplement functions inherited from QLayout. These functions add items to
|
We reimplement functions inherited from QLayout. These functions add items to
|
||||||
the layout and handle their orientation and geometry.
|
the layout and handle their orientation and geometry.
|
||||||
|
|
||||||
We also declare two private methods, \c doLayout() and \c smartSpacing().
|
We also declare two private methods, \c doLayout() and \c smartSpacing().
|
||||||
\c doLayout() lays out the layout items, while the \c
|
\c doLayout() lays out the layout items, while the \c
|
||||||
smartSpacing() function calculates the spacing between them.
|
smartSpacing() function calculates the spacing between them.
|
||||||
|
|
||||||
\section1 FlowLayout Class Implementation
|
\section1 FlowLayout Class Implementation
|
||||||
|
|
||||||
We start off by looking at the constructor:
|
We start off by looking at the constructor:
|
||||||
|
|
||||||
@ -63,32 +63,32 @@
|
|||||||
|
|
||||||
In the constructor we call \c setContentsMargins() to set the left, top,
|
In the constructor we call \c setContentsMargins() to set the left, top,
|
||||||
right and bottom margin. By default, QLayout uses values provided by
|
right and bottom margin. By default, QLayout uses values provided by
|
||||||
the current style (see QStyle::PixelMetric).
|
the current style (see QStyle::PixelMetric).
|
||||||
|
|
||||||
\snippet layouts/flowlayout/flowlayout.cpp 2
|
\snippet layouts/flowlayout/flowlayout.cpp 2
|
||||||
|
|
||||||
In this example we reimplement \c addItem(), which is a pure virtual
|
In this example we reimplement \c addItem(), which is a pure virtual
|
||||||
function. When using \c addItem() the ownership of the layout items is
|
function. When using \c addItem() the ownership of the layout items is
|
||||||
transferred to the layout, and it is therefore the layout's
|
transferred to the layout, and it is therefore the layout's
|
||||||
responsibility to delete them.
|
responsibility to delete them.
|
||||||
|
|
||||||
\snippet layouts/flowlayout/flowlayout.cpp 3
|
\snippet layouts/flowlayout/flowlayout.cpp 3
|
||||||
|
|
||||||
\c addItem() is implemented to add items to the layout.
|
\c addItem() is implemented to add items to the layout.
|
||||||
|
|
||||||
\snippet layouts/flowlayout/flowlayout.cpp 4
|
\snippet layouts/flowlayout/flowlayout.cpp 4
|
||||||
|
|
||||||
We implement \c horizontalSpacing() and \c verticalSpacing() to get
|
We implement \c horizontalSpacing() and \c verticalSpacing() to get
|
||||||
hold of the spacing between the widgets inside the layout. If the value
|
hold of the spacing between the widgets inside the layout. If the value
|
||||||
is less than or equal to 0, this value will be used. If not,
|
is less than or equal to 0, this value will be used. If not,
|
||||||
\c smartSpacing() will be called to calculate the spacing.
|
\c smartSpacing() will be called to calculate the spacing.
|
||||||
|
|
||||||
\snippet layouts/flowlayout/flowlayout.cpp 5
|
\snippet layouts/flowlayout/flowlayout.cpp 5
|
||||||
|
|
||||||
We then implement \c count() to return the number of items in the
|
We then implement \c count() to return the number of items in the
|
||||||
layout. To navigate the list of items we use \c itemAt() and
|
layout. To navigate the list of items we use \c itemAt() and
|
||||||
takeAt() to remove and return items from the list. If an item is
|
takeAt() to remove and return items from the list. If an item is
|
||||||
removed, the remaining items will be renumbered. All three
|
removed, the remaining items will be renumbered. All three
|
||||||
functions are pure virtual functions from QLayout.
|
functions are pure virtual functions from QLayout.
|
||||||
|
|
||||||
\snippet layouts/flowlayout/flowlayout.cpp 6
|
\snippet layouts/flowlayout/flowlayout.cpp 6
|
||||||
@ -103,7 +103,7 @@
|
|||||||
dependency, and \c heightForWidth() passes the width on to \c doLayout() which
|
dependency, and \c heightForWidth() passes the width on to \c doLayout() which
|
||||||
in turn uses the width as an argument for the layout rect, i.e., the bounds in
|
in turn uses the width as an argument for the layout rect, i.e., the bounds in
|
||||||
which the items are laid out. This rect does not include the layout margin().
|
which the items are laid out. This rect does not include the layout margin().
|
||||||
|
|
||||||
\snippet layouts/flowlayout/flowlayout.cpp 8
|
\snippet layouts/flowlayout/flowlayout.cpp 8
|
||||||
|
|
||||||
\c setGeometry() is normally used to do the actual layout, i.e., calculate
|
\c setGeometry() is normally used to do the actual layout, i.e., calculate
|
||||||
@ -116,30 +116,30 @@
|
|||||||
\snippet layouts/flowlayout/flowlayout.cpp 9
|
\snippet layouts/flowlayout/flowlayout.cpp 9
|
||||||
|
|
||||||
\c doLayout() handles the layout if \c horizontalSpacing() or \c
|
\c doLayout() handles the layout if \c horizontalSpacing() or \c
|
||||||
verticalSpacing() don't return the default value. It uses
|
verticalSpacing() don't return the default value. It uses
|
||||||
\c getContentsMargins() to calculate the area available to the
|
\c getContentsMargins() to calculate the area available to the
|
||||||
layout items.
|
layout items.
|
||||||
|
|
||||||
\snippet layouts/flowlayout/flowlayout.cpp 10
|
\snippet layouts/flowlayout/flowlayout.cpp 10
|
||||||
|
|
||||||
It then sets the proper amount of spacing for each widget in the
|
It then sets the proper amount of spacing for each widget in the
|
||||||
layout, based on the current style.
|
layout, based on the current style.
|
||||||
|
|
||||||
\snippet layouts/flowlayout/flowlayout.cpp 11
|
\snippet layouts/flowlayout/flowlayout.cpp 11
|
||||||
|
|
||||||
The position of each item in the layout is then calculated by
|
The position of each item in the layout is then calculated by
|
||||||
adding the items width and the line height to the initial x and y
|
adding the items width and the line height to the initial x and y
|
||||||
coordinates. This in turn lets us find out whether the next item
|
coordinates. This in turn lets us find out whether the next item
|
||||||
will fit on the current line or if it must be moved down to the next.
|
will fit on the current line or if it must be moved down to the next.
|
||||||
We also find the height of the current line based on the widgets height.
|
We also find the height of the current line based on the widgets height.
|
||||||
|
|
||||||
\snippet layouts/flowlayout/flowlayout.cpp 12
|
\snippet layouts/flowlayout/flowlayout.cpp 12
|
||||||
|
|
||||||
\c smartSpacing() is designed to get the default spacing for either
|
\c smartSpacing() is designed to get the default spacing for either
|
||||||
the top-level layouts or the sublayouts. The default spacing for
|
the top-level layouts or the sublayouts. The default spacing for
|
||||||
top-level layouts, when the parent is a QWidget, will be determined
|
top-level layouts, when the parent is a QWidget, will be determined
|
||||||
by querying the style. The default spacing for sublayouts, when
|
by querying the style. The default spacing for sublayouts, when
|
||||||
the parent is a QLayout, will be determined by querying the spacing
|
the parent is a QLayout, will be determined by querying the spacing
|
||||||
of the parent layout.
|
of the parent layout.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
\title Font Sampler Example
|
\title Font Sampler Example
|
||||||
\ingroup examples-painting
|
\ingroup examples-painting
|
||||||
\brief The Font Sampler example shows how to preview and print multi-page documents.
|
\brief The Font Sampler example shows how to preview and print multi-page documents.
|
||||||
|
|
||||||
The Font Sampler example shows how to preview and print multi-page documents.
|
The Font Sampler example shows how to preview and print multi-page documents.
|
||||||
|
|
||||||
\image fontsampler-example.png
|
\image fontsampler-example.png
|
||||||
|
@ -230,7 +230,7 @@
|
|||||||
top-level corner of the drag pixmap, to be the point we calculated
|
top-level corner of the drag pixmap, to be the point we calculated
|
||||||
above. This makes the process of dragging the label feel more natural
|
above. This makes the process of dragging the label feel more natural
|
||||||
because the cursor always points to the same place on the label
|
because the cursor always points to the same place on the label
|
||||||
during the drag operation.
|
during the drag operation.
|
||||||
|
|
||||||
We start the drag operation using QDrag's \l{QDrag::}{exec()} function,
|
We start the drag operation using QDrag's \l{QDrag::}{exec()} function,
|
||||||
requesting that the magnet is copied when the drag is completed.
|
requesting that the magnet is copied when the drag is completed.
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\example mainwindows/mdi
|
\example mainwindows/mdi
|
||||||
\title MDI Example
|
\title MDI Example
|
||||||
\ingroup examples-mainwindow
|
\ingroup examples-mainwindow
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
\li \c StateSwitcher inherits QState and can add
|
\li \c StateSwitcher inherits QState and can add
|
||||||
\c {StateSwitchTransition}s to other states.
|
\c {StateSwitchTransition}s to other states.
|
||||||
When entered, it will randomly transition to one of these
|
When entered, it will randomly transition to one of these
|
||||||
states.
|
states.
|
||||||
\li \c StateSwitchTransition is a custom transition that
|
\li \c StateSwitchTransition is a custom transition that
|
||||||
triggers on \c{StateSwitchEvent}s.
|
triggers on \c{StateSwitchEvent}s.
|
||||||
\li \c StateSwitchEvent is a QEvent that triggers \c{StateSwitchTransition}s.
|
\li \c StateSwitchEvent is a QEvent that triggers \c{StateSwitchTransition}s.
|
||||||
@ -152,7 +152,7 @@
|
|||||||
\c StateSwitcher is a state designed for a particular purpose and
|
\c StateSwitcher is a state designed for a particular purpose and
|
||||||
will always be a top-level state. We use \c m_stateCount to keep
|
will always be a top-level state. We use \c m_stateCount to keep
|
||||||
track of how many states we are managing, and \c m_lastIndex to
|
track of how many states we are managing, and \c m_lastIndex to
|
||||||
remember which state was the last state to which we transitioned.
|
remember which state was the last state to which we transitioned.
|
||||||
|
|
||||||
\snippet animation/moveblocks/main.cpp 11
|
\snippet animation/moveblocks/main.cpp 11
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@
|
|||||||
|
|
||||||
This enables the items to be drawn without any gaps between them. Removing
|
This enables the items to be drawn without any gaps between them. Removing
|
||||||
the headers also prevents the user from adjusting the sizes of individual
|
the headers also prevents the user from adjusting the sizes of individual
|
||||||
rows and columns.
|
rows and columns.
|
||||||
|
|
||||||
We also set the minimum section size to 1 on the headers. If we
|
We also set the minimum section size to 1 on the headers. If we
|
||||||
didn't, the headers would default to a larger size, preventing
|
didn't, the headers would default to a larger size, preventing
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\example mainwindows/recentfiles
|
\example mainwindows/recentfiles
|
||||||
\title Recent Files Example
|
\title Recent Files Example
|
||||||
\ingroup examples-mainwindow
|
\ingroup examples-mainwindow
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\example tools/regexp
|
\example tools/regexp
|
||||||
\title Regular Expressions Example
|
\title Regular Expressions Example
|
||||||
\ingroup examples-widgets-tools
|
\ingroup examples-widgets-tools
|
||||||
|
@ -151,7 +151,7 @@
|
|||||||
|
|
||||||
When we enter \c quitState, we update the status bar of the
|
When we enter \c quitState, we update the status bar of the
|
||||||
window.
|
window.
|
||||||
|
|
||||||
\c QKeyEventTransition is a utility class that removes the hassle
|
\c QKeyEventTransition is a utility class that removes the hassle
|
||||||
of implementing transitions for \l{QKeyEvent}s. We simply need to
|
of implementing transitions for \l{QKeyEvent}s. We simply need to
|
||||||
specify the key on which the transition should trigger and the
|
specify the key on which the transition should trigger and the
|
||||||
@ -161,7 +161,7 @@
|
|||||||
|
|
||||||
The transition from \c inputState allows triggering the quit state
|
The transition from \c inputState allows triggering the quit state
|
||||||
when the player types \c {q}.
|
when the player types \c {q}.
|
||||||
|
|
||||||
\snippet statemachine/rogue/window.cpp 5
|
\snippet statemachine/rogue/window.cpp 5
|
||||||
|
|
||||||
The machine is set up, so it's time to start it.
|
The machine is set up, so it's time to start it.
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\example mainwindows/sdi
|
\example mainwindows/sdi
|
||||||
\title SDI Example
|
\title SDI Example
|
||||||
\ingroup examples-mainwindow
|
\ingroup examples-mainwindow
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\example tools/settingseditor
|
\example tools/settingseditor
|
||||||
\title Settings Editor Example
|
\title Settings Editor Example
|
||||||
\ingroup examples-widgets-tools
|
\ingroup examples-widgets-tools
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
|
|
||||||
The constructor of the \c Window class can be explained in three parts.
|
The constructor of the \c Window class can be explained in three parts.
|
||||||
In the first part, we set up the widgets used for the user interface:
|
In the first part, we set up the widgets used for the user interface:
|
||||||
|
|
||||||
\snippet itemviews/simplewidgetmapper/window.cpp Set up widgets
|
\snippet itemviews/simplewidgetmapper/window.cpp Set up widgets
|
||||||
|
|
||||||
We also set up the buddy relationships between various labels and the
|
We also set up the buddy relationships between various labels and the
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\example widgets/spinboxes
|
\example widgets/spinboxes
|
||||||
\title Spin Boxes Example
|
\title Spin Boxes Example
|
||||||
\ingroup examples-widgets
|
\ingroup examples-widgets
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\example dialogs/standarddialogs
|
\example dialogs/standarddialogs
|
||||||
\title Standard Dialogs Example
|
\title Standard Dialogs Example
|
||||||
\ingroup examples-dialogs
|
\ingroup examples-dialogs
|
||||||
|
@ -257,7 +257,7 @@
|
|||||||
\l{QAbstractItemView::editTriggers()}{edit triggers}, so that the
|
\l{QAbstractItemView::editTriggers()}{edit triggers}, so that the
|
||||||
editor is opened with a single click when the star rating item is
|
editor is opened with a single click when the star rating item is
|
||||||
selected.
|
selected.
|
||||||
|
|
||||||
The \c populateTableWidget() function fills the QTableWidget with
|
The \c populateTableWidget() function fills the QTableWidget with
|
||||||
data:
|
data:
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
from that class, and adding a macro. In this example we extend Qt
|
from that class, and adding a macro. In this example we extend Qt
|
||||||
by adding a new GUI look and feel (i.e., making a new QStyle
|
by adding a new GUI look and feel (i.e., making a new QStyle
|
||||||
available). A high-level introduction to plugins is given in the
|
available). A high-level introduction to plugins is given in the
|
||||||
plugin \l{How to Create Qt Plugins}{overview document}.
|
plugin \l{How to Create Qt Plugins}{overview document}.
|
||||||
|
|
||||||
Plugins that provide new styles inherit the QStylePlugin base
|
Plugins that provide new styles inherit the QStylePlugin base
|
||||||
class. Style plugins are loaded by Qt and made available through
|
class. Style plugins are loaded by Qt and made available through
|
||||||
@ -72,7 +72,7 @@
|
|||||||
\section1 SimpleStylePlugin Class Definition
|
\section1 SimpleStylePlugin Class Definition
|
||||||
|
|
||||||
\c SimpleStylePlugin inherits QStylePlugin and is the plugin
|
\c SimpleStylePlugin inherits QStylePlugin and is the plugin
|
||||||
class.
|
class.
|
||||||
|
|
||||||
\snippet tools/styleplugin/plugin/simplestyleplugin.h 0
|
\snippet tools/styleplugin/plugin/simplestyleplugin.h 0
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
\title Style Sheet Example
|
\title Style Sheet Example
|
||||||
\ingroup examples-widgets
|
\ingroup examples-widgets
|
||||||
\brief The Style Sheet Example shows how to use style sheets.
|
\brief The Style Sheet Example shows how to use style sheets.
|
||||||
|
|
||||||
\image stylesheet-pagefold.png Screen Shot of the Pagefold style sheet
|
\image stylesheet-pagefold.png Screen Shot of the Pagefold style sheet
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
\brief This example shows Qt's ability to combine \l{The Animation Framework}{the animation framework}
|
\brief This example shows Qt's ability to combine \l{The Animation Framework}{the animation framework}
|
||||||
and \l{The State Machine Framework}{the state machine framework} to create a game.
|
and \l{The State Machine Framework}{the state machine framework} to create a game.
|
||||||
|
|
||||||
\image sub-attaq-demo.png
|
\image sub-attaq-demo.png
|
||||||
|
|
||||||
The purpose of the game is to destroy all submarines to win the current level.
|
The purpose of the game is to destroy all submarines to win the current level.
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
it is close but not pressed down on it), when a device is pushed
|
it is close but not pressed down on it), when a device is pushed
|
||||||
down and released from it, and when a device is moved on the
|
down and released from it, and when a device is moved on the
|
||||||
tablet.
|
tablet.
|
||||||
|
|
||||||
The information available in QTabletEvent depends on the device
|
The information available in QTabletEvent depends on the device
|
||||||
used. The tablet in this example has two different devices for
|
used. The tablet in this example has two different devices for
|
||||||
drawing: a stylus and an airbrush. For both devices the event
|
drawing: a stylus and an airbrush. For both devices the event
|
||||||
@ -61,23 +61,23 @@
|
|||||||
The example consists of the following:
|
The example consists of the following:
|
||||||
|
|
||||||
\list
|
\list
|
||||||
\li The \c MainWindow class inherits QMainWindow and creates
|
\li The \c MainWindow class inherits QMainWindow and creates
|
||||||
the examples menus and connect their slots and signals.
|
the examples menus and connect their slots and signals.
|
||||||
\li The \c TabletCanvas class inherits QWidget and
|
\li The \c TabletCanvas class inherits QWidget and
|
||||||
receives tablet events. It uses the events to paint on a
|
receives tablet events. It uses the events to paint on a
|
||||||
offscreen pixmap, which it draws onto itself.
|
offscreen pixmap, which it draws onto itself.
|
||||||
\li The \c TabletApplication class inherits QApplication. This
|
\li The \c TabletApplication class inherits QApplication. This
|
||||||
class handles tablet events that are not sent to \c tabletEvent().
|
class handles tablet events that are not sent to \c tabletEvent().
|
||||||
We will look at this later.
|
We will look at this later.
|
||||||
\li The \c main() function creates a \c MainWindow and shows it
|
\li The \c main() function creates a \c MainWindow and shows it
|
||||||
as a top level window.
|
as a top level window.
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
|
|
||||||
\section1 MainWindow Class Definition
|
\section1 MainWindow Class Definition
|
||||||
|
|
||||||
The \c MainWindow creates a \c TabletCanvas and sets it as its
|
The \c MainWindow creates a \c TabletCanvas and sets it as its
|
||||||
center widget.
|
center widget.
|
||||||
|
|
||||||
\snippet widgets/tablet/mainwindow.h 0
|
\snippet widgets/tablet/mainwindow.h 0
|
||||||
|
|
||||||
@ -115,10 +115,10 @@
|
|||||||
|
|
||||||
\snippet widgets/tablet/mainwindow.cpp 2
|
\snippet widgets/tablet/mainwindow.cpp 2
|
||||||
|
|
||||||
The \c TabletCanvas class supports two ways by which the alpha
|
The \c TabletCanvas class supports two ways by which the alpha
|
||||||
channel of the drawing color can be changed: tablet pressure and
|
channel of the drawing color can be changed: tablet pressure and
|
||||||
tilt. We have one action for each and an action if the alpha
|
tilt. We have one action for each and an action if the alpha
|
||||||
channel should not be changed.
|
channel should not be changed.
|
||||||
|
|
||||||
Here is the implementation of \c lineWidthActionTriggered():
|
Here is the implementation of \c lineWidthActionTriggered():
|
||||||
|
|
||||||
@ -155,12 +155,12 @@
|
|||||||
|
|
||||||
\snippet widgets/tablet/mainwindow.cpp 7
|
\snippet widgets/tablet/mainwindow.cpp 7
|
||||||
|
|
||||||
We show a message box with a short description of the example.
|
We show a message box with a short description of the example.
|
||||||
|
|
||||||
\c createActions() creates all actions and action groups of
|
\c createActions() creates all actions and action groups of
|
||||||
the example. We look at the creation of one action group and its
|
the example. We look at the creation of one action group and its
|
||||||
actions. See the \l{Application Example}{application example} if
|
actions. See the \l{Application Example}{application example} if
|
||||||
you want a high-level introduction to QActions.
|
you want a high-level introduction to QActions.
|
||||||
|
|
||||||
Here is the implementation of \c createActions:
|
Here is the implementation of \c createActions:
|
||||||
|
|
||||||
@ -189,7 +189,7 @@
|
|||||||
\section1 TabletCanvas Class Definition
|
\section1 TabletCanvas Class Definition
|
||||||
|
|
||||||
The \c TabletCanvas class provides a surface on which the
|
The \c TabletCanvas class provides a surface on which the
|
||||||
user can draw with a tablet.
|
user can draw with a tablet.
|
||||||
|
|
||||||
\snippet widgets/tablet/tabletcanvas.h 0
|
\snippet widgets/tablet/tabletcanvas.h 0
|
||||||
|
|
||||||
@ -198,7 +198,7 @@
|
|||||||
these; their values decide if it is the tablet pressure or tilt
|
these; their values decide if it is the tablet pressure or tilt
|
||||||
that will alter them. We keep a private variable for each, the \c
|
that will alter them. We keep a private variable for each, the \c
|
||||||
alphaChannelType, \c colorSturationType, and \c penWidthType,
|
alphaChannelType, \c colorSturationType, and \c penWidthType,
|
||||||
which we provide access functions for.
|
which we provide access functions for.
|
||||||
|
|
||||||
We draw on a QPixmap with \c myPen and \c myBrush using \c
|
We draw on a QPixmap with \c myPen and \c myBrush using \c
|
||||||
myColor. The \c saveImage() and \c loadImage() saves and loads
|
myColor. The \c saveImage() and \c loadImage() saves and loads
|
||||||
@ -291,7 +291,7 @@
|
|||||||
-60, 127 equals 0, and 255 equals 60 degrees. The angle measured
|
-60, 127 equals 0, and 255 equals 60 degrees. The angle measured
|
||||||
is between the device and the perpendicular of the tablet (see
|
is between the device and the perpendicular of the tablet (see
|
||||||
QTabletEvent for an illustration).
|
QTabletEvent for an illustration).
|
||||||
|
|
||||||
\snippet widgets/tablet/tabletcanvas.cpp 8
|
\snippet widgets/tablet/tabletcanvas.cpp 8
|
||||||
|
|
||||||
The alpha channel of QColor is given as a number between 0
|
The alpha channel of QColor is given as a number between 0
|
||||||
@ -301,8 +301,8 @@
|
|||||||
taking the absolute value we get the smallest alpha values (i.e.,
|
taking the absolute value we get the smallest alpha values (i.e.,
|
||||||
the color is most transparent) when the pen is perpendicular to
|
the color is most transparent) when the pen is perpendicular to
|
||||||
the tablet. We select the largest of the vertical and horizontal
|
the tablet. We select the largest of the vertical and horizontal
|
||||||
tilt value.
|
tilt value.
|
||||||
|
|
||||||
\snippet widgets/tablet/tabletcanvas.cpp 9
|
\snippet widgets/tablet/tabletcanvas.cpp 9
|
||||||
|
|
||||||
The colorsaturation is given as a number between 0 and 255. It is
|
The colorsaturation is given as a number between 0 and 255. It is
|
||||||
@ -317,7 +317,7 @@
|
|||||||
the angle between the device and the perpendicular of the tablet.
|
the angle between the device and the perpendicular of the tablet.
|
||||||
|
|
||||||
\snippet widgets/tablet/tabletcanvas.cpp 11
|
\snippet widgets/tablet/tabletcanvas.cpp 11
|
||||||
|
|
||||||
We finally check whether the pointer is the stylus or the eraser.
|
We finally check whether the pointer is the stylus or the eraser.
|
||||||
If it is the eraser, we set the color to the background color of
|
If it is the eraser, we set the color to the background color of
|
||||||
the pixmap an let the pressure decide the pen width, else we set
|
the pixmap an let the pressure decide the pen width, else we set
|
||||||
@ -327,7 +327,7 @@
|
|||||||
\section1 TabletApplication Class Definition
|
\section1 TabletApplication Class Definition
|
||||||
|
|
||||||
We inherit QApplication in this class because we want to
|
We inherit QApplication in this class because we want to
|
||||||
reimplement the \l{QApplication::}{event()} function.
|
reimplement the \l{QApplication::}{event()} function.
|
||||||
|
|
||||||
\snippet widgets/tablet/tabletapplication.h 0
|
\snippet widgets/tablet/tabletapplication.h 0
|
||||||
|
|
||||||
@ -336,7 +336,7 @@
|
|||||||
and TabletLeaveProximity events are not sendt to the QApplication
|
and TabletLeaveProximity events are not sendt to the QApplication
|
||||||
object, while other tablet events are sendt to the QWidget's
|
object, while other tablet events are sendt to the QWidget's
|
||||||
\c event(), which sends them on to \l{QWidget::}{tabletEvent()}.
|
\c event(), which sends them on to \l{QWidget::}{tabletEvent()}.
|
||||||
Since we want to handle these events we have implemented \c
|
Since we want to handle these events we have implemented \c
|
||||||
TabletApplication.
|
TabletApplication.
|
||||||
|
|
||||||
|
|
||||||
@ -352,7 +352,7 @@
|
|||||||
events is to do work that is dependent on what kind of device is
|
events is to do work that is dependent on what kind of device is
|
||||||
used on the tablet. This way, you don't have to do this work
|
used on the tablet. This way, you don't have to do this work
|
||||||
when other events are generated, which is more frequently than the
|
when other events are generated, which is more frequently than the
|
||||||
leave and enter proximity events. We call \c setTabletDevice() in
|
leave and enter proximity events. We call \c setTabletDevice() in
|
||||||
\c TabletCanvas.
|
\c TabletCanvas.
|
||||||
|
|
||||||
\section1 The \c main() function
|
\section1 The \c main() function
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\example widgets/tetrix
|
\example widgets/tetrix
|
||||||
\title Tetrix Example
|
\title Tetrix Example
|
||||||
\ingroup examples-widgets
|
\ingroup examples-widgets
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
\image undodemo.png
|
\image undodemo.png
|
||||||
|
|
||||||
Qt's undo framework is an implementation of the Command
|
Qt's undo framework is an implementation of the Command
|
||||||
pattern, which provides advanced undo/redo functionality.
|
pattern, which provides advanced undo/redo functionality.
|
||||||
|
|
||||||
To show the abilities of the framework, we have implemented a
|
To show the abilities of the framework, we have implemented a
|
||||||
small diagram application in which the diagram items are geometric
|
small diagram application in which the diagram items are geometric
|
||||||
|
@ -61,9 +61,9 @@
|
|||||||
|
|
||||||
The example consists of the following classes:
|
The example consists of the following classes:
|
||||||
|
|
||||||
\list
|
\list
|
||||||
\li \c MainWindow is the main window and arranges the
|
\li \c MainWindow is the main window and arranges the
|
||||||
example's widgets. It creates the commands based
|
example's widgets. It creates the commands based
|
||||||
on user input and keeps them on the command stack.
|
on user input and keeps them on the command stack.
|
||||||
\li \c AddCommand adds an item to the scene.
|
\li \c AddCommand adds an item to the scene.
|
||||||
\li \c DeleteCommand deletes an item from the scene.
|
\li \c DeleteCommand deletes an item from the scene.
|
||||||
@ -85,23 +85,23 @@
|
|||||||
\l{QUndoCommand}s and pushes and pops them from the stack when it
|
\l{QUndoCommand}s and pushes and pops them from the stack when it
|
||||||
receives the \c triggered() signal from \c undoAction and \c
|
receives the \c triggered() signal from \c undoAction and \c
|
||||||
redoAction.
|
redoAction.
|
||||||
|
|
||||||
\section1 MainWindow Class Implementation
|
\section1 MainWindow Class Implementation
|
||||||
|
|
||||||
We will start with a look at the constructor:
|
We will start with a look at the constructor:
|
||||||
|
|
||||||
\snippet tools/undoframework/mainwindow.cpp 0
|
\snippet tools/undoframework/mainwindow.cpp 0
|
||||||
|
|
||||||
In the constructor, we set up the DiagramScene and QGraphicsView.
|
In the constructor, we set up the DiagramScene and QGraphicsView.
|
||||||
|
|
||||||
Here is the \c createUndoView() function:
|
Here is the \c createUndoView() function:
|
||||||
|
|
||||||
\snippet tools/undoframework/mainwindow.cpp 1
|
\snippet tools/undoframework/mainwindow.cpp 1
|
||||||
|
|
||||||
The QUndoView is a widget that display the text, which is set with
|
The QUndoView is a widget that display the text, which is set with
|
||||||
the \l{QUndoCommand::}{setText()} function, for each QUndoCommand
|
the \l{QUndoCommand::}{setText()} function, for each QUndoCommand
|
||||||
in the undo stack in a list.
|
in the undo stack in a list.
|
||||||
|
|
||||||
Here is the \c createActions() function:
|
Here is the \c createActions() function:
|
||||||
|
|
||||||
\snippet tools/undoframework/mainwindow.cpp 2
|
\snippet tools/undoframework/mainwindow.cpp 2
|
||||||
@ -130,7 +130,7 @@
|
|||||||
|
|
||||||
We have to use the QMenu \c aboutToShow() and \c aboutToHide()
|
We have to use the QMenu \c aboutToShow() and \c aboutToHide()
|
||||||
signals since we only want \c deleteAction to be enabled when we
|
signals since we only want \c deleteAction to be enabled when we
|
||||||
have selected an item.
|
have selected an item.
|
||||||
|
|
||||||
Here is the \c itemMoved() slot:
|
Here is the \c itemMoved() slot:
|
||||||
|
|
||||||
@ -155,9 +155,9 @@
|
|||||||
\snippet tools/undoframework/mainwindow.cpp 12
|
\snippet tools/undoframework/mainwindow.cpp 12
|
||||||
|
|
||||||
We implement \c itemMenuAboutToShow() and \c itemMenuAboutToHide()
|
We implement \c itemMenuAboutToShow() and \c itemMenuAboutToHide()
|
||||||
to get a dynamic item menu. These slots are connected to the
|
to get a dynamic item menu. These slots are connected to the
|
||||||
\l{QMenu::}{aboutToShow()} and \l{QMenu::}{aboutToHide()} signals.
|
\l{QMenu::}{aboutToShow()} and \l{QMenu::}{aboutToHide()} signals.
|
||||||
We need this to disable or enable the \c deleteAction.
|
We need this to disable or enable the \c deleteAction.
|
||||||
|
|
||||||
Here is the \c addBox() slot:
|
Here is the \c addBox() slot:
|
||||||
|
|
||||||
@ -171,21 +171,21 @@
|
|||||||
\snippet tools/undoframework/mainwindow.cpp 14
|
\snippet tools/undoframework/mainwindow.cpp 14
|
||||||
|
|
||||||
The \c addTriangle() function creates an AddCommand and pushes it
|
The \c addTriangle() function creates an AddCommand and pushes it
|
||||||
on the undo stack.
|
on the undo stack.
|
||||||
|
|
||||||
Here is the implementation of \c about():
|
Here is the implementation of \c about():
|
||||||
|
|
||||||
\snippet tools/undoframework/mainwindow.cpp 15
|
\snippet tools/undoframework/mainwindow.cpp 15
|
||||||
|
|
||||||
The about slot is triggered by the \c aboutAction and displays an
|
The about slot is triggered by the \c aboutAction and displays an
|
||||||
about box for the example.
|
about box for the example.
|
||||||
|
|
||||||
\section1 AddCommand Class Definition
|
\section1 AddCommand Class Definition
|
||||||
|
|
||||||
\snippet tools/undoframework/commands.h 2
|
\snippet tools/undoframework/commands.h 2
|
||||||
|
|
||||||
The \c AddCommand class adds DiagramItem graphics items to the
|
The \c AddCommand class adds DiagramItem graphics items to the
|
||||||
DiagramScene.
|
DiagramScene.
|
||||||
|
|
||||||
\section1 AddCommand Class Implementation
|
\section1 AddCommand Class Implementation
|
||||||
|
|
||||||
@ -208,20 +208,20 @@
|
|||||||
constructor.
|
constructor.
|
||||||
|
|
||||||
\section1 DeleteCommand Class Definition
|
\section1 DeleteCommand Class Definition
|
||||||
|
|
||||||
\snippet tools/undoframework/commands.h 1
|
\snippet tools/undoframework/commands.h 1
|
||||||
|
|
||||||
The DeleteCommand class implements the functionality to remove an
|
The DeleteCommand class implements the functionality to remove an
|
||||||
item from the scene.
|
item from the scene.
|
||||||
|
|
||||||
\section1 DeleteCommand Class Implementation
|
\section1 DeleteCommand Class Implementation
|
||||||
|
|
||||||
\snippet tools/undoframework/commands.cpp 4
|
\snippet tools/undoframework/commands.cpp 4
|
||||||
|
|
||||||
We know that there must be one selected item as it is not possible
|
We know that there must be one selected item as it is not possible
|
||||||
to create a DeleteCommand unless the item to be deleted is
|
to create a DeleteCommand unless the item to be deleted is
|
||||||
selected and that only one item can be selected at any time.
|
selected and that only one item can be selected at any time.
|
||||||
The item must be unselected if it is inserted back into the
|
The item must be unselected if it is inserted back into the
|
||||||
scene.
|
scene.
|
||||||
|
|
||||||
\snippet tools/undoframework/commands.cpp 5
|
\snippet tools/undoframework/commands.cpp 5
|
||||||
@ -242,7 +242,7 @@
|
|||||||
|
|
||||||
\section1 MoveCommand Class Implementation
|
\section1 MoveCommand Class Implementation
|
||||||
|
|
||||||
|
|
||||||
The constructor of MoveCommand looks like this:
|
The constructor of MoveCommand looks like this:
|
||||||
|
|
||||||
\snippet tools/undoframework/commands.cpp 0
|
\snippet tools/undoframework/commands.cpp 0
|
||||||
@ -252,12 +252,12 @@
|
|||||||
|
|
||||||
\snippet tools/undoframework/commands.cpp 2
|
\snippet tools/undoframework/commands.cpp 2
|
||||||
|
|
||||||
We simply set the items old position and update the scene.
|
We simply set the items old position and update the scene.
|
||||||
|
|
||||||
\snippet tools/undoframework/commands.cpp 3
|
\snippet tools/undoframework/commands.cpp 3
|
||||||
|
|
||||||
We set the item to its new position.
|
We set the item to its new position.
|
||||||
|
|
||||||
\snippet tools/undoframework/commands.cpp 1
|
\snippet tools/undoframework/commands.cpp 1
|
||||||
|
|
||||||
Whenever a MoveCommand is created, this function is called to
|
Whenever a MoveCommand is created, this function is called to
|
||||||
@ -268,7 +268,7 @@
|
|||||||
We first check whether it is the same item that has been moved
|
We first check whether it is the same item that has been moved
|
||||||
twice, in which case we merge the commands. We update the position
|
twice, in which case we merge the commands. We update the position
|
||||||
of the item so that it will take the last position in the move
|
of the item so that it will take the last position in the move
|
||||||
sequence when undone.
|
sequence when undone.
|
||||||
|
|
||||||
\section1 DiagramScene Class Definition
|
\section1 DiagramScene Class Definition
|
||||||
|
|
||||||
@ -281,7 +281,7 @@
|
|||||||
as it only deals with graphics framework issues.
|
as it only deals with graphics framework issues.
|
||||||
|
|
||||||
\section1 The \c main() Function
|
\section1 The \c main() Function
|
||||||
|
|
||||||
The \c main() function of the program looks like this:
|
The \c main() function of the program looks like this:
|
||||||
|
|
||||||
\snippet tools/undoframework/main.cpp 0
|
\snippet tools/undoframework/main.cpp 0
|
||||||
|
@ -103,7 +103,7 @@ void DragWidget::dropEvent(QDropEvent *event)
|
|||||||
if (event->mimeData()->hasFormat("application/x-dnditemdata")) {
|
if (event->mimeData()->hasFormat("application/x-dnditemdata")) {
|
||||||
QByteArray itemData = event->mimeData()->data("application/x-dnditemdata");
|
QByteArray itemData = event->mimeData()->data("application/x-dnditemdata");
|
||||||
QDataStream dataStream(&itemData, QIODevice::ReadOnly);
|
QDataStream dataStream(&itemData, QIODevice::ReadOnly);
|
||||||
|
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
QPoint offset;
|
QPoint offset;
|
||||||
dataStream >> pixmap >> offset;
|
dataStream >> pixmap >> offset;
|
||||||
@ -143,7 +143,7 @@ void DragWidget::mousePressEvent(QMouseEvent *event)
|
|||||||
QMimeData *mimeData = new QMimeData;
|
QMimeData *mimeData = new QMimeData;
|
||||||
mimeData->setData("application/x-dnditemdata", itemData);
|
mimeData->setData("application/x-dnditemdata", itemData);
|
||||||
//! [2]
|
//! [2]
|
||||||
|
|
||||||
//! [3]
|
//! [3]
|
||||||
QDrag *drag = new QDrag(this);
|
QDrag *drag = new QDrag(this);
|
||||||
drag->setMimeData(mimeData);
|
drag->setMimeData(mimeData);
|
||||||
|
@ -87,7 +87,7 @@ void DropArea::dropEvent(QDropEvent *event)
|
|||||||
setText(mimeData->html());
|
setText(mimeData->html());
|
||||||
setTextFormat(Qt::RichText);
|
setTextFormat(Qt::RichText);
|
||||||
} else if (mimeData->hasText()) {
|
} else if (mimeData->hasText()) {
|
||||||
setText(mimeData->text());
|
setText(mimeData->text());
|
||||||
setTextFormat(Qt::PlainText);
|
setTextFormat(Qt::PlainText);
|
||||||
} else if (mimeData->hasUrls()) {
|
} else if (mimeData->hasUrls()) {
|
||||||
QList<QUrl> urlList = mimeData->urls();
|
QList<QUrl> urlList = mimeData->urls();
|
||||||
@ -102,7 +102,7 @@ void DropArea::dropEvent(QDropEvent *event)
|
|||||||
}
|
}
|
||||||
//! [dropEvent() function part2]
|
//! [dropEvent() function part2]
|
||||||
|
|
||||||
//! [dropEvent() function part3]
|
//! [dropEvent() function part3]
|
||||||
setBackgroundRole(QPalette::Dark);
|
setBackgroundRole(QPalette::Dark);
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ void DropSiteWindow::updateFormatsTable(const QMimeData *mimeData)
|
|||||||
return;
|
return;
|
||||||
//! [updateFormatsTable() part1]
|
//! [updateFormatsTable() part1]
|
||||||
|
|
||||||
//! [updateFormatsTable() part2]
|
//! [updateFormatsTable() part2]
|
||||||
foreach (QString format, mimeData->formats()) {
|
foreach (QString format, mimeData->formats()) {
|
||||||
QTableWidgetItem *formatItem = new QTableWidgetItem(format);
|
QTableWidgetItem *formatItem = new QTableWidgetItem(format);
|
||||||
formatItem->setFlags(Qt::ItemIsEnabled);
|
formatItem->setFlags(Qt::ItemIsEnabled);
|
||||||
@ -129,7 +129,7 @@ void DropSiteWindow::updateFormatsTable(const QMimeData *mimeData)
|
|||||||
text.append(hex + " ");
|
text.append(hex + " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//! [updateFormatsTable() part3]
|
//! [updateFormatsTable() part3]
|
||||||
|
|
||||||
//! [updateFormatsTable() part4]
|
//! [updateFormatsTable() part4]
|
||||||
int row = formatsTable->rowCount();
|
int row = formatsTable->rowCount();
|
||||||
@ -137,7 +137,7 @@ void DropSiteWindow::updateFormatsTable(const QMimeData *mimeData)
|
|||||||
formatsTable->setItem(row, 0, new QTableWidgetItem(format));
|
formatsTable->setItem(row, 0, new QTableWidgetItem(format));
|
||||||
formatsTable->setItem(row, 1, new QTableWidgetItem(text));
|
formatsTable->setItem(row, 1, new QTableWidgetItem(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
formatsTable->resizeColumnToContents(0);
|
formatsTable->resizeColumnToContents(0);
|
||||||
}
|
}
|
||||||
//! [updateFormatsTable() part4]
|
//! [updateFormatsTable() part4]
|
||||||
|
@ -567,7 +567,7 @@ void Scene::initGL()
|
|||||||
m_environmentProgram->link();
|
m_environmentProgram->link();
|
||||||
|
|
||||||
const int NOISE_SIZE = 128; // for a different size, B and BM in fbm.c must also be changed
|
const int NOISE_SIZE = 128; // for a different size, B and BM in fbm.c must also be changed
|
||||||
m_noise = new GLTexture3D(NOISE_SIZE, NOISE_SIZE, NOISE_SIZE);
|
m_noise = new GLTexture3D(NOISE_SIZE, NOISE_SIZE, NOISE_SIZE);
|
||||||
QRgb *data = new QRgb[NOISE_SIZE * NOISE_SIZE * NOISE_SIZE];
|
QRgb *data = new QRgb[NOISE_SIZE * NOISE_SIZE * NOISE_SIZE];
|
||||||
memset(data, 0, NOISE_SIZE * NOISE_SIZE * NOISE_SIZE * sizeof(QRgb));
|
memset(data, 0, NOISE_SIZE * NOISE_SIZE * NOISE_SIZE * sizeof(QRgb));
|
||||||
QRgb *p = data;
|
QRgb *p = data;
|
||||||
|
@ -51,7 +51,7 @@ int main(int argc, char *argv[])
|
|||||||
app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
|
app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
|
||||||
|
|
||||||
MainWindow window;
|
MainWindow window;
|
||||||
window.show();
|
window.show();
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
|
|
||||||
h1Splitter = new QSplitter;
|
h1Splitter = new QSplitter;
|
||||||
h2Splitter = new QSplitter;
|
h2Splitter = new QSplitter;
|
||||||
|
|
||||||
QSplitter *vSplitter = new QSplitter;
|
QSplitter *vSplitter = new QSplitter;
|
||||||
vSplitter->setOrientation(Qt::Vertical);
|
vSplitter->setOrientation(Qt::Vertical);
|
||||||
vSplitter->addWidget(h1Splitter);
|
vSplitter->addWidget(h1Splitter);
|
||||||
|
@ -54,11 +54,11 @@ class MainWindow : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
MainWindow(QWidget *parent = 0);
|
MainWindow(QWidget *parent = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupMatrix();
|
void setupMatrix();
|
||||||
void populateScene();
|
void populateScene();
|
||||||
|
|
||||||
QGraphicsScene *scene;
|
QGraphicsScene *scene;
|
||||||
QSplitter *h1Splitter;
|
QSplitter *h1Splitter;
|
||||||
QSplitter *h2Splitter;
|
QSplitter *h2Splitter;
|
||||||
|
@ -159,7 +159,7 @@ void Mouse::advance(int step)
|
|||||||
foreach (QGraphicsItem *item, dangerMice) {
|
foreach (QGraphicsItem *item, dangerMice) {
|
||||||
if (item == this)
|
if (item == this)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QLineF lineToMouse(QPointF(0, 0), mapFromItem(item, 0, 0));
|
QLineF lineToMouse(QPointF(0, 0), mapFromItem(item, 0, 0));
|
||||||
qreal angleToMouse = ::acos(lineToMouse.dx() / lineToMouse.length());
|
qreal angleToMouse = ::acos(lineToMouse.dx() / lineToMouse.length());
|
||||||
if (lineToMouse.dy() < 0)
|
if (lineToMouse.dy() < 0)
|
||||||
|
@ -162,7 +162,7 @@ void RobotTorso::paint(QPainter *painter,
|
|||||||
{
|
{
|
||||||
Q_UNUSED(option);
|
Q_UNUSED(option);
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
|
|
||||||
painter->setBrush(dragOver ? color.light(130) : color);
|
painter->setBrush(dragOver ? color.light(130) : color);
|
||||||
painter->drawRoundedRect(-20, -20, 40, 60, 25, 25, Qt::RelativeSize);
|
painter->drawRoundedRect(-20, -20, 40, 60, 25, 25, Qt::RelativeSize);
|
||||||
painter->drawEllipse(-25, -20, 20, 20);
|
painter->drawEllipse(-25, -20, 20, 20);
|
||||||
|
@ -109,7 +109,7 @@ class Robot : public RobotPart
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Robot(QGraphicsItem *parent = 0);
|
Robot(QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||||
};
|
};
|
||||||
|
@ -136,7 +136,7 @@ void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
|
|||||||
QPointF sourceArrowP1 = sourcePoint + QPointF(sin(angle + Pi / 3) * arrowSize,
|
QPointF sourceArrowP1 = sourcePoint + QPointF(sin(angle + Pi / 3) * arrowSize,
|
||||||
cos(angle + Pi / 3) * arrowSize);
|
cos(angle + Pi / 3) * arrowSize);
|
||||||
QPointF sourceArrowP2 = sourcePoint + QPointF(sin(angle + Pi - Pi / 3) * arrowSize,
|
QPointF sourceArrowP2 = sourcePoint + QPointF(sin(angle + Pi - Pi / 3) * arrowSize,
|
||||||
cos(angle + Pi - Pi / 3) * arrowSize);
|
cos(angle + Pi - Pi / 3) * arrowSize);
|
||||||
QPointF destArrowP1 = destPoint + QPointF(sin(angle - Pi / 3) * arrowSize,
|
QPointF destArrowP1 = destPoint + QPointF(sin(angle - Pi / 3) * arrowSize,
|
||||||
cos(angle - Pi / 3) * arrowSize);
|
cos(angle - Pi / 3) * arrowSize);
|
||||||
QPointF destArrowP2 = destPoint + QPointF(sin(angle - Pi + Pi / 3) * arrowSize,
|
QPointF destArrowP2 = destPoint + QPointF(sin(angle - Pi + Pi / 3) * arrowSize,
|
||||||
|
@ -58,11 +58,11 @@ public:
|
|||||||
|
|
||||||
enum { Type = UserType + 2 };
|
enum { Type = UserType + 2 };
|
||||||
int type() const { return Type; }
|
int type() const { return Type; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Node *source, *dest;
|
Node *source, *dest;
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ protected:
|
|||||||
|
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<Edge *> edgeList;
|
QList<Edge *> edgeList;
|
||||||
QPointF newPos;
|
QPointF newPos;
|
||||||
|
@ -64,7 +64,7 @@ void CustomProxy::paintWindowFrame(QPainter *painter, const QStyleOptionGraphics
|
|||||||
QWidget *widget)
|
QWidget *widget)
|
||||||
{
|
{
|
||||||
const QColor color(0, 0, 0, 64);
|
const QColor color(0, 0, 0, 64);
|
||||||
|
|
||||||
QRectF r = windowFrameRect();
|
QRectF r = windowFrameRect();
|
||||||
QRectF right(r.right(), r.top() + 10, 10, r.height() - 10);
|
QRectF right(r.right(), r.top() + 10, 10, r.height() - 10);
|
||||||
QRectF bottom(r.left() + 10, r.bottom(), r.width(), 10);
|
QRectF bottom(r.left() + 10, r.bottom(), r.width(), 10);
|
||||||
@ -159,7 +159,7 @@ void CustomProxy::zoomIn()
|
|||||||
{
|
{
|
||||||
if (timeLine->direction() != QTimeLine::Forward)
|
if (timeLine->direction() != QTimeLine::Forward)
|
||||||
timeLine->setDirection(QTimeLine::Forward);
|
timeLine->setDirection(QTimeLine::Forward);
|
||||||
if (timeLine->state() == QTimeLine::NotRunning)
|
if (timeLine->state() == QTimeLine::NotRunning)
|
||||||
timeLine->start();
|
timeLine->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,6 +167,6 @@ void CustomProxy::zoomOut()
|
|||||||
{
|
{
|
||||||
if (timeLine->direction() != QTimeLine::Backward)
|
if (timeLine->direction() != QTimeLine::Backward)
|
||||||
timeLine->setDirection(QTimeLine::Backward);
|
timeLine->setDirection(QTimeLine::Backward);
|
||||||
if (timeLine->state() == QTimeLine::NotRunning)
|
if (timeLine->state() == QTimeLine::NotRunning)
|
||||||
timeLine->start();
|
timeLine->start();
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ public:
|
|||||||
|
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
void paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
@ -50,31 +50,31 @@ AddDialog::AddDialog(QWidget *parent)
|
|||||||
addressLabel = new QLabel("Address");
|
addressLabel = new QLabel("Address");
|
||||||
okButton = new QPushButton("OK");
|
okButton = new QPushButton("OK");
|
||||||
cancelButton = new QPushButton("Cancel");
|
cancelButton = new QPushButton("Cancel");
|
||||||
|
|
||||||
nameText = new QLineEdit;
|
nameText = new QLineEdit;
|
||||||
addressText = new QTextEdit;
|
addressText = new QTextEdit;
|
||||||
|
|
||||||
QGridLayout *gLayout = new QGridLayout;
|
QGridLayout *gLayout = new QGridLayout;
|
||||||
gLayout->setColumnStretch(1, 2);
|
gLayout->setColumnStretch(1, 2);
|
||||||
gLayout->addWidget(nameLabel, 0, 0);
|
gLayout->addWidget(nameLabel, 0, 0);
|
||||||
gLayout->addWidget(nameText, 0, 1);
|
gLayout->addWidget(nameText, 0, 1);
|
||||||
|
|
||||||
gLayout->addWidget(addressLabel, 1, 0, Qt::AlignLeft|Qt::AlignTop);
|
gLayout->addWidget(addressLabel, 1, 0, Qt::AlignLeft|Qt::AlignTop);
|
||||||
gLayout->addWidget(addressText, 1, 1, Qt::AlignLeft);
|
gLayout->addWidget(addressText, 1, 1, Qt::AlignLeft);
|
||||||
|
|
||||||
QHBoxLayout *buttonLayout = new QHBoxLayout;
|
QHBoxLayout *buttonLayout = new QHBoxLayout;
|
||||||
buttonLayout->addWidget(okButton);
|
buttonLayout->addWidget(okButton);
|
||||||
buttonLayout->addWidget(cancelButton);
|
buttonLayout->addWidget(cancelButton);
|
||||||
|
|
||||||
gLayout->addLayout(buttonLayout, 2, 1, Qt::AlignRight);
|
gLayout->addLayout(buttonLayout, 2, 1, Qt::AlignRight);
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addLayout(gLayout);
|
mainLayout->addLayout(gLayout);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
|
connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
|
||||||
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
|
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
|
||||||
|
|
||||||
setWindowTitle(tr("Add a Contact"));
|
setWindowTitle(tr("Add a Contact"));
|
||||||
}
|
}
|
||||||
//! [0]
|
//! [0]
|
||||||
|
@ -54,7 +54,7 @@ QT_END_NAMESPACE
|
|||||||
class AddDialog : public QDialog
|
class AddDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AddDialog(QWidget *parent = 0);
|
AddDialog(QWidget *parent = 0);
|
||||||
QLineEdit *nameText;
|
QLineEdit *nameText;
|
||||||
|
@ -52,7 +52,7 @@ AddressWidget::AddressWidget(QWidget *parent)
|
|||||||
connect(newAddressTab, SIGNAL(sendDetails(QString, QString)),
|
connect(newAddressTab, SIGNAL(sendDetails(QString, QString)),
|
||||||
this, SLOT(addEntry(QString, QString)));
|
this, SLOT(addEntry(QString, QString)));
|
||||||
|
|
||||||
addTab(newAddressTab, "Address Book");
|
addTab(newAddressTab, "Address Book");
|
||||||
|
|
||||||
setupTabs();
|
setupTabs();
|
||||||
}
|
}
|
||||||
@ -60,13 +60,13 @@ AddressWidget::AddressWidget(QWidget *parent)
|
|||||||
|
|
||||||
//! [2]
|
//! [2]
|
||||||
void AddressWidget::addEntry()
|
void AddressWidget::addEntry()
|
||||||
{
|
{
|
||||||
AddDialog aDialog;
|
AddDialog aDialog;
|
||||||
|
|
||||||
if (aDialog.exec()) {
|
if (aDialog.exec()) {
|
||||||
QString name = aDialog.nameText->text();
|
QString name = aDialog.nameText->text();
|
||||||
QString address = aDialog.addressText->toPlainText();
|
QString address = aDialog.addressText->toPlainText();
|
||||||
|
|
||||||
addEntry(name, address);
|
addEntry(name, address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ void AddressWidget::addEntry()
|
|||||||
|
|
||||||
//! [3]
|
//! [3]
|
||||||
void AddressWidget::addEntry(QString name, QString address)
|
void AddressWidget::addEntry(QString name, QString address)
|
||||||
{
|
{
|
||||||
QList<QPair<QString, QString> >list = table->getList();
|
QList<QPair<QString, QString> >list = table->getList();
|
||||||
QPair<QString, QString> pair(name, address);
|
QPair<QString, QString> pair(name, address);
|
||||||
|
|
||||||
@ -110,14 +110,14 @@ void AddressWidget::editEntry()
|
|||||||
QModelIndex nameIndex = table->index(row, 0, QModelIndex());
|
QModelIndex nameIndex = table->index(row, 0, QModelIndex());
|
||||||
QVariant varName = table->data(nameIndex, Qt::DisplayRole);
|
QVariant varName = table->data(nameIndex, Qt::DisplayRole);
|
||||||
name = varName.toString();
|
name = varName.toString();
|
||||||
|
|
||||||
QModelIndex addressIndex = table->index(row, 1, QModelIndex());
|
QModelIndex addressIndex = table->index(row, 1, QModelIndex());
|
||||||
QVariant varAddr = table->data(addressIndex, Qt::DisplayRole);
|
QVariant varAddr = table->data(addressIndex, Qt::DisplayRole);
|
||||||
address = varAddr.toString();
|
address = varAddr.toString();
|
||||||
}
|
}
|
||||||
//! [4a]
|
//! [4a]
|
||||||
|
|
||||||
//! [4b]
|
//! [4b]
|
||||||
AddDialog aDialog;
|
AddDialog aDialog;
|
||||||
aDialog.setWindowTitle(tr("Edit a Contact"));
|
aDialog.setWindowTitle(tr("Edit a Contact"));
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ void AddressWidget::removeEntry()
|
|||||||
QTableView *temp = static_cast<QTableView*>(currentWidget());
|
QTableView *temp = static_cast<QTableView*>(currentWidget());
|
||||||
QSortFilterProxyModel *proxy = static_cast<QSortFilterProxyModel*>(temp->model());
|
QSortFilterProxyModel *proxy = static_cast<QSortFilterProxyModel*>(temp->model());
|
||||||
QItemSelectionModel *selectionModel = temp->selectionModel();
|
QItemSelectionModel *selectionModel = temp->selectionModel();
|
||||||
|
|
||||||
QModelIndexList indexes = selectionModel->selectedRows();
|
QModelIndexList indexes = selectionModel->selectedRows();
|
||||||
|
|
||||||
foreach (QModelIndex index, indexes) {
|
foreach (QModelIndex index, indexes) {
|
||||||
@ -163,7 +163,7 @@ void AddressWidget::setupTabs()
|
|||||||
|
|
||||||
for (int i = 0; i < groups.size(); ++i) {
|
for (int i = 0; i < groups.size(); ++i) {
|
||||||
QString str = groups.at(i);
|
QString str = groups.at(i);
|
||||||
|
|
||||||
proxyModel = new QSortFilterProxyModel(this);
|
proxyModel = new QSortFilterProxyModel(this);
|
||||||
proxyModel->setSourceModel(table);
|
proxyModel->setSourceModel(table);
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ void AddressWidget::setupTabs()
|
|||||||
proxyModel->setFilterRegExp(QRegExp(newStr, Qt::CaseInsensitive));
|
proxyModel->setFilterRegExp(QRegExp(newStr, Qt::CaseInsensitive));
|
||||||
proxyModel->setFilterKeyColumn(0);
|
proxyModel->setFilterKeyColumn(0);
|
||||||
proxyModel->sort(0, Qt::AscendingOrder);
|
proxyModel->sort(0, Qt::AscendingOrder);
|
||||||
|
|
||||||
connect(tableView->selectionModel(),
|
connect(tableView->selectionModel(),
|
||||||
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
|
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
|
||||||
this, SIGNAL(selectionChanged(QItemSelection)));
|
this, SIGNAL(selectionChanged(QItemSelection)));
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user