LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
IHaveRecoverableTabs Class Referenceabstract

Interface for plugins that can recover tabs after restart. More...

#include "ihaverecoverabletabs.h"

Public Member Functions

virtual ~IHaveRecoverableTabs ()
 
virtual void RecoverTabs (const QList< LC::TabRecoverInfo > &infos)=0
 Recovers the tabs according to the infos list. More...
 
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. More...
 

Static Protected Member Functions

template<typename T >
static bool StandardSimilarImpl (const QByteArray &data, const QList< QByteArray > &existing, const T &f)
 A standard implementation of the HasSimilarTab() function. More...
 

Detailed Description

Interface for plugins that can recover tabs after restart.

This interface should be implemented by plugins for which it makes sense to recover tabs in some way: either after restart or un-close, for instance. For example, a web browser or a media player may wish to implement this interface.

First, tabs which wish to be saved between runs should implement the IRecoverableTab interface. If a session manager plugin (like TabSessManager) is installed, then it will query the tabs regarding their state via that interface and save that information.

After restarting LeechCraft (or when requesting reopening a recently closed tab), the RecoverTabs() method will be called by a tab session manager plugin to recover the needed tabs.

See also
IRecoverableTab, LC::TabRecoverInfo, IHaveTabs

Definition at line 128 of file ihaverecoverabletabs.h.

Constructor & Destructor Documentation

◆ ~IHaveRecoverableTabs()

virtual IHaveRecoverableTabs::~IHaveRecoverableTabs ( )
inlinevirtual

Definition at line 131 of file ihaverecoverabletabs.h.

Member Function Documentation

◆ HasSimilarTab()

virtual bool IHaveRecoverableTabs::HasSimilarTab ( const QByteArray &  data,
const QList< QByteArray > &  existing 
) const
pure virtual

Checks if there is a tab similar to the one defined by data.

The data is guaranteed to be obtained from a tab belonging to the plugin being queried. That is, there is no need to perform any checks for the tab to be belonging to the plugin.

A standard implementation is provided for the convenience in the form of the StandardSimilarImpl() function.

Parameters
[in]dataThe tab recover data previously obtained from IRecoverableTab::GetTabRecoverData()
[in]existingThe list of existing tabs, provided for convenience.
Returns
Whether the tab similar to the one defined by data exists already.
See also
StandardSimilarImpl()

◆ RecoverTabs()

virtual void IHaveRecoverableTabs::RecoverTabs ( const QList< LC::TabRecoverInfo > &  infos)
pure virtual

Recovers the tabs according to the infos list.

This method should recover the tabs according to the information contained in the infos list. That is, for each tab recover info in that list it should create the tab, recover the tab state according to LC::TabRecoverInfo::Data_, set the dynamic properties of the tab (via QObject::setProperty()) according to LC::TabRecoverInfo::DynProperties_ list, and only then emit the IHaveTabs::addNewTab() signal.

Note
Please note that it's very important to emit the tab via the addNewTab() signal only after the tab's dynamic properties are restored.

◆ StandardSimilarImpl()

template<typename T >
static bool IHaveRecoverableTabs::StandardSimilarImpl ( const QByteArray &  data,
const QList< QByteArray > &  existing,
const T &  f 
)
inlinestaticprotected

A standard implementation of the HasSimilarTab() function.

This function is suitable for calling from HasSimilarTab() given an additional functor f, which should return some equality comparable type. If f(data) is equal to f(e) for some e in existing, then this function returns true.

Template Parameters
TThe type of the functor f.
Parameters
[in]dataThe tab recover data previously obtained from IRecoverableTab::GetTabRecoverData()
[in]existingThe list of existing tabs, provided for convenience.
[in]fA functor returning some equality comparable type.
Returns
Whether the tab similar to the one defined by data exists already.
See also
HasSimilarTab()

Definition at line 189 of file ihaverecoverabletabs.h.

References LC::Util::oral::sph::f.


The documentation for this class was generated from the following file: