LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
ihaverecoverabletabs.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 #ifndef INTERFACES_IHAVERECOVERABLETABS_H
10 #define INTERFACES_IHAVERECOVERABLETABS_H
11 #include <QList>
12 #include <QByteArray>
13 #include <QVariant>
14 
15 class QWidget;
16 class QIcon;
17 
34 class Q_DECL_EXPORT IRecoverableTab
35 {
36 public:
37  virtual ~IRecoverableTab () {}
38 
45  virtual QByteArray GetTabRecoverData () const = 0;
46 
55  virtual QString GetTabRecoverName () const = 0;
56 
64  virtual QIcon GetTabRecoverIcon () const = 0;
65 protected:
74  virtual void tabRecoverDataChanged () = 0;
75 };
76 
77 namespace LC
78 {
80 
93  {
99  QByteArray Data_;
100 
107  };
108 }
109 
128 class Q_DECL_EXPORT IHaveRecoverableTabs
129 {
130 public:
131  virtual ~IHaveRecoverableTabs () {}
132 
147  virtual void RecoverTabs (const QList<LC::TabRecoverInfo>& infos) = 0;
148 
166  virtual bool HasSimilarTab (const QByteArray& data,
167  const QList<QByteArray>& existing) const = 0;
168 protected:
188  template<typename T>
189  static bool StandardSimilarImpl (const QByteArray& data,
190  const QList<QByteArray>& existing, const T& f)
191  {
192  const auto& thisData = f (data);
193  return std::any_of (existing.begin (), existing.end (),
194  [&thisData, &f] (const QByteArray& other) { return thisData == f (other); });
195  }
196 };
197 
198 Q_DECLARE_INTERFACE (IRecoverableTab, "org.Deviant.LeechCraft.IRecoverableTab/1.0")
199 Q_DECLARE_INTERFACE (IHaveRecoverableTabs, "org.Deviant.LeechCraft.IHaveRecoverableTabs/1.0")
200 
201 #endif
QList
Definition: ianrulesstorage.h:14
LC::TabRecoverInfo::Data_
QByteArray Data_
The tab-specific restore data.
Definition: ihaverecoverabletabs.h:99
LC::TabRecoverInfo
Keeps the tab state between runs.
Definition: ihaverecoverabletabs.h:92
IRecoverableTab::~IRecoverableTab
virtual ~IRecoverableTab()
Definition: ihaverecoverabletabs.h:37
IHaveRecoverableTabs::StandardSimilarImpl
static bool StandardSimilarImpl(const QByteArray &data, const QList< QByteArray > &existing, const T &f)
A standard implementation of the HasSimilarTab() function.
Definition: ihaverecoverabletabs.h:189
IRecoverableTab
Interface for a single tab that may be recovered.
Definition: ihaverecoverabletabs.h:34
IHaveRecoverableTabs::~IHaveRecoverableTabs
virtual ~IHaveRecoverableTabs()
Definition: ihaverecoverabletabs.h:131
LC::DynPropertiesList_t
QList< QPair< QByteArray, QVariant > > DynPropertiesList_t
Definition: ihaverecoverabletabs.h:79
LC::TabRecoverInfo::DynProperties_
DynPropertiesList_t DynProperties_
Dynamic properties list from other plugins.
Definition: ihaverecoverabletabs.h:106
LC
Definition: constants.h:14
IHaveRecoverableTabs
Interface for plugins that can recover tabs after restart.
Definition: ihaverecoverabletabs.h:128
LC::Util::oral::sph::f
constexpr detail::ExprTree< detail::ExprType::LeafStaticPlaceholder, detail::MemberPtrs< Ptr > > f
Definition: oral.h:952