qavrg 0.0.28
qavrgtestwindow.h
Go to the documentation of this file.
00001 #ifndef QAVRGTESTWINDOW_H
00002 #define QAVRGTESTWINDOW_H
00003 
00004 #include <QMainWindow>
00005 #include <QThread>
00006 #include <QSpinBox>
00007 #include <QPushButton>
00008 #include <QMutex>
00009 #include <QMutexLocker>
00010 
00011 class QavrgTestWindow;
00012 class QavrgTestInteger;
00013 
00014 class QavrgTestProxy   : public QObject
00015 {
00016   Q_OBJECT;
00017 
00018 public:
00019   QavrgTestProxy(int useProxy, int useTransaction, QavrgTestInteger *integer, QSpinBox *spinBox, QObject *parent=0);
00020 
00021 public slots:
00022   void valueChanged(int value, qint64 id);
00023   void spinBoxChanged(int value);
00024 
00025 signals:
00026   void changeSpinBox(int value);
00027   void changeInteger(int value, qint64 id);
00028 
00029 private:
00030   mutable QMutex    m_Mutex;
00031   int               m_UseProxy;
00032   int               m_UseTransaction;
00033   int               m_Value;
00034   QavrgTestInteger *m_Integer;
00035   QSpinBox         *m_SpinBox;
00036   qint64            m_TransactionId;
00037 };
00038 
00039 class QavrgTestInteger : public QObject
00040 {
00041   Q_OBJECT;
00042 
00043 public:
00044   QavrgTestInteger(int useProxy, int useTransaction, QObject *parent=0);
00045 
00046   void linkTo(QSpinBox *spinBox);
00047 
00048 public slots:
00049   void set_Integer(int value);
00050   int  get_Integer() const;
00051   void setValue(int value, qint64 id=0);
00052 
00053 signals:
00054   void chg_Integer(int value, qint64 id=0);
00055 
00056 private:
00057   mutable QMutex  m_Mutex;
00058   int             m_UseProxy;
00059   int             m_UseTransaction;
00060   int             m_Value;
00061   qint64          m_TransactionId;
00062   int             m_NQueuedUpdates;
00063 };
00064 
00065 class QavrgTestThread : public QThread
00066 {
00067   Q_OBJECT;
00068 
00069 public:
00070   QavrgTestThread(int useProxy, int useTransaction, QavrgTestWindow *win, QObject *parent=0);
00071 
00072   void run();
00073 
00074 public:
00075   QavrgTestInteger *m_Integer;
00076 
00077 private:
00078   int               m_UseProxy;
00079   int               m_UseTransaction;
00080   QavrgTestWindow  *m_Window;
00081 };
00082 
00083 class QavrgTestWindow : public QWidget
00084 {
00085   Q_OBJECT;
00086 
00087 public:
00088   QavrgTestWindow(int useProxy, int useTransaction, QWidget *parent = NULL);
00089 
00090 public slots:
00091   void increment();
00092   void doubleIncrement();
00093   void countFive();
00094   void countThousand();
00095 
00096 signals:
00097   void set_Integer(int value);
00098 
00099 public:
00100   QSpinBox         *m_SpinBox;
00101   QPushButton      *m_Increment;
00102   QPushButton      *m_DoubleIncrement;
00103   QPushButton      *m_CountFive;
00104   QPushButton      *m_CountThousand;
00105 
00106 private:
00107   int               m_UseProxy;
00108   int               m_UseTransaction;
00109   QavrgTestThread  *m_Thread;
00110 };
00111 
00112 #endif // QAVRGTESTWINDOW_H