Changeset View
Changeset View
Standalone View
Standalone View
src/service/plugins/gtk-eventspy/GtkEventSpy.cpp
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | |||||
60 | 60 | | |||
61 | class Bookmark | 61 | class Bookmark | ||
62 | { | 62 | { | ||
63 | public: | 63 | public: | ||
64 | QUrl href; | 64 | QUrl href; | ||
65 | QDateTime added; | 65 | QDateTime added; | ||
66 | QDateTime modified; | 66 | QDateTime modified; | ||
67 | QDateTime visited; | 67 | QDateTime visited; | ||
68 | QString mimetype; | ||||
68 | QList<Application> applications; | 69 | QList<Application> applications; | ||
69 | 70 | | |||
70 | QString latestApplication() const; | 71 | QString latestApplication() const; | ||
71 | }; | 72 | }; | ||
72 | 73 | | |||
73 | QString Bookmark::latestApplication() const | 74 | QString Bookmark::latestApplication() const | ||
74 | { | 75 | { | ||
75 | Application current = applications.first(); | 76 | Application current = applications.first(); | ||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | 144 | if (spaceIndex != -1) { | |||
144 | exec = exec.mid(0, spaceIndex); | 145 | exec = exec.mid(0, spaceIndex); | ||
145 | } | 146 | } | ||
146 | app.name = exec; | 147 | app.name = exec; | ||
147 | } | 148 | } | ||
148 | 149 | | |||
149 | app.modified = QDateTime::fromString(attributes.value("modified"), Qt::ISODate); | 150 | app.modified = QDateTime::fromString(attributes.value("modified"), Qt::ISODate); | ||
150 | 151 | | |||
151 | current.applications.append(app); | 152 | current.applications.append(app); | ||
153 | } else if (qName == QStringLiteral("mime:mime-type")) { | ||||
154 | current.mimetype = attributes.value("type"); | ||||
152 | } | 155 | } | ||
153 | return true; | 156 | return true; | ||
154 | } | 157 | } | ||
155 | 158 | | |||
156 | bool BookmarkHandler::endElement(const QString &namespaceURI, const QString &localName, | 159 | bool BookmarkHandler::endElement(const QString &namespaceURI, const QString &localName, | ||
157 | const QString &qName) | 160 | const QString &qName) | ||
158 | { | 161 | { | ||
159 | Q_UNUSED(namespaceURI); | 162 | Q_UNUSED(namespaceURI); | ||
Show All 29 Lines | 189 | if (!reader.parse(source)) { | |||
189 | return; | 192 | return; | ||
190 | } | 193 | } | ||
191 | 194 | | |||
192 | // then find the files that were accessed since last run | 195 | // then find the files that were accessed since last run | ||
193 | const QList<Bookmark> bookmarks = bookmarkHandler.bookmarks(); | 196 | const QList<Bookmark> bookmarks = bookmarkHandler.bookmarks(); | ||
194 | for (const Bookmark &mark : bookmarks) { | 197 | for (const Bookmark &mark : bookmarks) { | ||
195 | if (mark.added > m_lastUpdate || mark.modified > m_lastUpdate | 198 | if (mark.added > m_lastUpdate || mark.modified > m_lastUpdate | ||
196 | || mark.visited > m_lastUpdate) { | 199 | || mark.visited > m_lastUpdate) { | ||
197 | addDocument(mark.href, mark.latestApplication()); | 200 | addDocument(mark.href, mark.latestApplication(), mark.mimetype); | ||
198 | } | 201 | } | ||
199 | } | 202 | } | ||
200 | 203 | | |||
201 | m_lastUpdate = QDateTime::currentDateTime(); | 204 | m_lastUpdate = QDateTime::currentDateTime(); | ||
202 | } | 205 | } | ||
203 | 206 | | |||
204 | void GtkEventSpyPlugin::addDocument(const QUrl &url, const QString &application) | 207 | void GtkEventSpyPlugin::addDocument(const QUrl &url, const QString &application, const QString &mimetype) | ||
ivan: const-ref not const val - `const QString& mimetype` | |||||
205 | { | 208 | { | ||
206 | const QString name = url.fileName(); | 209 | const QString name = url.fileName(); | ||
207 | 210 | | |||
208 | Plugin::invoke<Qt::QueuedConnection>( | 211 | Plugin::invoke<Qt::QueuedConnection>( | ||
209 | m_resources, "RegisterResourceEvent", | 212 | m_resources, "RegisterResourceEvent", | ||
210 | Q_ARG(QString, application), // Application | 213 | Q_ARG(QString, application), // Application | ||
211 | Q_ARG(uint, 0), // Window ID | 214 | Q_ARG(uint, 0), // Window ID | ||
212 | Q_ARG(QString, url.toString()), // URI | 215 | Q_ARG(QString, url.toString()), // URI | ||
213 | Q_ARG(uint, 0) // Event Activities::Accessed | 216 | Q_ARG(uint, 0) // Event Activities::Accessed | ||
214 | ); | 217 | ); | ||
218 | | ||||
219 | Plugin::invoke<Qt::QueuedConnection>( | ||||
220 | m_resources, "RegisteredResourceMimetype", | ||||
221 | Q_ARG(QString, url.toString()), // uri | ||||
222 | Q_ARG(QString, mimetype) // mimetype | ||||
223 | ); | ||||
215 | } | 224 | } | ||
216 | 225 | | |||
217 | GtkEventSpyPlugin::~GtkEventSpyPlugin() | 226 | GtkEventSpyPlugin::~GtkEventSpyPlugin() | ||
218 | { | 227 | { | ||
219 | } | 228 | } | ||
220 | 229 | | |||
221 | bool GtkEventSpyPlugin::init(QHash<QString, QObject *> &modules) | 230 | bool GtkEventSpyPlugin::init(QHash<QString, QObject *> &modules) | ||
222 | { | 231 | { | ||
223 | Plugin::init(modules); | 232 | Plugin::init(modules); | ||
224 | 233 | | |||
225 | m_resources = modules["resources"]; | 234 | m_resources = modules["resources"]; | ||
226 | 235 | | |||
227 | return true; | 236 | return true; | ||
228 | } | 237 | } | ||
229 | 238 | | |||
230 | #include "GtkEventSpy.moc" | 239 | #include "GtkEventSpy.moc" |
const-ref not const val - const QString& mimetype