File indexing completed on 2024-05-12 16:59:20

0001 /*
0002  *   SPDX-FileCopyrightText: 2011-2016 Ivan Cukic <ivan.cukic@kde.org>
0003  *
0004  *   SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #ifndef EVENT_H
0008 #define EVENT_H
0009 
0010 #include "kactivitymanagerd_plugin_export.h"
0011 
0012 // Qt
0013 #include <QDateTime>
0014 #include <QMetaType>
0015 #include <QString>
0016 
0017 /**
0018  *
0019  */
0020 class KACTIVITYMANAGERD_PLUGIN_EXPORT Event
0021 {
0022 public:
0023     enum Type {
0024         Accessed = 0, ///< resource was accessed, but we don't know for how long it will be open/used
0025 
0026         Opened = 1, ///< resource was opened
0027         Modified = 2, ///< previously opened resource was modified
0028         Closed = 3, ///< previously opened resource was closed
0029 
0030         FocussedIn = 4, ///< resource get the keyboard focus
0031         FocussedOut = 5, ///< resource lost the focus
0032 
0033         LastEventType = 5,
0034         UserEventType = 32,
0035     };
0036 
0037     // These events can't come outside of the activity manager daemon,
0038     // they are intended to provide some additional functionality
0039     // to the daemon plugins
0040     enum UserType {
0041         UpdateScore = UserEventType + 1,
0042     };
0043 
0044     Event();
0045 
0046     explicit Event(const QString &application, quintptr wid, const QString &uri, int type = Accessed);
0047 
0048     Event deriveWithType(Type type) const;
0049 
0050     bool operator==(const Event &other) const;
0051 
0052 public:
0053     QString application;
0054     quintptr wid;
0055     QString uri;
0056     int type;
0057     QDateTime timestamp;
0058 
0059     QString typeName() const;
0060 };
0061 
0062 typedef QList<Event> EventList;
0063 
0064 Q_DECLARE_METATYPE(Event)
0065 Q_DECLARE_METATYPE(EventList)
0066 
0067 #endif // EVENT_H