kmail

recipientseditortest.cpp
1/*
2 This file is part of KMail.
3
4 Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of TQt, and distribute the resulting executable,
22 without including the source code for TQt in the source distribution.
23*/
24
25#include "recipientseditortest.h"
26
27#include "recipientseditor.h"
28
29#include <tdeapplication.h>
30#include <kdebug.h>
31#include <tdelocale.h>
32#include <tdecmdlineargs.h>
33#include <tdemessagebox.h>
34#include "aboutdata.h"
35
36#include <tqpushbutton.h>
37#include <tqlayout.h>
38#include <tqlabel.h>
39#include <tqlineedit.h>
40#include <tqtextedit.h>
41
42Composer::Composer( TQWidget *parent )
43 : TQWidget( parent )
44{
45 TQGridLayout *topLayout = new TQGridLayout( this );
46 topLayout->setMargin( 4 );
47 topLayout->setSpacing( 4 );
48
49 TQLabel *label = new TQLabel( "From:", this );
50 topLayout->addWidget( label, 0, 0 );
51 TQLineEdit *edit = new TQLineEdit( this );
52 topLayout->addWidget( edit, 0, 1 );
53
54 mRecipients = new RecipientsEditor( this );
55 topLayout->addMultiCellWidget( mRecipients, 1, 1, 0, 1 );
56
57 kdDebug() << "SIZEHINT: " << mRecipients->sizeHint() << endl;
58
59// mRecipients->setFixedHeight( 10 );
60
61 TQTextEdit *editor = new TQTextEdit( this );
62 topLayout->addMultiCellWidget( editor, 2, 2, 0, 1 );
63 topLayout->setRowStretch( 2, 1 );
64
65 TQPushButton *button = new TQPushButton( "&Close", this );
66 topLayout->addMultiCellWidget( button, 3, 3, 0, 1 );
67 connect( button, TQ_SIGNAL( clicked() ), TQ_SLOT( slotClose() ) );
68}
69
70void Composer::slotClose()
71{
72#if 0
73 TQString text;
74
75 text += "<qt>";
76
77 Recipient::List recipients = mRecipients->recipients();
78 Recipient::List::ConstIterator it;
79 for( it = recipients.begin(); it != recipients.end(); ++it ) {
80 text += "<b>" + (*it).typeLabel() + ":</b> " + (*it).email() + "<br/>";
81 }
82
83 text += "</qt>";
84
85 KMessageBox::information( this, text );
86#endif
87
88 close();
89}
90
91int main( int argc, char **argv )
92{
93 TDEAboutData aboutData( "testrecipienteditor",
94 "Test Recipient Editor", "0.1" );
95 TDECmdLineArgs::init( argc, argv, &aboutData );
96
97 TDEApplication app;
98
99 TQObject::connect( &app, TQ_SIGNAL( lastWindowClosed() ), &app, TQ_SLOT( quit() ) );
100
101 TQWidget *wid = new Composer( 0 );
102
103 wid->show();
104
105 int ret = app.exec();
106
107 delete wid;
108
109 return ret;
110}
111
112#include "recipientseditortest.moc"