Logo Search packages:      
Sourcecode: qlandkarte version File versions  Download package

CCentralResources.h

/**********************************************************************************************
    Copyright (C) 2006, 2007 Oliver Eichler oliver.eichler@gmx.de

    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 2 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 USA

**********************************************************************************************/
#ifndef CCENTRALRESOURCES_H
#define CCENTRALRESOURCES_H

#include <QObject>
#include <QMutex>
#include <QTime>

#include "CFunctionStateMachine.h"
#include "CCanvas.h"

class CMainWindow;
class CGarminDBMap;
class CGarminDBWpt;
class CGarminDBTrack;
class CGarminDBRoute;
class CGarminLiveLog;
class CViewTrackInfo;
class QProgressDialog;

namespace Garmin
{
    class IDevice;
}


/// resource object for easy access to all GUI and data components
/**

 */
00048 class CCentralResources : public QObject
{
    Q_OBJECT
        public:
        CCentralResources(CMainWindow& parent);
        ~CCentralResources();
        /// get access to current canvas object
00055         CCanvas& canvas(){return *m_pCanvas;}
        /// get access to current map data base
00057         CGarminDBMap& mapdb(){return *m_pMapDB;}
        /// get access to current waypoint data base
00059         CGarminDBWpt& wptdb(){return *m_pWptDB;}
        /// get access to current track data base
00061         CGarminDBTrack& trackdb(){return *m_pTrackDB;}
        /// get access to current live log handler
00063         CGarminLiveLog& livelog(){return *m_pLiveLog;}
        /// get access to current route data base
00065         CGarminDBRoute& routedb(){return *m_pRouteDB;}
        /// get access to function statemachine
00067         CFunctionStateMachine& fsm(){return *m_pFSM;}
        /// handle key events from CMainWidget
00069         void keyPressEvent(QKeyEvent * e){m_pFSM->keyPressEvent(e);}
        /// get the map's font
00071         const QFont& getMapFont(){return m_mapfont;}
        /// convert a height value as string into the correct system and add unit
        void convertHeight(QString& val);
        /// get HTTP proxy settings
        /**
            @param url a string to store the proxy's URL
            @param port a 16bit unsigned integer to store the proxy's port

            @return The method will return true if the proxy is enabled.
        */
        bool getHttpProxy(QString& url, quint16& port);

        /// select widget in the lefthand toolbox tabwidget
        void setCurrentToolBoxWidget(QWidget * w);
        /// test for metric or imperial system settings
00086         bool doMetric(){return m_doMetric;}
        /// open a link in an external browser
        void openLink(const QString& link);
        /// get access to current device driver
        Garmin::IDevice * device();
        /// reset current device driver.
00092         void resetDevice(){m_DeviceName.clear();}

        /// set time offset to UTC in multiples of hours
        /**
            @param offset the offset in multiple of hours
        */
        void setUTCOffset(int offset, int fract);

        uint32_t getUTCOffset(){return time_offset;}

        /// global upload of GPS data
        void upload();
        /// global download of GPS data
        void download();

        const QString distance2str(double distance);

        signals:
        void sigProxyChanged();

    public slots:
        void slotCancel();

    protected:
        friend class CDlgConfig;
        friend class CDlgDevice;
        friend class CDlgDeviceNag;

        enum bowser_e
        {
            eFirefox = 0
            ,eKonqueror = 1
            ,eOther = 2
        };

        CMainWindow& main;
        /// the canvas widget to display the map
00129         CCanvas * m_pCanvas;
        /// statemachine and widget to handle F-key input
00131         CFunctionStateMachine * m_pFSM;
        /// keep track of all registered maps and the current displayed map
00133         CGarminDBMap * m_pMapDB;
        /// manage all waypoints
00135         CGarminDBWpt * m_pWptDB;
        /// manage all track data
00137         CGarminDBTrack * m_pTrackDB;
        /// control real time position data from the GPSr
00139         CGarminLiveLog * m_pLiveLog;
        /// manage all distance measurement and route data
00141         CGarminDBRoute * m_pRouteDB;

        /// font used by the map
00144         QFont m_mapfont;
        /// true for metric system, false for imperial
00146         bool m_doMetric;

        /// use proxy for http requests
00149         bool m_useHttpProxy;
        /// the  proxy name or address
00151         QString m_httpProxy;
        /// the proxy port
00153         quint16 m_httpProxyPort;
        /// offset to UTC in multiples of hours
00155         qint32 m_offsetUTC;
        /// offset to UTC fractional part
00157         qint32 m_offsetUTCfract;

        /// the installed browser type
00160         bowser_e m_eBrowser;
        /// command string to start Firefox
00162         QString cmdFirefox;
        /// command string to start Konqueror
00164         QString cmdKonqueror;
        /// user defined command string
00166         QString cmdOther;

        /// the device string to find device driver
00169         QString m_DeviceName;

        /// this offset is needed to correct time in seconds until Dec. 30th, 1989 12:00 to POSIX standard
00172         uint32_t time_offset;

        bool uploadMap;
        bool uploadWpt;
        bool uploadRte;
        bool downloadMap;
        bool downloadWpt;
        bool downloadTrk;
        /// alternative plugin path set by environment variable
00181         QString altPluginPath;
        /// serial port string
00183         QString serialPort;
        /// set true to show legal notice nag screen befor accessing a device
00185         bool doDriverNag;

        friend void GUICallback(int progress, int * ok, int * cancel, const char * title, const char * msg, void * self);
        struct dlgdata_t
        {
            dlgdata_t() : dlgProgress(0), canceled(false)
                {}

            QProgressDialog * dlgProgress;
            QTime timeProgress;
            bool canceled;
        };

        dlgdata_t dlgData;
};

extern CCentralResources * gpResources;
#endif                           //CCENTRALRESOURCES_H

Generated by  Doxygen 1.6.0   Back to index