Fotobot
Get data from your photovoltaic plant
Signals | Public Member Functions | Static Public Member Functions | Private Member Functions | List of all members
GeoController Class Reference
Inheritance diagram for GeoController:
WebPage MRequestHandler

Signals

void saveGeocoordinates (DBT_GEOCOORDINATES)
 

Public Member Functions

 GeoController ()
 
void servicePrivate (HttpRequest &request)
 
- Public Member Functions inherited from WebPage
 WebPage ()
 
virtual void service (HttpRequest &request, HttpResponse &response)
 
void redirect (const QString &location)
 
- Public Member Functions inherited from MRequestHandler
 MRequestHandler ()
 

Static Public Member Functions

static QString getGeoFormContents (DBT_GEOCOORDINATES geo=DBT_GEOCOORDINATES())
 
static void readGeoForm (DBT_GEOCOORDINATES &geo, HttpRequest &request)
 
- Static Public Member Functions inherited from WebPage
static QString percentEncode (const QString &s)
 

Private Member Functions

 Q_DISABLE_COPY (GeoController)
 
void actionGeo (HttpRequest &request)
 

Additional Inherited Members

- Protected Member Functions inherited from WebPage
void setStatus (int code, QByteArray description)
 
void setHeader (QByteArray name, QByteArray value)
 
void setHeader (QByteArray name, int value)
 
void write (QByteArray data)
 
void write (QString data)
 
void write (const char *data)
 
void about ()
 
HttpSession getSession ()
 
virtual void writeHeader (HttpRequest &request, HttpResponse &response)
 
virtual void writeFooter (HttpRequest &request, HttpResponse &response)
 
- Protected Member Functions inherited from MRequestHandler
bool needsLogin (HttpRequest &request, HttpResponse &response)
 
- Protected Attributes inherited from WebPage
QString m_javascript
 
- Protected Attributes inherited from MRequestHandler
bool m_needs_access_data
 
bool m_needs_change_settings
 
bool m_cacheable
 

Detailed Description

Definition at line 16 of file geocontroller.h.

Constructor & Destructor Documentation

GeoController::GeoController ( )

Constructor

Definition at line 10 of file geocontroller.cpp.

10  {
11  qRegisterMetaType<DBT_GEOCOORDINATES>();
12  connect(this, SIGNAL(saveGeocoordinates(DBT_GEOCOORDINATES)), Static::db, SLOT(setGeocoordinates(DBT_GEOCOORDINATES)), Qt::BlockingQueuedConnection);
13 }
Class describing database table GEOCOORDINATES.

Member Function Documentation

void GeoController::actionGeo ( HttpRequest &  request)
private

Edit geocoordinates settings action

a form

second page doing the action and redirecting validation

Definition at line 39 of file geocontroller.cpp.

39  {
40  QByteArray action = request.getParameter("action");
43  write(QString("<h3>%1</h3>\n").arg(tr("Geographical coordinates settings")));
44  write("<form method=\"post\">\n"
45  "<input type=\"hidden\" name=\"action\" value=\"geo2\" />\n");
46  if(action != "geo2") {
47  DBT_GEOCOORDINATES g = Static::db->geocoordinates();
48  qDebug() << "GEO" << g.longitude << g.latitude;
49  write("<table class=\"formTable\">");
50  write(getGeoFormContents(g));
51  write("</table>");
52  } else {
53  readGeoForm(geo, request);
54  write("<table class=\"formTable\">");
55  write(getGeoFormContents(geo));
56  write("</table>");
57  }
58  write(QString("<input type=\"submit\" value=\"%1\">\n"
59  "</form>\n").arg(tr("Save")));
60  if(action == "geo2") {
63  if(true) {
64  emit saveGeocoordinates(geo);
65  Static::slunce->setObserver(geo.latitude.toDouble(), geo.longitude.toDouble());
66  QString location = QString("/settings?message=%1").arg(percentEncode(tr("Geographical coordinates edited.")));
67  redirect(location);
68  } else {
69  write(QString("<p>%1</p>").arg(tr("Error: Geographical coordinates definition invalid.")));
70  }
71  }
72 }
Class describing database table GEOCOORDINATES.
void setObserver(double lat, double lng)
Definition: slunce.cpp:40
static void readGeoForm(DBT_GEOCOORDINATES &geo, HttpRequest &request)
static QString getGeoFormContents(DBT_GEOCOORDINATES geo=DBT_GEOCOORDINATES())
DBT_GEOCOORDINATES geocoordinates()
Returns geocoordinates.
Definition: database.cpp:581
QString GeoController::getGeoFormContents ( DBT_GEOCOORDINATES  geo = DBT_GEOCOORDINATES())
static

Generates an geo form contents (html input fields)

Definition at line 23 of file geocontroller.cpp.

23  {
24  QString s;
25  QString i ("<tr><td><label for=\"%2\">%1</label>: </td><td><input type=\"text\" name=\"%2\" value=\"%3\" /></td></tr>\n");
26  s.append(i.arg(tr("Longitude"), "longitude", geo.longitude.toString()));
27  s.append(i.arg(tr("Latitude"), "latitude", geo.latitude.toString()));
28  return s;
29 }
void GeoController::readGeoForm ( DBT_GEOCOORDINATES geo,
HttpRequest &  request 
)
static

Read form HTTP post reply and load into the line

Definition at line 31 of file geocontroller.cpp.

31  {
32  geo.longitude = request.getParameter("longitude");
33  geo.latitude = request.getParameter("latitude");
34 }
void GeoController::servicePrivate ( HttpRequest &  request)
virtual

Generates the response

Default action/page

Implements WebPage.

Definition at line 15 of file geocontroller.cpp.

15  {
16  QByteArray action = request.getParameter("action");
17 
19 
20  actionGeo(request);
21 }
void actionGeo(HttpRequest &request)

The documentation for this class was generated from the following files: