Commit 060a9ee0 authored by dt's avatar dt
Browse files

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

parents e9069668 87fd5298
......@@ -136,7 +136,7 @@
interface.
\section1 Placing Widgets on the Form
\section1 Placing Widgets on The Form
In the \gui{Project Sidebar}, double-click on the \c{addressbook.ui} file.
The \QD plugin will be launched, allowing you to design your program's user
......@@ -266,7 +266,7 @@
organized way.
\section1 Placing Widgets on the Form
\section1 Placing Widgets on The Form
We shall continue with the form we had from the last chapter; we have the
labels and input fields set up, but we need to add push buttons to complete
......@@ -451,7 +451,7 @@
\image addressbook-tutorial-part3-linkedlist.png
\section1 Placing Widgets on the Form
\section1 Placing Widgets on The Form
So far, our application allows us to add new contacts. However, we also
need to traverse the existing contacts. To do so, we add two push buttons
......@@ -581,7 +581,7 @@
\o \c{EditingMode}.
\endlist
\section1 Placing Widgets on the Form
\section1 Placing Widgets on The Form
To edit and remove contacts, we need two push buttons. Drag them and name
them accordingly. Their \c objectName properties should be \c editButton
......@@ -711,6 +711,10 @@
\dots
\snippet examples/addressbook-sdk/part4/addressbook.cpp cancel
*/
/*!
\page tutorials-addressbook-sdk-part5.html
\previouspage Address Book 4 - Editing and Removing Addresses
\contentspage {Address Book Tutorial}{Contents}
......@@ -804,20 +808,60 @@
\section1 The AddressBook Class
To ensure that we can use \c FindDialog from within our \c AddressBook
class, we include \c finddialog.h in the \c addressbook.h file.
\snippet examples/addressbook-sdk/part5/addressbook.cpp include
\snippet examples/addressbook-sdk/part5/addressbook.h include
So far, all our address book features have a QPushButton and a
corresponding slot. Similarly, for the \gui Find feature, we have
\c findButton and \c findContact().
Within the \c AddressBook class's constructor, we instantiate our private
objects, \c findButton and \c findDialog:
\snippet examples/addressbook-sdk/part5/addressbook.h findContact
\dots
\snippet examples/addressbook-sdk/part5/addressbook.h findButton
Lastly, we declare the private variable, \c dialog, which we will use to
refer to an instance of \c FindDialog.
Once we have instantiated a dialog, we might want to use it more than once;
using a private variable allows us to refer to it from more than one place
in the class.
Within the \c AddressBook class's constructor, we insantiate our private
objects, \c findButton and \c dialog:
\snippet examples/addressbook-sdk/part5/addressbook.cpp private members
Next, we connect the \c{findButton}'s \l{QPushButton::}{clicked()} signal
to \c findContact().
\snippet examples/addressbook-sdk/part5/addressbook.cpp signal slot
Now, all that is left is the code for our \c findContact() function:
\snippet examples/addressbook-sdk/part5/addressbook.cpp findContact
We start out by displaying the \c FindDialog instance, \c dialog. This is
when the user enters a contact name to look up. Once the user clicks the
dialog's \c findButton, the dialog is hidden and the result code is set to
QDialog::Accepted. THis ensures that our \c if statement is always true.
We then proceed to extract the search string, which in this case is
\c contactName, using \c{FindDialog}'s \c getFindText() function. If the
contact exists in our address book, we display it immediately. Otherwise,
we display the QMessageBox shown below to indicate that their search
failed.
# image
The concept behind finding a contact only applies for cases where we have
more than two contacts in our address book. Hence, we implement this
behavior by modifying our \c{Navigation Mode} within our
\c updateInterface() function, by only enabling the \gui Find button when
we have more than two contacts.
\snippet examples/addressbook-sdk/part5/addressbook.cpp
\snippet examples/addressbook-sdk/part5/addressbook.cpp enable
*/
......@@ -830,6 +874,51 @@
\example examples/addressbook-sdk/part6
\title Address Book 6 - Loading and Saving
This chapter covers the file handling features of Qt that we used to write
loading and saving routines for the address book application.
# screenshot
Although browsing and searching for contacts are useful features, our
address book is not really ready for use until we can save existing
contacts and load them again at a later time. Qt provides a number of
classes for \l{Input/Output and Networking}{input and output}, but we have
chosen to use two which are simple to use in combination: QFile and
QDataStream.
A QFile object represents a file on disk that can be read from and written
to. QFile isa subclass of the more general QIODevice class which represents
many different kinds of devices.
A QDataStream object is used to serialize binary data so that it can be
stored in a QIODevice and retrieved again later. Reading from a QIODevice
and writing to it is as simple as opening the stream - with the respective
device as a parameter - and reading from or writing to it.
\section1 Placing Widgets on The Form
\section1 The AddressBook Class
We declare two public slots, \c saveToFile() and \c loadFromFile(), as well
as two QPushButton objects, \c loadButton and \c saveButton.
# code
In our constructor, we instantiate \c loadButton and \c saveButton.
Ideally, it would be more user-friendly to set the push buttons' labels to
"Load contacts from a file" and "Save contacts to a file". However, due to
the size of our push buttons, we set the labels to \gui{Load...} and
\gui{Save...}. Fortunately, Qt provides a simple way to set tooltips with
\l{QWidget::}{setToolTip()} and we use it in the following way for our push
buttons:
# code
*/
......
......@@ -41,10 +41,12 @@ AddressBook::AddressBook(QWidget *parent)
removeButton = ui->removeButton;
removeButton->setEnabled(false);
//! [private members]
findButton = new QPushButton;
findButton = ui->findButton;
dialog = new FindDialog;
//! [private members]
connect(addButton, SIGNAL(clicked()), this,
SLOT(addContact()));
......@@ -60,8 +62,10 @@ AddressBook::AddressBook(QWidget *parent)
SLOT(editContact()));
connect(removeButton, SIGNAL(clicked()), this,
SLOT(removeContact()));
//! [signal slot]
connect(findButton, SIGNAL(clicked()), this,
SLOT(findContact()));
//! [signal slot]
setWindowTitle(tr("Simple Address Book"));
}
......@@ -234,6 +238,9 @@ void AddressBook::updateInterface(Mode mode)
int number = contacts.size();
editButton->setEnabled(number >= 1);
removeButton->setEnabled(number >= 1);
//! [enable]
findButton->setEnabled(number > 2);
//! [enable]
nextButton->setEnabled(number > 1);
previousButton->setEnabled(number >1);
......
......@@ -32,7 +32,9 @@ public slots:
void removeContact();
void next();
void previous();
//! [findContact]
void findContact();
//! [findContact]
private:
Ui::AddressBook *ui;
......@@ -45,7 +47,9 @@ private:
QPushButton *removeButton;
QPushButton *nextButton;
QPushButton *previousButton;
//! [findButton]
QPushButton *findButton;
//! [findButton]
QLineEdit *nameLine;
QTextEdit *addressText;
......@@ -53,7 +57,9 @@ private:
QString oldName;
QString oldAddress;
Mode currentMode;
//! [dialog]
FindDialog *dialog;
//! [dialog]
};
#endif // ADDRESSBOOK_H
#include "finddialog.h"
#include "ui_finddialog.h"
#include <QMessageBox>
//! [constructor]
FindDialog::FindDialog(QWidget *parent) :
......@@ -17,7 +18,7 @@ FindDialog::FindDialog(QWidget *parent) :
connect(findButton, SIGNAL(clicked()), this, SLOT(findClicked()));
setWindowTItle(tr("Find a Contact"));
setWindowTitle(tr("Find a Contact"));
}
//! [constructor]
......
#include "addressbook.h"
#include "ui_addressbook.h"
AddressBook::AddressBook(QWidget *parent)
: QWidget(parent), ui(new Ui::AddressBook)
{
ui->setupUi(this);
}
AddressBook::~AddressBook()
{
delete ui;
}
#ifndef ADDRESSBOOK_H
#define ADDRESSBOOK_H
#include <QtGui/QWidget>
namespace Ui
{
class AddressBook;
}
class AddressBook : public QWidget
{
Q_OBJECT
public:
AddressBook(QWidget *parent = 0);
~AddressBook();
private:
Ui::AddressBook *ui;
};
#endif // ADDRESSBOOK_H
<ui version="4.0">
<class>AddressBook</class>
<widget class="QWidget" name="AddressBook" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle" >
<string>AddressBook</string>
</property>
</widget>
<layoutDefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>
#include <QtGui/QApplication>
#include "addressbook.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
AddressBook w;
w.show();
return a.exec();
}
#-------------------------------------------------
#
# Project created by QtCreator 2009-07-01T16:46:33
#
#-------------------------------------------------
TARGET = part6
TEMPLATE = app
SOURCES += main.cpp\
addressbook.cpp
HEADERS += addressbook.h
FORMS += addressbook.ui
......@@ -62,9 +62,10 @@ int qtGhVersion = QT_VERSION;
#endif
#if USE_QT_GUI
# include <QtGui/QWidget>
# include <QtGui/QPixmap>
# include <QtGui/QApplication>
# include <QtGui/QImage>
# include <QtGui/QPixmap>
# include <QtGui/QWidget>
#endif
#ifdef Q_OS_WIN
......@@ -1457,7 +1458,9 @@ static void qDumpQHashNode(QDumper &d)
static void qDumpQImage(QDumper &d)
{
const QImage &im = *reinterpret_cast<const QImage *>(d.data);
d.putItem("value", "(").put(im.width()).put("x").put(im.height()).put(")");
d.beginItem("value");
d.put("(").put(im.width()).put("x").put(im.height()).put(")");
d.endItem();
d.putItem("type", NS"QImage");
d.putItem("numchild", "1");
if (d.dumpChildren) {
......@@ -2234,7 +2237,9 @@ static void qDumpQObjectSlotList(QDumper &d)
static void qDumpQPixmap(QDumper &d)
{
const QPixmap &im = *reinterpret_cast<const QPixmap *>(d.data);
d.putItem("value", "(").put(im.width()).put("x").put(im.height()).put(")");
d.beginItem("value");
d.put("(").put(im.width()).put("x").put(im.height()).put(")");
d.endItem();
d.putItem("type", NS"QPixmap");
d.putItem("numchild", "0");
d.disarm();
......@@ -2455,7 +2460,7 @@ static void qDumpQVariant(QDumper &d)
d.putItem("value", "(invalid)");
} else if (value.isEmpty()) {
d.beginItem("value");
d.put("(").put(v.typeName()).put(") ").put(qPrintable(value));
d.put("(").put(v.typeName()).put(") ");
d.endItem();
} else {
QByteArray ba;
......@@ -2464,7 +2469,7 @@ static void qDumpQVariant(QDumper &d)
ba += ") ";
ba += qPrintable(value);
d.putItem("value", ba);
d.putItem("valueencoded", "4");
d.putItem("valueencoded", "5");
}
d.putItem("type", NS"QVariant");
d.putItem("numchild", (isInvalid ? "0" : "1"));
......@@ -3023,6 +3028,14 @@ static void handleProtocolVersion2and3(QDumper & d)
} // anonymous namespace
#if USE_QT_GUI
extern "C" Q_DECL_EXPORT
void *watchPoint(int x, int y)
{
return QApplication::widgetAt(x, y);
}
#endif
extern "C" Q_DECL_EXPORT
void *qDumpObjectData440(
int protocolVersion,
......@@ -3115,7 +3128,7 @@ void *qDumpObjectData440(
.put(""NS"QStringList=\"").put(sizeof(QStringList)).put("\",")
.put(""NS"QObject=\"").put(sizeof(QObject)).put("\",")
#if USE_QT_GUI
.put(""NS"QWidget=\"").put(sizeof(QWidget)<< "\",")
.put(""NS"QWidget=\"").put(sizeof(QWidget)).put("\",")
#endif
#ifdef Q_OS_WIN
.put("string=\"").put(sizeof(std::string)).put("\",")
......
TEMPLATE = lib
CONFIG += shared
QT = core
linux-* {
CONFIG -= release
CONFIG += debug
}
SOURCES=gdbmacros.cpp
true {
false {
DEFINES += USE_QT_GUI=0
QT = core
} else {
......
<!DOCTYPE QPH>
<QPH language="fr">
<phrase>
<source>debugger</source>
<target>débogueur</target>
</phrase>
<phrase>
<source>Start Debugger</source>
<target>Lancer le débogueur</target>
</phrase>
<phrase>
<source>Executable:</source>
<target>Exécutable:</target>
</phrase>
<phrase>
<source>Filter:</source>
<target>Filtre:</target>
</phrase>
<phrase>
<source>Clear</source>
<target>Effacer</target>
</phrase>
<phrase>
<source>Host and port:</source>
<target>Hôte et port:</target>
</phrase>
<phrase>
<source>Architecture:</source>
<target>Architecture:</target>
</phrase>
<phrase>
<source>Server start script:</source>
<target>Script de démarrage du serveur:</target>
</phrase>
<phrase>
<source>&amp;Undo</source>
<target>Annu&amp;ler</target>
</phrase>
<phrase>
<source>Add Bookmark</source>
<target>Ajouter un signet</target>
</phrase>
<phrase>
<source>Bookmark:</source>
<target>Signet:</target>
</phrase>
<phrase>
<source>Add in Folder:</source>
<target>Ajouter dans le dossier:</target>
</phrase>
<phrase>
<source>+</source>
<target>+</target>
</phrase>
<phrase>
<source>New Folder</source>
<target>Nouveau Dossier</target>
</phrase>
<phrase>
<source>Bookmarks</source>
<target>Signets</target>
</phrase>
<phrase>
<source>Rename Folder</source>
<target>Renommer le Dossier</target>
</phrase>
<phrase>
<source>Bookmark</source>
<target>Signet</target>
</phrase>
<phrase>
<source>Remove</source>
<target>Retirer</target>
</phrase>
<phrase>
<source>Delete Folder</source>
<target>Supprimer le Dossier</target>
</phrase>
<phrase>
<source>Show Bookmark</source>
<target>Afficher le Signet</target>
</phrase>
<phrase>
<source>Show Bookmark in New Tab</source>
<target>Afficher le Signet dans un Nouvel Onglet</target>
</phrase>
<phrase>
<source>Delete Bookmark</source>
<target>Supprimer le Signet</target>
</phrase>
<phrase>
<source>Rename Bookmark</source>
<target>Renommer le Signet</target>
</phrase>
<phrase>
<source>Add</source>
<target>Ajouter</target>
</phrase>
<phrase>
<source>Move Up</source>
<target>Vers le Haut</target>
</phrase>
<phrase>
<source>Move Down</source>
<target>Vers le Bas</target>
</phrase>
<phrase>
<source>Previous Bookmark</source>
<target>Signet Précédent</target>
</phrase>
<phrase>
<source>Next Bookmark</source>
<target>Signet Suivant</target>
</phrase>
<phrase>
<source>Condition:</source>
<target>Condition:</target>
</phrase>
<phrase>
<source>Working Directory:</source>
<target>Répertoire de Travail:</target>
</phrase>
<phrase>
<source>Environment</source>
<target>Environnement</target>
</phrase>
<phrase>
<source>Arguments</source>
<target>Arguments</target>
</phrase>
<phrase>
<source>Build directory:</source>
<target>Répertoire de compilation:</target>
</phrase>
<phrase>
<source>Path:</source>
<target>Chemin:</target>
</phrase>
<phrase>
<source>CodePaster Error</source>
<target>Erreur dans CodePaster</target>
</phrase>
<phrase>
<source>General</source>
<target>Général</target>
</phrase>
<phrase>
<source>Username:</source>
<target>Nom d&apos;utilisateur:</target>
</phrase>
<phrase>
<source>CodePaster</source>
<target>CodePaster</target>
</phrase>
<phrase>
<source>User interface</source>
<target>Interface utilisateur</target>
</phrase>
<phrase>
<source>&lt;unlimited&gt;</source>
<target>&lt;illimitée&gt;</target>
</phrase>
<phrase>
<source>Open Link</source>
<target>Ouvrir le Lien</target>
</phrase>
<phrase>
<source> [read only]</source>
<target> [lecture seule]</target>
</phrase>
<phrase>
<source> [directory]</source>
<target> [répertoire]</target>
</phrase>
<phrase>
<source>Close</source>
<target>Fermer</target>
</phrase>
<phrase>
<source>Close All</source>
<target>Fermer Tout</target>
</phrase>
<phrase>
<source>Failed!</source>
<target>Échec!</target>
</phrase>
<phrase>
<source>Proceed</source>
<target>Continuer</target>
</phrase>
<phrase>
<source>Cancel</source>
<target>Annuler</target>
</phrase>
<phrase>
<source>Make writable</source>
<target>Rendre Inscriptible</target>
</phrase>
<phrase>
<source>Qt Creator</source>
<target>Qt Creator</target>