KTutorial
0.5.1
|
00001 /*************************************************************************** 00002 * Copyright (C) 2010 by Daniel Calviño Sánchez <danxuliu@gmail.com> * 00003 * Copyright (C) 2012 by Daniel Calviño Sánchez <danxuliu@gmail.com> * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; If not, see <http://www.gnu.org/licenses/>. * 00017 ***************************************************************************/ 00018 00019 #include "EventSpyAdaptor.h" 00020 00021 #include <QEvent> 00022 #include <QMetaEnum> 00023 00024 #include "EventSpy.h" 00025 #include "ObjectRegister.h" 00026 00027 namespace ktutorial { 00028 namespace editorsupport { 00029 00030 //public: 00031 00032 EventSpyAdaptor::EventSpyAdaptor(EventSpy* eventSpy, 00033 ObjectRegister* objectRegister): 00034 QDBusAbstractAdaptor(eventSpy), 00035 mObjectRegister(objectRegister) { 00036 connect(eventSpy, SIGNAL(eventReceived(QObject*,QEvent*)), 00037 this, SLOT(handleEventReceived(QObject*,QEvent*))); 00038 } 00039 00040 //private: 00041 00042 void EventSpyAdaptor::handleEventReceived(QObject* object, QEvent* event) { 00043 int id = mObjectRegister->idForObject(object); 00044 00045 int index = QEvent::staticMetaObject.indexOfEnumerator("Type"); 00046 QMetaEnum eventTypeEnumerator = QEvent::staticMetaObject.enumerator(index); 00047 QString eventType = eventTypeEnumerator.valueToKey(event->type()); 00048 00049 emit eventReceived(id, eventType); 00050 } 00051 00052 } 00053 }