mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-05 21:29:23 -04:00

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@246 b45a01b8-16f6-495d-af2f-9b41ad6348cc
84 lines
2.3 KiB
C++
84 lines
2.3 KiB
C++
/****************************************************************
|
|
* RetroShare is distributed under the following license:
|
|
*
|
|
* Copyright (C) 2006, 2007 crypton
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
* Boston, MA 02110-1301, USA.
|
|
****************************************************************/
|
|
|
|
#ifndef EVENTFILTER_H
|
|
#define EVENTFILTER_H
|
|
|
|
#include <util/rsqtutildll.h>
|
|
|
|
#include <util/NonCopyable.h>
|
|
|
|
#include <QtCore/QObject>
|
|
|
|
class QEvent;
|
|
|
|
/**
|
|
* EventFilter for QObject.
|
|
*
|
|
* Permits to make some special actions on Qt events.
|
|
* Example:
|
|
* <code>
|
|
* QMainWindow * widget = new QMainWindow();
|
|
* CloseEventFilter * closeFilter = new CloseEventFilter(this, SLOT(printHelloWorld()));
|
|
* ResizeEventFilter * resizeFilter = new ResizeEventFilter(this, SLOT(printHelloWorld()));
|
|
* widget->installEventFilter(closeFilter);
|
|
* widget->installEventFilter(resizeFilter);
|
|
* </code>
|
|
*
|
|
*
|
|
*/
|
|
class RSQTUTIL_API EventFilter : public QObject, NonCopyable {
|
|
Q_OBJECT
|
|
public:
|
|
|
|
/**
|
|
* Filters an event.
|
|
*
|
|
* @param receiver object receiver of the filter signal
|
|
* @param member member of the object called by the filter signal
|
|
* @param watched watched object the filter is going to be applied on
|
|
*/
|
|
EventFilter(QObject * receiver, const char * member);
|
|
|
|
protected:
|
|
|
|
/**
|
|
* Emits the filter signal.
|
|
*
|
|
* @param event event filtered
|
|
*/
|
|
void filter(QEvent * event);
|
|
|
|
/**
|
|
* Filters the event.
|
|
*
|
|
* @param watched watched object
|
|
* @param event event filtered of the watched object
|
|
* @return true then stops the event being handled further
|
|
*/
|
|
virtual bool eventFilter(QObject * watched, QEvent * event);
|
|
|
|
Q_SIGNALS:
|
|
|
|
void activate(QEvent * event);
|
|
};
|
|
|
|
#endif //EVENTFILTER_H
|