LeechCraft
0.6.70-18808-g3467692359
Modular cross-platform feature rich live environment.
Toggle main menu visibility
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
17
class
QWidget;
18
19
namespace
LC
20
{
21
struct
TabSaveInfo
22
{
29
QByteArray
Data_
{};
30
39
QString
Name_
;
40
48
QIcon
Icon_
{};
49
};
50
}
51
65
class
Q_DECL_EXPORT
IRecoverableTab
66
{
67
protected
:
68
virtual
~IRecoverableTab
() =
default
;
69
public
:
78
virtual
std::optional<LC::TabSaveInfo>
GetTabSaveInfo
()
const
= 0;
79
protected
:
88
virtual
void
tabRecoverDataChanged
() = 0;
89
};
90
91
namespace
LC
92
{
93
typedef
QList<QPair<QByteArray, QVariant>
>
DynPropertiesList_t
;
94
106
struct
TabRecoverInfo
107
{
113
QByteArray
Data_
;
114
120
DynPropertiesList_t
DynProperties_
;
121
};
122
}
123
142
class
Q_DECL_EXPORT
IHaveRecoverableTabs
143
{
144
public
:
145
virtual
~IHaveRecoverableTabs
() {}
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;
182
protected
:
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
212
Q_DECLARE_INTERFACE (
IRecoverableTab
,
"org.Deviant.LeechCraft.IRecoverableTab/1.0"
)
213
Q_DECLARE_INTERFACE (
IHaveRecoverableTabs
,
"org.Deviant.LeechCraft.IHaveRecoverableTabs/1.0"
)
IHaveRecoverableTabs
Interface for plugins that can recover tabs after restart.
Definition
ihaverecoverabletabs.h:143
IHaveRecoverableTabs::HasSimilarTab
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.
IHaveRecoverableTabs::RecoverTabs
virtual void RecoverTabs(const QList< LC::TabRecoverInfo > &infos)=0
Recovers the tabs according to the infos list.
IHaveRecoverableTabs::~IHaveRecoverableTabs
virtual ~IHaveRecoverableTabs()
Definition
ihaverecoverabletabs.h:145
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:203
IRecoverableTab
Interface for a single tab that may be recovered.
Definition
ihaverecoverabletabs.h:66
IRecoverableTab::GetTabSaveInfo
virtual std::optional< LC::TabSaveInfo > GetTabSaveInfo() const =0
Returns the tab's save information.
IRecoverableTab::~IRecoverableTab
virtual ~IRecoverableTab()=default
IRecoverableTab::tabRecoverDataChanged
virtual void tabRecoverDataChanged()=0
Notifies that tab state's changed.
QList
Definition
ianrulesstorage.h:14
LC
Definition
constants.h:15
LC::DynPropertiesList_t
QList< QPair< QByteArray, QVariant > > DynPropertiesList_t
Definition
ihaverecoverabletabs.h:93
LC::TabRecoverInfo
Keeps the tab state between runs.
Definition
ihaverecoverabletabs.h:107
LC::TabRecoverInfo::DynProperties_
DynPropertiesList_t DynProperties_
Dynamic properties list from other plugins.
Definition
ihaverecoverabletabs.h:120
LC::TabRecoverInfo::Data_
QByteArray Data_
The tab-specific restore data.
Definition
ihaverecoverabletabs.h:113
LC::TabSaveInfo
Definition
ihaverecoverabletabs.h:22
LC::TabSaveInfo::Icon_
QIcon Icon_
Returns the icon of this tab.
Definition
ihaverecoverabletabs.h:48
LC::TabSaveInfo::Name_
QString Name_
The user-readable name of the tab.
Definition
ihaverecoverabletabs.h:39
LC::TabSaveInfo::Data_
QByteArray Data_
The serialized state of a tab.
Definition
ihaverecoverabletabs.h:29
src
interfaces
ihaverecoverabletabs.h
Generated by
1.17.0