LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
item.h
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 #pragma once
10 
11 #include <memory>
12 #include <optional>
13 #include <QHash>
14 #include <QDebug>
15 #include <QIcon>
17 #include "xdgconfig.h"
18 #include "itemtypes.h"
19 
20 namespace LC::Util::XDG
21 {
22  class Item;
23 
24  using Item_ptr = std::shared_ptr<Item>;
25 
35  class UTIL_XDG_API Item
36  {
37  QHash<QString, QString> Name_;
38  QHash<QString, QString> GenericName_;
39  QHash<QString, QString> Comments_;
40 
41  QStringList Categories_;
42  QString Command_;
43  QString WD_;
44 
45  QString IconName_;
46  mutable std::optional<QIcon> Icon_;
47 
48  bool IsHidden_ = false;
49  Type Type_ = Type::Other;
50  public:
60  friend UTIL_XDG_API bool operator== (const Item& left, const Item& right);
61 
71  friend UTIL_XDG_API bool operator!= (const Item& left, const Item& right);
72 
79  bool IsValid () const;
80 
88  bool IsHidden () const;
89 
99  void Execute (const ICoreProxy_ptr& proxy) const;
100 
110  QString GetName (const QString& language) const;
111 
122  QString GetGenericName (const QString& language) const;
123 
132  QString GetComment (const QString& language) const;
133 
143  QString GetIconName () const;
144 
149  QStringList GetCategories () const;
150 
155  Type GetType () const;
156 
167  QString GetCommand () const;
168 
179  QString GetWorkingDirectory () const;
180 
188  QString GetPermanentID () const;
189 
206  QIcon GetIcon (const ICoreProxy_ptr&) const;
207 
217  QDebug DebugPrint (QDebug stream) const;
218 
228  static Item_ptr FromDesktopFile (const QString& file);
229  };
230 
240  QDebug operator<< (QDebug stream, const Item& item);
241 }
LC::Util::XDG::operator!=
bool operator!=(const Item &left, const Item &right)
Definition: item.cpp:42
LC::Util::XDG::operator<<
QDebug operator<<(QDebug dbg, const Item &item)
Serializes item contents to the debugging stream.
Definition: item.cpp:245
LC::Util::XDG::Item_ptr
std::shared_ptr< Item > Item_ptr
Definition: item.h:30
icoreproxy.h
xdgconfig.h
LC::Util::XDG::Type::Other
@ Other
Unknown type.
LC::Util::XDG::Type
Type
Describes the various types of XDG .desktop files.
Definition: itemtypes.h:23
LC::Util::XDG::Item
Describes a single XDG .desktop entry.
Definition: item.h:41
itemtypes.h
LC::Util::XDG
Definition: desktopparser.cpp:15
LC::Util::XDG::operator==
bool operator==(const Item &left, const Item &right)
Definition: item.cpp:29
ICoreProxy_ptr
std::shared_ptr< ICoreProxy > ICoreProxy_ptr
Definition: icoreproxy.h:181
LC::Util::XDG::Item
class UTIL_XDG_API Item
Definition: itemsfinder.h:25
UTIL_XDG_API
#define UTIL_XDG_API
Definition: xdgconfig.h:16
Name_
std::string Name_
Definition: desktopparser.cpp:35