1 /* 2 Copyright (C) 2014 Aseman 3 http://aseman.co 4 5 This project is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 This project is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #ifndef ASEMANBACKHANDLER_H 20 #define ASEMANBACKHANDLER_H 21 22 #include <QObject> 23 #include <QJSValue> 24 25 class AsemanBackHandlerPrivate; 26 class AsemanBackHandler : public QObject 27 { 28 Q_OBJECT 29 30 Q_PROPERTY(QObject* topHandlerObject READ topHandlerObject NOTIFY topHandlerChanged) 31 Q_PROPERTY(QJSValue topHandlerMethod READ topHandlerMethod NOTIFY topHandlerChanged) 32 Q_PROPERTY(int count READ count NOTIFY countChanged) 33 34 public: 35 AsemanBackHandler(QObject *parent = 0); 36 ~AsemanBackHandler(); 37 38 QObject *topHandlerObject() const; 39 QJSValue topHandlerMethod() const; 40 41 int count(); 42 43 public slots: 44 void pushHandler( QObject *obj, QJSValue jsv ); 45 void pushDownHandler( QObject *obj, QJSValue jsv ); 46 void removeHandler( QObject *obj ); 47 48 QObject *tryPopHandler(); 49 QObject *forcePopHandler(); 50 51 bool back(); 52 53 signals: 54 void topHandlerChanged(); 55 void countChanged(); 56 void backFinished(); 57 58 private slots: 59 void object_destroyed( QObject *obj ); 60 61 private: 62 AsemanBackHandlerPrivate *p; 63 }; 64 65 #endif // ASEMANBACKHANDLER_H 66