1 /**********************************************************************************************
2     Copyright (C) 2014 Oliver Eichler <oliver.eichler@gmx.de>
3 
4     This program is free software: you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation, either version 3 of the License, or
7     (at your option) any later version.
8 
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13 
14     You should have received a copy of the GNU General Public License
15     along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 
17 **********************************************************************************************/
18 
19 #ifndef CDETAILSPRJ_H
20 #define CDETAILSPRJ_H
21 
22 #include "gis/trk/CGisItemTrk.h"
23 #include "ui_IDetailsPrj.h"
24 #include <QMutex>
25 #include <QPointer>
26 #include <QWidget>
27 
28 class CDetailsPrj;
29 class IGisProject;
30 class CGisItemTrk;
31 class CGisItemWpt;
32 class CGisItemOvlArea;
33 class CGisItemRte;
34 class CProgressDialog;
35 class QTimer;
36 
37 struct wpt_info_t;
38 
39 class CDetailsPrj : public QWidget, public INotifyTrk, private Ui::IDetailsPrj
40 {
41     Q_OBJECT
42 public:
43     CDetailsPrj(IGisProject& prj, QWidget* parent);
44     virtual ~CDetailsPrj();
45 
46     void updateData() override;
setMouseFocus(const CTrackData::trkpt_t * pt)47     void setMouseFocus(const CTrackData::trkpt_t* pt) override {}
setMouseRangeFocus(const CTrackData::trkpt_t * pt1,const CTrackData::trkpt_t * pt2)48     void setMouseRangeFocus(const CTrackData::trkpt_t* pt1, const CTrackData::trkpt_t* pt2) override {}
setMouseClickFocus(const CTrackData::trkpt_t * pt)49     void setMouseClickFocus(const CTrackData::trkpt_t* pt) override {}
50 
51 
52 protected:
53     void resizeEvent(QResizeEvent* e) override;
54 
55 private slots:
56     void slotLinkActivated(const QString& link);
57     void slotLinkActivated(const QUrl& url);
58     void slotPrint();
59     void slotLock(bool on);
60     void slotSortMode(int idx);
61     void slotSetupGui();
62     void slotSetScrollbar();
63 
64 private:
65     void addIcon(QTextTable* table, int col, int row, const QPixmap& icon, const QString& key, bool isReadOnly, bool printable);
66     void getTrackProfile(CGisItemTrk* trk, const CTrackData::trkpt_t* pTrkpt, QImage& image);
67     void getTrackOverview(CGisItemTrk* trk, const CTrackData::trkpt_t* pTrkpt, QImage& image);
68     void draw(QTextDocument& doc, bool printable);
69     void drawInfo(QTextCursor& cursor, bool isReadOnly);
70     void drawTrackSummary(QTextCursor& cursor, const QList<CGisItemTrk*> trks, bool);
71     void drawWaypointSummary(QTextCursor& cursor, const QList<CGisItemWpt*> wpts, bool);
72     void drawByGroup(QTextCursor& cursor,
73                      QList<CGisItemTrk*>& trks,
74                      QList<CGisItemWpt*>& wpts,
75                      CProgressDialog& progress,
76                      int& n, bool printable);
77     void drawByTrack(QTextCursor& cursor,
78                      QList<CGisItemTrk*>& trks,
79                      QList<CGisItemWpt*>& wpts,
80                      CProgressDialog& progress,
81                      int& n, bool printable);
82     void drawByDetails(QTextCursor& cursor,
83                        QList<CGisItemTrk*>& trks,
84                        QList<CGisItemWpt*>& wpts,
85                        CProgressDialog& progress,
86                        int& n, bool printable);
87     void drawArea(QTextCursor& cursor, QList<CGisItemOvlArea*>& areas, CProgressDialog& progress, int& n, bool printable);
88     void drawRoute(QTextCursor& cursor, QList<CGisItemRte*>& rtes, CProgressDialog& progress, int& n, bool printable);
89 
90     QList<wpt_info_t> getWptInfo(const CGisItemTrk& trk) const;
91     QString getNameAndTime(const wpt_info_t& info, const CGisItemTrk& trk) const;
92     QString getStatistics(const wpt_info_t& info) const;
93     QImage getImage(const wpt_info_t& info) const;
94 
95     enum eTblCol1 {eSym1, eInfo1, eComment1, eMax1};
96     enum eTblCol2 {eSym2, eInfo2, eData2, eComment2, eMax2};
97 
98     IGisProject& prj;
99     QTextFrameFormat fmtFrameStandard;
100     QTextFrameFormat fmtFrameTrackSummary;
101     QTextCharFormat fmtCharStandard;
102     QTextBlockFormat fmtBlockStandard;
103     QTextFrameFormat fmtFrameRoot;
104     QTextTableFormat fmtTableStandard;
105     QTextTableFormat fmtTableHidden;
106     QTextTableFormat fmtTableInfo;
107     QTextCharFormat fmtCharHeader;
108 
109     int scrollVal = 0;
110 
111     QTimer* timerUpdateTime;
112 
113     QMutex mutex {QMutex::NonRecursive};
114 };
115 
116 #endif //CDETAILSPRJ_H
117 
118