LeechCraft 0.6.70-19424-g027e980fd1
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
sessionprops.cpp
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#include "sessionprops.h"
10#include <QObject>
11#include <QtDebug>
12
13namespace LC::Util
14{
15 bool IsSessionProp (const QByteArray& name)
16 {
17 return name.startsWith ("SessionData/");
18 }
19
21 {
23 for (const auto& name : tab.dynamicPropertyNames ())
24 if (IsSessionProp (name))
25 props.append ({ name, tab.property (name.constData ()) });
26 return props;
27 }
28
29 void SetSessionProps (QObject& tab, const DynPropertiesList_t& props)
30 {
31 for (const auto& [name, value] : props)
32 if (IsSessionProp (name))
33 tab.setProperty (name.constData (), value);
34 else
35 qWarning () << "skipping non-session property" << name << "for" << &tab;
36 }
37}
DynPropertiesList_t GetSessionProps(const QObject &tab)
Returns the dynamic properties of tab that a tab session keeps.
bool IsSessionProp(const QByteArray &name)
Checks whether a tab session keeps the dynamic property name.
void SetSessionProps(QObject &tab, const DynPropertiesList_t &props)
Sets the session properties among props as dynamic properties of tab.
QList< std::pair< QByteArray, QVariant > > DynPropertiesList_t