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 // Self 0008 #include "Event.h" 0009 0010 // Local 0011 #include <QDebug> 0012 0013 Event::Event() 0014 : wid(0) 0015 , type(Accessed) 0016 , timestamp(QDateTime::currentDateTime()) 0017 { 0018 } 0019 0020 Event::Event(const QString &vApplication, quintptr vWid, const QString &vUri, int vType) 0021 : application(vApplication) 0022 , wid(vWid) 0023 , uri(vUri) 0024 , type(vType) 0025 , timestamp(QDateTime::currentDateTime()) 0026 { 0027 Q_ASSERT(!vApplication.isEmpty()); 0028 Q_ASSERT(!vUri.isEmpty()); 0029 } 0030 0031 Event Event::deriveWithType(Type type) const 0032 { 0033 Event result(*this); 0034 result.type = type; 0035 return result; 0036 } 0037 0038 bool Event::operator==(const Event &other) const 0039 { 0040 return application == other.application && wid == other.wid && uri == other.uri && type == other.type && timestamp == other.timestamp; 0041 } 0042 0043 QString Event::typeName() const 0044 { 0045 switch (type) { 0046 case Accessed: 0047 return QStringLiteral("Accessed"); 0048 case Opened: 0049 return QStringLiteral("Opened"); 0050 case Modified: 0051 return QStringLiteral("Modified"); 0052 case Closed: 0053 return QStringLiteral("Closed"); 0054 case FocussedIn: 0055 return QStringLiteral("FocussedIn"); 0056 case FocussedOut: 0057 return QStringLiteral("FocussedOut"); 0058 default: 0059 return QStringLiteral("Other"); 0060 } 0061 } 0062 0063 QDebug operator<<(QDebug dbg, const Event &e) 0064 { 0065 #ifndef QT_NO_DEBUG_OUTPUT 0066 dbg << "Event(" << e.application << e.wid << e.typeName() << e.uri << ":" << e.timestamp << ")"; 0067 #else 0068 Q_UNUSED(e); 0069 #endif 0070 return dbg.space(); 0071 }