LeechCraft 0.6.70-17335-ge406ffdcaf
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
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
15class QWidget;
16class QIcon;
17
34class Q_DECL_EXPORT IRecoverableTab
35{
36public:
37 virtual ~IRecoverableTab () {}
38
45 virtual QByteArray GetTabRecoverData () const = 0;
46
55 virtual QString GetTabRecoverName () const = 0;
56
64 virtual QIcon GetTabRecoverIcon () const = 0;
65protected:
74 virtual void tabRecoverDataChanged () = 0;
75};
76
77namespace LC
78{
80
108}
109
128class Q_DECL_EXPORT IHaveRecoverableTabs
129{
130public:
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;
168protected:
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
198Q_DECLARE_INTERFACE (IRecoverableTab, "org.Deviant.LeechCraft.IRecoverableTab/1.0")
199Q_DECLARE_INTERFACE (IHaveRecoverableTabs, "org.Deviant.LeechCraft.IHaveRecoverableTabs/1.0")
200
201#endif
Interface for plugins that can recover tabs after restart.
virtual bool HasSimilarTab(const QByteArray &data, const QList< QByteArray > &existing) const =0
Checks if there is a tab similar to the one defined by data.
virtual void RecoverTabs(const QList< LC::TabRecoverInfo > &infos)=0
Recovers the tabs according to the infos list.
static bool StandardSimilarImpl(const QByteArray &data, const QList< QByteArray > &existing, const T &f)
A standard implementation of the HasSimilarTab() function.
Interface for a single tab that may be recovered.
virtual QByteArray GetTabRecoverData() const =0
Returns the serialized state of the tab.
virtual QIcon GetTabRecoverIcon() const =0
Returns the icon of this tab.
virtual QString GetTabRecoverName() const =0
Returns the user-readable name of the tab.
virtual void tabRecoverDataChanged()=0
Notifies that tab state's changed.
Definition constants.h:15
QList< QPair< QByteArray, QVariant > > DynPropertiesList_t
Keeps the tab state between runs.
DynPropertiesList_t DynProperties_
Dynamic properties list from other plugins.
QByteArray Data_
The tab-specific restore data.