Diffstat (limited to 'libopie2/opieui/big-screen/omodalhelper.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opieui/big-screen/omodalhelper.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie2/opieui/big-screen/omodalhelper.h b/libopie2/opieui/big-screen/omodalhelper.h index 096cec4..ed6fee3 100644 --- a/libopie2/opieui/big-screen/omodalhelper.h +++ b/libopie2/opieui/big-screen/omodalhelper.h @@ -111,257 +111,257 @@ private: virtual void done( int, TransactionID ); virtual void next( TransactionID ); virtual void prev( TransactionID ); Record nextRecord( TransactionID &, int & )const; Record prevRecord( TransactionID &, int & )const; int pos( TransactionID )const; Dialog* newDialogRecord( const Record& ); private: OModalHelperDialog *queuedDialog()const; // generate or recycle OModalHelperDialog *m_dialog; OModalHelperSignal *m_signal; // our signal OModalHelperControler *m_controler; IdMap m_ids; // maps ids (uids) to a record IdMap m_doneIds; TransactionMap m_transactions; // activate transactions TransactionMap m_done; // done and waiting for getting picked DialogMap m_editing; // only used for New Mode enum Mode m_mode; // the mode we're in bool m_disabled :1; }; /* ### FIXME use namespace with Qt3 */ /* * A note on flow. The Signal is used for QT Signals when * a record is done. * There is either one controler and this controler slot will * be connected to a dialog signal. * In Queue we get the next and prev signals and call the Helper. * this then changes the Record of the dialog and sets the transactionId * of the controler. * For the new mode * */ class OModalHelperSignal : public QObject { Q_OBJECT public: OModalHelperSignal(OModalHelperBase* base, QObject* parent); ~OModalHelperSignal(); signals: done( int status, TransactionID transaction ); accepted( TransactionID transaction ); rejected( TransactionID transaction ); private: OModalHelperBase* m_base; }; class OModalHelperControler : public QObject { Q_OBJECT public: OModalHelperControler( OModalHelperBase* , QObject* parent); virtual TransactionID transactionID()const; void setTransactionID( TransactionID id ); QDialog* dialog()const; public slots: virtual void done(int result ); virtual void next(); virtual void prev(); private: QDialog *m_dia; TransactionID m_id; OModalHelperBase *m_base; } struct OModalQueueBar; class OModalQueuedDialog : public QDialog { Q_OBJECT public: OModalQueuedDialog(QDialog *mainWidget); ~OModalQueuedDialog(); QDialog* centerDialog()const; void setQueueBarEnabled( bool = true ); void setRecord( int record, int count ); signals: void next(); void prev(); private: OModalQueueBar *m_bar; QDialog *m_center; }; /* * Tcpp Template Implementation */ /** * This is the simple Template c'tor. It takes the mode * this helper should operate in and the parent object. * This helper will be deleted when the parent gets deleted * or you delete it yourself. * * @param mode The mode this dialog should be in * @param parent The parent QObject of this helper. */ template<class Dialog, class Record, typename Id> OModalHelper<Dialog, Record, Id>::OModalHelper( enum Mode mode, QObject* parent ) { m_disabled = false; m_mode = mode; m_signal = new OModalHelperSignal( this, parent ); m_controler = new OModalHelperControler( this, m_signal ); } /** * This functions looks for your record and sees if it is * handled with this helper. Note that done records * will not be returned. * * @return true if the record is currenlty edited otherwise false * - * @param Id The id which might be handled + * @param id The id which might be handled */ template<class Dialog, class Record, typename Id> bool OModalHelper<Dialog, Record, Id>::handles( Id id )const { if ( m_transactions.isEmpty() ) return false; TransactionMap::ConstIterator it = m_transactions.begin(); for ( ; it != m_transactions.end(); ++it ) if ( it.data() == id ) return true; return false; } /** * just like handles( Id ) but returns the TransactionId */ template<class Dialog, class Record, typename Id> TransactionID OModalHelper<Dialog, Record, Id>::transactionID( Id id)const { if ( m_transactions.isEmpty() || !m_ids.contains( id ) ) return 0; TransactionMap::ConstIterator it = m_transactions.begin(); for ( ; it != m_transactions.end(); ++it ) if ( it.data() == id ) return it.key(); return 0; } /** * If you're requested to flush your data and you do not want * to call cancel with this method you can disable and enabled * all dialogs. * The state gets saved so if you want to handle a new record the dialog * will be disabled as well. * * @param sus If true setDisabled(TRUE) will be called otherwise FALSE */ template<class Dialog, class Record, typename Id> void OModalHelper<Dialog, Record, Id>::suspend(bool sus) { m_disabled = sus; if (m_mode == New ) for (DialogMap::Iterator it = m_editing.begin(); it != m_editing.end(); ++it ) it.key()->setDisabled( sus ); else if (m_dialog ) queuedDialog()->setDisabled( sus ); } /** * Cancel will cancel all current operations and clear the list * of done operations as well. * This also clears all done operations you did not popped */ template<class Dialog, class Record, typename Id> void OModalHelper<Dialog, Record, Id>::cancel() { m_ids.clear(); m_doneIds.clear(); m_done.clear(); m_transactions.clear(); /* we also need to remove the QDialogs */ /* and hide the queue dialog if present */ if (m_mode == New && !m_editing.isEmpty() ) { for (DialogMap::Iterator it = m_editing.begin(); it != m_editing.end(); ++it ) delete it.key(); m_editing.clear(); } else if (m_dialog ) queuedDialog()->setRecord( 0, 0 ); m_controler->setTransactionID( 0 ); } /** * This cancels editing of the record behind the Transaction Number * Note that if editing is already done it will also be removed from this list */ template<class Dialog, class Record, typename Id> void OModalHelper::cancel( TransactionID tid ) { /* wrong tid */ if (!m_transactions.contains( tid ) && !m_done.contains( tid) ) return; if (m_mode == New ) /* reverse map eek */ for (DialogMap::Iterator it = m_editing.begin(); it != m_editing.end(); ++it ) if ( it.data() == tid ) { it.key()->hide(); delete it.key(); it = m_editing.remove( it ); break; } /* now remove from the various maps done and currently editing map*/ if (m_transactions.contains( tid ) ) m_ids.remove( m_transactions[tid] ); if (m_done.contains( tid ) ) m_doneIds.remove( m_done[tid ] ); m_done.remove( tid ); m_transactions.remove( tid ); next( 0 ); } /** * Connect to the done Signal. SIGNAL( done(int, TransactionID ) ) * This signal gets emitted whenever a Record was accepted or rejected * * @param rec The object where the slot belongs to * @param slot The slot which should be called. See the needed parameter above */ template<class Dialog, class Record, typename Id> void OModalHelper<Dialog, Record, Id>::connectDone( QObject* rec, const char* slot ) { QObject::connect(m_signal, SIGNAL(done(int, TransactionID) ), rec, slot ); } |