<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt - 3.3.8 - espenr - 2499/qt - x11 - free - 3.3.8/examples/addressbook/addressbook.doc:4 -->
< html >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=ISO-8859-1" >
< title > Simple Addressbook< / title >
< style type = "text/css" > < ! - -
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
-->< / style >
< / head >
< body >
< table border = "0" cellpadding = "0" cellspacing = "0" width = "100%" >
< tr bgcolor = "#E5E5E5" >
< td valign = center >
< a href = "index.html" >
< font color = "#004faf" > Home< / font > < / a >
| < a href = "classes.html" >
< font color = "#004faf" > All Classes< / font > < / a >
| < a href = "mainclasses.html" >
< font color = "#004faf" > Main Classes< / font > < / a >
| < a href = "annotated.html" >
< font color = "#004faf" > Annotated< / font > < / a >
| < a href = "groups.html" >
< font color = "#004faf" > Grouped Classes< / font > < / a >
| < a href = "functions.html" >
< font color = "#004faf" > Functions< / font > < / a >
< / td >
< td align = "right" valign = "center" > < img src = "logo32.png" align = "right" width = "64" height = "32" border = "0" > < / td > < / tr > < / table > < h1 align = center > Simple Addressbook< / h1 >
< p >
This examples shows how to write a very simple, but complete application
using an addressbook as the example.
< p > < hr >
< p > Header file of the mainwindow:
< p > < pre > /****************************************************************************
** $Id: qt/mainwindow.h 3.3.8 edited Jan 11 14:37 $
**
** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
**
** This file is part of an example program for TQt. This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/
#ifndef AB_MAINWINDOW_H
#define AB_MAINWINDOW_H
#include < < a href = "tqmainwindow-h.html" > tqmainwindow.h< / a > >
#include < < a href = "tqstring-h.html" > tqstring.h< / a > >
class TQToolBar;
class TQPopupMenu;
class ABCentralWidget;
class ABMainWindow: public < a href = "tqmainwindow.html" > TQMainWindow< / a >
{
< a href = "metaobjects.html#TQ_OBJECT" > TQ_OBJECT< / a >
public:
ABMainWindow();
~ABMainWindow();
protected slots:
void fileNew();
void fileOpen();
void fileSave();
void fileSaveAs();
void filePrint();
void closeWindow();
protected:
void setupMenuBar();
void setupFileTools();
void setupStatusBar();
void setupCentralWidget();
< a href = "tqtoolbar.html" > TQToolBar< / a > *fileTools;
< a href = "tqstring.html" > TQString< / a > filename;
ABCentralWidget *view;
};
#endif
< / pre >
< p > < hr >
< p > Implementation of the mainwindow:
< p > < pre > /****************************************************************************
** $Id: qt/mainwindow.cpp 3.3.8 edited Jan 11 14:37 $
**
** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
**
** This file is part of an example program for TQt. This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/
#include "mainwindow.h"
#include "centralwidget.h"
#include < < a href = "tqtoolbar-h.html" > tqtoolbar.h< / a > >
#include < < a href = "tqtoolbutton-h.html" > tqtoolbutton.h< / a > >
#include < < a href = "tqpopupmenu-h.html" > tqpopupmenu.h< / a > >
#include < < a href = "tqmenubar-h.html" > tqmenubar.h< / a > >
#include < < a href = "tqstatusbar-h.html" > tqstatusbar.h< / a > >
#include < < a href = "qapplication-h.html" > ntqapplication.h< / a > >
#include < < a href = "tqfiledialog-h.html" > tqfiledialog.h< / a > >
< a name = "f263" > < / a > ABMainWindow::ABMainWindow()
: < a href = "tqmainwindow.html" > TQMainWindow< / a > ( 0, "example addressbook application" ),
filename( < a href = "tqstring.html#TQString-null" > TQString::null< / a > )
{
setupMenuBar();
setupFileTools();
setupStatusBar();
setupCentralWidget();
}
ABMainWindow::~ABMainWindow()
{
}
void < a name = "f264" > < / a > ABMainWindow::setupMenuBar()
{
< a href = "tqpopupmenu.html" > TQPopupMenu< / a > *file = new < a href = "tqpopupmenu.html" > TQPopupMenu< / a > ( this );
< a href = "tqmainwindow.html#menuBar" > menuBar< / a > ()-> insertItem( "& File", file );
< a name = "x569" > < / a > file-> < a href = "tqmenudata.html#insertItem" > insertItem< / a > ( "New", this, TQ_SLOT( fileNew() ), CTRL + Key_N );
file-> < a href = "tqmenudata.html#insertItem" > insertItem< / a > ( TQPixmap( "fileopen.xpm" ), "Open", this, TQ_SLOT( fileOpen() ), CTRL + Key_O );
< a name = "x570" > < / a > file-> < a href = "tqmenudata.html#insertSeparator" > insertSeparator< / a > ();
file-> < a href = "tqmenudata.html#insertItem" > insertItem< / a > ( TQPixmap( "filesave.xpm" ), "Save", this, TQ_SLOT( fileSave() ), CTRL + Key_S );
file-> < a href = "tqmenudata.html#insertItem" > insertItem< / a > ( "Save As...", this, TQ_SLOT( fileSaveAs() ) );
file-> < a href = "tqmenudata.html#insertSeparator" > insertSeparator< / a > ();
file-> < a href = "tqmenudata.html#insertItem" > insertItem< / a > ( TQPixmap( "fileprint.xpm" ), "Print...", this, TQ_SLOT( filePrint() ), CTRL + Key_P );
file-> < a href = "tqmenudata.html#insertSeparator" > insertSeparator< / a > ();
file-> < a href = "tqmenudata.html#insertItem" > insertItem< / a > ( "Close", this, TQ_SLOT( closeWindow() ), CTRL + Key_W );
file-> < a href = "tqmenudata.html#insertItem" > insertItem< / a > ( "Quit", tqApp, TQ_SLOT( < a href = "ntqapplication.html#quit" > quit< / a > () ), CTRL + Key_Q );
}
void < a name = "f265" > < / a > ABMainWindow::setupFileTools()
{
//fileTools = new < a href = "tqtoolbar.html" > TQToolBar< / a > ( this, "file operations" );
}
void < a name = "f266" > < / a > ABMainWindow::setupStatusBar()
{
//statusBar()-> message( "Ready", 2000 );
}
void < a name = "f267" > < / a > ABMainWindow::setupCentralWidget()
{
view = new ABCentralWidget( this );
< a href = "tqmainwindow.html#setCentralWidget" > setCentralWidget< / a > ( view );
}
void < a name = "f268" > < / a > ABMainWindow::closeWindow()
{
< a href = "tqwidget.html#close" > close< / a > ();
}
void < a name = "f269" > < / a > ABMainWindow::fileNew()
{
}
void < a name = "f270" > < / a > ABMainWindow::fileOpen()
{
< a name = "x567" > < / a > < a href = "tqstring.html" > TQString< / a > fn = TQFileDialog::< a href = "tqfiledialog.html#getOpenFileName" > getOpenFileName< / a > ( TQString::null, TQString::null, this );
< a name = "x571" > < / a > if ( !fn.< a href = "tqstring.html#isEmpty" > isEmpty< / a > () ) {
filename = fn;
view-> load( filename );
}
}
void < a name = "f271" > < / a > ABMainWindow::fileSave()
{
if ( filename.isEmpty() ) {
fileSaveAs();
return;
}
view-> save( filename );
}
void < a name = "f272" > < / a > ABMainWindow::fileSaveAs()
{
< a name = "x568" > < / a > < a href = "tqstring.html" > TQString< / a > fn = TQFileDialog::< a href = "tqfiledialog.html#getSaveFileName" > getSaveFileName< / a > ( TQString::null, TQString::null, this );
if ( !fn.< a href = "tqstring.html#isEmpty" > isEmpty< / a > () ) {
filename = fn;
fileSave();
}
}
void < a name = "f273" > < / a > ABMainWindow::filePrint()
{
}
< / pre >
< p > < hr >
< p > Header file of the centralwidget:
< p > < pre > /****************************************************************************
** $Id: qt/centralwidget.h 3.3.8 edited Jan 11 14:37 $
**
** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
**
** This file is part of an example program for TQt. This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/
#ifndef AB_CENTRALWIDGET_H
#define AB_CENTRALWIDGET_H
#include < < a href = "tqwidget-h.html" > tqwidget.h< / a > >
#include < < a href = "tqstring-h.html" > tqstring.h< / a > >
class TQTabWidget;
class TQListView;
class TQGridLayout;
class TQLineEdit;
class TQPushButton;
class TQListViewItem;
class TQCheckBox;
class ABCentralWidget : public < a href = "tqwidget.html" > TQWidget< / a >
{
TQ_OBJECT
public:
ABCentralWidget( < a href = "tqwidget.html" > TQWidget< / a > *parent, const char *name = 0 );
void save( const < a href = "tqstring.html" > TQString< / a > & filename );
void load( const < a href = "tqstring.html" > TQString< / a > & filename );
protected slots:
void addEntry();
void changeEntry();
void itemSelected( < a href = "tqlistviewitem.html" > TQListViewItem< / a > * );
void selectionChanged();
void toggleFirstName();
void toggleLastName();
void toggleAddress();
void toggleEMail();
void findEntries();
protected:
void setupTabWidget();
void setupListView();
< a href = "tqgridlayout.html" > TQGridLayout< / a > *mainGrid;
< a href = "tqtabwidget.html" > TQTabWidget< / a > *tabWidget;
< a href = "tqlistview.html" > TQListView< / a > *listView;
< a href = "tqpushbutton.html" > TQPushButton< / a > *add, *change, *find;
< a href = "tqlineedit.html" > TQLineEdit< / a > *iFirstName, *iLastName, *iAddress, *iEMail,
*sFirstName, *sLastName, *sAddress, *sEMail;
< a href = "tqcheckbox.html" > TQCheckBox< / a > *cFirstName, *cLastName, *cAddress, *cEMail;
};
#endif
< / pre >
< p > < hr >
< p > Implementation of the centralwidget:
< p > < pre > /****************************************************************************
** $Id: qt/centralwidget.cpp 3.3.8 edited Jan 11 14:37 $
**
** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
**
** This file is part of an example program for TQt. This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/
#include "centralwidget.h"
#include < < a href = "tqtabwidget-h.html" > tqtabwidget.h< / a > >
#include < < a href = "tqlistview-h.html" > tqlistview.h< / a > >
#include < < a href = "tqlayout-h.html" > tqlayout.h< / a > >
#include < < a href = "tqwidget-h.html" > tqwidget.h< / a > >
#include < < a href = "tqlabel-h.html" > tqlabel.h< / a > >
#include < < a href = "tqpushbutton-h.html" > tqpushbutton.h< / a > >
#include < < a href = "tqlineedit-h.html" > tqlineedit.h< / a > >
#include < < a href = "tqlabel-h.html" > tqlabel.h< / a > >
#include < < a href = "tqcheckbox-h.html" > tqcheckbox.h< / a > >
#include < < a href = "tqfile-h.html" > tqfile.h< / a > >
#include < < a href = "tqtextstream-h.html" > tqtextstream.h< / a > >
< a name = "f274" > < / a > ABCentralWidget::ABCentralWidget( < a href = "tqwidget.html" > TQWidget< / a > *parent, const char *name )
: < a href = "tqwidget.html" > TQWidget< / a > ( parent, name )
{
mainGrid = new < a href = "tqgridlayout.html" > TQGridLayout< / a > ( this, 2, 1, 5, 5 );
setupTabWidget();
setupListView();
< a name = "x579" > < / a > mainGrid-> < a href = "tqgridlayout.html#setRowStretch" > setRowStretch< / a > ( 0, 0 );
mainGrid-> < a href = "tqgridlayout.html#setRowStretch" > setRowStretch< / a > ( 1, 1 );
}
void < a name = "f275" > < / a > ABCentralWidget::save( const < a href = "tqstring.html" > TQString< / a > & filename )
{
< a name = "x590" > < / a > if ( !listView-> < a href = "tqlistview.html#firstChild" > firstChild< / a > () )
return;
< a href = "tqfile.html" > TQFile< / a > f( filename );
if ( !f.< a href = "tqfile.html#open" > open< / a > ( < a href = "tqfile.html#open" > IO_WriteOnly< / a > ) )
return;
< a href = "tqtextstream.html" > TQTextStream< / a > t( & f );
< a name = "x603" > < / a > t.< a href = "tqtextstream.html#setEncoding" > setEncoding< / a > (TQTextStream::UnicodeUTF8);
< a href = "tqlistviewitemiterator.html" > TQListViewItemIterator< / a > it( listView );
< a name = "x597" > < / a > for ( ; it.< a href = "tqlistviewitemiterator.html#current" > current< / a > (); ++it )
for ( unsigned int i = 0; i < 4; i++ )
t < < it.< a href = "tqlistviewitemiterator.html#current" > current< / a > ()-> text( i ) < < "\n";
f.< a href = "tqfile.html#close" > close< / a > ();
}
void < a name = "f276" > < / a > ABCentralWidget::load( const < a href = "tqstring.html" > TQString< / a > & filename )
{
< a name = "x586" > < / a > listView-> < a href = "tqlistview.html#clear" > clear< / a > ();
< a href = "tqfile.html" > TQFile< / a > f( filename );
if ( !f.< a href = "tqfile.html#open" > open< / a > ( < a href = "tqfile.html#open" > IO_ReadOnly< / a > ) )
return;
< a href = "tqtextstream.html" > TQTextStream< / a > t( & f );
t.< a href = "tqtextstream.html#setEncoding" > setEncoding< / a > (TQTextStream::UnicodeUTF8);
< a name = "x601" > < / a > while ( !t.< a href = "tqtextstream.html#atEnd" > atEnd< / a > () ) {
< a href = "tqlistviewitem.html" > TQListViewItem< / a > *item = new < a href = "tqlistviewitem.html" > TQListViewItem< / a > ( listView );
for ( unsigned int i = 0; i < 4; i++ )
< a name = "x602" > < / a > < a name = "x595" > < / a > item-> < a href = "tqlistviewitem.html#setText" > setText< / a > ( i, t.< a href = "tqtextstream.html#readLine" > readLine< / a > () );
}
f.< a href = "tqfile.html#close" > close< / a > ();
}
void < a name = "f277" > < / a > ABCentralWidget::setupTabWidget()
{
tabWidget = new < a href = "tqtabwidget.html" > TQTabWidget< / a > ( this );
< a href = "tqwidget.html" > TQWidget< / a > *input = new < a href = "tqwidget.html" > TQWidget< / a > ( tabWidget );
< a href = "tqgridlayout.html" > TQGridLayout< / a > *grid1 = new < a href = "tqgridlayout.html" > TQGridLayout< / a > ( input, 2, 5, 5, 5 );
< a href = "tqlabel.html" > TQLabel< / a > *liFirstName = new < a href = "tqlabel.html" > TQLabel< / a > ( "First & Name", input );
< a name = "x604" > < / a > < a name = "x581" > < / a > liFirstName-> < a href = "tqwidget.html#resize" > resize< / a > ( liFirstName-> < a href = "tqwidget.html#sizeHint" > sizeHint< / a > () );
< a name = "x578" > < / a > grid1-> < a href = "tqgridlayout.html#addWidget" > addWidget< / a > ( liFirstName, 0, 0 );
< a href = "tqlabel.html" > TQLabel< / a > *liLastName = new < a href = "tqlabel.html" > TQLabel< / a > ( "& Last Name", input );
liLastName-> < a href = "tqwidget.html#resize" > resize< / a > ( liLastName-> < a href = "tqwidget.html#sizeHint" > sizeHint< / a > () );
grid1-> < a href = "tqgridlayout.html#addWidget" > addWidget< / a > ( liLastName, 0, 1 );
< a href = "tqlabel.html" > TQLabel< / a > *liAddress = new < a href = "tqlabel.html" > TQLabel< / a > ( "Add& ress", input );
liAddress-> < a href = "tqwidget.html#resize" > resize< / a > ( liAddress-> < a href = "tqwidget.html#sizeHint" > sizeHint< / a > () );
grid1-> < a href = "tqgridlayout.html#addWidget" > addWidget< / a > ( liAddress, 0, 2 );
< a href = "tqlabel.html" > TQLabel< / a > *liEMail = new < a href = "tqlabel.html" > TQLabel< / a > ( "& E-Mail", input );
liEMail-> < a href = "tqwidget.html#resize" > resize< / a > ( liEMail-> < a href = "tqwidget.html#sizeHint" > sizeHint< / a > () );
grid1-> < a href = "tqgridlayout.html#addWidget" > addWidget< / a > ( liEMail, 0, 3 );
add = new < a href = "tqpushbutton.html" > TQPushButton< / a > ( "A& dd", input );
< a name = "x599" > < / a > < a name = "x598" > < / a > add-> < a href = "tqwidget.html#resize" > resize< / a > ( add-> < a href = "tqwidget.html#sizeHint" > sizeHint< / a > () );
grid1-> < a href = "tqgridlayout.html#addWidget" > addWidget< / a > ( add, 0, 4 );
< a href = "tqobject.html#connect" > connect< / a > ( add, TQ_SIGNAL( < a href = "tqbutton.html#clicked" > clicked< / a > () ), this, TQ_SLOT( addEntry() ) );
iFirstName = new < a href = "tqlineedit.html" > TQLineEdit< / a > ( input );
< a name = "x583" > < / a > iFirstName-> < a href = "tqwidget.html#resize" > resize< / a > ( iFirstName-> < a href = "tqlineedit.html#sizeHint" > sizeHint< / a > () );
grid1-> < a href = "tqgridlayout.html#addWidget" > addWidget< / a > ( iFirstName, 1, 0 );
< a name = "x580" > < / a > liFirstName-> < a href = "tqlabel.html#setBuddy" > setBuddy< / a > ( iFirstName );
iLastName = new < a href = "tqlineedit.html" > TQLineEdit< / a > ( input );
iLastName-> < a href = "tqwidget.html#resize" > resize< / a > ( iLastName-> < a href = "tqlineedit.html#sizeHint" > sizeHint< / a > () );
grid1-> < a href = "tqgridlayout.html#addWidget" > addWidget< / a > ( iLastName, 1, 1 );
liLastName-> < a href = "tqlabel.html#setBuddy" > setBuddy< / a > ( iLastName );
iAddress = new < a href = "tqlineedit.html" > TQLineEdit< / a > ( input );
iAddress-> < a href = "tqwidget.html#resize" > resize< / a > ( iAddress-> < a href = "tqlineedit.html#sizeHint" > sizeHint< / a > () );
grid1-> < a href = "tqgridlayout.html#addWidget" > addWidget< / a > ( iAddress, 1, 2 );
liAddress-> < a href = "tqlabel.html#setBuddy" > setBuddy< / a > ( iAddress );
iEMail = new < a href = "tqlineedit.html" > TQLineEdit< / a > ( input );
iEMail-> < a href = "tqwidget.html#resize" > resize< / a > ( iEMail-> < a href = "tqlineedit.html#sizeHint" > sizeHint< / a > () );
grid1-> < a href = "tqgridlayout.html#addWidget" > addWidget< / a > ( iEMail, 1, 3 );
liEMail-> < a href = "tqlabel.html#setBuddy" > setBuddy< / a > ( iEMail );
change = new < a href = "tqpushbutton.html" > TQPushButton< / a > ( "& Change", input );
change-> < a href = "tqwidget.html#resize" > resize< / a > ( change-> < a href = "tqwidget.html#sizeHint" > sizeHint< / a > () );
grid1-> < a href = "tqgridlayout.html#addWidget" > addWidget< / a > ( change, 1, 4 );
< a href = "tqobject.html#connect" > connect< / a > ( change, TQ_SIGNAL( < a href = "tqbutton.html#clicked" > clicked< / a > () ), this, TQ_SLOT( changeEntry() ) );
< a name = "x600" > < / a > tabWidget-> < a href = "tqtabwidget.html#addTab" > addTab< / a > ( input, "& Add/Change Entry" );
// --------------------------------------
< a href = "tqwidget.html" > TQWidget< / a > *search = new < a href = "tqwidget.html" > TQWidget< / a > ( this );
< a href = "tqgridlayout.html" > TQGridLayout< / a > *grid2 = new < a href = "tqgridlayout.html" > TQGridLayout< / a > ( search, 2, 5, 5, 5 );
cFirstName = new < a href = "tqcheckbox.html" > TQCheckBox< / a > ( "First & Name", search );
< a name = "x575" > < / a > cFirstName-> < a href = "tqwidget.html#resize" > resize< / a > ( cFirstName-> < a href = "tqwidget.html#sizeHint" > sizeHint< / a > () );
grid2-> < a href = "tqgridlayout.html#addWidget" > addWidget< / a > ( cFirstName, 0, 0 );
< a href = "tqobject.html#connect" > connect< / a > ( cFirstName, TQ_SIGNAL( < a href = "tqbutton.html#clicked" > clicked< / a > () ), this, TQ_SLOT( toggleFirstName() ) );
cLastName = new < a href = "tqcheckbox.html" > TQCheckBox< / a > ( "& Last Name", search );
cLastName-> < a href = "tqwidget.html#resize" > resize< / a > ( cLastName-> < a href = "tqwidget.html#sizeHint" > sizeHint< / a > () );
grid2-> < a href = "tqgridlayout.html#addWidget" > addWidget< / a > ( cLastName, 0, 1 );
< a href = "tqobject.html#connect" > connect< / a > ( cLastName, TQ_SIGNAL( < a href = "tqbutton.html#clicked" > clicked< / a > () ), this, TQ_SLOT( toggleLastName() ) );
cAddress = new < a href = "tqcheckbox.html" > TQCheckBox< / a > ( "Add& ress", search );
cAddress-> < a href = "tqwidget.html#resize" > resize< / a > ( cAddress-> < a href = "tqwidget.html#sizeHint" > sizeHint< / a > () );
grid2-> < a href = "tqgridlayout.html#addWidget" > addWidget< / a > ( cAddress, 0, 2 );
< a href = "tqobject.html#connect" > connect< / a > ( cAddress, TQ_SIGNAL( < a href = "tqbutton.html#clicked" > clicked< / a > () ), this, TQ_SLOT( toggleAddress() ) );
cEMail = new < a href = "tqcheckbox.html" > TQCheckBox< / a > ( "& E-Mail", search );
cEMail-> < a href = "tqwidget.html#resize" > resize< / a > ( cEMail-> < a href = "tqwidget.html#sizeHint" > sizeHint< / a > () );
grid2-> < a href = "tqgridlayout.html#addWidget" > addWidget< / a > ( cEMail, 0, 3 );
< a href = "tqobject.html#connect" > connect< / a > ( cEMail, TQ_SIGNAL( < a href = "tqbutton.html#clicked" > clicked< / a > () ), this, TQ_SLOT( toggleEMail() ) );
sFirstName = new < a href = "tqlineedit.html" > TQLineEdit< / a > ( search );
sFirstName-> < a href = "tqwidget.html#resize" > resize< / a > ( sFirstName-> < a href = "tqlineedit.html#sizeHint" > sizeHint< / a > () );
grid2-> < a href = "tqgridlayout.html#addWidget" > addWidget< / a > ( sFirstName, 1, 0 );
sLastName = new < a href = "tqlineedit.html" > TQLineEdit< / a > ( search );
sLastName-> < a href = "tqwidget.html#resize" > resize< / a > ( sLastName-> < a href = "tqlineedit.html#sizeHint" > sizeHint< / a > () );
grid2-> < a href = "tqgridlayout.html#addWidget" > addWidget< / a > ( sLastName, 1, 1 );
sAddress = new < a href = "tqlineedit.html" > TQLineEdit< / a > ( search );
sAddress-> < a href = "tqwidget.html#resize" > resize< / a > ( sAddress-> < a href = "tqlineedit.html#sizeHint" > sizeHint< / a > () );
grid2-> < a href = "tqgridlayout.html#addWidget" > addWidget< / a > ( sAddress, 1, 2 );
sEMail = new < a href = "tqlineedit.html" > TQLineEdit< / a > ( search );
sEMail-> < a href = "tqwidget.html#resize" > resize< / a > ( sEMail-> < a href = "tqlineedit.html#sizeHint" > sizeHint< / a > () );
grid2-> < a href = "tqgridlayout.html#addWidget" > addWidget< / a > ( sEMail, 1, 3 );
find = new < a href = "tqpushbutton.html" > TQPushButton< / a > ( "F& ind", search );
find-> < a href = "tqwidget.html#resize" > resize< / a > ( find-> < a href = "tqwidget.html#sizeHint" > sizeHint< / a > () );
grid2-> < a href = "tqgridlayout.html#addWidget" > addWidget< / a > ( find, 1, 4 );
< a href = "tqobject.html#connect" > connect< / a > ( find, TQ_SIGNAL( < a href = "tqbutton.html#clicked" > clicked< / a > () ), this, TQ_SLOT( findEntries() ) );
< a name = "x574" > < / a > cFirstName-> < a href = "tqcheckbox.html#setChecked" > setChecked< / a > ( TRUE );
< a name = "x605" > < / a > sFirstName-> < a href = "tqwidget.html#setEnabled" > setEnabled< / a > ( TRUE );
sLastName-> < a href = "tqwidget.html#setEnabled" > setEnabled< / a > ( FALSE );
sAddress-> < a href = "tqwidget.html#setEnabled" > setEnabled< / a > ( FALSE );
sEMail-> < a href = "tqwidget.html#setEnabled" > setEnabled< / a > ( FALSE );
tabWidget-> < a href = "tqtabwidget.html#addTab" > addTab< / a > ( search, "& Search" );
mainGrid-> < a href = "tqgridlayout.html#addWidget" > addWidget< / a > ( tabWidget, 0, 0 );
}
void < a name = "f278" > < / a > ABCentralWidget::setupListView()
{
listView = new < a href = "tqlistview.html" > TQListView< / a > ( this );
< a name = "x585" > < / a > listView-> < a href = "tqlistview.html#addColumn" > addColumn< / a > ( "First Name" );
listView-> < a href = "tqlistview.html#addColumn" > addColumn< / a > ( "Last Name" );
listView-> < a href = "tqlistview.html#addColumn" > addColumn< / a > ( "Address" );
listView-> < a href = "tqlistview.html#addColumn" > addColumn< / a > ( "E-Mail" );
< a name = "x592" > < / a > listView-> < a href = "tqlistview.html#setSelectionMode" > setSelectionMode< / a > ( TQListView::Single );
< a name = "x588" > < / a > < a href = "tqobject.html#connect" > connect< / a > ( listView, TQ_SIGNAL( < a href = "tqlistview.html#clicked" > clicked< / a > ( < a href = "tqlistviewitem.html" > TQListViewItem< / a > * ) ), this, TQ_SLOT( itemSelected( < a href = "tqlistviewitem.html" > TQListViewItem< / a > * ) ) );
mainGrid-> < a href = "tqgridlayout.html#addWidget" > addWidget< / a > ( listView, 1, 0 );
< a name = "x591" > < / a > listView-> < a href = "tqlistview.html#setAllColumnsShowFocus" > setAllColumnsShowFocus< / a > ( TRUE );
}
void < a name = "f279" > < / a > ABCentralWidget::addEntry()
{
< a name = "x584" > < / a > if ( !iFirstName-> < a href = "tqlineedit.html#text" > text< / a > ().isEmpty() || !iLastName-> < a href = "tqlineedit.html#text" > text< / a > ().isEmpty() ||
!iAddress-> < a href = "tqlineedit.html#text" > text< / a > ().isEmpty() || !iEMail-> < a href = "tqlineedit.html#text" > text< / a > ().isEmpty() ) {
< a href = "tqlistviewitem.html" > TQListViewItem< / a > *item = new < a href = "tqlistviewitem.html" > TQListViewItem< / a > ( listView );
item-> < a href = "tqlistviewitem.html#setText" > setText< / a > ( 0, iFirstName-> < a href = "tqlineedit.html#text" > text< / a > () );
item-> < a href = "tqlistviewitem.html#setText" > setText< / a > ( 1, iLastName-> < a href = "tqlineedit.html#text" > text< / a > () );
item-> < a href = "tqlistviewitem.html#setText" > setText< / a > ( 2, iAddress-> < a href = "tqlineedit.html#text" > text< / a > () );
item-> < a href = "tqlistviewitem.html#setText" > setText< / a > ( 3, iEMail-> < a href = "tqlineedit.html#text" > text< / a > () );
}
< a name = "x582" > < / a > iFirstName-> < a href = "tqlineedit.html#setText" > setText< / a > ( "" );
iLastName-> < a href = "tqlineedit.html#setText" > setText< / a > ( "" );
iAddress-> < a href = "tqlineedit.html#setText" > setText< / a > ( "" );
iEMail-> < a href = "tqlineedit.html#setText" > setText< / a > ( "" );
}
void < a name = "f280" > < / a > ABCentralWidget::changeEntry()
{
< a name = "x589" > < / a > < a href = "tqlistviewitem.html" > TQListViewItem< / a > *item = listView-> < a href = "tqlistview.html#currentItem" > currentItem< / a > ();
if ( item & &
( !iFirstName-> < a href = "tqlineedit.html#text" > text< / a > ().isEmpty() || !iLastName-> < a href = "tqlineedit.html#text" > text< / a > ().isEmpty() ||
!iAddress-> < a href = "tqlineedit.html#text" > text< / a > ().isEmpty() || !iEMail-> < a href = "tqlineedit.html#text" > text< / a > ().isEmpty() ) ) {
item-> < a href = "tqlistviewitem.html#setText" > setText< / a > ( 0, iFirstName-> < a href = "tqlineedit.html#text" > text< / a > () );
item-> < a href = "tqlistviewitem.html#setText" > setText< / a > ( 1, iLastName-> < a href = "tqlineedit.html#text" > text< / a > () );
item-> < a href = "tqlistviewitem.html#setText" > setText< / a > ( 2, iAddress-> < a href = "tqlineedit.html#text" > text< / a > () );
item-> < a href = "tqlistviewitem.html#setText" > setText< / a > ( 3, iEMail-> < a href = "tqlineedit.html#text" > text< / a > () );
}
}
void < a name = "f281" > < / a > ABCentralWidget::selectionChanged()
{
iFirstName-> < a href = "tqlineedit.html#setText" > setText< / a > ( "" );
iLastName-> < a href = "tqlineedit.html#setText" > setText< / a > ( "" );
iAddress-> < a href = "tqlineedit.html#setText" > setText< / a > ( "" );
iEMail-> < a href = "tqlineedit.html#setText" > setText< / a > ( "" );
}
void < a name = "f282" > < / a > ABCentralWidget::itemSelected( < a href = "tqlistviewitem.html" > TQListViewItem< / a > *item )
{
if ( !item )
return;
< a name = "x594" > < / a > item-> < a href = "tqlistviewitem.html#setSelected" > setSelected< / a > ( TRUE );
< a name = "x593" > < / a > item-> < a href = "tqlistviewitem.html#repaint" > repaint< / a > ();
< a name = "x596" > < / a > iFirstName-> < a href = "tqlineedit.html#setText" > setText< / a > ( item-> < a href = "tqlistviewitem.html#text" > text< / a > ( 0 ) );
iLastName-> < a href = "tqlineedit.html#setText" > setText< / a > ( item-> < a href = "tqlistviewitem.html#text" > text< / a > ( 1 ) );
iAddress-> < a href = "tqlineedit.html#setText" > setText< / a > ( item-> < a href = "tqlistviewitem.html#text" > text< / a > ( 2 ) );
iEMail-> < a href = "tqlineedit.html#setText" > setText< / a > ( item-> < a href = "tqlistviewitem.html#text" > text< / a > ( 3 ) );
}
void < a name = "f283" > < / a > ABCentralWidget::toggleFirstName()
{
sFirstName-> < a href = "tqlineedit.html#setText" > setText< / a > ( "" );
< a name = "x573" > < / a > if ( cFirstName-> < a href = "tqcheckbox.html#isChecked" > isChecked< / a > () ) {
sFirstName-> < a href = "tqwidget.html#setEnabled" > setEnabled< / a > ( TRUE );
< a name = "x606" > < / a > sFirstName-> < a href = "tqwidget.html#setFocus" > setFocus< / a > ();
}
else
sFirstName-> < a href = "tqwidget.html#setEnabled" > setEnabled< / a > ( FALSE );
}
void < a name = "f284" > < / a > ABCentralWidget::toggleLastName()
{
sLastName-> < a href = "tqlineedit.html#setText" > setText< / a > ( "" );
if ( cLastName-> < a href = "tqcheckbox.html#isChecked" > isChecked< / a > () ) {
sLastName-> < a href = "tqwidget.html#setEnabled" > setEnabled< / a > ( TRUE );
sLastName-> < a href = "tqwidget.html#setFocus" > setFocus< / a > ();
}
else
sLastName-> < a href = "tqwidget.html#setEnabled" > setEnabled< / a > ( FALSE );
}
void < a name = "f285" > < / a > ABCentralWidget::toggleAddress()
{
sAddress-> < a href = "tqlineedit.html#setText" > setText< / a > ( "" );
if ( cAddress-> < a href = "tqcheckbox.html#isChecked" > isChecked< / a > () ) {
sAddress-> < a href = "tqwidget.html#setEnabled" > setEnabled< / a > ( TRUE );
sAddress-> < a href = "tqwidget.html#setFocus" > setFocus< / a > ();
}
else
sAddress-> < a href = "tqwidget.html#setEnabled" > setEnabled< / a > ( FALSE );
}
void < a name = "f286" > < / a > ABCentralWidget::toggleEMail()
{
sEMail-> < a href = "tqlineedit.html#setText" > setText< / a > ( "" );
if ( cEMail-> < a href = "tqcheckbox.html#isChecked" > isChecked< / a > () ) {
sEMail-> < a href = "tqwidget.html#setEnabled" > setEnabled< / a > ( TRUE );
sEMail-> < a href = "tqwidget.html#setFocus" > setFocus< / a > ();
}
else
sEMail-> < a href = "tqwidget.html#setEnabled" > setEnabled< / a > ( FALSE );
}
void < a name = "f287" > < / a > ABCentralWidget::findEntries()
{
if ( !cFirstName-> < a href = "tqcheckbox.html#isChecked" > isChecked< / a > () & &
!cLastName-> < a href = "tqcheckbox.html#isChecked" > isChecked< / a > () & &
!cAddress-> < a href = "tqcheckbox.html#isChecked" > isChecked< / a > () & &
!cEMail-> < a href = "tqcheckbox.html#isChecked" > isChecked< / a > () ) {
< a name = "x587" > < / a > listView-> < a href = "tqlistview.html#clearSelection" > clearSelection< / a > ();
return;
}
< a href = "tqlistviewitemiterator.html" > TQListViewItemIterator< / a > it( listView );
for ( ; it.< a href = "tqlistviewitemiterator.html#current" > current< / a > (); ++it ) {
bool select = TRUE;
if ( cFirstName-> < a href = "tqcheckbox.html#isChecked" > isChecked< / a > () ) {
if ( select & & it.< a href = "tqlistviewitemiterator.html#current" > current< / a > ()-> text( 0 ).contains( sFirstName-> < a href = "tqlineedit.html#text" > text< / a > () ) )
select = TRUE;
else
select = FALSE;
}
if ( cLastName-> < a href = "tqcheckbox.html#isChecked" > isChecked< / a > () ) {
if ( select & & it.< a href = "tqlistviewitemiterator.html#current" > current< / a > ()-> text( 1 ).contains( sLastName-> < a href = "tqlineedit.html#text" > text< / a > () ) )
select = TRUE;
else
select = FALSE;
}
if ( cAddress-> < a href = "tqcheckbox.html#isChecked" > isChecked< / a > () ) {
if ( select & & it.< a href = "tqlistviewitemiterator.html#current" > current< / a > ()-> text( 2 ).contains( sAddress-> < a href = "tqlineedit.html#text" > text< / a > () ) )
select = TRUE;
else
select = FALSE;
}
if ( cEMail-> < a href = "tqcheckbox.html#isChecked" > isChecked< / a > () ) {
if ( select & & it.< a href = "tqlistviewitemiterator.html#current" > current< / a > ()-> text( 3 ).contains( sEMail-> < a href = "tqlineedit.html#text" > text< / a > () ) )
select = TRUE;
else
select = FALSE;
}
if ( select )
it.< a href = "tqlistviewitemiterator.html#current" > current< / a > ()-> setSelected( TRUE );
else
it.< a href = "tqlistviewitemiterator.html#current" > current< / a > ()-> setSelected( FALSE );
it.< a href = "tqlistviewitemiterator.html#current" > current< / a > ()-> repaint();
}
}
< / pre >
< p > < hr >
< p > Main:
< p > < pre > /****************************************************************************
** $Id: qt/main.cpp 3.3.8 edited Jan 11 14:37 $
**
** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
**
** This file is part of an example program for TQt. This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/
#include < < a href = "qapplication-h.html" > ntqapplication.h< / a > >
#include "mainwindow.h"
int main( int argc, char ** argv )
{
< a href = "ntqapplication.html" > TQApplication< / a > a( argc, argv );
ABMainWindow *mw = new ABMainWindow();
mw-> < a href = "tqwidget.html#setCaption" > setCaption< / a > ( "TQt Example - Addressbook" );
a.< a href = "ntqapplication.html#setMainWidget" > setMainWidget< / a > ( mw );
< a name = "x611" > < / a > mw-> < a href = "tqwidget.html#show" > show< / a > ();
< a name = "x609" > < / a > < a name = "x608" > < / a > a.< a href = "tqobject.html#connect" > connect< / a > ( & a, TQ_SIGNAL( < a href = "ntqapplication.html#lastWindowClosed" > lastWindowClosed< / a > () ), & a, TQ_SLOT( < a href = "ntqapplication.html#quit" > quit< / a > () ) );
int result = a.< a href = "ntqapplication.html#exec" > exec< / a > ();
delete mw;
return result;
}
< / pre >
< p > See also < a href = "examples.html" > Examples< / a > .
<!-- eof -->
< p > < address > < hr > < div align = center >
< table width = 100% cellspacing = 0 border = 0 > < tr >
< td > Copyright © 2007
< a href = "troll.html" > Trolltech< / a > < td align = center > < a href = "trademarks.html" > Trademarks< / a >
< td align = right > < div align = right > TQt 3.3.8< / div >
< / table > < / div > < / address > < / body >
< / html >