kmail

recipientseditortest.cpp

Go to the documentation of this file.
00001 /*
00002     This file is part of KMail.
00003 
00004     Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010     
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014     GNU General Public License for more details.
00015     
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019     
00020     As a special exception, permission is given to link this program
00021     with any edition of Qt, and distribute the resulting executable,
00022     without including the source code for Qt in the source distribution.
00023 */
00024 
00025 #include "recipientseditortest.h"
00026 
00027 #include "recipientseditor.h"
00028 
00029 #include <kapplication.h>
00030 #include <kdebug.h>
00031 #include <klocale.h>
00032 #include <kcmdlineargs.h>
00033 #include <kmessagebox.h>
00034 #include "aboutdata.h"
00035 
00036 #include <qpushbutton.h>
00037 #include <qlayout.h>
00038 #include <qlabel.h>
00039 #include <qlineedit.h>
00040 #include <qtextedit.h>
00041 
00042 Composer::Composer( QWidget *parent )
00043   : QWidget( parent )
00044 {
00045   QGridLayout *topLayout = new QGridLayout( this );
00046   topLayout->setMargin( 4 );
00047   topLayout->setSpacing( 4 );
00048   
00049   QLabel *label = new QLabel( "From:", this );
00050   topLayout->addWidget( label, 0, 0 );
00051   QLineEdit *edit = new QLineEdit( this );
00052   topLayout->addWidget( edit, 0, 1 );
00053   
00054   mRecipients = new RecipientsEditor( this );
00055   topLayout->addMultiCellWidget( mRecipients, 1, 1, 0, 1 );
00056 
00057   kdDebug() << "SIZEHINT: " << mRecipients->sizeHint() << endl;
00058 
00059 //  mRecipients->setFixedHeight( 10 );
00060   
00061   QTextEdit *editor = new QTextEdit( this );
00062   topLayout->addMultiCellWidget( editor, 2, 2, 0, 1 );
00063   topLayout->setRowStretch( 2, 1 );
00064   
00065   QPushButton *button = new QPushButton( "&Close", this );
00066   topLayout->addMultiCellWidget( button, 3, 3, 0, 1 );
00067   connect( button, SIGNAL( clicked() ), SLOT( slotClose() ) );
00068 }
00069 
00070 void Composer::slotClose()
00071 {
00072 #if 0
00073   QString text;
00074 
00075   text += "<qt>";
00076 
00077   Recipient::List recipients = mRecipients->recipients();
00078   Recipient::List::ConstIterator it;
00079   for( it = recipients.begin(); it != recipients.end(); ++it ) {
00080     text += "<b>" + (*it).typeLabel() + ":</b> " + (*it).email() + "<br/>";
00081   }
00082 
00083   text += "</qt>";
00084 
00085   KMessageBox::information( this, text );
00086 #endif
00087 
00088   close();
00089 }
00090 
00091 int main( int argc, char **argv )
00092 {
00093   KAboutData aboutData( "testrecipienteditor",
00094    "Test Recipient Editor", "0.1" );
00095   KCmdLineArgs::init( argc, argv, &aboutData );
00096 
00097   KApplication app;
00098 
00099   QObject::connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
00100 
00101   QWidget *wid = new Composer( 0 );
00102   
00103   wid->show();
00104 
00105   int ret = app.exec();
00106   
00107   delete wid;
00108   
00109   return ret;
00110 }
00111 
00112 #include "recipientseditortest.moc"