LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
itemsdatabase.cpp
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#include "itemsdatabase.h"
10#include <QFileSystemWatcher>
11#include <QTimer>
12#include "itemtypes.h"
13
14namespace LC::Util::XDG
15{
16 ItemsDatabase::ItemsDatabase (const ICoreProxy_ptr& proxy, const QList<Type>& types, QObject *parent)
17 : ItemsFinder { proxy, types, parent }
18 {
19 const auto watcher = new QFileSystemWatcher { this };
20 watcher->addPaths (ToPaths (types));
21 connect (watcher,
22 &QFileSystemWatcher::directoryChanged,
23 this,
24 [this]
25 {
26 if (UpdateScheduled_)
27 return;
28
29 UpdateScheduled_ = true;
30 QTimer::singleShot (10000,
31 this,
32 [this]
33 {
34 UpdateScheduled_ = false;
35 Update ();
36 });
37 });
38 }
39}
ItemsDatabase(const ICoreProxy_ptr &proxy, const QList< Type > &types, QObject *parent=nullptr)
Creates the ItemsDatabase for the given types.
Finds and parses XDG .desktop files.
Definition itemsfinder.h:41
std::shared_ptr< ICoreProxy > ICoreProxy_ptr
Definition icoreproxy.h:181
QStringList ToPaths(const QList< Type > &types)
Returns a set of typical directories with desktop files of the given types.
Definition itemtypes.cpp:60