1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 05:34:47 +01:00

Added basic print/export formating options

This commit is contained in:
Martin Tůma 2016-12-16 02:30:58 +01:00
parent 2bc112c7b4
commit 0448ae5eea
9 changed files with 233 additions and 47 deletions

View File

@ -18,6 +18,7 @@
<file>icons/preferences-desktop-display.png</file> <file>icons/preferences-desktop-display.png</file>
<file>icons/flag_48.png</file> <file>icons/flag_48.png</file>
<file>icons/system-run.png</file> <file>icons/system-run.png</file>
<file>icons/document-print-preview.png</file>
<file>lang/gpxsee_cs.qm</file> <file>lang/gpxsee_cs.qm</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -200,7 +200,7 @@
<translation>Otevřít soubor</translation> <translation>Otevřít soubor</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="690"/> <location filename="../src/gui.cpp" line="698"/>
<source>Open POI file</source> <source>Open POI file</source>
<translation>Otevřít POI soubor</translation> <translation>Otevřít POI soubor</translation>
</message> </message>
@ -457,8 +457,8 @@
<translation>Všechny soubory (*)</translation> <translation>Všechny soubory (*)</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="817"/> <location filename="../src/gui.cpp" line="837"/>
<location filename="../src/gui.cpp" line="820"/> <location filename="../src/gui.cpp" line="840"/>
<source>Date</source> <source>Date</source>
<translation>Datum</translation> <translation>Datum</translation>
</message> </message>
@ -468,12 +468,12 @@
<translation>Trasy</translation> <translation>Trasy</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="1017"/> <location filename="../src/gui.cpp" line="1053"/>
<source>No GPX files loaded</source> <source>No GPX files loaded</source>
<translation>Nejsou načteny žádné GPX soubory</translation> <translation>Nejsou načteny žádné GPX soubory</translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../src/gui.cpp" line="1021"/> <location filename="../src/gui.cpp" line="1057"/>
<source>%n files</source> <source>%n files</source>
<translation> <translation>
<numerusform>%n soubor</numerusform> <numerusform>%n soubor</numerusform>
@ -552,21 +552,26 @@
<translation>POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře:</translation> <translation>POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře:</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="679"/> <location filename="../src/gui.cpp" line="687"/>
<source>Error loading data file:</source> <source>Error loading data file:</source>
<translation>Datový soubor nelze načíst:</translation> <translation>Datový soubor nelze načíst:</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="682"/> <location filename="../src/gui.cpp" line="690"/>
<location filename="../src/gui.cpp" line="707"/> <location filename="../src/gui.cpp" line="715"/>
<source>Line: %1</source> <source>Line: %1</source>
<translation>Řádka: %1</translation> <translation>Řádka: %1</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="704"/> <location filename="../src/gui.cpp" line="712"/>
<source>Error loading POI file:</source> <source>Error loading POI file:</source>
<translation>Soubor POI nelze načíst:</translation> <translation>Soubor POI nelze načíst:</translation>
</message> </message>
<message>
<location filename="../src/gui.cpp" line="823"/>
<source>Name</source>
<translation>Název</translation>
</message>
<message> <message>
<location filename="../src/gui.cpp" line="827"/> <location filename="../src/gui.cpp" line="827"/>
<source>Tracks</source> <source>Tracks</source>
@ -595,13 +600,13 @@
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="326"/> <location filename="../src/gui.cpp" line="326"/>
<location filename="../src/gui.cpp" line="834"/> <location filename="../src/gui.cpp" line="847"/>
<source>Distance</source> <source>Distance</source>
<translation>Vzdálenost</translation> <translation>Vzdálenost</translation>
</message> </message>
<message> <message>
<location filename="../src/gui.cpp" line="333"/> <location filename="../src/gui.cpp" line="333"/>
<location filename="../src/gui.cpp" line="836"/> <location filename="../src/gui.cpp" line="849"/>
<source>Time</source> <source>Time</source>
<translation>Čas</translation> <translation>Čas</translation>
</message> </message>
@ -684,12 +689,12 @@
<message> <message>
<location filename="../src/optionsdialog.cpp" line="34"/> <location filename="../src/optionsdialog.cpp" line="34"/>
<source>Base color:</source> <source>Base color:</source>
<translation>Základní barva</translation> <translation>Základní barva:</translation>
</message> </message>
<message> <message>
<location filename="../src/optionsdialog.cpp" line="35"/> <location filename="../src/optionsdialog.cpp" line="35"/>
<source>Palette shift:</source> <source>Palette shift:</source>
<translation>Posun palety</translation> <translation>Posun palety:</translation>
</message> </message>
<message> <message>
<location filename="../src/optionsdialog.cpp" line="47"/> <location filename="../src/optionsdialog.cpp" line="47"/>
@ -744,6 +749,7 @@
</message> </message>
<message> <message>
<location filename="../src/optionsdialog.cpp" line="115"/> <location filename="../src/optionsdialog.cpp" line="115"/>
<location filename="../src/optionsdialog.cpp" line="180"/>
<source>Graphs</source> <source>Graphs</source>
<translation>Grafy</translation> <translation>Grafy</translation>
</message> </message>
@ -760,32 +766,72 @@
<message> <message>
<location filename="../src/optionsdialog.cpp" line="134"/> <location filename="../src/optionsdialog.cpp" line="134"/>
<source>POI radius:</source> <source>POI radius:</source>
<translation>POI radius</translation> <translation>POI radius:</translation>
</message> </message>
<message> <message>
<location filename="../src/optionsdialog.cpp" line="140"/> <location filename="../src/optionsdialog.cpp" line="140"/>
<location filename="../src/optionsdialog.cpp" line="184"/> <location filename="../src/optionsdialog.cpp" line="225"/>
<source>POI</source> <source>POI</source>
<translation>POI</translation> <translation>POI</translation>
</message> </message>
<message> <message>
<location filename="../src/optionsdialog.cpp" line="147"/> <location filename="../src/optionsdialog.cpp" line="147"/>
<source>Name</source>
<translation>Název</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="149"/>
<source>Date</source>
<translation>Datum</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="151"/>
<source>Distance</source>
<translation>Vzdálenost</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="153"/>
<source>Time</source>
<translation>Čas</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="155"/>
<source>Item count (&gt;1)</source>
<translation>Počet objektů (&gt;1)</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="169"/>
<source>Separate graph page</source>
<translation>Samostatná stránka s grafy</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="179"/>
<source>Header</source>
<translation>Záhlaví</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="187"/>
<source>Use OpenGL</source> <source>Use OpenGL</source>
<translation>Používat OpenGL</translation> <translation>Používat OpenGL</translation>
</message> </message>
<message> <message>
<location filename="../src/optionsdialog.cpp" line="167"/> <location filename="../src/optionsdialog.cpp" line="207"/>
<location filename="../src/optionsdialog.cpp" line="185"/> <location filename="../src/optionsdialog.cpp" line="228"/>
<source>System</source> <source>System</source>
<translation>Systém</translation> <translation>Systém</translation>
</message> </message>
<message> <message>
<location filename="../src/optionsdialog.cpp" line="182"/> <location filename="../src/optionsdialog.cpp" line="223"/>
<source>Appearance</source> <source>Appearance</source>
<translation>Vzhled</translation> <translation>Vzhled</translation>
</message> </message>
<message> <message>
<location filename="../src/optionsdialog.cpp" line="212"/> <location filename="../src/optionsdialog.cpp" line="226"/>
<source>Print &amp; Export</source>
<translation>Tisk a export</translation>
</message>
<message>
<location filename="../src/optionsdialog.cpp" line="255"/>
<source>Options</source> <source>Options</source>
<translation>Nastavení</translation> <translation>Nastavení</translation>
</message> </message>

View File

@ -668,6 +668,14 @@ bool GUI::loadFile(const QString &fileName)
_waypointCount += data.waypoints().count(); _waypointCount += data.waypoints().count();
if (_pathName.isNull()) {
if (data.tracks().count() == 1 && !data.routes().count())
_pathName = data.tracks().first()->name();
else if (data.routes().count() == 1 && !data.tracks().count())
_pathName = data.routes().first()->routeData().name();
} else
_pathName = QString();
return true; return true;
} else { } else {
updateNavigationActions(); updateNavigationActions();
@ -811,7 +819,19 @@ void GUI::plot(QPrinter *printer)
qreal d = distance(); qreal d = distance();
qreal t = time(); qreal t = time();
if (_dateRange.first.isValid()) { if (!_pathName.isNull() && _options.printName)
info.insert(tr("Name"), _pathName);
if (_options.printItemCount) {
if (_trackCount > 1)
info.insert(tr("Tracks"), QString::number(_trackCount));
if (_routeCount > 1)
info.insert(tr("Routes"), QString::number(_routeCount));
if (_waypointCount > 2)
info.insert(tr("Waypoints"), QString::number(_waypointCount));
}
if (_dateRange.first.isValid() && _options.printDate) {
if (_dateRange.first == _dateRange.second) { if (_dateRange.first == _dateRange.second) {
QString format = QLocale::system().dateFormat(QLocale::LongFormat); QString format = QLocale::system().dateFormat(QLocale::LongFormat);
info.insert(tr("Date"), _dateRange.first.toString(format)); info.insert(tr("Date"), _dateRange.first.toString(format));
@ -823,16 +843,9 @@ void GUI::plot(QPrinter *printer)
} }
} }
if (_trackCount > 1) if (d > 0 && _options.printDistance)
info.insert(tr("Tracks"), QString::number(_trackCount));
if (_routeCount > 1)
info.insert(tr("Routes"), QString::number(_routeCount));
if (_waypointCount > 2)
info.insert(tr("Waypoints"), QString::number(_waypointCount));
if (d > 0)
info.insert(tr("Distance"), Format::distance(d, units)); info.insert(tr("Distance"), Format::distance(d, units));
if (t > 0) if (t > 0 && _options.printTime)
info.insert(tr("Time"), Format::timeSpan(t)); info.insert(tr("Time"), Format::timeSpan(t));
@ -845,7 +858,7 @@ void GUI::plot(QPrinter *printer)
mh = ih / 2; mh = ih / 2;
info.plot(&p, QRectF(0, 0, printer->width(), ih)); info.plot(&p, QRectF(0, 0, printer->width(), ih));
} }
if (_graphTabWidget->isVisible()) { if (_graphTabWidget->isVisible() && !_options.separateGraphPage) {
qreal r = (((qreal)(printer)->width()) / (qreal)(printer->height())); qreal r = (((qreal)(printer)->width()) / (qreal)(printer->height()));
gh = (printer->width() > printer->height()) gh = (printer->width() > printer->height())
? 0.15 * r * (printer->height() - ih - 2*mh) ? 0.15 * r * (printer->height() - ih - 2*mh)
@ -857,6 +870,27 @@ void GUI::plot(QPrinter *printer)
gh = 0; gh = 0;
_pathView->plot(&p, QRectF(0, ih + mh, printer->width(), printer->height() _pathView->plot(&p, QRectF(0, ih + mh, printer->width(), printer->height()
- (ih + 2*mh + gh))); - (ih + 2*mh + gh)));
if (_graphTabWidget->isVisible() && _options.separateGraphPage) {
printer->newPage();
int cnt = 0;
for (int i = 0; i < _tabs.size(); i++)
if (_tabs.at(i)->count())
cnt++;
qreal sp = ratio * 20;
gh = qMin((printer->height() - ((cnt - 1) * sp))/(qreal)cnt,
0.20 * printer->height());
qreal y = 0;
for (int i = 0; i < _tabs.size(); i++) {
if (_tabs.at(i)->count()) {
_tabs.at(i)->plot(&p, QRectF(0, y, printer->width(), gh));
y += gh + sp;
}
}
}
} }
void GUI::reloadFile() void GUI::reloadFile()
@ -868,6 +902,7 @@ void GUI::reloadFile()
_routeDistance = 0; _routeDistance = 0;
_time = 0; _time = 0;
_dateRange = DateRange(QDate(), QDate()); _dateRange = DateRange(QDate(), QDate());
_pathName = QString();
for (int i = 0; i < _tabs.count(); i++) for (int i = 0; i < _tabs.count(); i++)
_tabs.at(i)->clear(); _tabs.at(i)->clear();
@ -901,6 +936,7 @@ void GUI::closeFiles()
_routeDistance = 0; _routeDistance = 0;
_time = 0; _time = 0;
_dateRange = DateRange(QDate(), QDate()); _dateRange = DateRange(QDate(), QDate());
_pathName = QString();
_sliderPos = 0; _sliderPos = 0;
@ -1378,6 +1414,19 @@ void GUI::writeSettings()
settings.setValue(POI_RADIUS_SETTING, _options.poiRadius); settings.setValue(POI_RADIUS_SETTING, _options.poiRadius);
if (_options.useOpenGL != USE_OPENGL_DEFAULT) if (_options.useOpenGL != USE_OPENGL_DEFAULT)
settings.setValue(USE_OPENGL_SETTING, _options.useOpenGL); settings.setValue(USE_OPENGL_SETTING, _options.useOpenGL);
if (_options.printName != PRINT_NAME_DEFAULT)
settings.setValue(PRINT_NAME_SETTING, _options.printName);
if (_options.printDate != PRINT_DATE_DEFAULT)
settings.setValue(PRINT_DATE_SETTING, _options.printDate);
if (_options.printDistance != PRINT_DISTANCE_DEFAULT)
settings.setValue(PRINT_DISTANCE_SETTING, _options.printDistance);
if (_options.printTime != PRINT_TIME_DEFAULT)
settings.setValue(PRINT_TIME_SETTING, _options.printTime);
if (_options.printItemCount != PRINT_ITEM_COUNT_DEFAULT)
settings.setValue(PRINT_ITEM_COUNT_SETTING, _options.printItemCount);
if (_options.separateGraphPage != SEPARATE_GRAPH_PAGE_DEFAULT)
settings.setValue(SEPARATE_GRAPH_PAGE_SETTING,
_options.separateGraphPage);
settings.endGroup(); settings.endGroup();
} }
@ -1534,6 +1583,18 @@ void GUI::readSettings()
.toInt(); .toInt();
_options.useOpenGL = settings.value(USE_OPENGL_SETTING, USE_OPENGL_DEFAULT) _options.useOpenGL = settings.value(USE_OPENGL_SETTING, USE_OPENGL_DEFAULT)
.toBool(); .toBool();
_options.printName = settings.value(PRINT_NAME_SETTING, PRINT_NAME_DEFAULT)
.toBool();
_options.printDate = settings.value(PRINT_DATE_SETTING, PRINT_DATE_DEFAULT)
.toBool();
_options.printDistance = settings.value(PRINT_DISTANCE_SETTING,
PRINT_DISTANCE_DEFAULT).toBool();
_options.printTime = settings.value(PRINT_TIME_SETTING, PRINT_TIME_DEFAULT)
.toBool();
_options.printItemCount = settings.value(PRINT_ITEM_COUNT_SETTING,
PRINT_ITEM_COUNT_DEFAULT).toBool();
_options.separateGraphPage = settings.value(SEPARATE_GRAPH_PAGE_SETTING,
SEPARATE_GRAPH_PAGE_DEFAULT).toBool();
_pathView->setPalette(_options.palette); _pathView->setPalette(_options.palette);
_pathView->setTrackWidth(_options.trackWidth); _pathView->setTrackWidth(_options.trackWidth);

View File

@ -189,6 +189,7 @@ private:
qreal _routeDistance; qreal _routeDistance;
qreal _time; qreal _time;
DateRange _dateRange; DateRange _dateRange;
QString _pathName;
qreal _sliderPos; qreal _sliderPos;

View File

@ -23,5 +23,6 @@
#define APPEARANCE_ICON ":/icons/preferences-desktop-display.png" #define APPEARANCE_ICON ":/icons/preferences-desktop-display.png"
#define POI_ICON ":/icons/flag_48.png" #define POI_ICON ":/icons/flag_48.png"
#define SYSTEM_ICON ":/icons/system-run.png" #define SYSTEM_ICON ":/icons/system-run.png"
#define PRINT_EXPORT_ICON ":/icons/document-print-preview.png"
#endif /* ICONS_H */ #endif /* ICONS_H */

View File

@ -142,6 +142,46 @@ QWidget *OptionsDialog::createPOIPage()
return poiPage; return poiPage;
} }
QWidget *OptionsDialog::createExportPage()
{
_name = new QCheckBox(tr("Name"));
_name->setChecked(_options->printName);
_date = new QCheckBox(tr("Date"));
_date->setChecked(_options->printDate);
_distance = new QCheckBox(tr("Distance"));
_distance->setChecked(_options->printDistance);
_time = new QCheckBox(tr("Time"));
_time->setChecked(_options->printTime);
_itemCount = new QCheckBox(tr("Item count (>1)"));
_itemCount->setChecked(_options->printItemCount);
QFormLayout *headerTabLayout = new QFormLayout();
headerTabLayout->addWidget(_name);
headerTabLayout->addWidget(_date);
headerTabLayout->addWidget(_distance);
headerTabLayout->addWidget(_time);
headerTabLayout->addItem(new QSpacerItem(10, 10));
headerTabLayout->addWidget(_itemCount);
QWidget *headerTab = new QWidget();
headerTab->setLayout(headerTabLayout);
_separateGraphPage = new QCheckBox(tr("Separate graph page"));
_separateGraphPage->setChecked(_options->separateGraphPage);
QFormLayout *graphTabLayout = new QFormLayout();
graphTabLayout->addWidget(_separateGraphPage);
QWidget *graphTab = new QWidget();
graphTab->setLayout(graphTabLayout);
QTabWidget *exportPage = new QTabWidget();
exportPage->addTab(headerTab, tr("Header"));
exportPage->addTab(graphTab, tr("Graphs"));
return exportPage;
}
QWidget *OptionsDialog::createSystemPage() QWidget *OptionsDialog::createSystemPage()
{ {
_useOpenGL = new QCheckBox(tr("Use OpenGL")); _useOpenGL = new QCheckBox(tr("Use OpenGL"));
@ -175,6 +215,7 @@ OptionsDialog::OptionsDialog(Options *options, QWidget *parent)
QStackedWidget *pages = new QStackedWidget(); QStackedWidget *pages = new QStackedWidget();
pages->addWidget(createAppearancePage()); pages->addWidget(createAppearancePage());
pages->addWidget(createPOIPage()); pages->addWidget(createPOIPage());
pages->addWidget(createExportPage());
pages->addWidget(createSystemPage()); pages->addWidget(createSystemPage());
QListWidget *menu = new QListWidget(); QListWidget *menu = new QListWidget();
@ -182,6 +223,8 @@ OptionsDialog::OptionsDialog(Options *options, QWidget *parent)
new QListWidgetItem(QIcon(QPixmap(APPEARANCE_ICON)), tr("Appearance"), new QListWidgetItem(QIcon(QPixmap(APPEARANCE_ICON)), tr("Appearance"),
menu); menu);
new QListWidgetItem(QIcon(QPixmap(POI_ICON)), tr("POI"), menu); new QListWidgetItem(QIcon(QPixmap(POI_ICON)), tr("POI"), menu);
new QListWidgetItem(QIcon(QPixmap(PRINT_EXPORT_ICON)), tr("Print & Export"),
menu);
new QListWidgetItem(QIcon(QPixmap(SYSTEM_ICON)), tr("System"), menu); new QListWidgetItem(QIcon(QPixmap(SYSTEM_ICON)), tr("System"), menu);
QHBoxLayout *contentLayout = new QHBoxLayout(); QHBoxLayout *contentLayout = new QHBoxLayout();
@ -234,5 +277,12 @@ void OptionsDialog::accept()
_options->useOpenGL = _useOpenGL->isChecked(); _options->useOpenGL = _useOpenGL->isChecked();
_options->printName = _name->isChecked();
_options->printDate = _date->isChecked();
_options->printDistance = _distance->isChecked();
_options->printTime = _time->isChecked();
_options->printItemCount = _itemCount->isChecked();
_options->separateGraphPage = _separateGraphPage->isChecked();
QDialog::accept(); QDialog::accept();
} }

View File

@ -26,6 +26,13 @@ struct Options {
int poiRadius; int poiRadius;
// System // System
bool useOpenGL; bool useOpenGL;
// Print/Export
bool printName;
bool printDate;
bool printDistance;
bool printTime;
bool printItemCount;
bool separateGraphPage;
Units units; Units units;
}; };
@ -44,6 +51,7 @@ private:
QWidget *createAppearancePage(); QWidget *createAppearancePage();
QWidget *createPOIPage(); QWidget *createPOIPage();
QWidget *createSystemPage(); QWidget *createSystemPage();
QWidget *createExportPage();
Options *_options; Options *_options;
@ -58,6 +66,12 @@ private:
QCheckBox *_graphAA; QCheckBox *_graphAA;
QDoubleSpinBox *_poiRadius; QDoubleSpinBox *_poiRadius;
QCheckBox *_useOpenGL; QCheckBox *_useOpenGL;
QCheckBox *_name;
QCheckBox *_date;
QCheckBox *_distance;
QCheckBox *_time;
QCheckBox *_itemCount;
QCheckBox *_separateGraphPage;
}; };
#endif // OPTIONSDIALOG_H #endif // OPTIONSDIALOG_H

View File

@ -92,5 +92,17 @@
#define POI_RADIUS_DEFAULT (IMPERIAL_UNITS() ? MIINM : KMINM) #define POI_RADIUS_DEFAULT (IMPERIAL_UNITS() ? MIINM : KMINM)
#define USE_OPENGL_SETTING "useOpenGL" #define USE_OPENGL_SETTING "useOpenGL"
#define USE_OPENGL_DEFAULT false #define USE_OPENGL_DEFAULT false
#define PRINT_NAME_SETTING "printName"
#define PRINT_NAME_DEFAULT true
#define PRINT_DATE_SETTING "printDate"
#define PRINT_DATE_DEFAULT true
#define PRINT_DISTANCE_SETTING "printDistance"
#define PRINT_DISTANCE_DEFAULT true
#define PRINT_TIME_SETTING "printTime"
#define PRINT_TIME_DEFAULT true
#define PRINT_ITEM_COUNT_SETTING "printItemCount"
#define PRINT_ITEM_COUNT_DEFAULT true
#define SEPARATE_GRAPH_PAGE_SETTING "separateGraphPage"
#define SEPARATE_GRAPH_PAGE_DEFAULT false
#endif // SETTINGS_H #endif // SETTINGS_H