1 /******************************************************************* 2 3 Part of the Fritzing project - http://fritzing.org 4 Copyright (c) 2007-2014 Fachhochschule Potsdam - http://fh-potsdam.de 5 6 Fritzing is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 Fritzing is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with Fritzing. If not, see <http://www.gnu.org/licenses/>. 18 19 ******************************************************************** 20 21 $Revision: 6469 $: 22 $Author: irascibl@gmail.com $: 23 $Date: 2012-09-23 00:54:30 +0200 (So, 23. Sep 2012) $ 24 25 ********************************************************************/ 26 27 #ifndef WAITPUSHUNDOSTACK_H 28 #define WAITPUSHUNDOSTACK_H 29 30 #include <QUndoStack> 31 #include <QTimer> 32 #include <QMutex> 33 #include <QFile> 34 #include <QPointer> 35 36 class WaitPushUndoStack : public QUndoStack 37 { 38 Q_OBJECT 39 public: 40 WaitPushUndoStack(QObject * parent = 0); 41 ~WaitPushUndoStack(); 42 43 void waitPush(QUndoCommand *, int delayMS); 44 void waitPushTemporary(QUndoCommand *, int delayMS); 45 void resolveTemporary(); 46 void deleteTemporary(); 47 void deleteTimer(QTimer *); 48 void addTimer(QTimer *); 49 void push(QUndoCommand *); 50 bool hasTimers(); 51 52 #ifndef QT_NO_DEBUG 53 public: 54 void writeUndo(const QUndoCommand *, int indent, const class BaseCommand * parent); 55 56 protected: 57 QFile m_file; 58 #endif 59 60 protected: 61 void clearDeadTimers(); 62 void clearLiveTimers(); 63 void clearTimers(QList<QTimer *> &); 64 65 protected: 66 QList<QTimer *> m_deadTimers; 67 QList<QTimer *> m_liveTimers; 68 QMutex m_mutex; 69 QUndoCommand * m_temporary; 70 }; 71 72 73 class CommandTimer : public QTimer 74 { 75 76 Q_OBJECT 77 78 public: 79 CommandTimer(QUndoCommand * command, int delayMS, WaitPushUndoStack * undoStack); 80 81 protected slots: 82 void timedout(); 83 84 protected: 85 QUndoCommand * m_command; 86 QPointer<WaitPushUndoStack> m_undoStack; 87 }; 88 89 90 #endif 91