Kstars

hipsmanager.h
1/*
2 SPDX-FileCopyrightText: 2015-2017 Pavel Mraz
3
4 SPDX-FileCopyrightText: 2017 Jasem Mutlaq
5
6 SPDX-License-Identifier: GPL-2.0-or-later
7*/
8
9#pragma once
10
11#include "hips.h"
12#include "opships.h"
13#include "pixcache.h"
14#include "urlfiledownload.h"
15
16#include <QObject>
17
18#include <memory>
19
20class RemoveTimer : public QTimer
21{
23 public:
24 RemoveTimer()
25 {
26 connect(this, SIGNAL(timeout()), this, SLOT(done()));
27 start(5000);
28 }
29
30 void setKey(const pixCacheKey_t &key);
31
32 pixCacheKey_t m_key { 0, 0, 0 };
33
34 signals:
35 void remove(pixCacheKey_t &key);
36
37 private slots:
38 void done()
39 {
40 emit remove(m_key);
42 }
43};
44
45class HIPSManager : public QObject
46{
48
49 public:
50 static HIPSManager *Instance();
51
52 typedef enum { HIPS_EQUATORIAL_FRAME, HIPS_GALACTIC_FRAME, HIPS_OTHER_FRAME } HIPSFrame;
53
54 QImage *getPix(bool allsky, int level, int pix, bool &freeImage);
55
56 void readSources();
57
58 void cancelAll();
59 void clearDiscCache();
60
61 // Getters
62 const QMap<QString, QString> &getCurrentSource() const
63 {
64 return m_currentSource;
65 }
66 const QList<QMap<QString, QString>> &getHIPSSources() const
67 {
68 return m_hipsSources;
69 }
70 int getUsableLevel(int level) const;
71 int getUsableOfflineLevel(int level) const;
72 PixCache *getCache();
73 qint64 getDiscCacheSize() const;
74 const QString &getCurrentFormat() const
75 {
76 return m_currentFormat;
77 }
78 HIPSFrame getCurrentFrame() const
79 {
80 return m_currentFrame;
81 }
82 const uint8_t &getCurrentOrder() const
83 {
84 return m_currentOrder;
85 }
86 const uint16_t &getCurrentTileWidth() const
87 {
88 return m_currentTileWidth;
89 }
90 const QUrl &getCurrentURL() const
91 {
92 return m_currentURL;
93 }
94 qint64 getUID() const
95 {
96 return m_uid;
97 }
98 void setOfflineLevels(const QStringList &value);
99
100 public slots:
101 bool setCurrentSource(const QString &title);
102 void showSettings();
103
104 signals:
105 void sigRepaint();
106
107 private slots:
108 void slotDone(QNetworkReply::NetworkError error, QByteArray &data, pixCacheKey_t &key);
109 void slotApply();
110 void removeTimer(pixCacheKey_t &key);
111
112 private:
113 HIPSManager();
114
115 static HIPSManager * _HIPSManager;
116
117 // Cache
118 PixCache m_cache;
119 QSet <pixCacheKey_t> m_downloadMap;
120
121 void addToMemoryCache(pixCacheKey_t &key, pixCacheItem_t *item);
122 pixCacheItem_t *getCacheItem(pixCacheKey_t &key);
123
124 // List of all sources in the database
125 QList<QMap<QString, QString>> m_hipsSources;
126
127 // Current Active Source
128 QMap<QString, QString> m_currentSource;
129
130 std::unique_ptr<OpsHIPS> sourceSettings;
131 std::unique_ptr<OpsHIPSCache> cacheSettings;
132 std::unique_ptr<OpsHIPSDisplay> displaySettings;
133
134 // Handy shortcuts
135 qint64 m_uid { 0 };
136 QString m_currentFormat;
137 HIPSFrame m_currentFrame { HIPS_OTHER_FRAME };
138 uint8_t m_currentOrder { 0 };
139 uint16_t m_currentTileWidth { 0 };
140 QUrl m_currentURL;
141 QMap<int, int> m_OfflineLevelsMap;
142};
Q_OBJECTQ_OBJECT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void deleteLater()
void start()
void timeout()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:41 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.