LeechCraft
0.6.70-18450-gabe19ee3b0
Modular cross-platform feature rich live environment.
Toggle main menu visibility
Loading...
Searching...
No Matches
itemtypes.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 "
itemtypes.h
"
10
#include <QStringList>
11
#include <QDir>
12
#include <QtDebug>
13
#include <
util/sll/prelude.h
>
14
15
namespace
LC::Util::XDG
16
{
17
namespace
18
{
19
QStringList ToPathsImpl (
Type
type)
20
{
21
switch
(type)
22
{
23
case
Type::Application
:
24
case
Type::Dir
:
25
case
Type::URL
:
26
return
27
{
28
QStringLiteral (
"/usr/share/applications"
),
29
QStringLiteral (
"/usr/local/share/applications"
)
30
};
31
case
Type::Other
:
32
return
{};
33
}
34
35
qWarning () << Q_FUNC_INFO
36
<<
"unknown type"
37
<<
static_cast<
int
>
(type);
38
return
{};
39
}
40
41
QStringList Recurse (
const
QString& path)
42
{
43
const
auto
& infos = QDir { path }.entryInfoList (QDir::AllDirs | QDir::NoDotAndDotDot);
44
45
QStringList result { path };
46
result +=
Util::ConcatMap
(infos,
47
[] (
const
QFileInfo& info)
48
{
49
return
Recurse (info.absoluteFilePath ());
50
});
51
return
result;
52
}
53
54
QStringList ToPathsRecurse (
Type
type)
55
{
56
return
Util::ConcatMap
(ToPathsImpl (type), Recurse);
57
}
58
}
59
60
QStringList
ToPaths
(
const
QList<Type>
& types)
61
{
62
return
Util::ConcatMap
(types, ToPathsRecurse);
63
}
64
}
QList
Definition
ianrulesstorage.h:14
itemtypes.h
LC::Util::XDG
Definition
desktopparser.cpp:16
LC::Util::XDG::Type
Type
Describes the various types of XDG .desktop files.
Definition
itemtypes.h:20
LC::Util::XDG::Type::Dir
@ Dir
A shortcut to a directory.
Definition
itemtypes.h:35
LC::Util::XDG::Type::Other
@ Other
Unknown type.
Definition
itemtypes.h:23
LC::Util::XDG::Type::Application
@ Application
A shortcut to an application.
Definition
itemtypes.h:27
LC::Util::XDG::Type::URL
@ URL
A shortcut to an URL.
Definition
itemtypes.h:31
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:60
LC::Util::ConcatMap
auto ConcatMap(Cont &&c, F &&f)
Definition
prelude.h:168
prelude.h
src
util
xdg
itemtypes.cpp
Generated by
1.17.0