Qt Virtual Chart Table (QVCT)
CVesselOverlay.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_CVESSELOVERLAY_HPP
27 #define QVCT_CVESSELOVERLAY_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 CVesselContainer;
43 
44 
46 
51 {
52 
53  //------------------------------------------------------------------------------
54  // CONSTANTS / STATIC
55  //------------------------------------------------------------------------------
56 
57 public:
59  enum EColumn {
60  NAME = 0,
61  VISIBLE = 1,
62  SELECT = 2
63  };
64 
65 
66  //------------------------------------------------------------------------------
67  // CONSTRUCTORS / DESTRUCTOR
68  //------------------------------------------------------------------------------
69 
70 public:
71  CVesselOverlay( QWidget* _pqParent = 0 );
72  virtual ~CVesselOverlay();
73 
74 
75  //------------------------------------------------------------------------------
76  // METHODS: QTreeWidget (implement/override)
77  //------------------------------------------------------------------------------
78 
79 private:
80  virtual QStringList mimeTypes() const;
81  virtual QMimeData* mimeData( const QList<QTreeWidgetItem*> _qListTreeWidgetItems ) const;
82  virtual bool dropMimeData ( QTreeWidgetItem* _pqTreeWidgetItem, int _iIndex, const QMimeData* _pqMimeData, Qt::DropAction eAction );
83  virtual void dropEvent( QDropEvent* _pqDropEvent );
84 
85 
86  //------------------------------------------------------------------------------
87  // METHODS: COverlay (implement/override)
88  //------------------------------------------------------------------------------
89 
90 public:
91  virtual void drawContent( const CChart* _poChart, QPainter* _pqPainter ) const;
92  virtual void showDetail( const QTreeWidgetItem* _pqTreeWidgetItem ) const;
93  virtual void setPosition( const QTreeWidgetItem* _pqTreeWidgetItem ) const;
94  virtual COverlayPoint* matchScrPosition( const CChart* _poChart, const QPointF& _rqPointFScrPosition ) const;
95 
96 
97  //------------------------------------------------------------------------------
98  // METHODS: COverlayBaseTree (implement/override)
99  //------------------------------------------------------------------------------
100 
101 public:
102  virtual void onChange( QTreeWidgetItem* _pqTreeWidgetItem, int __iColumn );
103 
104 
105  //------------------------------------------------------------------------------
106  // METHODS
107  //------------------------------------------------------------------------------
108 
109  // OTHER
110 public:
112  void importSettings();
114  CVesselContainer* addContainer( const QString& _rqsName );
116  int deleteSelection();
118  void clear();
119 
120 public:
122  CVesselContainer* load( const QString& _rqsFilename );
124  void save( const QString& _rqsFilename, CVesselContainer* _poVesselContainer = 0 ) const;
126  int parseQVCT( const QDomElement& _rqDomElement, CVesselContainer** _ppoVesselContainer = 0 );
128  void dumpQVCT( QXmlStreamWriter & _rqXmlStreamWriter, CVesselContainer* _poVesselContainer = 0, bool _bProjectDump = false ) const;
129 
130 };
131 
132 #endif // QVCT_CVESSELOVERLAY_HPP
[UI] Chart (view)
Definition: CChart.hpp:44
Generic overlay base (tree widget)
Generic overlay point.
[UI] Vessel overlay container / flotilla
[UI] Vessel overlay container
virtual void onChange(QTreeWidgetItem *_pqTreeWidgetItem, int __iColumn)
Handles item (content) changes in the underlying QTreeWidget.
CVesselOverlay(QWidget *_pqParent=0)
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 QStringList mimeTypes() const
void save(const QString &_rqsFilename, CVesselContainer *_poVesselContainer=0) const
Save this object's content (container) to the given file (all selected items if no container is given...
void importSettings()
Imports settings from the application's global settings.
void clear()
Clear the entire content of this overlay.
virtual void drawContent(const CChart *_poChart, QPainter *_pqPainter) const
Draws this overlay's content.
virtual void dropEvent(QDropEvent *_pqDropEvent)
int deleteSelection()
Deletes selected items within this overlay's containers.
virtual bool dropMimeData(QTreeWidgetItem *_pqTreeWidgetItem, int _iIndex, const QMimeData *_pqMimeData, Qt::DropAction eAction)
EColumn
Implemented tree-widget columns.
@ NAME
Vessel name.
@ SELECT
Vessel selection status.
@ VISIBLE
Vessel visibility status.
CVesselContainer * addContainer(const QString &_rqsName)
Add a new vessel (container) to this overlay.
virtual void showDetail(const QTreeWidgetItem *_pqTreeWidgetItem) const
Displays the given overlay object's details (in the appropriate widget/view)
int parseQVCT(const QDomElement &_rqDomElement, CVesselContainer **_ppoVesselContainer=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 ~CVesselOverlay()
void dumpQVCT(QXmlStreamWriter &_rqXmlStreamWriter, CVesselContainer *_poVesselContainer=0, bool _bProjectDump=false) const
Stores this object's content to the given QVCT destination (file)
CVesselContainer * load(const QString &_rqsFilename)
Load this object's content from the given file and returns the last loaded container (0 if none)
virtual QMimeData * mimeData(const QList< QTreeWidgetItem * > _qListTreeWidgetItems) const