Alkimia API

alkonlinequotesprofilemanager.cpp
1/*
2 SPDX-FileCopyrightText: 2018 Ralf Habacker ralf.habacker @freenet.de
3
4 This file is part of libalkimia.
5
6 SPDX-License-Identifier: LGPL-2.1-or-later
7*/
8
9#include "alkonlinequotesprofilemanager.h"
10#include "alkonlinequotesprofile.h"
11#include "alkwebpage.h"
12#include "alkwebview.h"
13
14#include <QPointer>
15
16#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
17#include <QLocale>
18#define initLocale() QLocale()
19#else
20#include <KGlobal>
21#define initLocale() KGlobal::locale()
22#endif
23
24class AlkOnlineQuotesProfileManager::Private
25{
26public:
30 bool m_withView;
31 Private()
32 : m_withView(false)
33 {
34 }
35
36 ~Private()
37 {
38 if (m_view.data()) {
39 m_view.data()->deleteLater();
40 }
41 }
42};
43
44AlkOnlineQuotesProfileManager::AlkOnlineQuotesProfileManager()
45 : d(new Private)
46{
47}
48
49AlkOnlineQuotesProfileManager::~AlkOnlineQuotesProfileManager()
50{
51 delete d;
52}
53
54bool AlkOnlineQuotesProfileManager::webViewEnabled()
55{
56 return d->m_withView;
57}
58
59void AlkOnlineQuotesProfileManager::setWebViewEnabled(bool enable)
60{
61 d->m_withView = enable;
62}
63
64void AlkOnlineQuotesProfileManager::addProfile(AlkOnlineQuotesProfile *profile)
65{
66 if (!d->m_profiles.contains(profile)) {
67 d->m_profiles.append(profile);
68 profile->setManager(this);
69 connect(profile, SIGNAL(updateAvailable(const QString &, const QString &)), this, SIGNAL(updateAvailable(const QString &, const QString &)));
70 }
71}
72
73AlkOnlineQuotesProfileList AlkOnlineQuotesProfileManager::profiles()
74{
75 return d->m_profiles;
76}
77
78AlkOnlineQuotesProfile *AlkOnlineQuotesProfileManager::profile(const QString &name)
79{
80 for (AlkOnlineQuotesProfile *profile : profiles()) {
81 if (name == profile->name()) {
82 return profile;
83 }
84 }
85 return nullptr;
86}
87
88QStringList AlkOnlineQuotesProfileManager::profileNames()
89{
90 QStringList profiles;
91 for (AlkOnlineQuotesProfile *profile : d->m_profiles) {
92 profiles.append(profile->name());
93 }
94 return profiles;
95}
96
97void AlkOnlineQuotesProfileManager::setWebPage(AlkWebPage *webPage)
98{
99 d->m_page = webPage;
100}
101
102AlkWebPage *AlkOnlineQuotesProfileManager::webPage()
103{
104 return d->m_page;
105}
106
107void AlkOnlineQuotesProfileManager::setWebView(AlkWebView *webView)
108{
109 d->m_view = webView;
110}
111
112AlkWebView *AlkOnlineQuotesProfileManager::webView()
113{
114 return d->m_view;
115}
116
117AlkOnlineQuotesProfileManager &AlkOnlineQuotesProfileManager::instance()
118{
119 static AlkOnlineQuotesProfileManager manager;
120 return manager;
121}
122
123AlkOnlineQuotesProfileManager *AlkOnlineQuotesProfileManager::instancePointer()
124{
125 return &instance();
126}
The AlkWebPage class provides an object to load and view web documents to provide functionality like ...
Definition alkwebpage.h:100
The AlkWebView class provides a widget that is used to load and display web documents.
Definition alkwebview.h:87
void append(QList< T > &&value)
bool contains(const AT &value) const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
T * data() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.