summaryrefslogtreecommitdiff
path: root/libopie/big-screen
Unidiff
Diffstat (limited to 'libopie/big-screen') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/big-screen/omodalhelper.h91
1 files changed, 79 insertions, 12 deletions
diff --git a/libopie/big-screen/omodalhelper.h b/libopie/big-screen/omodalhelper.h
index 643458f..32d921d 100644
--- a/libopie/big-screen/omodalhelper.h
+++ b/libopie/big-screen/omodalhelper.h
@@ -30,16 +30,19 @@
30#define HAZE_OMODAL_HELPER_H 30#define HAZE_OMODAL_HELPER_H
31 31
32#include <qwidget.h> 32#include <qwidget.h>
33#include <qvaluelist.h>
34#include <qmap.h>
33 35
34class OModalHelperSignal : public QObject { 36typedef int TransactionID;
35 Q_OBJECT
36public:
37 OModalHelperSignal();
38 37
39signals: 38class OModalHelperControler;
40 done( int status, int transaction ); 39class OModalHelperSignal;
41 accpeted( int transaction ); 40class QDialog;
42 rejected( int transaction ); 41
42struct OModalHelperBase {
43 virtual void done( TransactionID id, QWidget* ) = 0;
44 virtual void next( TransactionID, OModalHelperControler * );
45 virtual void prev( TransactionID, OModalHelperControler * );
43}; 46};
44 47
45/** 48/**
@@ -58,15 +61,79 @@ signals:
58 * so smart that if only one item is shown that the queue bar is not shown 61 * so smart that if only one item is shown that the queue bar is not shown
59 * See the example for simple usage. 62 * See the example for simple usage.
60 * 63 *
61 * @short helps to live without modaility 64 * @short helps to life without modaility
62 * @author hOlgAr 65 * @author hOlgAr
63 * @version 0.01 66 * @version 0.01
64 */ 67 */
65template<class Dialog, class Record> 68template<class Dialog, class Record, typename Id = QString>
66class OModalHelper{ 69class OModalHelper : private OModalHelperBase{
70 friend class OModalHelperSignal;
71 friend class OModalHelperControler;
67public: 72public:
68 OModalHelper(QObject* parnet ); 73 typedef QValueList<Record> RecordList;
74 typedef QMap<Id, Record> IdMap;
75 typedef QMap<TransactionID, Id> TransactionMap;
76 typedef QMap<QDialog*, TransactionID> DialogMap
77 enum Mode { Queue, New };
78 OModalHelper(enum Mode mode, QObject* parnet );
79
80 bool handles( Id id)const;
81
82 void cancel();
83 void cancel( TransactionID );
69 84
85 void connect( QObject* rec, const char* slot );
86
87 TransactionID handle( const Record& rec = Record() );
88
89 void edited( TransactionID, int what, const QString& data );
90
91 Record record( TransactionID )const;
92 RecordList done()const;
93private:
70}; 94};
71 95
96
97
98/* ### FIXME use namespace with Qt3 */
99
100/*
101 * A note on flow. The Signal is used for QT Signals when
102 * a record is done.
103 * There is either one controler and this controler slot will
104 * be connected to a dialog signal.
105 * In Queue we get the next and prev signals and call the Helper.
106 * this then changes the Record of the dialog and sets the transactionId
107 * of the controler.
108 * For the new mode
109 *
110 */
111
112class OModalHelperSignal : public QObject {
113 Q_OBJECT
114public:
115 OModalHelperSignal();
116
117signals:
118 done( int status, TransactionID transaction );
119 accpeted( TransactionID transaction );
120 rejected( TransactionID transaction );
121};
122
123
124class OModalHelperControler : public QObject {
125 Q_OBJECT
126public:
127 OModalHelperControler( TransactionID id );
128 virtual TransactionID transactionID()const;
129 void setTransactionID( TransactionID id );
130 QDialog* dialog()const;
131
132public slots:
133 virtual done(int result );
134private:
135 QDialog *m_dia;
136 TransactionID m_id;
137}
138
72#endif 139#endif