configuration.h 4.89 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
/**
******************************************************************************
*
* @file       configuration.h
* @author     The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief      A class that centralizes most of the mapcontrol configurations
* @see        The GNU Public License (GPL) Version 3
* @defgroup   OPMapWidget
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#ifndef CONFIGURATION_H
#define CONFIGURATION_H

#include <QBrush>
#include <QPen>
#include <QString>
#include <QFont>
#include "../core/opmaps.h"
#include "../core/accessmode.h"
#include "../core/cache.h"
namespace mapcontrol
{
    
/**
* @brief  A class that centralizes most of the mapcontrol configurations
*
* @class Configuration configuration.h "configuration.h"
*/
class Configuration
{
public:
    Configuration();
    /**
    * @brief Used to draw empty map tiles
    *
    * @var EmptytileBrush
    */
    QBrush EmptytileBrush;
    /**
    * @brief Used for empty tiles text
    *
    * @var EmptyTileText
    */
    QString EmptyTileText;
    /**
    * @brief Used to draw empty tile borders
    *
    * @var EmptyTileBorders
    */
    QPen EmptyTileBorders;
    /**
    * @brief Used to Draw the maps scale
    *
    * @var ScalePen
    */
    QPen ScalePen;
    /**
    * @brief Used to draw selection box
    *
    * @var SelectionPen
    */
    QPen SelectionPen;
    /**
    * @brief
    *
    * @var MissingDataFont
    */
    QFont MissingDataFont;

    /**
    * @brief Button used for dragging
    *
    * @var DragButton
    */
    Qt::MouseButton DragButton;

    /**
    * @brief Sets the access mode for the map (cache only, server and cache...)
    *
    * @param type access mode
    */
    void SetAccessMode(core::AccessMode::Types const& type);
    /**
    * @brief Returns the access mode for the map (cache only, server and cache...)
    *
    * @return core::AccessMode::Types access mode for the map
    */
    core::AccessMode::Types AccessMode();

    /**
    * @brief Sets the language used for geocaching
    *
    * @param type The language to be used
    */
    void SetLanguage(core::LanguageType::Types const& type);
    /**
    * @brief Returns the language used for geocaching
    *
    * @return core::LanguageType::Types
    */
    core::LanguageType::Types Language();

    /**
    * @brief Used to allow disallow use of memory caching
    *
    * @param value
    * @return
    */
    void SetUseMemoryCache(bool const& value);
    /**
    * @brief  Return if memory caching is in use
    *
    * @return
    */
    bool UseMemoryCache(){return core::OPMaps::Instance()->UseMemoryCache();}

    /**
    * @brief  Returns the currently used memory for tiles
    *
    * @return
    */
    double TileMemoryUsed()const{return core::OPMaps::Instance()->TilesInMemory.MemoryCacheSize();}

    /**
    * @brief  Sets the size of the memory for tiles
    *
    * @param  value size in Mb to use for tiles
    * @return
    */
    void SetTileMemorySize(int const& value){core::OPMaps::Instance()->TilesInMemory.setMemoryCacheCapacity(value);}

    /**
    * @brief Sets the location for the SQLite Database used for caching and the geocoding cache files
    *
    * @param dir The path location for the cache file-IMPORTANT Must end with closing slash "/"
    */
    void SetCacheLocation(QString const& dir)
    {
        core::Cache::Instance()->setCacheLocation(dir);

    }

    /**
    * @brief  Deletes tiles in DataBase older than "days" days
    *
    * @param days
    * @return
    */
    void DeleteTilesOlderThan(int const& days){core::Cache::Instance()->ImageCache.deleteOlderTiles(days);}

    /**
    * @brief  Exports tiles from one DB to another. Only new tiles are added.
    *
    * @param sourceDB the source DB
    * @param destDB the destination DB. If it doesnt exhist it will be created.
    * @return
    */
    void ExportMapDataToDB(QString const& sourceDB, QString const& destDB)const{core::PureImageCache::ExportMapDataToDB(sourceDB,destDB);}
    /**
    * @brief Returns the location for the SQLite Database used for caching and the geocoding cache files
    *
    * @return
    */
    QString CacheLocation(){return core::Cache::Instance()->CacheLocation();}


};
}
#endif // CONFIGURATION_H