Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

mailpluginwidget.cpp

Go to the documentation of this file.
00001 /*
00002  * mailpluginwidget.cpp
00003  *
00004  * copyright   : (c) 2002,2003,2004 by Maximilian Reiß
00005  * email       : harlekin@handhelds.org
00006  *
00007  */
00008 /***************************************************************************
00009  *                                                                         *
00010  *   This program is free software; you can redistribute it and/or modify  *
00011  *   it under the terms of the GNU General Public License as published by  *
00012  *   the Free Software Foundation; either version 2 of the License, or     *
00013  *   (at your option) any later version.                                   *
00014  *                                                                         *
00015  ***************************************************************************/
00016 #include "mailpluginwidget.h"
00017 
00018 #include <qpe/config.h>
00019 #include <qpe/qcopenvelope_qws.h>
00020 
00021 using namespace Opie::Ui;
00022 MailPluginWidget::MailPluginWidget( QWidget *parent,  const char* name)
00023     : QWidget(parent,  name ) {
00024 
00025     m_mailLabel = 0l;
00026     m_layout = 0l;
00027 
00028     if ( m_mailLabel )  {
00029         delete m_mailLabel;
00030     }
00031     m_mailLabel = new OClickableLabel( this );
00032     connect( m_mailLabel, SIGNAL( clicked() ), this, SLOT( startMail() ) );
00033 
00034     if ( m_layout )  {
00035         delete m_layout;
00036     }
00037     m_layout = new QHBoxLayout( this );
00038     m_layout->setAutoAdd( true );
00039 
00040 
00041 #if defined(Q_WS_QWS)
00042 #if !defined(QT_NO_COP)
00043     QCopChannel *qCopChannel = new QCopChannel( "QPE/Pim" , this );
00044     connect ( qCopChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
00045               this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) );
00046 #endif
00047 #endif
00048 
00049     readConfig();
00050     getInfo();
00051 }
00052 
00053 
00054 void MailPluginWidget::channelReceived( const QCString &msg, const QByteArray & data ) {
00055     QDataStream stream( data, IO_ReadOnly );
00056     if ( msg == "outgoingMails(int)" ) {
00057        stream >> m_outgoing;
00058     } else if ( msg == "newMails(int)" ) {
00059        stream >> m_newMails;
00060     }
00061     getInfo();
00062 }
00063 MailPluginWidget::~MailPluginWidget() {
00064     delete m_mailLabel;
00065     delete m_layout;
00066 }
00067 
00068 
00069 void MailPluginWidget::readConfig() {
00070     Config cfg( "todaymailplugin" );
00071     cfg.setGroup( "config" );
00072 
00073     Config cfg2( "mail" );
00074     cfg2.setGroup( "Status" );
00075 
00076     m_newMails = cfg2.readNumEntry( "newMails", 0 );
00077     m_outgoing = cfg2.readNumEntry( "outgoing", 0 );
00078 }
00079 
00080 
00081 void MailPluginWidget::refresh()  {
00082     getInfo();
00083 }
00084 
00085 void MailPluginWidget::getInfo() {
00086 
00087 
00088 
00089     m_mailLabel->setText(  QObject::tr( "<b>%1</b> new mail(s), <b>%2</b> outgoing" ).arg( m_newMails ).arg( m_outgoing ) );
00090 }
00091 
00095 void MailPluginWidget::startMail() {
00096     QCopEnvelope e("QPE/System", "execute(QString)");
00097     e << QString( "opiemail" );
00098 }

Generated on Sat Nov 5 16:15:55 2005 for OPIE by  doxygen 1.4.2