• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.12
  • kdeedu
  • marble
  • src
  • lib
  • marble
FileStorageWatcher.h
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2009 Bastian Holst <bastianholst@gmx.de>
9 //
10 
11 #ifndef MARBLE_FILESTORAGEWATCHER_H
12 #define MARBLE_FILESTORAGEWATCHER_H
13 
14 #include <QThread>
15 #include <QMutex>
16 #include <QSet>
17 
18 namespace Marble
19 {
20 
21 // Lives inside the new Thread
22 class FileStorageWatcherThread : public QObject
23 {
24  Q_OBJECT
25 
26  public:
27  explicit FileStorageWatcherThread( const QString &dataDirectory, QObject * parent = 0 );
28 
29  ~FileStorageWatcherThread();
30 
31  quint64 cacheLimit();
32 
33  Q_SIGNALS:
37  void variableChanged();
38 
39  public Q_SLOTS:
43  void setCacheLimit( quint64 bytes );
44 
49  void addToCurrentSize( qint64 bytes );
50 
54  void resetCurrentSize();
55 
62  void updateTheme( const QString &mapTheme );
63 
67  void prepareQuit();
68 
72  void getCurrentCacheSize();
73 
74  private Q_SLOTS:
78  void ensureCacheSize();
79 
80  private:
81  Q_DISABLE_COPY( FileStorageWatcherThread )
82 
83 
86  void ensureSizePerPlanet( const QString &planetDirectory, const QString &currentTheme = QString() );
87 
91  void ensureSizePerTheme( const QString &themeDirectory );
92 
96  bool keepDeleting() const;
97 
98  QString m_dataDirectory;
99 
100  quint64 m_cacheLimit;
101  quint64 m_cacheSoftLimit;
102  quint64 m_currentCacheSize;
103  int m_filesDeleted;
104  bool m_deleting;
105  QString m_mapThemeId;
106  QMutex m_limitMutex;
107  QMutex m_themeMutex;
108  bool m_willQuit;
109 };
110 
111 
112 // Lives inside main thread
113 class FileStorageWatcher : public QThread
114 {
115  Q_OBJECT
116 
117  public:
125  explicit FileStorageWatcher( const QString &dataDirectory = QString(), QObject * parent = 0 );
126 
127  ~FileStorageWatcher();
128 
132  quint64 cacheLimit();
133 
134  public Q_SLOTS:
138  void setCacheLimit( quint64 bytes );
139 
144  void addToCurrentSize( qint64 bytes );
145 
149  void resetCurrentSize();
150 
157  void updateTheme( const QString &mapTheme );
158 
159  Q_SIGNALS:
160  void sizeChanged( qint64 bytes );
161  void cleared();
162 
163  protected:
168  void run();
169 
170  private:
171  Q_DISABLE_COPY( FileStorageWatcher )
172 
173  QString m_dataDirectory;
174  FileStorageWatcherThread *m_thread;
175  QMutex *m_themeLimitMutex;
176  QString m_theme;
177  quint64 m_limit;
178  bool m_started;
179  bool m_quitting;
180 };
181 
182 }
183 
184 #endif
Marble::FileStorageWatcher::cleared
void cleared()
Marble::FileStorageWatcherThread::variableChanged
void variableChanged()
Is emitted when a variable has changed.
Marble::FileStorageWatcher
Definition: FileStorageWatcher.h:113
Marble::FileStorageWatcherThread::cacheLimit
quint64 cacheLimit()
Definition: FileStorageWatcher.cpp:56
Marble::FileStorageWatcher::FileStorageWatcher
FileStorageWatcher(const QString &dataDirectory=QString(), QObject *parent=0)
Creates a new FileStorageWatcher, which is a thread watching the space Marble takes on the hard drive...
Definition: FileStorageWatcher.cpp:306
QObject
Marble::FileStorageWatcherThread::addToCurrentSize
void addToCurrentSize(qint64 bytes)
Add bytes to the current cache size.
Definition: FileStorageWatcher.cpp:70
Marble::FileStorageWatcher::sizeChanged
void sizeChanged(qint64 bytes)
Marble::FileStorageWatcher::cacheLimit
quint64 cacheLimit()
Returns the limit of the cache in bytes.
Definition: FileStorageWatcher.cpp:354
Marble::FileStorageWatcher::run
void run()
The function being called at starting Thread.
Definition: FileStorageWatcher.cpp:382
Marble::FileStorageWatcher::resetCurrentSize
void resetCurrentSize()
Setting current cache size to 0.
Definition: FileStorageWatcher.cpp:367
Marble::FileStorageWatcherThread::getCurrentCacheSize
void getCurrentCacheSize()
Getting the current size of the data stored on the disc.
Definition: FileStorageWatcher.cpp:101
Marble::FileStorageWatcher::addToCurrentSize
void addToCurrentSize(qint64 bytes)
Add bytes to the current cache size.
Definition: FileStorageWatcher.cpp:362
Marble::FileStorageWatcher::updateTheme
void updateTheme(const QString &mapTheme)
Updates the name of the theme.
Definition: FileStorageWatcher.cpp:372
Marble::FileStorageWatcherThread::updateTheme
void updateTheme(const QString &mapTheme)
Updates the name of the theme.
Definition: FileStorageWatcher.cpp:87
Marble::FileStorageWatcher::setCacheLimit
void setCacheLimit(quint64 bytes)
Sets the limit of the cache in bytes.
Definition: FileStorageWatcher.cpp:343
Marble::FileStorageWatcherThread::~FileStorageWatcherThread
~FileStorageWatcherThread()
Definition: FileStorageWatcher.cpp:52
Marble::FileStorageWatcherThread::resetCurrentSize
void resetCurrentSize()
Setting current cache size to 0.
Definition: FileStorageWatcher.cpp:81
Marble::FileStorageWatcherThread::FileStorageWatcherThread
FileStorageWatcherThread(const QString &dataDirectory, QObject *parent=0)
Definition: FileStorageWatcher.cpp:37
QThread
Marble::FileStorageWatcherThread::setCacheLimit
void setCacheLimit(quint64 bytes)
Sets the limit of the cache in bytes.
Definition: FileStorageWatcher.cpp:61
Marble::FileStorageWatcherThread::prepareQuit
void prepareQuit()
Stop doing things that take a long time to quit.
Definition: FileStorageWatcher.cpp:96
Marble::FileStorageWatcher::~FileStorageWatcher
~FileStorageWatcher()
Definition: FileStorageWatcher.cpp:323
Marble::FileStorageWatcherThread
Definition: FileStorageWatcher.h:22
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:49 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal