We now have a current svn snapshot of libqxt in our contrib dir, and
[quassel.git] / src / contrib / libqxt-2007-10-24 / src / core / qxtslotjob.h
1
2 /****************************************************************************
3 **
4 ** Copyright (C) Qxt Foundation. Some rights reserved.
5 **
6 ** This file is part of the QxtCore module of the Qt eXTension library
7 **
8 ** This library is free software; you can redistribute it and/or modify it
9 ** under the terms of th Common Public License, version 1.0, as published by
10 ** IBM.
11 **
12 ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY
13 ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
14 ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
15 ** FITNESS FOR A PARTICULAR PURPOSE.
16 **
17 ** You should have received a copy of the CPL along with this file.
18 ** See the LICENSE file and the cpl1.0.txt file included with the source
19 ** distribution for more information. If you did not receive a copy of the
20 ** license, contact the Qxt Foundation.
21 **
22 ** <http://libqxt.sourceforge.net>  <foundation@libqxt.org>
23 **
24 ****************************************************************************/
25 #ifndef QXTJOB_H_GUARD
26 #define QXTJOB_H_GUARD
27
28
29 #include <QVariant>
30
31 #include <qxtpimpl.h>
32 #include <qxtglobal.h>
33 #include <qxtjob.h>
34
35
36 class QxtSignalWaiter;
37 class QxtSlotJob;
38 class QXT_CORE_EXPORT QxtFuture: public QObject
39 {
40 Q_OBJECT
41 public:
42     QVariant delayedResult(int msec=-1);
43     QVariant joinedResult();
44
45     QxtFuture(const QxtFuture& other);
46     ~QxtFuture();
47 private:
48     friend class QxtSlotJob;
49     QxtFuture(QxtSlotJob* j);
50     QxtSlotJob * job;
51     QxtSignalWaiter * waiter;
52 signals:
53     void done();
54     void done(QVariant);
55 };
56
57
58 class QxtSlotJobPrivate;
59 class QThread;
60 class QXT_CORE_EXPORT QxtSlotJob : public QxtJob
61 {
62 Q_OBJECT
63 public:
64      static QxtFuture detach(QThread * o,QObject* recv, const char* slot,
65         QGenericArgument p1=QGenericArgument(),
66         QGenericArgument p2=QGenericArgument(),
67         QGenericArgument p3=QGenericArgument(),
68         QGenericArgument p4=QGenericArgument(),
69         QGenericArgument p5=QGenericArgument(),
70         QGenericArgument p6=QGenericArgument(),
71         QGenericArgument p7=QGenericArgument(),
72         QGenericArgument p8=QGenericArgument(),
73         QGenericArgument p9=QGenericArgument(),
74         QGenericArgument p10=QGenericArgument()); 
75
76     QxtSlotJob(QObject* recv, const char* slot,
77         QGenericArgument p1=QGenericArgument(),
78         QGenericArgument p2=QGenericArgument(),
79         QGenericArgument p3=QGenericArgument(),
80         QGenericArgument p4=QGenericArgument(),
81         QGenericArgument p5=QGenericArgument(),
82         QGenericArgument p6=QGenericArgument(),
83         QGenericArgument p7=QGenericArgument(),
84         QGenericArgument p8=QGenericArgument(),
85         QGenericArgument p9=QGenericArgument(),
86         QGenericArgument p10=QGenericArgument());
87
88     QVariant result();
89     QxtFuture exec(QThread *o);
90
91 protected:
92     virtual void run();
93 signals:
94     void done(QVariant);
95 private:
96     QXT_DECLARE_PRIVATE(QxtSlotJob);
97 ///must not be in pimpl. that's heavy doom when they are both Qobject and one moves to another thread
98 private slots:  
99     void pdone();
100
101 };
102
103
104
105
106 #endif
107
108