LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
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 
14 namespace 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 }
QList< Type >
itemsdatabase.h
itemtypes.h
LC::Util::XDG
Definition: desktopparser.cpp:15
ICoreProxy_ptr
std::shared_ptr< ICoreProxy > ICoreProxy_ptr
Definition: icoreproxy.h:181
LC::Util::XDG::ItemsFinder
class UTIL_XDG_API ItemsFinder
Definition: xdgfwd.h:25
LC::Util::XDG::ToPaths
QStringList ToPaths(const QList< Type > &types)
Returns a set of typical directories with desktop files of the given types.
Definition: itemtypes.cpp:66
LC::Util::XDG::ItemsDatabase::ItemsDatabase
ItemsDatabase(const ICoreProxy_ptr &proxy, const QList< Type > &types, QObject *parent=nullptr)
Creates the ItemsDatabase for the given types.
Definition: itemsdatabase.cpp:22