kpilot
actionQueue.h
Go to the documentation of this file.00001 #ifndef KPILOT_ACTIONQUEUE_H 00002 #define KPILOT_ACTIONQUEUE_H 00003 /* 00004 ** 00005 ** Copyright (C) 1998-2001,2003 by Dan Pilone <dan@kpilot.org> 00006 ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> 00007 ** 00008 */ 00009 00010 /* 00011 ** This program is free software; you can redistribute it and/or modify 00012 ** it under the terms of the GNU General Public License as published by 00013 ** the Free Software Foundation; either version 2 of the License, or 00014 ** (at your option) any later version. 00015 ** 00016 ** This program is distributed in the hope that it will be useful, 00017 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 ** GNU General Public License for more details. 00020 ** 00021 ** You should have received a copy of the GNU General Public License 00022 ** along with this program in a file called COPYING; if not, write to 00023 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00024 ** MA 02110-1301, USA. 00025 */ 00026 00027 /* 00028 ** Bug reports and questions can be sent to kde-pim@kde.org 00029 */ 00030 00031 // KPilot headers 00032 #include "syncAction.h" 00033 00034 // Qt headers 00035 #include <QtCore/QQueue> 00036 00037 00060 class KPILOT_EXPORT ActionQueue : public SyncAction 00061 { 00062 Q_OBJECT 00063 public: 00069 ActionQueue(KPilotLink *device); 00070 00072 virtual ~ActionQueue(); 00073 00075 bool isEmpty() const 00076 { 00077 return SyncActionQueue.isEmpty(); 00078 }; 00079 00084 void addAction(SyncAction *a) 00085 { 00086 SyncActionQueue.enqueue(a); 00087 }; 00088 00089 public: 00090 /* 00091 * Call these queue*() functions to append standard functional 00092 * blocks. You should at least call queueInit() and 00093 * queueCleanup() to add the welcome and cleanup actions to 00094 * the queue (unless you do that yourself.) 00095 * 00096 * For queueInit, a WelcomeAction is added. 00097 * For queueConduits, whatever is relevant for the conduits 00098 * can be used, usually things in the FlagMask and ActionMask. 00099 * The list of conduits in @p conduits is queued automatically. 00100 */ 00101 00111 void queueInit(); 00112 00122 void queueConduits(const QStringList &conduits, 00123 const SyncAction::SyncMode &mode); 00124 00131 void queueCleanup(); 00132 00133 protected: 00138 void clear(); 00139 00145 SyncAction *nextAction() 00146 { 00147 // Make sure the queue isn't empty. 00148 if( !SyncActionQueue.isEmpty() ) 00149 { 00150 return SyncActionQueue.dequeue(); 00151 } 00152 else 00153 { 00154 return 0L; 00155 } 00156 }; 00157 00159 virtual bool exec(); 00160 00161 protected slots: 00165 void actionCompleted(SyncAction *); 00166 00167 private: 00169 QQueue<SyncAction*> SyncActionQueue; 00170 }; 00171 00172 00173 #endif
KDE 4.2 API Reference