Qt Virtual Chart Table (QVCT)
CTrackOverlay.hpp
Go to the documentation of this file.
1 // INDENTING (emacs/vi): -*- mode:c++; tab-width:2; c-basic-offset:2; intent-tabs-mode:nil; -*- ex: set tabstop=2 expandtab:
2 
3 /*
4  * Qt Virtual Chart Table (QVCT)
5  * Copyright (C) 2012 Cedric Dufour <http://cedric.dufour.name>
6  * Author: Cedric Dufour <http://cedric.dufour.name>
7  *
8  * The Qt Virtual Chart Table (QVCT) is free software:
9  * you can redistribute it and/or modify it under the terms of the GNU General
10  * Public License as published by the Free Software Foundation, Version 3.
11  *
12  * The Qt Virtual Chart Table (QVCT) is distributed in the hope
13  * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
14  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  *
16  * See the GNU General Public License for more details.
17  */
18 
26 #ifndef QVCT_CTRACKOVERLAY_HPP
27 #define QVCT_CTRACKOVERLAY_HPP
28 
29 // QT
30 #include <QDomElement> // QtXml module
31 #include <QList>
32 #include <QMimeData>
33 #include <QPainter>
34 #include <QPointF>
35 #include <QStringList>
36 #include <QWidget>
37 #include <QXmlStreamWriter>
38 
39 // QVCT
41 class CChart;
42 class CTrackContainer;
43 class CTrackPoint;
44 class CTrackSubContainer;
45 
46 
48 
53 {
54 
55  //------------------------------------------------------------------------------
56  // CONSTANTS / STATIC
57  //------------------------------------------------------------------------------
58 
59 public:
61  enum EColumn {
62  NAME = 0,
63  VISIBLE = 1,
64  SELECT = 2
65  };
66 
67 
68  //------------------------------------------------------------------------------
69  // CONSTRUCTORS / DESTRUCTOR
70  //------------------------------------------------------------------------------
71 
72 public:
73  CTrackOverlay( QWidget* _pqParent = 0 );
74  virtual ~CTrackOverlay();
75 
76 
77  //------------------------------------------------------------------------------
78  // METHODS: QTreeWidget (implement/override)
79  //------------------------------------------------------------------------------
80 
81 private:
82  virtual QStringList mimeTypes() const;
83  virtual QMimeData* mimeData( const QList<QTreeWidgetItem*> _qListTreeWidgetItems ) const;
84  virtual bool dropMimeData ( QTreeWidgetItem* _pqTreeWidgetItem, int _iIndex, const QMimeData* _pqMimeData, Qt::DropAction eAction );
85  virtual void dropEvent( QDropEvent* _pqDropEvent );
86 
87 
88  //------------------------------------------------------------------------------
89  // METHODS: COverlay (implement/override)
90  //------------------------------------------------------------------------------
91 
92 public:
93  virtual void drawContent( const CChart* _poChart, QPainter* _pqPainter ) const;
94  virtual void showDetail( const QTreeWidgetItem* _pqTreeWidgetItem ) const;
95  virtual void setPosition( const QTreeWidgetItem* _pqTreeWidgetItem ) const;
96  virtual COverlayPoint* matchScrPosition( const CChart* _poChart, const QPointF& _rqPointFScrPosition ) const;
97 
98 
99  //------------------------------------------------------------------------------
100  // METHODS: COverlayBaseTree (implement/override)
101  //------------------------------------------------------------------------------
102 
103 public:
104  virtual void onChange( QTreeWidgetItem* _pqTreeWidgetItem, int __iColumn );
105 
106 
107  //------------------------------------------------------------------------------
108  // METHODS
109  //------------------------------------------------------------------------------
110 
111  // OTHER
112 public:
114  void importSettings();
116 
117  CTrackContainer* pickContainer( const QString& _rqsName );
119 
120  CTrackSubContainer* pickSubContainer( const QString& _rqsName );
122  CTrackContainer* addContainer( const QString& _rqsName );
124  int deleteSelection();
126  void clear();
127 
128 public:
130  CTrackContainer* load( const QString& _rqsFilename );
132  void save( const QString& _rqsFilename, CTrackContainer* _poTrackContainer = 0 ) const;
134  int parseQVCT( const QDomElement& _rqDomElement, CTrackContainer** _ppoTrackContainer = 0 );
136  int parseGPX( const QDomElement& _rqDomElement, CTrackContainer** _ppoTrackContainer = 0 );
138  void dumpQVCT( QXmlStreamWriter & _rqXmlStreamWriter, CTrackContainer* _poTrackContainer = 0, bool _bProjectDump = false ) const;
140  void dumpGPX( QXmlStreamWriter & _rqXmlStreamWriter, CTrackContainer* _poTrackContainer = 0 ) const;
141 
142 };
143 
144 #endif // QVCT_CTRACKOVERLAY_HPP
[UI] Chart (view)
Definition: CChart.hpp:44
Generic overlay base (tree widget)
Generic overlay point.
[UI] Track overlay container
[UI] Track overlay container
EColumn
Implemented tree-widget columns.
@ VISIBLE
Track visibility status.
@ SELECT
Track selection status.
@ NAME
Track name.
CTrackOverlay(QWidget *_pqParent=0)
void clear()
Clear the entire content of this overlay.
virtual void dropEvent(QDropEvent *_pqDropEvent)
CTrackContainer * addContainer(const QString &_rqsName)
Add a new track (container) to this overlay.
virtual void drawContent(const CChart *_poChart, QPainter *_pqPainter) const
Draws this overlay's content.
CTrackContainer * pickContainer(const QString &_rqsName)
Returns a track (container) matching the given name.
void dumpQVCT(QXmlStreamWriter &_rqXmlStreamWriter, CTrackContainer *_poTrackContainer=0, bool _bProjectDump=false) const
Stores this object's content to the given QVCT destination (file)
virtual void showDetail(const QTreeWidgetItem *_pqTreeWidgetItem) const
Displays the given overlay object's details (in the appropriate widget/view)
virtual ~CTrackOverlay()
void dumpGPX(QXmlStreamWriter &_rqXmlStreamWriter, CTrackContainer *_poTrackContainer=0) const
Stores this object's content to the given GPX destination (file)
int parseGPX(const QDomElement &_rqDomElement, CTrackContainer **_ppoTrackContainer=0)
Retrieves this object's content from the given GPX source (file)
virtual bool dropMimeData(QTreeWidgetItem *_pqTreeWidgetItem, int _iIndex, const QMimeData *_pqMimeData, Qt::DropAction eAction)
CTrackSubContainer * pickSubContainer(const QString &_rqsName)
Returns the last/current segment (sub-container) of the track (container) matching the given name.
virtual QStringList mimeTypes() const
int deleteSelection()
Deletes selected items within this overlay's containers.
virtual COverlayPoint * matchScrPosition(const CChart *_poChart, const QPointF &_rqPointFScrPosition) const
Returns the overlay's point that (first) matches the given screen position (0 if none is found)
virtual void onChange(QTreeWidgetItem *_pqTreeWidgetItem, int __iColumn)
Handles item (content) changes in the underlying QTreeWidget.
void importSettings()
Imports settings from the application's global settings.
void save(const QString &_rqsFilename, CTrackContainer *_poTrackContainer=0) const
Save this object's content (container) to the given file (all selected items if no container is given...
CTrackContainer * load(const QString &_rqsFilename)
Load this object's content from the given file and returns the last loaded container (0 if none)
int parseQVCT(const QDomElement &_rqDomElement, CTrackContainer **_ppoTrackContainer=0)
Retrieves this object's content from the given QVCT source (file)
virtual void setPosition(const QTreeWidgetItem *_pqTreeWidgetItem) const
Centers the chart on the given overlay object's position.
virtual QMimeData * mimeData(const QList< QTreeWidgetItem * > _qListTreeWidgetItems) const
[UI] Track overlay point (item)
Definition: CTrackPoint.hpp:40
[UI] Track overlay sub-container