00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "omodalhelper.h"
00030
00031
00032 #include <qpushbutton.h>
00033 #include <qvbox.h>
00034 #include <qlayout.h>
00035 #include <qlabel.h>
00036
00037
00038 OModalHelperSignal::OModalHelperSignal( OModalHelperBase* base, QObject* parent )
00039 : QObject( parent, "OModal Helper Signal" ), m_base( base )
00040 {}
00041
00042 OModalHelperSignal::~OModalHelperSignal()
00043 {
00044
00045 delete m_base;
00046 }
00047
00048
00049
00050
00051
00052
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
00076
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
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
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 }