diff options
author | Leena Miettinen <riitta-leena.miettinen@digia.com> | 2014-04-01 14:10:05 +0200 |
---|---|---|
committer | Leena Miettinen <riitta-leena.miettinen@digia.com> | 2014-04-01 14:26:03 +0200 |
commit | f0fc3af0a8f8ccdb76cfe6cd4de9dbf44e934fb2 (patch) | |
tree | 2202975c5586bd870b9ae4e253ee4a462e18d5a5 /doc | |
parent | b7336d18f04c06f5d3d940b13ad0c74a015904c9 (diff) | |
download | qt-creator-f0fc3af0a8f8ccdb76cfe6cd4de9dbf44e934fb2.tar.gz |
Doc: Delete obsolete doc examples
The tutorials that were based on the Addressbook and Battery Status examples
have been removed from the manual.
Change-Id: I3eb55e40d652205d66ebe9e901736d1971809186
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Diffstat (limited to 'doc')
46 files changed, 0 insertions, 4092 deletions
diff --git a/doc/examples/addressbook-sdk/part1/addressbook.cpp b/doc/examples/addressbook-sdk/part1/addressbook.cpp deleted file mode 100644 index cf752ffaa1..0000000000 --- a/doc/examples/addressbook-sdk/part1/addressbook.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -//! [class implementation] -#include "addressbook.h" -#include "ui_addressbook.h" - -AddressBook::AddressBook(QWidget *parent) - : QWidget(parent), ui(new Ui::AddressBookClass) -{ - ui->setupUi(this); -} - -AddressBook::~AddressBook() -{ - delete ui; -} -//! [class implementation] diff --git a/doc/examples/addressbook-sdk/part1/addressbook.h b/doc/examples/addressbook-sdk/part1/addressbook.h deleted file mode 100644 index 3b8e5d3711..0000000000 --- a/doc/examples/addressbook-sdk/part1/addressbook.h +++ /dev/null @@ -1,62 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -//! [class definition] -#ifndef ADDRESSBOOK_H -#define ADDRESSBOOK_H - -#include <QWidget> - -namespace Ui -{ - class AddressBookClass; -} - -class AddressBook : public QWidget -{ - Q_OBJECT - -public: - AddressBook(QWidget *parent = 0); - ~AddressBook(); - -private: - Ui::AddressBookClass *ui; -}; - -#endif // ADDRESSBOOK_H -//! [class definition] diff --git a/doc/examples/addressbook-sdk/part1/addressbook.ui b/doc/examples/addressbook-sdk/part1/addressbook.ui deleted file mode 100644 index f1262875eb..0000000000 --- a/doc/examples/addressbook-sdk/part1/addressbook.ui +++ /dev/null @@ -1,49 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>AddressBookClass</class> - <widget class="QWidget" name="AddressBookClass"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>356</width> - <height>261</height> - </rect> - </property> - <property name="windowTitle"> - <string>AddressBook</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="nameEdit"> - <property name="text"> - <string>Name:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="lineEdit"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="addressEdit"> - <property name="text"> - <string>Address:</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QTextEdit" name="textEdit"/> - </item> - </layout> - </item> - </layout> - </widget> - <layoutdefault spacing="6" margin="11"/> - <resources/> - <connections/> -</ui> diff --git a/doc/examples/addressbook-sdk/part1/main.cpp b/doc/examples/addressbook-sdk/part1/main.cpp deleted file mode 100644 index 6a79c3e206..0000000000 --- a/doc/examples/addressbook-sdk/part1/main.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -//! [main function] -#include <QApplication> -#include "addressbook.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - AddressBook w; - w.show(); - return a.exec(); -} -//! [main function] diff --git a/doc/examples/addressbook-sdk/part1/part1.pro b/doc/examples/addressbook-sdk/part1/part1.pro deleted file mode 100644 index bbbdde9130..0000000000 --- a/doc/examples/addressbook-sdk/part1/part1.pro +++ /dev/null @@ -1,16 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2009-03-06T12:30:35 -# -#------------------------------------------------- - -TARGET = addressbook -TEMPLATE = app - - -SOURCES += main.cpp\ - addressbook.cpp - -HEADERS += addressbook.h - -FORMS += addressbook.ui diff --git a/doc/examples/addressbook-sdk/part2/addressbook.cpp b/doc/examples/addressbook-sdk/part2/addressbook.cpp deleted file mode 100644 index 104380a670..0000000000 --- a/doc/examples/addressbook-sdk/part2/addressbook.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#include "addressbook.h" -#include "ui_addressbook.h" - -AddressBook::AddressBook(QWidget *parent) - : QWidget(parent), ui(new Ui::AddressBook) -{ - ui->setupUi(this); - - //! [setup fields] - ui->nameLine->setReadOnly(true); - ui->addressText->setReadOnly(true); - ui->submitButton->hide(); - ui->cancelButton->hide(); - //! [setup fields] - - //! [signal slot] - connect(ui->addButton, SIGNAL(clicked()), this, - SLOT(addContact())); - connect(ui->submitButton, SIGNAL(clicked()), this, - SLOT(submitContact())); - connect(ui->cancelButton, SIGNAL(clicked()), this, - SLOT(cancel())); - //! [signal slot] - - //! [window title] - setWindowTitle(tr("Simple Address Book")); - //! [window title] -} - -AddressBook::~AddressBook() -{ - delete ui; -} - -//! [addContact] -void AddressBook::addContact() -{ - oldName = ui->nameLine->text(); - oldAddress = ui->addressText->toPlainText(); - - ui->nameLine->clear(); - ui->addressText->clear(); - - ui->nameLine->setReadOnly(false); - ui->nameLine->setFocus(Qt::OtherFocusReason); - ui->addressText->setReadOnly(false); - - ui->addButton->setEnabled(false); - ui->submitButton->show(); - ui->cancelButton->show(); -} -//! [addContact] - -//! [submitContact part1] -void AddressBook::submitContact() -{ - QString name = ui->nameLine->text(); - QString address = ui->addressText->toPlainText(); - - if (name.isEmpty() || address.isEmpty()) { - QMessageBox::information(this, tr("Empty Field"), - tr("Please enter a name and address.")); - return; - } -//! [submitContact part1] - -//! [submitContact part2] - if (!contacts.contains(name)) { - contacts.insert(name, address); - QMessageBox::information(this, tr("Add Successful"), - tr("\"%1\" has been added to your address book.").arg(name)); - } else { - QMessageBox::information(this, tr("Add Unsuccessful"), - tr("Sorry, \"%1\" is already in your address book.").arg(name)); - return; - } -//! [submitContact part2] - -//! [submitContact part3] - if (contacts.isEmpty()) { - ui->nameLine->clear(); - ui->addressText->clear(); - } - - ui->nameLine->setReadOnly(true); - ui->addressText->setReadOnly(true); - ui->addButton->setEnabled(true); - ui->submitButton->hide(); - ui->cancelButton->hide(); -} -//! [submitContact part3] - -//! [cancel] -void AddressBook::cancel() -{ - ui->nameLine->setText(oldName); - ui->nameLine->setReadOnly(true); - - ui->addressText->setText(oldAddress); - ui->addressText->setReadOnly(true); - - ui->addButton->setEnabled(true); - ui->submitButton->hide(); - ui->cancelButton->hide(); -} -//! [cancel] diff --git a/doc/examples/addressbook-sdk/part2/addressbook.h b/doc/examples/addressbook-sdk/part2/addressbook.h deleted file mode 100644 index 2eab34cc90..0000000000 --- a/doc/examples/addressbook-sdk/part2/addressbook.h +++ /dev/null @@ -1,77 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#ifndef ADDRESSBOOK_H -#define ADDRESSBOOK_H - -//! [include] -#include <QWidget> -#include <QMap> -#include <QMessageBox> -//! [include] - -namespace Ui -{ - class AddressBook; -} - -class AddressBook : public QWidget -{ - Q_OBJECT - -public: - AddressBook(QWidget *parent = 0); - ~AddressBook(); - -//! [slot definition] -public slots: - void addContact(); - void submitContact(); - void cancel(); -//! [slot definition] - -private: - Ui::AddressBook *ui; - -//! [members] - QMap<QString, QString> contacts; - QString oldName; - QString oldAddress; -//! [members] -}; - -#endif // ADDRESSBOOK_H diff --git a/doc/examples/addressbook-sdk/part2/addressbook.ui b/doc/examples/addressbook-sdk/part2/addressbook.ui deleted file mode 100644 index f97e3f551f..0000000000 --- a/doc/examples/addressbook-sdk/part2/addressbook.ui +++ /dev/null @@ -1,87 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>AddressBook</class> - <widget class="QWidget" name="AddressBook"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>463</width> - <height>245</height> - </rect> - </property> - <property name="windowTitle"> - <string>AddressBook</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="nameLabel"> - <property name="text"> - <string>Name:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="nameLine"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="addressLabel"> - <property name="text"> - <string>Address:</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QTextEdit" name="addressText"/> - </item> - <item row="1" column="2"> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QPushButton" name="addButton"> - <property name="text"> - <string>Add</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="submitButton"> - <property name="text"> - <string>Submit</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="cancelButton"> - <property name="text"> - <string>Cancel</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - <layoutdefault spacing="6" margin="11"/> - <resources/> - <connections/> -</ui> diff --git a/doc/examples/addressbook-sdk/part2/main.cpp b/doc/examples/addressbook-sdk/part2/main.cpp deleted file mode 100644 index 6a79c3e206..0000000000 --- a/doc/examples/addressbook-sdk/part2/main.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -//! [main function] -#include <QApplication> -#include "addressbook.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - AddressBook w; - w.show(); - return a.exec(); -} -//! [main function] diff --git a/doc/examples/addressbook-sdk/part2/part2.pro b/doc/examples/addressbook-sdk/part2/part2.pro deleted file mode 100644 index bbbdde9130..0000000000 --- a/doc/examples/addressbook-sdk/part2/part2.pro +++ /dev/null @@ -1,16 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2009-03-06T12:30:35 -# -#------------------------------------------------- - -TARGET = addressbook -TEMPLATE = app - - -SOURCES += main.cpp\ - addressbook.cpp - -HEADERS += addressbook.h - -FORMS += addressbook.ui diff --git a/doc/examples/addressbook-sdk/part3/addressbook.cpp b/doc/examples/addressbook-sdk/part3/addressbook.cpp deleted file mode 100644 index 23c16175b9..0000000000 --- a/doc/examples/addressbook-sdk/part3/addressbook.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#include "addressbook.h" -#include "ui_addressbook.h" - -AddressBook::AddressBook(QWidget *parent) - : QWidget(parent), ui(new Ui::AddressBook) -{ - ui->setupUi(this); - - ui->nameLine->setReadOnly(true); - ui->addressText->setReadOnly(true); - ui->addButton = ui->addButton; - ui->submitButton->hide(); - ui->cancelButton->hide(); - -//! [setup fields] - ui->nextButton->setEnabled(false); - ui->previousButton->setEnabled(false); -//! [setup fields] - - connect(ui->addButton, SIGNAL(clicked()), this, - SLOT(addContact())); - connect(ui->submitButton, SIGNAL(clicked()), this, - SLOT(submitContact())); - connect(ui->cancelButton, SIGNAL(clicked()), this, - SLOT(cancel())); -//! [signal slot] - connect(ui->nextButton, SIGNAL(clicked()), this, - SLOT(next())); - connect(ui->previousButton, SIGNAL(clicked()), this, - SLOT(previous())); -//! [signal slot] - - setWindowTitle(tr("Simple Address Book")); -} - -AddressBook::~AddressBook() -{ - delete ui; -} - -void AddressBook::addContact() -{ - oldName = ui->nameLine->text(); - oldAddress = ui->addressText->toPlainText(); - - ui->nameLine->clear(); - ui->addressText->clear(); - - ui->nameLine->setReadOnly(false); - ui->nameLine->setFocus(Qt::OtherFocusReason); - ui->addressText->setReadOnly(false); - - ui->addButton->setEnabled(false); -//! [disable navigation] - ui->nextButton->setEnabled(false); - ui->previousButton->setEnabled(false); -//! [disable navigation] - ui->submitButton->show(); - ui->cancelButton->show(); -} - -void AddressBook::submitContact() -{ - QString name = ui->nameLine->text(); - QString address = ui->addressText->toPlainText(); - - if (name.isEmpty() || address.isEmpty()) { - QMessageBox::information(this, tr("Empty Field"), - tr("Please enter a name and address.")); - return; - } - - if (!contacts.contains(name)) { - contacts.insert(name, address); - QMessageBox::information(this, tr("Add Successful"), - tr("\"%1\" has been added to your address book.").arg(name)); - } else { - QMessageBox::information(this, tr("Add Unsuccessful"), - tr("Sorry, \"%1\" is already in your address book.").arg(name)); - return; - } - - if (contacts.isEmpty()) { - ui->nameLine->clear(); - ui->addressText->clear(); - } - - ui->nameLine->setReadOnly(true); - ui->addressText->setReadOnly(true); - ui->addButton->setEnabled(true); - -//! [enable navigation] - int number = contacts.size(); - ui->nextButton->setEnabled(number > 1); - ui->previousButton->setEnabled(number > 1); -//! [enable navigation] - ui->submitButton->hide(); - ui->cancelButton->hide(); -} - -void AddressBook::cancel() -{ - ui->nameLine->setText(oldName); - ui->nameLine->setReadOnly(true); - - ui->addressText->setText(oldAddress); - ui->addressText->setReadOnly(true); - ui->addButton->setEnabled(true); - - int number = contacts.size(); - ui->nextButton->setEnabled(number > 1); - ui->previousButton->setEnabled(number > 1); - - ui->submitButton->hide(); - ui->cancelButton->hide(); -} - -//! [next] -void AddressBook::next() -{ - QString name = ui->nameLine->text(); - QMap<QString, QString>::iterator i = contacts.find(name); - - if (i != contacts.end()) - i++; - if (i == contacts.end()) - i = contacts.begin(); - - ui->nameLine->setText(i.key()); - ui->addressText->setText(i.value()); -} -//! [next] - -//! [previous] -void AddressBook::previous() -{ - QString name = ui->nameLine->text(); - QMap<QString, QString>::iterator i = contacts.find(name); - - if (i == contacts.end()) { - ui->nameLine->clear(); - ui->addressText->clear(); - return; - } - - if (i == contacts.begin()) - i = contacts.end(); - - i--; - ui->nameLine->setText(i.key()); - ui->addressText->setText(i.value()); -} -//! [previous] diff --git a/doc/examples/addressbook-sdk/part3/addressbook.h b/doc/examples/addressbook-sdk/part3/addressbook.h deleted file mode 100644 index b573311d01..0000000000 --- a/doc/examples/addressbook-sdk/part3/addressbook.h +++ /dev/null @@ -1,74 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#ifndef ADDRESSBOOK_H -#define ADDRESSBOOK_H - -#include <QWidget> -#include <QMessageBox> -#include <QMap> - -namespace Ui -{ - class AddressBook; -} - -class AddressBook : public QWidget -{ - Q_OBJECT - -public: - AddressBook(QWidget *parent = 0); - ~AddressBook(); - -public slots: - void addContact(); - void submitContact(); - void cancel(); -//! [slot definition] - void next(); - void previous(); -//! [slot definition] - -private: - Ui::AddressBook *ui; - QMap<QString, QString> contacts; - QString oldName; - QString oldAddress; -}; - -#endif // ADDRESSBOOK_H diff --git a/doc/examples/addressbook-sdk/part3/addressbook.ui b/doc/examples/addressbook-sdk/part3/addressbook.ui deleted file mode 100644 index 33f99cc409..0000000000 --- a/doc/examples/addressbook-sdk/part3/addressbook.ui +++ /dev/null @@ -1,105 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>AddressBook</class> - <widget class="QWidget" name="AddressBook"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>498</width> - <height>333</height> - </rect> - </property> - <property name="windowTitle"> - <string>AddressBook</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="nameLabel"> - <property name="text"> - <string>Name:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="nameLine"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="addressLabel"> - <property name="text"> - <string>Address:</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QTextEdit" name="addressText"/> - </item> - <item row="1" column="2"> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QPushButton" name="addButton"> - <property name="text"> - <string>Add</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="submitButton"> - <property name="text"> - <string>Submit</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="cancelButton"> - <property name="text"> - <string>Cancel</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="2" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QPushButton" name="nextButton"> - <property name="text"> - <string>Previous</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="previousButton"> - <property name="text"> - <string>Next</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - <layoutdefault spacing="6" margin="11"/> - <resources/> - <connections/> -</ui> diff --git a/doc/examples/addressbook-sdk/part3/main.cpp b/doc/examples/addressbook-sdk/part3/main.cpp deleted file mode 100644 index dcc63bf3b5..0000000000 --- a/doc/examples/addressbook-sdk/part3/main.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#include <QApplication> -#include "addressbook.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - AddressBook w; - w.show(); - return a.exec(); -} diff --git a/doc/examples/addressbook-sdk/part3/part3.pro b/doc/examples/addressbook-sdk/part3/part3.pro deleted file mode 100644 index 5640aaa1d3..0000000000 --- a/doc/examples/addressbook-sdk/part3/part3.pro +++ /dev/null @@ -1,16 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2009-06-04T13:35:14 -# -#------------------------------------------------- - -TARGET = part3 -TEMPLATE = app - - -SOURCES += main.cpp\ - addressbook.cpp - -HEADERS += addressbook.h - -FORMS += addressbook.ui diff --git a/doc/examples/addressbook-sdk/part4/addressbook.cpp b/doc/examples/addressbook-sdk/part4/addressbook.cpp deleted file mode 100644 index 2c02eb26bd..0000000000 --- a/doc/examples/addressbook-sdk/part4/addressbook.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#include "addressbook.h" -#include "ui_addressbook.h" - -AddressBook::AddressBook(QWidget *parent) - : QWidget(parent), ui(new Ui::AddressBook) -{ - ui->setupUi(this); - - ui->nameLine->setReadOnly(true); - ui->addressText->setReadOnly(true); - ui->submitButton->hide(); - ui->cancelButton->hide(); - ui->nextButton->setEnabled(false); - ui->previousButton->setEnabled(false); - -//! [extract objects] - ui->editButton->setEnabled(false); - ui->removeButton->setEnabled(false); -//! [extract objects] - - connect(ui->addButton, SIGNAL(clicked()), this, - SLOT(addContact())); - connect(ui->submitButton, SIGNAL(clicked()), this, - SLOT(submitContact())); - connect(ui->cancelButton, SIGNAL(clicked()), this, - SLOT(cancel())); - connect(ui->nextButton, SIGNAL(clicked()), this, - SLOT(next())); - connect(ui->previousButton, SIGNAL(clicked()), this, - SLOT(previous())); -//! [signal slot] - connect(ui->editButton, SIGNAL(clicked()), this, - SLOT(editContact())); - connect(ui->removeButton, SIGNAL(clicked()), this, - SLOT(removeContact())); -//! [signal slot] - - setWindowTitle(tr("Simple Address Book")); -} - -AddressBook::~AddressBook() -{ - delete ui; -} - -//! [addContact] -void AddressBook::addContact() -{ - oldName = ui->nameLine->text(); - oldAddress = ui->addressText->toPlainText(); - - ui->nameLine->clear(); - ui->addressText->clear(); - - updateInterface(AddingMode); -} -//! [addContact] - -//! [submitContact part1] -void AddressBook::submitContact() -{ -//! [submitContact part1] - QString name = ui->nameLine->text(); - QString address = ui->addressText->toPlainText(); - - if (name.isEmpty() || address.isEmpty()) { - QMessageBox::information(this, tr("Empty Field"), - tr("Please enter a name and address.")); - } - -//! [submitContact part2] - if (currentMode == AddingMode) { - - if (!contacts.contains(name)) { - contacts.insert(name, address); - QMessageBox::information(this, tr("Add Successful"), - tr("\"%1\" has been added to your address book.").arg(name)); - } else { - QMessageBox::information(this, tr("Add Unsuccessful"), - tr("Sorry, \"%1\" is already in your address book.").arg(name)); - return; - } -//! [submitContact part2] - -//! [submitContact part3] - } else if (currentMode == EditingMode) { - - if (oldName != name) { - if (!contacts.contains(name)) { - QMessageBox::information(this, tr("Edit Successful"), - tr("\"%1\" has been edited in your address book.").arg(oldName)); - contacts.remove(oldName); - contacts.insert(name, address); - } else { - QMessageBox::information(this, tr("Edit Unsuccessful"), - tr("Sorry, \"%1\" is already in your address book.").arg(name)); - return; - } - } else if (oldAddress != address) { - QMessageBox::information(this, tr("Edit Successful"), - tr("\"%1\" has been edited in your address book.").arg(name)); - contacts[name] = address; - } - } - updateInterface(NavigationMode); -} -//! [submitContact part3] - -//! [cancel] -void AddressBook::cancel() -{ - ui->nameLine->setText(oldName); - ui->nameLine->setReadOnly(true); - - updateInterface(NavigationMode); -} -//! [cancel] - -void AddressBook::next() -{ - QString name = ui->nameLine->text(); - QMap<QString, QString>::iterator i = contacts.find(name); - - if (i != contacts.end()) - i++; - if (i == contacts.end()) - i = contacts.begin(); - - ui->nameLine->setText(i.key()); - ui->addressText->setText(i.value()); -} - -void AddressBook::previous() -{ - QString name = ui->nameLine->text(); - QMap<QString, QString>::iterator i = contacts.find(name); - - if (i == contacts.end()) { - ui->nameLine->clear(); - ui->addressText->clear(); - return; - } - - if (i == contacts.begin()) - i = contacts.end(); - - i--; - ui->nameLine->setText(i.key()); - ui->addressText->setText(i.value()); -} - -//! [editContact] -void AddressBook::editContact() -{ - oldName = ui->nameLine->text(); - oldAddress = ui->addressText->toPlainText(); - - updateInterface(EditingMode); -} -//! [editContact] - -//! [removeContact] -void AddressBook::removeContact() -{ - QString name = ui->nameLine->text(); - QString address = ui->addressText->toPlainText(); - - if (contacts.contains(name)) { - int button = QMessageBox::question(this, - tr("Confirm Remove"), - tr("Are you sure you want to remove \"%1\"?").arg(name), - QMessageBox::Yes | QMessageBox::No); - - if (button == QMessageBox::Yes) { - previous(); - contacts.remove(name); - - QMessageBox::information(this, tr("Remove Successful"), - tr("\"%1\" has been removed from your address book.").arg(name)); - } - } - - updateInterface(NavigationMode); -} -//! [removeContact] - -//! [updateInterface part1] -void AddressBook::updateInterface(Mode mode) -{ - currentMode = mode; - - switch (currentMode) { - - case AddingMode: - case EditingMode: - - ui->nameLine->setReadOnly(false); - ui->nameLine->setFocus(Qt::OtherFocusReason); - ui->addressText->setReadOnly(false); - - ui->addButton->setEnabled(false); - ui->editButton->setEnabled(false); - ui->removeButton->setEnabled(false); - - ui->nextButton->setEnabled(false); - ui->previousButton->setEnabled(false); - - ui->submitButton->show(); - ui->cancelButton->show(); - break; -//! [updateInterface part1] - -//! [updateInterface part2] - case NavigationMode: - - if (contacts.isEmpty()) { - ui->nameLine->clear(); - ui->addressText->clear(); - } - - ui->nameLine->setReadOnly(true); - ui->addressText->setReadOnly(true); - ui->addButton->setEnabled(true); - - int number = contacts.size(); - ui->editButton->setEnabled(number >= 1); - ui->removeButton->setEnabled(number >= 1); - ui->nextButton->setEnabled(number > 1); - ui->previousButton->setEnabled(number >1); - - ui->submitButton->hide(); - ui->cancelButton->hide(); - break; - } -} -//! [updateInterface part2] diff --git a/doc/examples/addressbook-sdk/part4/addressbook.h b/doc/examples/addressbook-sdk/part4/addressbook.h deleted file mode 100644 index 693362ef1f..0000000000 --- a/doc/examples/addressbook-sdk/part4/addressbook.h +++ /dev/null @@ -1,87 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#ifndef ADDRESSBOOK_H -#define ADDRESSBOOK_H - -#include <QWidget> -#include <QMessageBox> -#include <QMap> - - -namespace Ui -{ - class AddressBook; -} - -class AddressBook : public QWidget -{ - Q_OBJECT - -public: - AddressBook(QWidget *parent = 0); -//! [enum] - enum Mode { NavigationMode, AddingMode, EditingMode }; -//! [enum] - ~AddressBook(); - -public slots: - void addContact(); - void submitContact(); - void cancel(); -//! [slot definition] - void editContact(); - void removeContact(); -//! [slot definition] - void next(); - void previous(); - -private: - Ui::AddressBook *ui; -//! [updateInterface] - void updateInterface(Mode mode); -//! [updateInterface] - - QMap<QString, QString> contacts; - QString oldName; - QString oldAddress; -//! [current mode] - Mode currentMode; -//! [current mode] -}; - -#endif // ADDRESSBOOK_H diff --git a/doc/examples/addressbook-sdk/part4/addressbook.ui b/doc/examples/addressbook-sdk/part4/addressbook.ui deleted file mode 100644 index 44b4940ac9..0000000000 --- a/doc/examples/addressbook-sdk/part4/addressbook.ui +++ /dev/null @@ -1,119 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>AddressBook</class> - <widget class="QWidget" name="AddressBook"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>472</width> - <height>294</height> - </rect> - </property> - <property name="windowTitle"> - <string>AddressBook</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="nameLabel"> - <property name="text"> - <string>Name:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="nameLine"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="addressLabel"> - <property name="text"> - <string>Address:</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QTextEdit" name="addressText"/> - </item> - <item row="1" column="2"> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QPushButton" name="addButton"> - <property name="text"> - <string>Add</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="submitButton"> - <property name="text"> - <string>Submit</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="cancelButton"> - <property name="text"> - <string>Cancel</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="editButton"> - <property name="text"> - <string>Edit</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="removeButton"> - <property name="text"> - <string>Remove</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="2" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QPushButton" name="nextButton"> - <property name="text"> - <string>Previous</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="previousButton"> - <property name="text"> - <string>Next</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - <layoutdefault spacing="6" margin="11"/> - <resources/> - <connections/> -</ui> diff --git a/doc/examples/addressbook-sdk/part4/main.cpp b/doc/examples/addressbook-sdk/part4/main.cpp deleted file mode 100644 index dcc63bf3b5..0000000000 --- a/doc/examples/addressbook-sdk/part4/main.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#include <QApplication> -#include "addressbook.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - AddressBook w; - w.show(); - return a.exec(); -} diff --git a/doc/examples/addressbook-sdk/part4/part4.pro b/doc/examples/addressbook-sdk/part4/part4.pro deleted file mode 100644 index 8c34931ed3..0000000000 --- a/doc/examples/addressbook-sdk/part4/part4.pro +++ /dev/null @@ -1,16 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2009-06-05T16:03:06 -# -#------------------------------------------------- - -TARGET = part4 -TEMPLATE = app - - -SOURCES += main.cpp\ - addressbook.cpp - -HEADERS += addressbook.h - -FORMS += addressbook.ui diff --git a/doc/examples/addressbook-sdk/part5/addressbook.cpp b/doc/examples/addressbook-sdk/part5/addressbook.cpp deleted file mode 100644 index 9e91bb1fb1..0000000000 --- a/doc/examples/addressbook-sdk/part5/addressbook.cpp +++ /dev/null @@ -1,279 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#include "addressbook.h" -#include "ui_addressbook.h" - -AddressBook::AddressBook(QWidget *parent) - : QWidget(parent), ui(new Ui::AddressBook) -{ - ui->setupUi(this); - - ui->nameLine->setReadOnly(true); - ui->addressText->setReadOnly(true); - ui->submitButton->hide(); - ui->cancelButton->hide(); - ui->nextButton->setEnabled(false); - ui->previousButton->setEnabled(false); - ui->editButton->setEnabled(false); - ui->removeButton->setEnabled(false); - - connect(ui->addButton, SIGNAL(clicked()), this, - SLOT(addContact())); - connect(ui->submitButton, SIGNAL(clicked()), this, - SLOT(submitContact())); - connect(ui->cancelButton, SIGNAL(clicked()), this, - SLOT(cancel())); - connect(ui->nextButton, SIGNAL(clicked()), this, - SLOT(next())); - connect(ui->previousButton, SIGNAL(clicked()), this, - SLOT(previous())); - connect(ui->editButton, SIGNAL(clicked()), this, - SLOT(editContact())); - connect(ui->removeButton, SIGNAL(clicked()), this, - SLOT(removeContact())); -//! [signal slot] - connect(ui->findButton, SIGNAL(clicked()), this, - SLOT(findContact())); -//! [signal slot] - - setWindowTitle(tr("Simple Address Book")); -} - -AddressBook::~AddressBook() -{ - delete ui; -} - -void AddressBook::addContact() -{ - oldName = ui->nameLine->text(); - oldAddress = ui->addressText->toPlainText(); - - ui->nameLine->clear(); - ui->addressText->clear(); - - updateInterface(AddingMode); -} - -void AddressBook::submitContact() -{ - QString name = ui->nameLine->text(); - QString address = ui->addressText->toPlainText(); - - if (name.isEmpty() || address.isEmpty()) { - QMessageBox::information(this, tr("Empty Field"), - tr("Please enter a name and address.")); - updateInterface(NavigationMode); - return; - } - - if (currentMode == AddingMode) { - - if (!contacts.contains(name)) { - contacts.insert(name, address); - QMessageBox::information(this, tr("Add Successful"), - tr("\"%1\" has been added to your address book.").arg(name)); - } else { - QMessageBox::information(this, tr("Add Unsuccessful"), - tr("Sorry, \"%1\" is already in your address book.").arg(name)); - } - - } else if (currentMode == EditingMode) { - - if (oldName != name) { - if (!contacts.contains(name)) { - QMessageBox::information(this, tr("Edit Successful"), - tr("\"%1\" has been edited in your address book.").arg(oldName)); - contacts.remove(oldName); - contacts.insert(name, address); - } else { - QMessageBox::information(this, tr("Edit Unsuccessful"), - tr("Sorry, \"%1\" is already in your address book.").arg(name)); - } - } else if (oldAddress != address) { - QMessageBox::information(this, tr("Edit Successful"), - tr("\"%1\" has been edited in your address book.").arg(name)); - contacts[name] = address; - } - } - updateInterface(NavigationMode); -} - -void AddressBook::cancel() -{ - ui->nameLine->setText(oldName); - ui->nameLine->setReadOnly(true); - - updateInterface(NavigationMode); -} - -void AddressBook::next() -{ - QString name = ui->nameLine->text(); - QMap<QString, QString>::iterator i = contacts.find(name); - - if (i != contacts.end()) - i++; - if (i == contacts.end()) - i = contacts.begin(); - - ui->nameLine->setText(i.key()); - ui->addressText->setText(i.value()); -} - -void AddressBook::previous() -{ - QString name = ui->nameLine->text(); - QMap<QString, QString>::iterator i = contacts.find(name); - - if (i == contacts.end()) { - ui->nameLine->clear(); - ui->addressText->clear(); - return; - } - - if (i == contacts.begin()) - i = contacts.end(); - - i--; - ui->nameLine->setText(i.key()); - ui->addressText->setText(i.value()); -} - -void AddressBook::editContact() -{ - oldName = ui->nameLine->text(); - oldAddress = ui->addressText->toPlainText(); - - updateInterface(EditingMode); -} - -void AddressBook::removeContact() -{ - QString name = ui->nameLine->text(); - QString address = ui->addressText->toPlainText(); - - if (contacts.contains(name)) { - int button = QMessageBox::question(this, - tr("Confirm Remove"), - tr("Are you sure you want to remove \"%1\"?").arg(name), - QMessageBox::Yes | QMessageBox::No); - - if (button == QMessageBox::Yes) { - previous(); - contacts.remove(name); - - QMessageBox::information(this, tr("Remove Successful"), - tr("\"%1\" has been removed from your address book.").arg(name)); - } - } - - updateInterface(NavigationMode); -} - -void AddressBook::updateInterface(Mode mode) -{ - currentMode = mode; - - switch (currentMode) { - - case AddingMode: - case EditingMode: - - ui->nameLine->setReadOnly(false); - ui->nameLine->setFocus(Qt::OtherFocusReason); - ui->addressText->setReadOnly(false); - - ui->addButton->setEnabled(false); - ui->editButton->setEnabled(false); - ui->removeButton->setEnabled(false); - - ui->nextButton->setEnabled(false); - ui->previousButton->setEnabled(false); - - ui->submitButton->show(); - ui->cancelButton->show(); - break; - - case NavigationMode: - - if (contacts.isEmpty()) { - ui->nameLine->clear(); - ui->addressText->clear(); - } - - ui->nameLine->setReadOnly(true); - ui->addressText->setReadOnly(true); - ui->addButton->setEnabled(true); - - int number = contacts.size(); - ui->editButton->setEnabled(number >= 1); - ui->removeButton->setEnabled(number >= 1); -//! [enable] - ui->findButton->setEnabled(number > 2); -//! [enable] - ui->nextButton->setEnabled(number > 1); - ui->previousButton->setEnabled(number >1); - - ui->submitButton->hide(); - ui->cancelButton->hide(); - break; - } -} - -//! [findContact] -void AddressBook::findContact() -{ - FindDialog dialog; - - if (dialog.exec() == QDialog::Accepted) { - QString contactName = dialog.findText(); - - if (contacts.contains(contactName)) { - ui->nameLine->setText(contactName); - ui->addressText->setText(contacts.value(contactName)); - } else { - QMessageBox::information(this, tr("Contact Not Found"), - tr("Sorry, \"%1\" is not in your address book.").arg(contactName)); - return; - } - } - - updateInterface(NavigationMode); -} -//! [findContact] diff --git a/doc/examples/addressbook-sdk/part5/addressbook.h b/doc/examples/addressbook-sdk/part5/addressbook.h deleted file mode 100644 index 6c95245029..0000000000 --- a/doc/examples/addressbook-sdk/part5/addressbook.h +++ /dev/null @@ -1,84 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#ifndef ADDRESSBOOK_H -#define ADDRESSBOOK_H - -#include <QWidget> -#include <QMessageBox> -#include <QMap> -//! [include] -#include "finddialog.h" -//! [include] - -namespace Ui -{ - class AddressBook; -} - -class AddressBook : public QWidget -{ - Q_OBJECT - -public: - AddressBook(QWidget *parent = 0); - enum Mode { NavigationMode, AddingMode, EditingMode }; - ~AddressBook(); - -public slots: - void addContact(); - void submitContact(); - void cancel(); - void editContact(); - void removeContact(); - void next(); - void previous(); -//! [slot definition] - void findContact(); -//! [slot definition] - -private: - Ui::AddressBook *ui; - void updateInterface(Mode mode); - - QMap<QString, QString> contacts; - QString oldName; - QString oldAddress; - Mode currentMode; -}; - -#endif // ADDRESSBOOK_H diff --git a/doc/examples/addressbook-sdk/part5/addressbook.ui b/doc/examples/addressbook-sdk/part5/addressbook.ui deleted file mode 100644 index cbee039e03..0000000000 --- a/doc/examples/addressbook-sdk/part5/addressbook.ui +++ /dev/null @@ -1,126 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>AddressBook</class> - <widget class="QWidget" name="AddressBook"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>470</width> - <height>253</height> - </rect> - </property> - <property name="windowTitle"> - <string>AddressBook</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="nameLabel"> - <property name="text"> - <string>Name:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="nameLine"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="addressLabel"> - <property name="text"> - <string>Address:</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QTextEdit" name="addressText"/> - </item> - <item row="1" column="2"> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QPushButton" name="addButton"> - <property name="text"> - <string>Add</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="submitButton"> - <property name="text"> - <string>Submit</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="cancelButton"> - <property name="text"> - <string>Cancel</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="editButton"> - <property name="text"> - <string>Edit</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="removeButton"> - <property name="text"> - <string>Remove</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="findButton"> - <property name="text"> - <string>Find</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="2" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QPushButton" name="nextButton"> - <property name="text"> - <string>Previous</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="previousButton"> - <property name="text"> - <string>Next</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - <layoutdefault spacing="6" margin="11"/> - <resources/> - <connections/> -</ui> diff --git a/doc/examples/addressbook-sdk/part5/finddialog.cpp b/doc/examples/addressbook-sdk/part5/finddialog.cpp deleted file mode 100644 index 4ae21a2e45..0000000000 --- a/doc/examples/addressbook-sdk/part5/finddialog.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#include "finddialog.h" -#include "ui_finddialog.h" -#include <QMessageBox> - -//! [constructor] -FindDialog::FindDialog(QWidget *parent) : - QDialog(parent), - m_ui(new Ui::FindDialog) -{ - m_ui->setupUi(this); - - connect(m_ui->findButton, SIGNAL(clicked()), this, SLOT(findClicked())); - - setWindowTitle(tr("Find a Contact")); -} -//! [constructor] - -FindDialog::~FindDialog() -{ - delete m_ui; -} - -//! [findClicked] -void FindDialog::findClicked() -{ - QString text = m_ui->lineEdit->text(); - - if (text.isEmpty()) { - QMessageBox::information(this, tr("Empty Field"), - tr("Please enter a name.")); - reject(); - } else { - accept(); - } -} -//! [findClicked] - -//! [findText] -QString FindDialog::findText() -{ - return m_ui->lineEdit->text(); -} -//! [findText] diff --git a/doc/examples/addressbook-sdk/part5/finddialog.h b/doc/examples/addressbook-sdk/part5/finddialog.h deleted file mode 100644 index 868c080375..0000000000 --- a/doc/examples/addressbook-sdk/part5/finddialog.h +++ /dev/null @@ -1,69 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#ifndef FINDDIALOG_H -#define FINDDIALOG_H - -#include <QDialog> -#include <QLineEdit> -#include <QPushButton> - -namespace Ui { - class FindDialog; -} - -class FindDialog : public QDialog { - Q_OBJECT -public: - FindDialog(QWidget *parent = 0); - ~FindDialog(); -//! [findText] - QString findText(); -//! [findText] - -//! [findClicked] -public slots: - void findClicked(); -//! [findClicked] - -//! [private members] -private: - Ui::FindDialog *m_ui; -//! [private members] -}; - -#endif // FINDDIALOG_H diff --git a/doc/examples/addressbook-sdk/part5/finddialog.ui b/doc/examples/addressbook-sdk/part5/finddialog.ui deleted file mode 100644 index 3f39d27d59..0000000000 --- a/doc/examples/addressbook-sdk/part5/finddialog.ui +++ /dev/null @@ -1,59 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>FindDialog</class> - <widget class="QDialog" name="FindDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>486</width> - <height>65</height> - </rect> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Enter the name of a contact:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit"/> - </item> - <item> - <widget class="QPushButton" name="findButton"> - <property name="text"> - <string>Find</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>findButton</sender> - <signal>clicked()</signal> - <receiver>FindDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>415</x> - <y>42</y> - </hint> - <hint type="destinationlabel"> - <x>385</x> - <y>50</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/doc/examples/addressbook-sdk/part5/main.cpp b/doc/examples/addressbook-sdk/part5/main.cpp deleted file mode 100644 index dcc63bf3b5..0000000000 --- a/doc/examples/addressbook-sdk/part5/main.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#include <QApplication> -#include "addressbook.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - AddressBook w; - w.show(); - return a.exec(); -} diff --git a/doc/examples/addressbook-sdk/part5/part5.pro b/doc/examples/addressbook-sdk/part5/part5.pro deleted file mode 100644 index f41e5e85f1..0000000000 --- a/doc/examples/addressbook-sdk/part5/part5.pro +++ /dev/null @@ -1,12 +0,0 @@ -# ------------------------------------------------- -# Project created by QtCreator 2009-06-08T17:25:28 -# ------------------------------------------------- -TARGET = part5 -TEMPLATE = app -SOURCES += main.cpp \ - addressbook.cpp \ - finddialog.cpp -HEADERS += addressbook.h \ - finddialog.h -FORMS += addressbook.ui \ - finddialog.ui diff --git a/doc/examples/addressbook-sdk/part6/addressbook.cpp b/doc/examples/addressbook-sdk/part6/addressbook.cpp deleted file mode 100644 index 64603bd0a1..0000000000 --- a/doc/examples/addressbook-sdk/part6/addressbook.cpp +++ /dev/null @@ -1,351 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#include <QFileDialog> - -#include "addressbook.h" -#include "ui_addressbook.h" - -AddressBook::AddressBook(QWidget *parent) - : QWidget(parent), ui(new Ui::AddressBook) -{ - ui->setupUi(this); - - ui->nameLine->setReadOnly(true); - ui->addressText->setReadOnly(true); - ui->submitButton->hide(); - ui->cancelButton->hide(); - ui->nextButton->setEnabled(false); - ui->previousButton->setEnabled(false); - ui->editButton->setEnabled(false); - ui->removeButton->setEnabled(false); - - connect(ui->addButton, SIGNAL(clicked()), this, - SLOT(addContact())); - connect(ui->submitButton, SIGNAL(clicked()), this, - SLOT(submitContact())); - connect(ui->cancelButton, SIGNAL(clicked()), this, - SLOT(cancel())); - connect(ui->nextButton, SIGNAL(clicked()), this, - SLOT(next())); - connect(ui->previousButton, SIGNAL(clicked()), this, - SLOT(previous())); - connect(ui->editButton, SIGNAL(clicked()), this, - SLOT(editContact())); - connect(ui->removeButton, SIGNAL(clicked()), this, - SLOT(removeContact())); - connect(ui->findButton, SIGNAL(clicked()), this, - SLOT(findContact())); - //! [connectSlots] - connect(ui->loadButton, SIGNAL(clicked()), this, - SLOT(loadFromFile())); - connect(ui->saveButton, SIGNAL(clicked()), this, - SLOT(saveToFile())); - //! [connectSlots] - - setWindowTitle(tr("Simple Address Book")); -} - -AddressBook::~AddressBook() -{ - delete ui; -} - -void AddressBook::addContact() -{ - oldName = ui->nameLine->text(); - oldAddress = ui->addressText->toPlainText(); - - ui->nameLine->clear(); - ui->addressText->clear(); - - updateInterface(AddingMode); -} - -void AddressBook::submitContact() -{ - QString name = ui->nameLine->text(); - QString address = ui->addressText->toPlainText(); - - if (name.isEmpty() || address.isEmpty()) { - QMessageBox::information(this, tr("Empty Field"), - tr("Please enter a name and address.")); - updateInterface(NavigationMode); - return; - } - - if (currentMode == AddingMode) { - - if (!contacts.contains(name)) { - contacts.insert(name, address); - QMessageBox::information(this, tr("Add Successful"), - tr("\"%1\" has been added to your address book.").arg(name)); - } else { - QMessageBox::information(this, tr("Add Unsuccessful"), - tr("Sorry, \"%1\" is already in your address book.").arg(name)); - } - - } else if (currentMode == EditingMode) { - - if (oldName != name) { - if (!contacts.contains(name)) { - QMessageBox::information(this, tr("Edit Successful"), - tr("\"%1\" has been edited in your address book.").arg(oldName)); - contacts.remove(oldName); - contacts.insert(name, address); - } else { - QMessageBox::information(this, tr("Edit Unsuccessful"), - tr("Sorry, \"%1\" is already in your address book.").arg(name)); - } - } else if (oldAddress != address) { - QMessageBox::information(this, tr("Edit Successful"), - tr("\"%1\" has been edited in your address book.").arg(name)); - contacts[name] = address; - } - } - updateInterface(NavigationMode); -} - -void AddressBook::cancel() -{ - ui->nameLine->setText(oldName); - ui->nameLine->setReadOnly(true); - - updateInterface(NavigationMode); -} - -void AddressBook::next() -{ - QString name = ui->nameLine->text(); - QMap<QString, QString>::iterator i = contacts.find(name); - - if (i != contacts.end()) - i++; - if (i == contacts.end()) - i = contacts.begin(); - - ui->nameLine->setText(i.key()); - ui->addressText->setText(i.value()); -} - -void AddressBook::previous() -{ - QString name = ui->nameLine->text(); - QMap<QString, QString>::iterator i = contacts.find(name); - - if (i == contacts.end()) { - ui->nameLine->clear(); - ui->addressText->clear(); - return; - } - - if (i == contacts.begin()) - i = contacts.end(); - - i--; - ui->nameLine->setText(i.key()); - ui->addressText->setText(i.value()); -} - -void AddressBook::editContact() -{ - oldName = ui->nameLine->text(); - oldAddress = ui->addressText->toPlainText(); - - updateInterface(EditingMode); -} - -void AddressBook::removeContact() -{ - QString name = ui->nameLine->text(); - QString address = ui->addressText->toPlainText(); - - if (contacts.contains(name)) { - int button = QMessageBox::question(this, - tr("Confirm Remove"), - tr("Are you sure you want to remove \"%1\"?").arg(name), - QMessageBox::Yes | QMessageBox::No); - - if (button == QMessageBox::Yes) { - previous(); - contacts.remove(name); - - QMessageBox::information(this, tr("Remove Successful"), - tr("\"%1\" has been removed from your address book.").arg(name)); - } - } - - updateInterface(NavigationMode); -} - -void AddressBook::updateInterface(Mode mode) -{ - currentMode = mode; - - switch (currentMode) { - - case AddingMode: - case EditingMode: - - ui->nameLine->setReadOnly(false); - ui->nameLine->setFocus(Qt::OtherFocusReason); - ui->addressText->setReadOnly(false); - - ui->addButton->setEnabled(false); - ui->editButton->setEnabled(false); - ui->removeButton->setEnabled(false); - - ui->nextButton->setEnabled(false); - ui->previousButton->setEnabled(false); - - ui->submitButton->show(); - ui->cancelButton->show(); - break; - - case NavigationMode: - - if (contacts.isEmpty()) { - ui->nameLine->clear(); - ui->addressText->clear(); - } - - ui->nameLine->setReadOnly(true); - ui->addressText->setReadOnly(true); - ui->addButton->setEnabled(true); - - int number = contacts.size(); - ui->editButton->setEnabled(number >= 1); - ui->removeButton->setEnabled(number >= 1); - ui->findButton->setEnabled(number > 2); - ui->nextButton->setEnabled(number > 1); - ui->previousButton->setEnabled(number >1); - - ui->submitButton->hide(); - ui->cancelButton->hide(); - break; - } -} - -void AddressBook::findContact() -{ - FindDialog dialog; - - if (dialog.exec() == QDialog::Accepted) { - QString contactName = dialog.findText(); - - if (contacts.contains(contactName)) { - ui->nameLine->setText(contactName); - ui->addressText->setText(contacts.value(contactName)); - } else { - QMessageBox::information(this, tr("Contact Not Found"), - tr("Sorry, \"%1\" is not in your address book.").arg(contactName)); - return; - } - } - - updateInterface(NavigationMode); -} - -//! [saveToFile part1] -void AddressBook::saveToFile() -{ - QString fileName = QFileDialog::getSaveFileName(this, - tr("Save Address Book"), "", - tr("Address book (*.abk);; AllFiles (*)")); -//! [saveToFile part1] - -//! [saveToFile part2] - if (fileName.isEmpty()) - return; - else { - QFile file(fileName); - - if (!file.open(QIODevice::WriteOnly)) { - QMessageBox::information(this, tr("Unable to open file"), - file.errorString()); - return; - } -//! [saveToFile part2] - -//! [saveToFile part3] - QDataStream out(&file); - out.setVersion(QDataStream::Qt_4_5); - out << contacts; - } -} -//! [saveToFile part3] - -//! [loadFromFile part1] -void AddressBook::loadFromFile() -{ - QString fileName = QFileDialog::getOpenFileName(this, - tr("Open Address Book"), "", - tr("Address Book(*.abk);; All Files(*)")); -//! [loadFromFile part1] - -//! [loadFromFile part2] - if (fileName.isEmpty()) - return; - else { - QFile file(fileName); - - if (!file.open(QIODevice::ReadOnly)) { - QMessageBox::information(this, tr("Unable to open file"), - file.errorString()); - return; - } - - QDataStream in(&file); - in.setVersion(QDataStream::Qt_4_5); - contacts.clear(); // remove all items - in >> contacts; -//! [loadFromFile part2] - -//! [loadFromFile part3] - if (contacts.isEmpty()) { - QMessageBox::information(this, tr("No contacts in file"), - tr("The file you are attempting to open contains no contacts.")); - } else { - QMap<QString, QString>::iterator i = contacts.begin(); - ui->nameLine->setText(i.key()); - ui->addressText->setText(i.value()); - } - } - - updateInterface(NavigationMode); -} -//! [loadFromFile part3] diff --git a/doc/examples/addressbook-sdk/part6/addressbook.h b/doc/examples/addressbook-sdk/part6/addressbook.h deleted file mode 100644 index 79bd250357..0000000000 --- a/doc/examples/addressbook-sdk/part6/addressbook.h +++ /dev/null @@ -1,85 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#ifndef ADDRESSBOOK_H -#define ADDRESSBOOK_H - -#include <QWidget> -#include <QMessageBox> -#include <QMap> -#include "finddialog.h" - -namespace Ui -{ - class AddressBook; -} - -class AddressBook : public QWidget -{ - Q_OBJECT - -public: - AddressBook(QWidget *parent = 0); - enum Mode { NavigationMode, AddingMode, EditingMode }; - ~AddressBook(); - -public slots: - void addContact(); - void submitContact(); - void cancel(); - void editContact(); - void removeContact(); - void next(); - void previous(); - void findContact(); -//! [slot definition] - void saveToFile(); - void loadFromFile(); -//! [slot definition] - -private: - Ui::AddressBook *ui; - void updateInterface(Mode mode); - - QMap<QString, QString> contacts; - QString oldName; - QString oldAddress; - Mode currentMode; - FindDialog *dialog; -}; - -#endif // ADDRESSBOOK_H diff --git a/doc/examples/addressbook-sdk/part6/addressbook.ui b/doc/examples/addressbook-sdk/part6/addressbook.ui deleted file mode 100644 index 9942235f0a..0000000000 --- a/doc/examples/addressbook-sdk/part6/addressbook.ui +++ /dev/null @@ -1,146 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>AddressBook</class> - <widget class="QWidget" name="AddressBook"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>478</width> - <height>352</height> - </rect> - </property> - <property name="windowTitle"> - <string>AddressBook</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="nameLabel"> - <property name="text"> - <string>Name:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="nameLine"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="addressLabel"> - <property name="text"> - <string>Address:</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QTextEdit" name="addressText"/> - </item> - <item row="1" column="2"> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QPushButton" name="addButton"> - <property name="text"> - <string>Add</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="submitButton"> - <property name="text"> - <string>Submit</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="cancelButton"> - <property name="text"> - <string>Cancel</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="editButton"> - <property name="text"> - <string>Edit</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="removeButton"> - <property name="text"> - <string>Remove</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="findButton"> - <property name="text"> - <string>Find</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="loadButton"> - <property name="toolTip"> - <string>Load contacts from a file</string> - </property> - <property name="text"> - <string>Load...</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="saveButton"> - <property name="toolTip"> - <string>Save contacts to a file</string> - </property> - <property name="text"> - <string>Save...</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="2" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QPushButton" name="nextButton"> - <property name="text"> - <string>Previous</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="previousButton"> - <property name="text"> - <string>Next</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - <layoutdefault spacing="6" margin="11"/> - <resources/> - <connections/> -</ui> diff --git a/doc/examples/addressbook-sdk/part6/finddialog.cpp b/doc/examples/addressbook-sdk/part6/finddialog.cpp deleted file mode 100644 index b289e0ca19..0000000000 --- a/doc/examples/addressbook-sdk/part6/finddialog.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#include "finddialog.h" -#include "ui_finddialog.h" -#include <QMessageBox> - -FindDialog::FindDialog(QWidget *parent) : - QDialog(parent), - m_ui(new Ui::FindDialog) -{ - m_ui->setupUi(this); - - connect(m_ui->findButton, SIGNAL(clicked()), this, SLOT(findClicked())); - - setWindowTitle(tr("Find a Contact")); -} - -FindDialog::~FindDialog() -{ - delete m_ui; -} - -void FindDialog::findClicked() -{ - QString text = m_ui->lineEdit->text(); - - if (text.isEmpty()) { - QMessageBox::information(this, tr("Empty Field"), - tr("Please enter a name.")); - reject(); - } else { - accept(); - } -} - -QString FindDialog::findText() -{ - return m_ui->lineEdit->text(); -} diff --git a/doc/examples/addressbook-sdk/part6/finddialog.h b/doc/examples/addressbook-sdk/part6/finddialog.h deleted file mode 100644 index 32c340a505..0000000000 --- a/doc/examples/addressbook-sdk/part6/finddialog.h +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#ifndef FINDDIALOG_H -#define FINDDIALOG_H - -#include <QDialog> -#include <QLineEdit> -#include <QPushButton> - -namespace Ui { - class FindDialog; -} - -class FindDialog : public QDialog { - Q_OBJECT -public: - FindDialog(QWidget *parent = 0); - ~FindDialog(); - QString findText(); - -public slots: - void findClicked(); - -private: - Ui::FindDialog *m_ui; -}; - -#endif // FINDDIALOG_H diff --git a/doc/examples/addressbook-sdk/part6/finddialog.ui b/doc/examples/addressbook-sdk/part6/finddialog.ui deleted file mode 100644 index 09333e18ca..0000000000 --- a/doc/examples/addressbook-sdk/part6/finddialog.ui +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>FindDialog</class> - <widget class="QDialog" name="FindDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>475</width> - <height>71</height> - </rect> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Enter the name of a contact:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit"/> - </item> - <item> - <widget class="QPushButton" name="findButton"> - <property name="text"> - <string>Find</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/doc/examples/addressbook-sdk/part6/main.cpp b/doc/examples/addressbook-sdk/part6/main.cpp deleted file mode 100644 index dcc63bf3b5..0000000000 --- a/doc/examples/addressbook-sdk/part6/main.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#include <QApplication> -#include "addressbook.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - AddressBook w; - w.show(); - return a.exec(); -} diff --git a/doc/examples/addressbook-sdk/part6/part6.pro b/doc/examples/addressbook-sdk/part6/part6.pro deleted file mode 100644 index 3daaf7f846..0000000000 --- a/doc/examples/addressbook-sdk/part6/part6.pro +++ /dev/null @@ -1,12 +0,0 @@ -# ------------------------------------------------- -# Project created by QtCreator 2009-07-01T16:46:33 -# ------------------------------------------------- -TARGET = part6 -TEMPLATE = app -SOURCES += main.cpp \ - addressbook.cpp \ - finddialog.cpp -HEADERS += addressbook.h \ - finddialog.h -FORMS += addressbook.ui \ - finddialog.ui diff --git a/doc/examples/addressbook-sdk/part7/addressbook.cpp b/doc/examples/addressbook-sdk/part7/addressbook.cpp deleted file mode 100644 index 104bb8d121..0000000000 --- a/doc/examples/addressbook-sdk/part7/addressbook.cpp +++ /dev/null @@ -1,392 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#include <QFileDialog> -#include <QTextStream> - -#include "addressbook.h" -#include "ui_addressbook.h" - -AddressBook::AddressBook(QWidget *parent) - : QWidget(parent), ui(new Ui::AddressBook) -{ - ui->setupUi(this); - - ui->nameLine->setReadOnly(true); - ui->addressText->setReadOnly(true); - ui->submitButton->hide(); - ui->cancelButton->hide(); - ui->nextButton->setEnabled(false); - ui->previousButton->setEnabled(false); - ui->editButton->setEnabled(false); - ui->removeButton->setEnabled(false); - - connect(ui->addButton, SIGNAL(clicked()), this, - SLOT(addContact())); - connect(ui->submitButton, SIGNAL(clicked()), this, - SLOT(submitContact())); - connect(ui->cancelButton, SIGNAL(clicked()), this, - SLOT(cancel())); - connect(ui->nextButton, SIGNAL(clicked()), this, - SLOT(next())); - connect(ui->previousButton, SIGNAL(clicked()), this, - SLOT(previous())); - connect(ui->editButton, SIGNAL(clicked()), this, - SLOT(editContact())); - connect(ui->removeButton, SIGNAL(clicked()), this, - SLOT(removeContact())); - connect(ui->findButton, SIGNAL(clicked()), this, - SLOT(findContact())); - connect(ui->exportButton, SIGNAL(clicked()), this, - SLOT(exportAsVCard())); - - setWindowTitle(tr("Simple Address Book")); -} - -AddressBook::~AddressBook() -{ - delete ui; -} - -void AddressBook::addContact() -{ - oldName = ui->nameLine->text(); - oldAddress = ui->addressText->toPlainText(); - - ui->nameLine->clear(); - ui->addressText->clear(); - - updateInterface(AddingMode); -} - -void AddressBook::submitContact() -{ - QString name = ui->nameLine->text(); - QString address = ui->addressText->toPlainText(); - - if (name.isEmpty() || address.isEmpty()) { - QMessageBox::information(this, tr("Empty Field"), - tr("Please enter a name and address.")); - updateInterface(NavigationMode); - return; - } - - if (currentMode == AddingMode) { - - if (!contacts.contains(name)) { - contacts.insert(name, address); - QMessageBox::information(this, tr("Add Successful"), - tr("\"%1\" has been added to your address book.").arg(name)); - } else { - QMessageBox::information(this, tr("Add Unsuccessful"), - tr("Sorry, \"%1\" is already in your address book.").arg(name)); - } - - } else if (currentMode == EditingMode) { - - if (oldName != name) { - if (!contacts.contains(name)) { - QMessageBox::information(this, tr("Edit Successful"), - tr("\"%1\" has been edited in your address book.").arg(oldName)); - contacts.remove(oldName); - contacts.insert(name, address); - } else { - QMessageBox::information(this, tr("Edit Unsuccessful"), - tr("Sorry, \"%1\" is already in your address book.").arg(name)); - } - } else if (oldAddress != address) { - QMessageBox::information(this, tr("Edit Successful"), - tr("\"%1\" has been edited in your address book.").arg(name)); - contacts[name] = address; - } - } - updateInterface(NavigationMode); -} - -void AddressBook::cancel() -{ - ui->nameLine->setText(oldName); - ui->nameLine->setReadOnly(true); - - updateInterface(NavigationMode); -} - -void AddressBook::next() -{ - QString name = ui->nameLine->text(); - QMap<QString, QString>::iterator i = contacts.find(name); - - if (i != contacts.end()) - i++; - if (i == contacts.end()) - i = contacts.begin(); - - ui->nameLine->setText(i.key()); - ui->addressText->setText(i.value()); -} - -void AddressBook::previous() -{ - QString name = ui->nameLine->text(); - QMap<QString, QString>::iterator i = contacts.find(name); - - if (i == contacts.end()) { - ui->nameLine->clear(); - ui->addressText->clear(); - return; - } - - if (i == contacts.begin()) - i = contacts.end(); - - i--; - ui->nameLine->setText(i.key()); - ui->addressText->setText(i.value()); -} - -void AddressBook::editContact() -{ - oldName = ui->nameLine->text(); - oldAddress = ui->addressText->toPlainText(); - - updateInterface(EditingMode); -} - -void AddressBook::removeContact() -{ - QString name = ui->nameLine->text(); - QString address = ui->addressText->toPlainText(); - - if (contacts.contains(name)) { - int button = QMessageBox::question(this, - tr("Confirm Remove"), - tr("Are you sure you want to remove \"%1\"?").arg(name), - QMessageBox::Yes | QMessageBox::No); - - if (button == QMessageBox::Yes) { - previous(); - contacts.remove(name); - - QMessageBox::information(this, tr("Remove Successful"), - tr("\"%1\" has been removed from your address book.").arg(name)); - } - } - - updateInterface(NavigationMode); -} - -void AddressBook::updateInterface(Mode mode) -{ - currentMode = mode; - - switch (currentMode) { - - case AddingMode: - case EditingMode: - - ui->nameLine->setReadOnly(false); - ui->nameLine->setFocus(Qt::OtherFocusReason); - ui->addressText->setReadOnly(false); - - ui->addButton->setEnabled(false); - ui->editButton->setEnabled(false); - ui->removeButton->setEnabled(false); - - ui->nextButton->setEnabled(false); - ui->previousButton->setEnabled(false); - - ui->submitButton->show(); - ui->cancelButton->show(); - break; - - case NavigationMode: - - if (contacts.isEmpty()) { - ui->nameLine->clear(); - ui->addressText->clear(); - } - - ui->nameLine->setReadOnly(true); - ui->addressText->setReadOnly(true); - ui->addButton->setEnabled(true); - - int number = contacts.size(); - ui->editButton->setEnabled(number >= 1); - ui->removeButton->setEnabled(number >= 1); - ui->findButton->setEnabled(number > 2); - ui->nextButton->setEnabled(number > 1); - ui->previousButton->setEnabled(number >1); - - ui->submitButton->hide(); - ui->cancelButton->hide(); - break; - } -} - -void AddressBook::findContact() -{ - FindDialog dialog; - - if (dialog.exec() == QDialog::Accepted) { - QString contactName = dialog.findText(); - - if (contacts.contains(contactName)) { - ui->nameLine->setText(contactName); - ui->addressText->setText(contacts.value(contactName)); - } else { - QMessageBox::information(this, tr("Contact Not Found"), - tr("Sorry, \"%1\" is not in your address book.").arg(contactName)); - return; - } - } - - updateInterface(NavigationMode); -} - -void AddressBook::saveToFile() -{ - QString fileName = QFileDialog::getSaveFileName(this, - tr("Save Address Book"), "", - tr("Address book (*.abk);; AllFiles (*)")); - - if (fileName.isEmpty()) - return; - else { - QFile file(fileName); - - if (!file.open(QIODevice::WriteOnly)) { - QMessageBox::information(this, tr("Unable to open file"), - file.errorString()); - return; - } - - QDataStream out(&file); - out.setVersion(QDataStream::Qt_4_5); - out << contacts; - } -} - -void AddressBook::loadFromFile() -{ - QString fileName = QFileDialog::getOpenFileName(this, - tr("Open Address Book"), "", - tr("Address Book(*.abk);; All Files(*)")); - - if (fileName.isEmpty()) - return; - else { - QFile file(fileName); - - if (!file.open(QIODevice::ReadOnly)) { - QMessageBox::information(this, tr("Unable to open file"), - file.errorString()); - return; - } - - QDataStream in(&file); - in.setVersion(QDataStream::Qt_4_5); - contacts.empty(); // empty existing contacts - in >> contacts; - - if (contacts.isEmpty()) { - QMessageBox::information(this, tr("No contacts in file"), - tr("The file you are attempting to open contains no contacts.")); - } else { - QMap<QString, QString>::iterator i = contacts.begin(); - ui->nameLine->setText(i.key()); - ui->addressText->setText(i.value()); - } - } - - updateInterface(NavigationMode); -} - -void AddressBook::exportAsVCard() -{ - QString name = ui->nameLine->text(); - QString address = ui->addressText->toPlainText(); - QString firstName; - QString lastName; - QStringList nameList; - - int index = name.indexOf(" "); - - if (index != -1) { - nameList = name.split(QRegExp("\\s+"), QString::SkipEmptyParts); - firstName = nameList.first(); - lastName = nameList.last(); - } else { - firstName = name; - lastName.clear(); - } - - QString fileName = QFileDialog::getSaveFileName(this, - tr("Export Coontact"), "", - tr("vCard files (*.vcf);;All Files (*)")); - - if (fileName.isEmpty()) - return; - - QFile file(fileName); - - if (!file.open(QIODevice::WriteOnly)) { - QMessageBox::information(this, tr("Unable to open file"), - file.errorString()); - return; - } - - QTextStream out(&file); - - out << "BEGIN:VCARD" << "\n"; - out << "VERSION:2.1" << "\n"; - out << "N:" << lastName << ";" << firstName << "\n"; - - if (!nameList.isEmpty()) - out << "FN:" << nameList.join(" ") << "\n"; - else - out << "FN:" << firstName << "\n"; - - address.replace(';', "\\;", Qt::CaseInsensitive); - address.replace('\n', ";", Qt::CaseInsensitive); - address.replace(',', " ", Qt::CaseInsensitive); - - out << "ADR;HOME:;" << address << "\n"; - out << "END;VCARD" << "\n"; - - QMessageBox::information(this, tr("Export Successful"), - tr("\"%1\" has been exported as a vCard.").arg(name)); -} diff --git a/doc/examples/addressbook-sdk/part7/addressbook.h b/doc/examples/addressbook-sdk/part7/addressbook.h deleted file mode 100644 index c76a0cd1b7..0000000000 --- a/doc/examples/addressbook-sdk/part7/addressbook.h +++ /dev/null @@ -1,86 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#ifndef ADDRESSBOOK_H -#define ADDRESSBOOK_H - -#include <QWidget> -#include <QMessageBox> -#include <QMap> -#include "finddialog.h" - -namespace Ui -{ - class AddressBook; -} - -class AddressBook : public QWidget -{ - Q_OBJECT - -public: - AddressBook(QWidget *parent = 0); - enum Mode { NavigationMode, AddingMode, EditingMode }; - ~AddressBook(); - -public slots: - void addContact(); - void submitContact(); - void cancel(); - void editContact(); - void removeContact(); - void next(); - void previous(); - void findContact(); - void saveToFile(); - void loadFromFile(); -//! [slot definition] - void exportAsVCard(); -//! [slot definition] - -private: - Ui::AddressBook *ui; - void updateInterface(Mode mode); - - QMap<QString, QString> contacts; - QString oldName; - QString oldAddress; - Mode currentMode; - FindDialog *dialog; -}; - -#endif // ADDRESSBOOK_H diff --git a/doc/examples/addressbook-sdk/part7/addressbook.ui b/doc/examples/addressbook-sdk/part7/addressbook.ui deleted file mode 100644 index 00f09db0de..0000000000 --- a/doc/examples/addressbook-sdk/part7/addressbook.ui +++ /dev/null @@ -1,156 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<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> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="nameLabel"> - <property name="text"> - <string>Name:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="nameLine"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="addressLabel"> - <property name="text"> - <string>Address:</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QTextEdit" name="addressText"/> - </item> - <item row="1" column="2"> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QPushButton" name="addButton"> - <property name="text"> - <string>Add</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="submitButton"> - <property name="text"> - <string>Submit</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="cancelButton"> - <property name="text"> - <string>Cancel</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="editButton"> - <property name="text"> - <string>Edit</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="removeButton"> - <property name="text"> - <string>Remove</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="findButton"> - <property name="text"> - <string>Find</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="loadButton"> - <property name="toolTip"> - <string>Load contacts from a file</string> - </property> - <property name="text"> - <string>Load...</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="saveButton"> - <property name="toolTip"> - <string>Save contacts to a file</string> - </property> - <property name="text"> - <string>Save...</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="exportButton"> - <property name="toolTip"> - <string>Export as vCard</string> - </property> - <property name="text"> - <string>Export</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="2" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QPushButton" name="nextButton"> - <property name="text"> - <string>Previous</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="previousButton"> - <property name="text"> - <string>Next</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - <layoutdefault spacing="6" margin="11"/> - <resources/> - <connections/> -</ui> diff --git a/doc/examples/addressbook-sdk/part7/finddialog.cpp b/doc/examples/addressbook-sdk/part7/finddialog.cpp deleted file mode 100644 index b289e0ca19..0000000000 --- a/doc/examples/addressbook-sdk/part7/finddialog.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#include "finddialog.h" -#include "ui_finddialog.h" -#include <QMessageBox> - -FindDialog::FindDialog(QWidget *parent) : - QDialog(parent), - m_ui(new Ui::FindDialog) -{ - m_ui->setupUi(this); - - connect(m_ui->findButton, SIGNAL(clicked()), this, SLOT(findClicked())); - - setWindowTitle(tr("Find a Contact")); -} - -FindDialog::~FindDialog() -{ - delete m_ui; -} - -void FindDialog::findClicked() -{ - QString text = m_ui->lineEdit->text(); - - if (text.isEmpty()) { - QMessageBox::information(this, tr("Empty Field"), - tr("Please enter a name.")); - reject(); - } else { - accept(); - } -} - -QString FindDialog::findText() -{ - return m_ui->lineEdit->text(); -} diff --git a/doc/examples/addressbook-sdk/part7/finddialog.h b/doc/examples/addressbook-sdk/part7/finddialog.h deleted file mode 100644 index 32c340a505..0000000000 --- a/doc/examples/addressbook-sdk/part7/finddialog.h +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#ifndef FINDDIALOG_H -#define FINDDIALOG_H - -#include <QDialog> -#include <QLineEdit> -#include <QPushButton> - -namespace Ui { - class FindDialog; -} - -class FindDialog : public QDialog { - Q_OBJECT -public: - FindDialog(QWidget *parent = 0); - ~FindDialog(); - QString findText(); - -public slots: - void findClicked(); - -private: - Ui::FindDialog *m_ui; -}; - -#endif // FINDDIALOG_H diff --git a/doc/examples/addressbook-sdk/part7/finddialog.ui b/doc/examples/addressbook-sdk/part7/finddialog.ui deleted file mode 100644 index a4cba217d9..0000000000 --- a/doc/examples/addressbook-sdk/part7/finddialog.ui +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>FindDialog</class> - <widget class="QDialog" name="FindDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>555</width> - <height>73</height> - </rect> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Enter the name of a contact:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit"/> - </item> - <item> - <widget class="QPushButton" name="findButton"> - <property name="text"> - <string>Find</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/doc/examples/addressbook-sdk/part7/main.cpp b/doc/examples/addressbook-sdk/part7/main.cpp deleted file mode 100644 index dcc63bf3b5..0000000000 --- a/doc/examples/addressbook-sdk/part7/main.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -**************************************************************************/ - -#include <QApplication> -#include "addressbook.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - AddressBook w; - w.show(); - return a.exec(); -} diff --git a/doc/examples/addressbook-sdk/part7/part7.pro b/doc/examples/addressbook-sdk/part7/part7.pro deleted file mode 100644 index efdbe0bb6e..0000000000 --- a/doc/examples/addressbook-sdk/part7/part7.pro +++ /dev/null @@ -1,12 +0,0 @@ -# ------------------------------------------------- -# Project created by QtCreator 2009-07-07T17:10:19 -# ------------------------------------------------- -TARGET = part7 -TEMPLATE = app -SOURCES += main.cpp \ - addressbook.cpp \ - finddialog.cpp -HEADERS += addressbook.h \ - finddialog.h -FORMS += addressbook.ui \ - finddialog.ui diff --git a/doc/examples/batterystatus/BatteryStatus.pro b/doc/examples/batterystatus/BatteryStatus.pro deleted file mode 100644 index 90fb201047..0000000000 --- a/doc/examples/batterystatus/BatteryStatus.pro +++ /dev/null @@ -1,19 +0,0 @@ -# Add more folders to ship with the application, here -folder_01.source = qml/BatteryStatus -folder_01.target = qml -DEPLOYMENTFOLDERS = folder_01 - -# Additional import path used to resolve QML modules in Creator's code model -QML_IMPORT_PATH = - -# If your application uses the Qt Mobility libraries, uncomment the following -# lines and add the respective components to the MOBILITY variable. -CONFIG += mobility -MOBILITY += systeminfo - -# The .cpp file which was generated for your project. Feel free to hack it. -SOURCES += main.cpp - -# Please do not modify the following two lines. Required for deployment. -include(qmlapplicationviewer/qmlapplicationviewer.pri) -qtcAddDeployment() diff --git a/doc/examples/batterystatus/main.cpp b/doc/examples/batterystatus/main.cpp deleted file mode 100644 index 4cc7da7ea4..0000000000 --- a/doc/examples/batterystatus/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** All rights reserved. -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of Qt Creator. -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -****************************************************************************/ - -#include <QApplication> -#include "qmlapplicationviewer.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - QmlApplicationViewer viewer; - viewer.setMainQmlFile(QLatin1String("qml/BatteryStatus/main.qml")); - viewer.showExpanded(); - - return app.exec(); -} |