Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
77df5904
Commit
77df5904
authored
Jun 10, 2009
by
Kavindra Devi Palaraja
Browse files
Doc - More on Part 5
RevBy: TrustMe
parent
a8b496c9
Changes
3
Hide whitespace changes
Inline
Side-by-side
doc/examples/addressbook-sdk/part5/addressbook.cpp
View file @
77df5904
...
...
@@ -41,6 +41,11 @@ AddressBook::AddressBook(QWidget *parent)
removeButton
=
ui
->
removeButton
;
removeButton
->
setEnabled
(
false
);
findButton
=
new
QPushButton
;
findButton
=
ui
->
findButton
;
dialog
=
new
FindDialog
;
connect
(
addButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
addContact
()));
connect
(
submitButton
,
SIGNAL
(
clicked
()),
this
,
...
...
@@ -55,6 +60,8 @@ AddressBook::AddressBook(QWidget *parent)
SLOT
(
editContact
()));
connect
(
removeButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
removeContact
()));
connect
(
findButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
findContact
()));
setWindowTitle
(
tr
(
"Simple Address Book"
));
}
...
...
@@ -235,3 +242,23 @@ void AddressBook::updateInterface(Mode mode)
break
;
}
}
void
AddressBook
::
findContact
()
{
dialog
->
show
();
if
(
dialog
->
exec
()
==
QDialog
::
Accepted
)
{
QString
contactName
=
dialog
->
getFindText
();
if
(
contacts
.
contains
(
contactName
))
{
nameLine
->
setText
(
contactName
);
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
);
}
doc/examples/addressbook-sdk/part5/addressbook.h
View file @
77df5904
...
...
@@ -6,6 +6,7 @@
#include <QtGui/QLineEdit>
#include <QtGui/QTextEdit>
#include <QtGui/QMessageBox>
#include "finddialog.h"
namespace
Ui
...
...
@@ -30,6 +31,7 @@ public slots:
void
removeContact
();
void
next
();
void
previous
();
void
findContact
();
private:
Ui
::
AddressBook
*
ui
;
...
...
@@ -42,6 +44,7 @@ private:
QPushButton
*
removeButton
;
QPushButton
*
nextButton
;
QPushButton
*
previousButton
;
QPushButton
*
findButton
;
QLineEdit
*
nameLine
;
QTextEdit
*
addressText
;
...
...
@@ -49,6 +52,7 @@ private:
QString
oldName
;
QString
oldAddress
;
Mode
currentMode
;
FindDialog
*
dialog
;
};
#endif // ADDRESSBOOK_H
doc/examples/addressbook-sdk/part5/finddialog.cpp
View file @
77df5904
...
...
@@ -6,6 +6,17 @@ FindDialog::FindDialog(QWidget *parent) :
m_ui
(
new
Ui
::
FindDialog
)
{
m_ui
->
setupUi
(
this
);
lineEdit
=
new
QLineEdit
;
lineEdit
=
m_ui
->
lineEdit
;
findButton
=
new
QPushButton
;
findButton
=
m_ui
->
findButton
;
findText
=
""
;
connect
(
findButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
findClicked
()));
setWindowTItle
(
tr
(
"Find a Contact"
));
}
FindDialog
::~
FindDialog
()
...
...
@@ -15,8 +26,20 @@ FindDialog::~FindDialog()
void
FindDialog
::
findClicked
()
{
QString
text
=
lineEdit
->
text
();
if
(
text
.
isEmpty
())
{
QMessageBox
::
information
(
this
,
tr
(
"Empty Field"
),
tr
(
"Please enter a name."
));
return
;
}
else
{
findText
=
text
;
lineEdit
->
clear
();
hide
();
}
}
QString
FindDialog
::
getFindText
()
{
return
findText
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment