mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-27 11:39:16 +02:00
Added basic print/export formating options
This commit is contained in:
83
src/gui.cpp
83
src/gui.cpp
@ -668,6 +668,14 @@ bool GUI::loadFile(const QString &fileName)
|
||||
|
||||
_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;
|
||||
} else {
|
||||
updateNavigationActions();
|
||||
@ -811,7 +819,19 @@ void GUI::plot(QPrinter *printer)
|
||||
qreal d = distance();
|
||||
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) {
|
||||
QString format = QLocale::system().dateFormat(QLocale::LongFormat);
|
||||
info.insert(tr("Date"), _dateRange.first.toString(format));
|
||||
@ -823,16 +843,9 @@ void GUI::plot(QPrinter *printer)
|
||||
}
|
||||
}
|
||||
|
||||
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 (d > 0)
|
||||
if (d > 0 && _options.printDistance)
|
||||
info.insert(tr("Distance"), Format::distance(d, units));
|
||||
if (t > 0)
|
||||
if (t > 0 && _options.printTime)
|
||||
info.insert(tr("Time"), Format::timeSpan(t));
|
||||
|
||||
|
||||
@ -845,7 +858,7 @@ void GUI::plot(QPrinter *printer)
|
||||
mh = ih / 2;
|
||||
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()));
|
||||
gh = (printer->width() > printer->height())
|
||||
? 0.15 * r * (printer->height() - ih - 2*mh)
|
||||
@ -857,6 +870,27 @@ void GUI::plot(QPrinter *printer)
|
||||
gh = 0;
|
||||
_pathView->plot(&p, QRectF(0, ih + mh, printer->width(), printer->height()
|
||||
- (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()
|
||||
@ -868,6 +902,7 @@ void GUI::reloadFile()
|
||||
_routeDistance = 0;
|
||||
_time = 0;
|
||||
_dateRange = DateRange(QDate(), QDate());
|
||||
_pathName = QString();
|
||||
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->clear();
|
||||
@ -901,6 +936,7 @@ void GUI::closeFiles()
|
||||
_routeDistance = 0;
|
||||
_time = 0;
|
||||
_dateRange = DateRange(QDate(), QDate());
|
||||
_pathName = QString();
|
||||
|
||||
_sliderPos = 0;
|
||||
|
||||
@ -1378,6 +1414,19 @@ void GUI::writeSettings()
|
||||
settings.setValue(POI_RADIUS_SETTING, _options.poiRadius);
|
||||
if (_options.useOpenGL != USE_OPENGL_DEFAULT)
|
||||
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();
|
||||
}
|
||||
|
||||
@ -1534,6 +1583,18 @@ void GUI::readSettings()
|
||||
.toInt();
|
||||
_options.useOpenGL = settings.value(USE_OPENGL_SETTING, USE_OPENGL_DEFAULT)
|
||||
.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->setTrackWidth(_options.trackWidth);
|
||||
|
@ -189,6 +189,7 @@ private:
|
||||
qreal _routeDistance;
|
||||
qreal _time;
|
||||
DateRange _dateRange;
|
||||
QString _pathName;
|
||||
|
||||
qreal _sliderPos;
|
||||
|
||||
|
35
src/icons.h
35
src/icons.h
@ -4,24 +4,25 @@
|
||||
#define APP_ICON ":/icons/gpxsee.png"
|
||||
|
||||
// Toolbar/menu icons
|
||||
#define OPEN_FILE_ICON ":/icons/document-open.png"
|
||||
#define EXPORT_FILE_ICON ":/icons/document-export.png"
|
||||
#define PRINT_FILE_ICON ":/icons/document-print.png"
|
||||
#define CLOSE_FILE_ICON ":/icons/dialog-close.png"
|
||||
#define SHOW_POI_ICON ":/icons/flag.png"
|
||||
#define SHOW_MAP_ICON ":/icons/applications-internet.png"
|
||||
#define SHOW_GRAPHS_ICON ":/icons/office-chart-line-stacked.png"
|
||||
#define QUIT_ICON ":/icons/application-exit.png"
|
||||
#define RELOAD_FILE_ICON ":/icons/view-refresh.png"
|
||||
#define NEXT_FILE_ICON ":/icons/arrow-right.png"
|
||||
#define PREV_FILE_ICON ":/icons/arrow-left.png"
|
||||
#define LAST_FILE_ICON ":/icons/arrow-right-double.png"
|
||||
#define FIRST_FILE_ICON ":/icons/arrow-left-double.png"
|
||||
#define FULLSCREEN_ICON ":/icons/view-fullscreen.png"
|
||||
#define OPEN_FILE_ICON ":/icons/document-open.png"
|
||||
#define EXPORT_FILE_ICON ":/icons/document-export.png"
|
||||
#define PRINT_FILE_ICON ":/icons/document-print.png"
|
||||
#define CLOSE_FILE_ICON ":/icons/dialog-close.png"
|
||||
#define SHOW_POI_ICON ":/icons/flag.png"
|
||||
#define SHOW_MAP_ICON ":/icons/applications-internet.png"
|
||||
#define SHOW_GRAPHS_ICON ":/icons/office-chart-line-stacked.png"
|
||||
#define QUIT_ICON ":/icons/application-exit.png"
|
||||
#define RELOAD_FILE_ICON ":/icons/view-refresh.png"
|
||||
#define NEXT_FILE_ICON ":/icons/arrow-right.png"
|
||||
#define PREV_FILE_ICON ":/icons/arrow-left.png"
|
||||
#define LAST_FILE_ICON ":/icons/arrow-right-double.png"
|
||||
#define FIRST_FILE_ICON ":/icons/arrow-left-double.png"
|
||||
#define FULLSCREEN_ICON ":/icons/view-fullscreen.png"
|
||||
|
||||
// Options dialog icons
|
||||
#define APPEARANCE_ICON ":/icons/preferences-desktop-display.png"
|
||||
#define POI_ICON ":/icons/flag_48.png"
|
||||
#define SYSTEM_ICON ":/icons/system-run.png"
|
||||
#define APPEARANCE_ICON ":/icons/preferences-desktop-display.png"
|
||||
#define POI_ICON ":/icons/flag_48.png"
|
||||
#define SYSTEM_ICON ":/icons/system-run.png"
|
||||
#define PRINT_EXPORT_ICON ":/icons/document-print-preview.png"
|
||||
|
||||
#endif /* ICONS_H */
|
||||
|
@ -142,6 +142,46 @@ QWidget *OptionsDialog::createPOIPage()
|
||||
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()
|
||||
{
|
||||
_useOpenGL = new QCheckBox(tr("Use OpenGL"));
|
||||
@ -175,6 +215,7 @@ OptionsDialog::OptionsDialog(Options *options, QWidget *parent)
|
||||
QStackedWidget *pages = new QStackedWidget();
|
||||
pages->addWidget(createAppearancePage());
|
||||
pages->addWidget(createPOIPage());
|
||||
pages->addWidget(createExportPage());
|
||||
pages->addWidget(createSystemPage());
|
||||
|
||||
QListWidget *menu = new QListWidget();
|
||||
@ -182,6 +223,8 @@ OptionsDialog::OptionsDialog(Options *options, QWidget *parent)
|
||||
new QListWidgetItem(QIcon(QPixmap(APPEARANCE_ICON)), tr("Appearance"),
|
||||
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);
|
||||
|
||||
QHBoxLayout *contentLayout = new QHBoxLayout();
|
||||
@ -234,5 +277,12 @@ void OptionsDialog::accept()
|
||||
|
||||
_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();
|
||||
}
|
||||
|
@ -26,6 +26,13 @@ struct Options {
|
||||
int poiRadius;
|
||||
// System
|
||||
bool useOpenGL;
|
||||
// Print/Export
|
||||
bool printName;
|
||||
bool printDate;
|
||||
bool printDistance;
|
||||
bool printTime;
|
||||
bool printItemCount;
|
||||
bool separateGraphPage;
|
||||
|
||||
Units units;
|
||||
};
|
||||
@ -44,6 +51,7 @@ private:
|
||||
QWidget *createAppearancePage();
|
||||
QWidget *createPOIPage();
|
||||
QWidget *createSystemPage();
|
||||
QWidget *createExportPage();
|
||||
|
||||
Options *_options;
|
||||
|
||||
@ -58,6 +66,12 @@ private:
|
||||
QCheckBox *_graphAA;
|
||||
QDoubleSpinBox *_poiRadius;
|
||||
QCheckBox *_useOpenGL;
|
||||
QCheckBox *_name;
|
||||
QCheckBox *_date;
|
||||
QCheckBox *_distance;
|
||||
QCheckBox *_time;
|
||||
QCheckBox *_itemCount;
|
||||
QCheckBox *_separateGraphPage;
|
||||
};
|
||||
|
||||
#endif // OPTIONSDIALOG_H
|
||||
|
@ -92,5 +92,17 @@
|
||||
#define POI_RADIUS_DEFAULT (IMPERIAL_UNITS() ? MIINM : KMINM)
|
||||
#define USE_OPENGL_SETTING "useOpenGL"
|
||||
#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
|
||||
|
Reference in New Issue
Block a user