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

omodalhelper.cpp

Go to the documentation of this file.
00001 /*
00002                =.            This file is part of the OPIE Project
00003              .=l.            Copyright (c)  2003 hOlgAr <zecke@handhelds.org>
00004            .>+-=
00005  _;:,     .>    :=|.         This library is free software; you can
00006 .> <`_,   >  .   <=          redistribute it and/or  modify it under
00007 :`=1 )Y*s>-.--   :           the terms of the GNU Library General Public
00008 .="- .-=="i,     .._         License as published by the Free Software
00009  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00010      ._= =}       :          or (at your option) any later version.
00011     .%`+i>       _;_.
00012     .i_,=:_.      -<s.       This library is distributed in the hope that
00013      +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
00014     : ..    .:,     . . .    without even the implied warranty of
00015     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00016   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
00017 ..}^=.=       =       ;      Library General Public License for more
00018 ++=   -.     .`     .:       details.
00019  :     =  ...= . :.=-
00020  -.   .:....=;==+<;          You should have received a copy of the GNU
00021   -_. . .   )=.  =           Library General Public License along with
00022     --        :-=`           this library; see the file COPYING.LIB.
00023                              If not, write to the Free Software Foundation,
00024                              Inc., 59 Temple Place - Suite 330,
00025                              Boston, MA 02111-1307, USA.
00026  
00027 */
00028 
00029 #include "omodalhelper.h"
00030 
00031 /* QT */
00032 #include <qpushbutton.h>
00033 #include <qvbox.h>
00034 #include <qlayout.h>
00035 #include <qlabel.h>
00036 
00037 /* Signal handling */
00038 OModalHelperSignal::OModalHelperSignal( OModalHelperBase* base, QObject* parent )
00039         : QObject( parent, "OModal Helper Signal" ), m_base( base )
00040 {}
00041 
00042 OModalHelperSignal::~OModalHelperSignal()
00043 {
00044     /* special the ancestor deletes its creator */
00045     delete m_base;
00046 }
00047 
00048 
00049 /* Helper Controler */
00050 /*
00051  * the dialogs signal will be slotted here
00052  * and we will call into m_base
00053  */
00054 OModalHelperControler::OModalHelperControler( OModalHelperBase* base, QObject* parent )
00055         : QObject(parent, "OModal Helper Controler" ), m_base( base ), m_dia( 0 ), m_id( -1 )
00056 {}
00057 
00058 TransactionID OModalHelperControler::transactionID()const
00059 {
00060     return m_id;
00061 }
00062 
00063 void OModalHelperControler::setTransactionID( TransactionID id )
00064 {
00065     m_dia = 0;
00066     m_id = id;
00067 }
00068 
00069 QDialog* OModalHelperControler::dialog()const
00070 {
00071     return m_dia;
00072 }
00073 
00074 /*
00075  * If we're in the New mode we will map the QDialog
00076  * to the TransactionID
00077  */
00078 void OModalHelperControler::done( int result )
00079 {
00080     if ( sender() && !sender()->isA("OModalQueuedDialog") )
00081         m_dia = static_cast<QDialog*>( sender() );
00082 
00083     m_base->done( result, m_id );
00084 }
00085 
00086 void OModalHelperControler::next()
00087 {
00088     m_base->next( m_id );
00089 }
00090 
00091 void OModalHelperControler::prev()
00092 {
00093     m_base->prev( m_id );
00094 }
00095 
00096 /* The Queued Dialog inclusive QueuedBar */
00097 struct OModalQueueBar : public QHBox
00098 {
00099     QPushButton* next;
00100     QPushButton* prev;
00101     QLabel     * label;
00102 
00103     OModalQueueBar( QWidget* parent );
00104     void setText( const QString& str );
00105 };
00106 
00107 OModalQueueBar::OModalQueueBar( QWidget* parent )
00108         : QWidget( parent, "OModal Queue Bar" )
00109 {
00110     prev = new QPushButton( this );
00111     prev->setText( OModalQueuedDialog::tr("Prev") );
00112 
00113     label = new QLabel(this);
00114 
00115     next = new QPushButton( this );
00116     next->setText( OModalQueuedDialog::tr("Next") );
00117 }
00118 
00119 void OModalQueueBar::setText( const QString& str )
00120 {
00121     label->setText( str );
00122 }
00123 
00124 
00125 OModalQueuedDialog::OModalQueuedDialog( QDialog* mainWidget )
00126         : QDialog(0, "OModal Queued Dialog" )
00127 {
00128     QVBoxLayout *lay = new QVBoxLayout( this );
00129 
00130     m_bar = new OModalQueueBar( this );
00131     lay->addWidget( m_bar );
00132 
00133     m_center = mainWidget;
00134     m_center->reparent(this, 0, QPoint(0, 0) );
00135     lay->addWidget( m_center );
00136 
00137 
00138     connect(m_bar->next, SIGNAL(clicked() ), this,
00139             SIGNAL(next() ) );
00140     connect(m_bar->prev, SIGNAL(clicked() ), this,
00141             SIGNAL(prev() ) );
00142 
00143 }
00144 
00145 OModalQueuedDialog::~OModalQueuedDialog()
00146 {}
00147 
00148 QDialog* OModalQueuedDialog::centerDialog()const
00149 {
00150     return m_center;
00151 }
00152 
00153 void OModalQueuedDialog::setQueueBarEnabled( bool b)
00154 {
00155     /* in Qt3 use setEnabled( bool ) */
00156     if (b)
00157         m_bar->show();
00158     else
00159         m_bar->hide();
00160 }
00161 
00162 void OModalQueuedDialog::setRecord( int record, int count )
00163 {
00164     if (!record && !count )
00165     {
00166         hide();
00167         return;
00168     }
00169     else
00170         show();
00171 
00172     if ( count > 1 )
00173         m_bar->show();
00174     else
00175         m_bar->hide();
00176 
00177     m_bar->setText( tr("Editing record %1 out of %2",
00178                        "Shows the current edited record out of an array of records").arg( record ). arg( count ) );
00179 }

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