LeechCraft 0.6.70-18808-g3467692359
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#pragma once
10
11#include <optional>
12#include <QByteArray>
13#include <QIcon>
14#include <QList>
15#include <QVariant>
16
17class QWidget;
18
19namespace LC
20{
22 {
29 QByteArray Data_ {};
30
39 QString Name_;
40
48 QIcon Icon_ {};
49 };
50}
51
65class Q_DECL_EXPORT IRecoverableTab
66{
67protected:
68 virtual ~IRecoverableTab () = default;
69public:
78 virtual std::optional<LC::TabSaveInfo> GetTabSaveInfo () const = 0;
79protected:
88 virtual void tabRecoverDataChanged () = 0;
89};
90
91namespace LC
92{
94
122}
123
142class Q_DECL_EXPORT IHaveRecoverableTabs
143{
144public:
146
161 virtual void RecoverTabs (const QList<LC::TabRecoverInfo>& infos) = 0;
162
180 virtual bool HasSimilarTab (const QByteArray& data,
181 const QList<QByteArray>& existing) const = 0;
182protected:
202 template<typename T>
203 static bool StandardSimilarImpl (const QByteArray& data,
204 const QList<QByteArray>& existing, const T& f)
205 {
206 const auto& thisData = f (data);
207 return std::any_of (existing.begin (), existing.end (),
208 [&thisData, &f] (const QByteArray& other) { return thisData == f (other); });
209 }
210};
211
212Q_DECLARE_INTERFACE (IRecoverableTab, "org.Deviant.LeechCraft.IRecoverableTab/1.0")
213Q_DECLARE_INTERFACE (IHaveRecoverableTabs, "org.Deviant.LeechCraft.IHaveRecoverableTabs/1.0")
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 std::optional< LC::TabSaveInfo > GetTabSaveInfo() const =0
Returns the tab's save information.
virtual ~IRecoverableTab()=default
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.
QIcon Icon_
Returns the icon of this tab.
QString Name_
The user-readable name of the tab.
QByteArray Data_
The serialized state of a tab.