Skip to content

Commit

Permalink
Fixes for HTML page export. Now exporting full document instead of a …
Browse files Browse the repository at this point in the history
…snipped.

#4
  • Loading branch information
albar965 committed Aug 29, 2019
1 parent c9e2962 commit a2ae3ad
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/gui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -10894,7 +10894,7 @@ relation to shown airport</string>
</action>
<action name="actionRouteSaveAsHtml">
<property name="text">
<string>Export Flight Plan as HTML ...</string>
<string>Export Flight Plan as HTML Page ...</string>
</property>
<property name="toolTip">
<string>Export the flight plan as a HTML page</string>
Expand Down
15 changes: 13 additions & 2 deletions src/route/routecontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,18 @@ void RouteController::flightplanHeader(atools::util::HtmlBuilder& html, bool tit
html.p(buildFlightplanLabel2(), atools::util::html::NO_ENTITIES | atools::util::html::BIG);
}

QString RouteController::getFlightplanTableAsHtml(float iconSizePixel) const
QString RouteController::getFlightplanTableAsHtmlDoc(float iconSizePixel) const
{
atools::util::HtmlBuilder html(true);
html.doc(tr("%1 - %2").arg(QApplication::applicationName()).
arg(RouteExport::buildDefaultFilenameLong(QString(), QString())));
html.text(NavApp::getRouteController()->getFlightplanTableAsHtml(iconSizePixel, false),
atools::util::html::NO_ENTITIES);
html.docEnd();
return html.getHtml();
}

QString RouteController::getFlightplanTableAsHtml(float iconSizePixel, bool print) const
{
qDebug() << Q_FUNC_INFO;
using atools::util::HtmlBuilder;
Expand All @@ -469,7 +480,7 @@ QString RouteController::getFlightplanTableAsHtml(float iconSizePixel) const
int minColWidth = view->horizontalHeader()->minimumSectionSize() + 1;

// Header lines
html.p(buildFlightplanLabel(true /* print */), atools::util::html::NO_ENTITIES | atools::util::html::BIG);
html.p(buildFlightplanLabel(print), atools::util::html::NO_ENTITIES | atools::util::html::BIG);
html.p(buildFlightplanLabel2(), atools::util::html::NO_ENTITIES | atools::util::html::BIG);
html.table();

Expand Down
7 changes: 5 additions & 2 deletions src/route/routecontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,12 @@ class RouteController :
void optionsChanged();
void styleChanged();

/* Get the route table as a HTML document only containing the table and header.
/* Get the route table as a HTML snipped only containing the table and header.
* Uses own colors for table background. */
QString getFlightplanTableAsHtml(float iconSizePixel) const;
QString getFlightplanTableAsHtml(float iconSizePixel, bool print) const;

/* Same as above but full HTML document */
QString getFlightplanTableAsHtmlDoc(float iconSizePixel) const;

/* Insert a flight plan table as QTextTable object at the cursor position */
void flightplanTableAsTextTable(QTextCursor& cursor, const QBitArray& selectedCols, float fontPointSize) const;
Expand Down
8 changes: 3 additions & 5 deletions src/route/routeexport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,14 +817,12 @@ bool RouteExport::routeExportHtml()

if(!routeFile.isEmpty())
{
QString htmlpage = NavApp::getRouteController()->getFlightplanTableAsHtml(24);

QFile file(routeFile);
if(file.open(QIODevice::WriteOnly | QIODevice::Text))
{
QTextStream stream(&file);
stream.setCodec("UTF-8");
stream << htmlpage;
stream << NavApp::getRouteController()->getFlightplanTableAsHtmlDoc(24);
mainWindow->setStatusMessage(tr("Flight plan saved as HTML."));
return true;
}
Expand Down Expand Up @@ -912,7 +910,7 @@ QString RouteExport::buildDefaultFilename(const QString& sep, const QString& suf
buildDefaultFilenameShort(sep, suffix) : buildDefaultFilenameLong(extension, suffix);
}

QString RouteExport::buildDefaultFilenameLong(const QString& extension, const QString& suffix) const
QString RouteExport::buildDefaultFilenameLong(const QString& extension, const QString& suffix)
{
QString filename;

Expand Down Expand Up @@ -944,7 +942,7 @@ QString RouteExport::buildDefaultFilenameLong(const QString& extension, const QS
return filename;
}

QString RouteExport::buildDefaultFilenameShort(const QString& sep, const QString& suffix) const
QString RouteExport::buildDefaultFilenameShort(const QString& sep, const QString& suffix)
{
QString filename;

Expand Down
4 changes: 2 additions & 2 deletions src/route/routeexport.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ class RouteExport :
const QString& extension = QString()) const;

/* Create a default filename based on departure and destination names. Suffix includes dot. */
QString buildDefaultFilenameLong(const QString& extension = QString(), const QString& suffix = ".pln") const;
QString buildDefaultFilenameShort(const QString& sep, const QString& suffix) const;
static QString buildDefaultFilenameLong(const QString& extension = QString(), const QString& suffix = ".pln");
static QString buildDefaultFilenameShort(const QString& sep, const QString& suffix);

/* Return a copy of the route that has procedures replaced with waypoints depending on selected options in the menu.
* Also sets altitude into FlightplanEntry position. */
Expand Down
2 changes: 1 addition & 1 deletion src/web/requesthandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void RequestHandler::service(HttpRequest& request, HttpResponse& response)
// ===========================================================================
// Flight plan
if(t.contains("{flightplanText}"))
t.setVariable("flightplanText", emit getFlightplanTableAsHtml(20));
t.setVariable("flightplanText", emit getFlightplanTableAsHtml(20, false));

// ===========================================================================
// Airport information
Expand Down
2 changes: 1 addition & 1 deletion src/web/requesthandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class RequestHandler :

atools::fs::sc::SimConnectUserAircraft getUserAircraft();
Route getRoute();
QString getFlightplanTableAsHtml(int iconSize);
QString getFlightplanTableAsHtml(int iconSize, bool print);
QStringList getAirportText(QString ident);
atools::geo::Pos getCurrentMapWidgetPos();

Expand Down

0 comments on commit a2ae3ad

Please sign in to comment.