TDE core libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

event.cpp 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* This file is part of the KDE project
  2. Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
  3. (C) 1999 David Faure <faure@kde.org>
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public License
  13. along with this library; see the file COPYING.LIB. If not, write to
  14. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. #include <tdeparts/event.h>
  18. using namespace KParts;
  19. //the answer!
  20. #define TDEPARTS_EVENT_MAGIC 42
  21. Event::Event( const char *eventName )
  22. : TQCustomEvent( (TQEvent::Type)(TQEvent::User + TDEPARTS_EVENT_MAGIC), (void *)eventName )
  23. {
  24. }
  25. const char *Event::eventName() const
  26. {
  27. if ( !test( this ) )
  28. return 0L;
  29. return (const char *)data();
  30. }
  31. bool Event::test( const TQEvent *event )
  32. {
  33. if ( !event )
  34. return false;
  35. return ( event->type() == (TQEvent::Type)(TQEvent::User + TDEPARTS_EVENT_MAGIC ) );
  36. }
  37. bool Event::test( const TQEvent *event, const char *name )
  38. {
  39. if ( !test( event ) )
  40. return false;
  41. return ( strcmp( name, (const char *)((TQCustomEvent *)event)->data() ) == 0 );
  42. }
  43. const char *GUIActivateEvent::s_strGUIActivateEvent = "KParts/GUIActivate";
  44. const char *PartActivateEvent::s_strPartActivateEvent = "KParts/PartActivateEvent";
  45. const char *PartSelectEvent::s_strPartSelectEvent = "KParts/PartSelectEvent";