LeechCraft  0.6.70-10870-g558588d6ec
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  * Boost Software License - Version 1.0 - August 17th, 2003
6  *
7  * Permission is hereby granted, free of charge, to any person or organization
8  * obtaining a copy of the software and accompanying documentation covered by
9  * this license (the "Software") to use, reproduce, display, distribute,
10  * execute, and transmit the Software, and to prepare derivative works of the
11  * Software, and to permit third-parties to whom the Software is furnished to
12  * do so, all subject to the following:
13  *
14  * The copyright notices in the Software and this entire statement, including
15  * the above license grant, this restriction and the following disclaimer,
16  * must be included in all copies of the Software, in whole or in part, and
17  * all derivative works of the Software, unless such copies or derivative
18  * works are solely in the form of machine-executable object code generated by
19  * a source language processor.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
24  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
25  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  **********************************************************************/
29 
30 #pragma once
31 
32 #include <memory>
33 #include <boost/optional.hpp>
34 #include <QHash>
35 #include <QDebug>
36 #include <QIcon>
38 #include "xdgconfig.h"
39 #include "itemtypes.h"
40 
41 namespace LeechCraft
42 {
43 namespace Util
44 {
45 namespace XDG
46 {
47  class Item;
48 
49  using Item_ptr = std::shared_ptr<Item>;
50 
61  {
62  QHash<QString, QString> Name_;
63  QHash<QString, QString> GenericName_;
64  QHash<QString, QString> Comments_;
65 
66  QStringList Categories_;
67  QString Command_;
68  QString WD_;
69 
70  QString IconName_;
71  mutable boost::optional<QIcon> Icon_;
72 
73  bool IsHidden_ = false;
74  Type Type_ = Type::Other;
75  public:
85  friend UTIL_XDG_API bool operator== (const Item& left, const Item& right);
86 
96  friend UTIL_XDG_API bool operator!= (const Item& left, const Item& right);
97 
104  bool IsValid () const;
105 
113  bool IsHidden () const;
114 
124  void Execute (ICoreProxy_ptr proxy) const;
125 
135  QString GetName (const QString& language) const;
136 
147  QString GetGenericName (const QString& language) const;
148 
157  QString GetComment (const QString& language) const;
158 
168  QString GetIconName () const;
169 
174  QStringList GetCategories () const;
175 
180  Type GetType () const;
181 
192  QString GetCommand () const;
193 
204  QString GetWorkingDirectory () const;
205 
213  QString GetPermanentID () const;
214 
231  QIcon GetIcon (const ICoreProxy_ptr&) const;
232 
242  QDebug DebugPrint (QDebug stream) const;
243 
253  static Item_ptr FromDesktopFile (const QString& file);
254  };
255 
265  QDebug operator<< (QDebug stream, const Item& item);
266 }
267 }
268 }
std::string Name_
class UTIL_XDG_API Item
Definition: itemsfinder.h:44
std::shared_ptr< Item > Item_ptr
Definition: item.h:49
bool operator!=(const Item &left, const Item &right)
Definition: item.cpp:60
Describes a single XDG .desktop entry.
Definition: item.h:60
bool operator==(const Item &left, const Item &right)
Definition: item.cpp:47
Type
Describes the various types of XDG .desktop files.
Definition: itemtypes.h:48
std::shared_ptr< ICoreProxy > ICoreProxy_ptr
Definition: icoreproxy.h:225
#define UTIL_XDG_API
Definition: xdgconfig.h:37
QDebug operator<<(QDebug dbg, const Item &item)
Serializes item contents to the debugging stream.
Definition: item.cpp:263