[Phoneorder-commits] SF.net SVN: phoneorder:[51] trunk
Status: Alpha
Brought to you by:
hurikhan
|
From: <hur...@us...> - 2010-06-13 08:47:22
|
Revision: 51
http://phoneorder.svn.sourceforge.net/phoneorder/?rev=51&view=rev
Author: hurikhan
Date: 2010-06-13 08:47:15 +0000 (Sun, 13 Jun 2010)
Log Message:
-----------
Migration to Qt4 and template system
First working version after migration to Qt4 with first implementation
of the new template system. This version still has some rough edges but
should not crash in normal workflows.
Modified Paths:
--------------
trunk/src/main.cpp
trunk/src/mainform.ui.h
trunk/src/orderwidget.ui
trunk/src/orderwidget.ui.h
trunk/src/src.pro
trunk/src/widgets/historylineedit.cpp
Added Paths:
-----------
trunk/src/templatereader.cpp
trunk/src/templatereader.h
trunk/templates/AdvertBox.html
trunk/templates/DocumentHeader.html
trunk/templates/GroupHeader.html
trunk/templates/IngredientLine.html
trunk/templates/ItemLine.html
trunk/templates/ReportFooter.html
trunk/templates/ReportHeader.html
trunk/templates/SloganBox.html
Removed Paths:
-------------
trunk/templates/cpp
trunk/templates/h
Modified: trunk/src/main.cpp
===================================================================
--- trunk/src/main.cpp 2010-03-21 21:31:19 UTC (rev 50)
+++ trunk/src/main.cpp 2010-06-13 08:47:15 UTC (rev 51)
@@ -23,6 +23,8 @@
#include <QTabWidget>
#include <QPushButton>
#include <QSettings>
+#include <QDialog>
+#include <QPrintDialog>
#include "mainform.h"
#include "po_priceseditor.h"
@@ -43,7 +45,7 @@
delete settings;
QApplication a (argc, argv);
- MainForm *mw = new MainForm ();
+ MainForm *mw = new MainForm();
a.setMainWidget (mw);
mw->pickupWidget->removePage (mw->pickupWidget->page (0));
@@ -72,10 +74,15 @@
mw->createNewOrder ();
- mw->printer = new QPrinter ();
- mw->printer->setPageSize (QPrinter::A5); // FS#46
- mw->printer->setNumCopies (2);
- mw->printer->setup (mw);
+ mw->printer = new QPrinter(QPrinter::HighResolution);
+ mw->printer->setPaperSize(QPrinter::A5); // FS#46
+ mw->printer->setNumCopies(2);
+ mw->printer->setColorMode(QPrinter::GrayScale);
+ mw->printer->setCreator("PhoneOrder");
- return a.exec ();
+ QPrintDialog *dialog = new QPrintDialog(mw->printer, mw);
+ dialog->setWindowTitle(QObject::tr("Printer Setup"));
+ if (dialog->exec() == QDialog::Accepted) return a.exec ();
+
+ return 1;
}
Modified: trunk/src/mainform.ui.h
===================================================================
--- trunk/src/mainform.ui.h 2010-03-21 21:31:19 UTC (rev 50)
+++ trunk/src/mainform.ui.h 2010-06-13 08:47:15 UTC (rev 51)
@@ -20,43 +20,49 @@
void MainForm::createOrderPage (PO_Customer *from)
{
- OrderWidget *ow = new OrderWidget ();
- ow->custNum->setText (from->num);
- ow->custName->setText (from->name);
- ow->custStreet->setText (from->street);
- ow->custCity->setText (from->city);
- ow->custPhone->setText (from->phone);
- ow->custNotes->setText (from->notes);
- int max = 1;
- for (int i = 0; i < pickupWidget->count (); i++)
- {
- QString l = pickupWidget->label (i);
- l.replace (QRegExp ("[^0-9]+"), "");
- int num = l.toInt ();
- if (num >= max) max = num + 1;
- }
- pickupWidget->addTab (ow, QString ("&%1 %2") .arg (max) .arg (ow->custName->text ()));
- ow->itemGroup->setFocus ();
- pickupWidget->showPage (ow);
+ OrderWidget *ow = new OrderWidget ();
+ ow->custNum->setText (from->num);
+ ow->custName->setText (from->name);
+ ow->custStreet->setText (from->street);
+ ow->custCity->setText (from->city);
+ ow->custPhone->setText (from->phone);
+ ow->custNotes->setText (from->notes);
+ int max = 1;
+ for (int i = 0; i < pickupWidget->count (); i++)
+ {
+ QString l = pickupWidget->label (i);
+ l.replace (QRegExp ("[^0-9]+"), "");
+ int num = l.toInt ();
+ if (num >= max) max = num + 1;
+ }
+ pickupWidget->addTab (ow, QString ("&%1 %2") .arg (max) .arg (ow->custName->text ()));
+ ow->itemGroup->setFocus ();
+ pickupWidget->showPage (ow);
}
void MainForm::createNewOrder ()
{
- PO_NewOrderWidget *ow = new PO_NewOrderWidget ();
- pickupWidget->addTab (ow, tr ("Ne&w Order"));
- pickupWidget->showPage (ow);
- ow->custNumEdit->setFocus ();
+ PO_NewOrderWidget *ow = new PO_NewOrderWidget ();
+ pickupWidget->addTab (ow, tr ("Ne&w Order"));
+ pickupWidget->showPage (ow);
+ ow->custNumEdit->setFocus ();
}
void MainForm::cancelOrder (OrderWidget *ow)
{
- if (pickupWidget->count () <= 1)
- pickupWidget->addTab (new PO_NewOrderWidget (), tr ("Ne&w Order"));
- pickupWidget->removePage (ow);
- delete ow;
+ qDebug("Cancel order from main window");
+ if (pickupWidget->count() <= 1) {
+ qDebug("Last order tab closing - spawning new");
+ pickupWidget->addTab(new PO_NewOrderWidget(), tr("Ne&w Order"));
+ }
+ qDebug("Removing current order tab");
+ pickupWidget->removePage(ow);
+ qDebug("Deleting widget");
+ delete ow;
+ qDebug("Deleted - now returning");
}
void MainForm::createPreparedOrder (QString)
{
- //TODO NewOrderWidget anhand der Telefonnummer ausfüllen
+ //TODO NewOrderWidget anhand der Telefonnummer ausfüllen
}
Modified: trunk/src/orderwidget.ui
===================================================================
--- trunk/src/orderwidget.ui 2010-03-21 21:31:19 UTC (rev 50)
+++ trunk/src/orderwidget.ui 2010-06-13 08:47:15 UTC (rev 51)
@@ -690,6 +690,9 @@
<slot>nextButton_clicked()</slot>
</connection>
</connections>
+<signals>
+ <signal>cancelOrder(OrderWidget*)</signal>
+</signals>
<tabstops>
<tabstop>itemCount</tabstop>
<tabstop>itemName</tabstop>
Modified: trunk/src/orderwidget.ui.h
===================================================================
--- trunk/src/orderwidget.ui.h 2010-03-21 21:31:19 UTC (rev 50)
+++ trunk/src/orderwidget.ui.h 2010-06-13 08:47:15 UTC (rev 51)
@@ -20,6 +20,7 @@
#include <QSettings>
#include <QDateTime>
+#include "templatereader.h"
#include "mainform.h"
void OrderWidget::init ()
@@ -45,6 +46,8 @@
orderDateTime->setDateTime (QDateTime::currentDateTime ()); // FS#24
orderDateTime->setAutoAdvance (true);
+
+ QObject::connect(this, SIGNAL(cancelOrder(OrderWidget*)), qApp->mainWidget(), SLOT(cancelOrder(OrderWidget*)), Qt::QueuedConnection);
}
void OrderWidget::lookupField (QString t)
@@ -639,8 +642,8 @@
void OrderWidget::cancelButton_clicked()
{
- MainForm *mw = (MainForm *) qApp->mainWidget ();
- mw->cancelOrder (this);
+ qDebug("Cancel button clicked");
+ emit cancelOrder(this);
}
void OrderWidget::nextButton_clicked()
@@ -650,207 +653,202 @@
/* load static template settings */
QSettings settings("kaishome.de", "PhoneOrder"); // FS#14
- settings.beginGroup ("Printing");
- QString companyName = settings.readEntry ("CompanyName", tr ("Example Company"));
- QString companyStreet = settings.readEntry ("CompanyStreet", tr ("Example Street 123"));
- QString companyCity = settings.readEntry ("CompanyCity", tr ("12345 Some Place"));
- QString companyPhone = settings.readEntry ("CompanyPhone", tr ("012 / 34 56 7"));
- QString companyFax = settings.readEntry ("CompanyFax", tr ("012 / 34 56 8"));
- QString companySlogan = settings.readEntry ("CompanySlogan", tr ("Have a nice meal. It's always a pleasure to serve you!"));
- QString advertSlogan = settings.readEntry ("AdvertSlogan");
- double marginSize = settings.readDoubleEntry ("PrintMargin", 0.75); // 3/4 cm margin
- double marginLeft = settings.readDoubleEntry ("PrintMarginLeft", marginSize); // FS#46
- double marginRight = settings.readDoubleEntry ("PrintMarginRight", marginSize);
- double marginTop = settings.readDoubleEntry ("PrintMarginTop", marginSize);
- double marginBottom = settings.readDoubleEntry ("PrintMarginBottom", marginSize);
- QString day = QDate::currentDate ().toString ("yyyyMMdd"); // FS#49
+ settings.beginGroup("Template");
+ QString companyName = settings.value("CompanyName", tr("Example Company")).toString();
+ QString companyStreet = settings.value("CompanyStreet", tr("Example Street 123")).toString();
+ QString companyCity = settings.value("CompanyCity", tr("12345 Some Place")).toString();
+ QString companyPhone = settings.value("CompanyPhone", tr("012 / 34 56 7")).toString();
+ QString companyFax = settings.value("CompanyFax", tr("012 / 34 56 8")).toString();
+ QString companySlogan = settings.value("CompanySlogan", tr("Have a nice meal. It's always a pleasure to serve you!")).toString();
+ QString advertSlogan = settings.value("AdvertSlogan").toString();
+ settings.endGroup();
+
+ settings.beginGroup("Printing");
+ double marginSize = settings.value("PrintMargin", 0.75).toDouble(); // 3/4 cm margin
+ double marginLeft = settings.value("PrintMarginLeft", marginSize).toDouble(); // FS#46
+ double marginRight = settings.value("PrintMarginRight", marginSize).toDouble();
+ double marginTop = settings.value("PrintMarginTop", marginSize).toDouble();
+ double marginBottom = settings.value("PrintMarginBottom", marginSize).toDouble();
+ int fontSize = settings.value("FontSize", 10).toInt();
+ settings.endGroup();
+
+ QString day = QDate::currentDate().toString("yyyyMMdd"); // FS#49
int number = 0;
- QSqlQuery query = QSqlQuery (QString ("SELECT MAX(number) FROM invoices WHERE day = '%1'") .arg (day));
- if (query.first ())
+ QSqlQuery query = QSqlQuery(QString("SELECT MAX(number) FROM invoices WHERE day = '%1'").arg(day));
+ if (query.first())
{
- qDebug ("QSqlQuery( \"%s\" )", query.executedQuery ().ascii ());
- number = query.value (0).toInt ();
+ qDebug("QSqlQuery( \"%s\" )", query.executedQuery().ascii());
+ number = query.value(0).toInt();
}
number += 1;
- query = QSqlQuery (QString ("REPLACE INTO invoices SET number = '%1', day = '%2'") .arg (number) .arg (day));
- if (query.isActive ())
- qDebug ("QSqlQuery( \"%s\" )", query.executedQuery ().ascii ());
+ query = QSqlQuery(QString("REPLACE INTO invoices SET number = '%1', day = '%2'").arg(number).arg(day));
+ if (query.isActive())
+ qDebug("QSqlQuery( \"%s\" )", query.executedQuery().ascii());
else
- qFatal ("QSqlQuery( \"%s\" )", query.executedQuery ().ascii ());
+ qFatal("QSqlQuery( \"%s\" )", query.executedQuery().ascii());
QString invoiceNumber;
- invoiceNumber.sprintf ("RN%8s-%04d", day.ascii (), number);
+ invoiceNumber.sprintf("RN%8s-%04d", day.ascii(), number);
- int fontSize = settings.readNumEntry ("FontSize", 10);
- settings.endGroup ();
-
- qDebug ("Printing");
- printer->setFullPage (TRUE);
+ qDebug("Printing");
+ printer->setFullPage(TRUE);
QPainter p;
- if (!p.begin (printer))
+ if (!p.begin(printer))
{
- qDebug ("Printing aborted");
+ qDebug("Printing aborted");
return;
}
- Q3PaintDeviceMetrics metrics (p.device ());
- int dpiy = metrics.logicalDpiY ();
- int dpix = metrics.logicalDpiX (); // FS#46
+ Q3PaintDeviceMetrics metrics(p.device());
+ int dpiy = metrics.logicalDpiY();
+ int dpix = metrics.logicalDpiX(); // FS#46
int tmargin = (int) ((marginTop / 2.54) * dpiy);
int bmargin = (int) ((marginBottom / 2.54) * dpiy);
int lmargin = (int) ((marginLeft / 2.54) * dpix);
int rmargin = (int) ((marginRight / 2.54) * dpix);
- QRect body (lmargin, tmargin, metrics.width () - (lmargin + rmargin), metrics.height () - (tmargin + bmargin));
- QString document = QString (
- "<table width='100%' cellpadding='0' cellspacing='0'>"
- "<tr><td colspan='3'><font size='-2'>Kd-Nr</font></td></tr>"
- "<tr>"
- "<td rowspan='2' valign='top'>"
- "<font size='+3'><%custnum%> <%name%></font><br>"
- "<nobr>"
- "<font size='+2'><%street%><br><%city%><br></font>"
- "Telefon: <%phone%>"
- "</nobr>"
- "<%notes%>"
- "</td>"
- "<td> </td>"
- "<td valign='top' align='right'>"
- "<table cellpadding='0' cellspacing='0'>"
- "<tr>"
- "<td>"
- "<nobr>"
- "<font size='+2'><%companyname%></font><br>"
- "<%companystreet%><br>"
- "<%companycity%><br>"
- "<font size='-1'>Telefon: <%companyphone%><br>Telefax: <%companyfax%></font>"
- "</nobr>"
- "</td>"
- "</tr>"
- "</table>"
- "</td>"
- "</tr>"
- "<tr>"
- "<td colspan='2' align='right' valign='bottom'>" // FS#29
- "<font size='+3'>Rechnung</font><br>"
- "<nobr><%invoicenumber%></nobr><br>" // FS#49
- "<nobr><b><%date%></b></nobr>"
- "</td>"
- "</tr>"
- "<tr><td colspan='3'><hr></td></tr>"
- "</table>"
- "<table width='100%' cellpadding='0' cellspacing='0'>");
+ QRect body(lmargin, tmargin, metrics.width() - (lmargin + rmargin), metrics.height() - (tmargin + bmargin));
- /* replace placeholders */
- document.replace ("<%custnum%>", Q3StyleSheet::escape (custNum->text ()));
- document.replace ("<%name%>", Q3StyleSheet::escape (custName->text ()));
- document.replace ("<%street%>", Q3StyleSheet::escape (custStreet->text ()));
- document.replace ("<%city%>", Q3StyleSheet::escape (custCity->text ()));
- document.replace ("<%phone%>", Q3StyleSheet::escape (custPhone->text ()));
- document.replace ("<%companyname%>", companyName);
- document.replace ("<%companystreet%>", companyStreet);
- document.replace ("<%companycity%>", companyCity);
- document.replace ("<%companyphone%>", companyPhone);
- document.replace ("<%companyfax%>", companyFax);
- document.replace ("<%invoicenumber%>", invoiceNumber); // FS#49
+ TemplatePlaceholders vars;
- if (custNotes->text ().isEmpty ())
- document.replace ("<%notes%>", QString::null);
- else
- document.replace ("<%notes%>", "<br><br><u>Anmerkungen:</u><br>" + Q3StyleSheet::convertFromPlainText (custNotes->text ()).stripWhiteSpace ());
- if (orderDateTime->dateTime () > QDateTime::currentDateTime ())
- document.replace ("<%date%>", orderDateTime->dateTime ().toString ("<big><b>ddd, d. MMM. yyyy h:mm</b></big>")); // FS#29
- else
- document.replace ("<%date%>", orderDateTime->dateTime ().toString ("ddd, d. MMM. yyyy h:mm")); // FS#24
+ vars["custnum"] = Q3StyleSheet::escape(custNum->text());
+ vars["name"] = Q3StyleSheet::escape(custName->text());
+ vars["street"] = Q3StyleSheet::escape(custStreet->text());
+ vars["city"] = Q3StyleSheet::escape(custCity->text());
+ vars["phone"] = Q3StyleSheet::escape(custPhone->text());
+ vars["companyname"] = companyName;
+ vars["companystreet"] = companyStreet;
+ vars["companycity"] = companyCity;
+ vars["companyphone"] = companyPhone;
+ vars["companyfax"] = companyFax;
+ vars["invoicenumber"] = invoiceNumber; // FS#49
+ vars["notes"] = custNotes->text().trimmed().isEmpty()
+ ? QString::null
+ : Q3StyleSheet::convertFromPlainText(custNotes->text()).trimmed().prepend("<br><br><u>Anmerkungen:</u><br>");
+
+ vars["date"] = orderDateTime->dateTime() > QDateTime::currentDateTime()
+ ? orderDateTime->dateTime().toString("<big><b>ddd, d. MMM. yyyy h:mm</b></big>") // FS#29
+ : orderDateTime->dateTime().toString("ddd, d. MMM. yyyy h:mm"); // FS#24
+
+ TemplateReader documentHeader("DocumentHeader.html", this);
+ TemplateReader reportHeader("ReportHeader.html", this);
+ TemplateReader groupHeader("GroupHeader.html", this);
+ TemplateReader itemLine("ItemLine.html", this);
+ TemplateReader ingredientLine("IngredientLine.html", this);
+ TemplateReader reportFooter("ReportFooter.html", this);
+ TemplateReader advertBox("AdvertBox.html", this);
+ TemplateReader sloganBox("SloganBox.html", this);
+
+ QString document(documentHeader.getContents(&vars));
+ document += reportHeader.getContents(&vars);
+
Q3ListViewItemIterator it = Q3ListViewItemIterator (orderList);
double sum = 0.0;
int prevGroupId = -1;
- while (it.current ())
+ while (it.current())
{
- Q3ListViewItem *i = it.current ();
+ Q3ListViewItem *i = it.current();
- double price = i->text (3).replace (QChar (','), QChar ('.')).toDouble (); // FS#6
- if (i->text (4).isNull ()) // is ingredient
+ double price = i->text(3).replace(QChar(','), QChar('.')).toDouble(); // FS#6
+ if (i->text(4).isNull()) // is ingredient
{
double price1 = 0.0;
- QSqlQuery query (QString ("SELECT price FROM ingprices WHERE ipid = '%1'") .arg (i->text (5)));
- if (query.isActive ())
+ QSqlQuery query(QString("SELECT price FROM ingprices WHERE ipid = '%1'").arg(i->text(5)));
+ if (query.isActive())
{
- if (query.first ())
+ if (query.first())
{
- qDebug ("QSqlQuery( \"%s\" )", query.executedQuery ().ascii ());
- price1 = query.value (0).toDouble ();
+ qDebug("QSqlQuery( \"%s\" )", query.executedQuery().ascii());
+ price1 = query.value(0).toDouble();
}
}
else
- qDebug ("%s", query.lastError ().text ().ascii ());
- document += QString ("<tr>"
- "<td> </td>"
- "<td valign='top'>%1 %2</td>"
- "<td valign='top' align='right'>%L3</td>"
- "<td valign='top' align='right'><b>%L4</b></td>"
- "</tr>") .arg (i->text (1)) .arg (i->text (2));
+ qDebug("%s", query.lastError().text().ascii());
+
+ vars["itemType"] = i->text(1);
+ vars["itemName"] = i->text(2);
if (price != 0.0)
- document = document .arg (price1, 0, 'f', 2) .arg (price, 0, 'f', 2);
+ {
+ vars["itemPrice"] = QString("%L1").arg(price1, 0, 'f', 2);
+ vars["linePrice"] = QString("%L1").arg(price, 0, 'f', 2);
+ }
else
- document = document .arg (price1, 0, 'f', 2) .arg (" ");
+ {
+ vars["itemPrice"] = QString("%L1").arg(price1, 0, 'f', 2);
+ vars["linePrice"] = QString(" ");
+ }
+ document += ingredientLine.getContents(&vars);
}
else // is item
{
- QSqlQuery query (QString ("SELECT dp.groupid, `group`, dish, price FROM dishprices dp "
- "LEFT JOIN groups USING (groupid) LEFT JOIN dishes d ON (d.dishid = dp.dishid) "
- "WHERE dpid = '%1'") .arg (i->text (4)));
- if (query.isActive ())
+ QSqlQuery query(QString("SELECT dp.groupid, `group`, dish, price FROM dishprices dp "
+ "LEFT JOIN groups USING (groupid) LEFT JOIN dishes d ON (d.dishid = dp.dishid) "
+ "WHERE dpid = '%1'").arg(i->text(4)));
+ if (query.isActive())
{
- if (query.first ())
+ if (query.first())
{
- qDebug ("QSqlQuery( \"%s\" )", query.executedQuery ().ascii ());
- int groupId = query.value (0).toInt ();
+ qDebug("QSqlQuery( \"%s\" )", query.executedQuery().ascii());
+ int groupId = query.value(0).toInt();
if (prevGroupId != groupId)
{
prevGroupId = groupId;
- document += QString ("<tr><td colspan='4'><font size='+1'><u><i>%1</i></u></font></td></tr>") .arg (query.value (1).toString ());
+ vars["groupName"] = query.value(1).toString();
+ document += groupHeader.getContents(&vars);
}
}
- document += QString ("<tr>"
- "<td valign='top' align='right'>%1 </td>"
- "<td valign='top'>%2 %3</td>"
- "<td valign='top' align='right'>%L4</td>"
- "<td valign='top' align='right'><b>%L5</b></td>"
- "</tr>") .arg (i->text (0)) .arg (i->text (1)) .arg (query.value (2).toString ()) .arg (query.value (3).toDouble (), 0, 'f', 2) .arg (price, 0, 'f', 2);
+
+ vars["itemCount"] = i->text(0);
+ vars["itemNumber"] = i->text(1);
+ vars["itemName"] = query.value(2).toString();
+ vars["itemPrice"] = QString("%L1").arg(query.value(3).toDouble(), 0, 'f', 2);
+ vars["linePrice"] = QString("%L1").arg(price, 0, 'f', 2);
+
+ document += itemLine.getContents(&vars);
}
else
- qDebug ("%s", query.lastError ().text ().ascii ());
+ qDebug("%s", query.lastError().text().ascii());
}
sum += price;
it++;
}
- document += QString (
- "<tr><td colspan='4'><hr></td></tr>"
- "<tr><td colspan='2'>Inkl. gesetzliche MwSt. 7%</td><td align='right'>%L1</td><td rowspan='2' align='right' valign='top'><font size='+2'> <b><u>%L2</u></b></font></td></tr>"
- "<tr><td colspan='3'><b>Zu zahlende Summe in €</b></td></tr>"
- "</table>") .arg (sum * 0.07 / 1.07, 0, 'f', 2) .arg (sum, 0, 'f', 2); // FS#39
+ vars["taxTotal"] = QString("%L1").arg(sum * 0.07 / 1.07, 0, 'f', 2);
+ vars["linesTotal"] = QString("%L1").arg(sum, 0, 'f', 2); // FS#39
+ document += reportFooter.getContents(&vars);
- if (!advertSlogan.isEmpty ())
- document += QString ("<center><i><font size='+2'>%1</font></i></center><br />") .arg (advertSlogan);
+ if (!advertSlogan.isEmpty())
+ {
+ vars["advertSlogan"] = advertSlogan;
+ document += advertBox.getContents(&vars);
+ }
- document += QString ("<center><i><font size='+1'>%1</font></i></center>") .arg (companySlogan);
+ vars["companySlogan"] = companySlogan;
+ document += sloganBox.getContents(&vars);
- Q3SimpleRichText richText (QString ("<qt>%1</qt>") .arg (document), QFont ("Arial", fontSize));
- richText.setWidth (&p, body.width ());
- QRect view (body);
+ Q3SimpleRichText richText(QString("<qt>%1</qt>").arg(document), QFont("Arial", fontSize));
+ richText.setWidth(&p, body.width());
+
+ QRect view(body);
int page = 1;
do {
// draw text
- richText.draw (&p, body.left (), body.top (), view, colorGroup ());
- view.moveBy (0, body.height ()); // FS#15
- p.translate (0, -body.height ());
+ richText.draw(&p, body.left(), body.top(), view, colorGroup());
+ view.moveBy(0, body.height()); // FS#15
+ p.translate(0, -body.height());
+
// insert page number
- p.drawText (view.right () - p.fontMetrics ().width (QString::number (page)), view.bottom () + p.fontMetrics ().ascent () + 5, QString::number (page));
+ p.drawText(view.right() - p.fontMetrics().width(QString::number(page)),
+ view.bottom() + p.fontMetrics().ascent() + 5,
+ QString::number(page));
+
+ // exit loop on last page
if (view.top () >= richText.height ()) break;
- printer->newPage ();
+
+ printer->newPage();
page++;
} while (TRUE);
- cancelButton_clicked ();
+
+ qDebug("Closing form");
+ this->cancelButton_clicked();
}
Modified: trunk/src/src.pro
===================================================================
--- trunk/src/src.pro 2010-03-21 21:31:19 UTC (rev 50)
+++ trunk/src/src.pro 2010-06-13 08:47:15 UTC (rev 51)
@@ -1,41 +1,54 @@
-# Diese Datei wurde mit dem qmake-Manager von KDevelop erstellt.
-# -------------------------------------------
+# Diese Datei wurde mit dem qmake-Manager von KDevelop erstellt.
+# -------------------------------------------
# Unterordner relativ zum Projektordner: ./src
# Das Target ist eine Anwendung: ../bin/phoneorder
+LANGUAGE = C++
+DBFILE = src.db
+TARGET = ../bin/phoneorder
+CONFIG += debug \
+ warn_on \
+ qt \
+ thread
+TEMPLATE = app
-LANGUAGE = C++
-DBFILE = src.db
-TARGET = ../bin/phoneorder
-CONFIG += debug \
- warn_on \
- qt \
- thread
-TEMPLATE = app
-#The following line was changed from FORMS to FORMS3 by qt3to4
+# The following line was changed from FORMS to FORMS3 by qt3to4
FORMS3 += mainform.ui \
- orderwidget.ui \
- customereditor.ui \
- entrydialog.ui \
- po_priceseditorbase.ui \
- po_locationseditorbase.ui
+ orderwidget.ui \
+ customereditor.ui \
+ entrydialog.ui \
+ po_priceseditorbase.ui \
+ po_locationseditorbase.ui
HEADERS += mainform.ui.h \
- widgets/historylineedit.h \
- orderwidget.ui.h \
- po_customer.h \
- po_neworderwidget.h \
- customereditor.ui.h \
- po_fullcustomereditor.h \
- po_priceseditor.h \
- po_locationseditor.h
+ widgets/historylineedit.h \
+ orderwidget.ui.h \
+ po_customer.h \
+ po_neworderwidget.h \
+ customereditor.ui.h \
+ po_fullcustomereditor.h \
+ po_priceseditor.h \
+ po_locationseditor.h \
+ templatereader.h
SOURCES += main.cpp \
- widgets/historylineedit.cpp \
- po_customer.cpp \
- po_neworderwidget.cpp \
- po_fullcustomereditor.cpp \
- po_priceseditor.cpp \
- po_locationseditor.cpp
-#The following line was inserted by qt3to4
-QT += sql qt3support
-#The following line was inserted by qt3to4
+ widgets/historylineedit.cpp \
+ po_customer.cpp \
+ po_neworderwidget.cpp \
+ po_fullcustomereditor.cpp \
+ po_priceseditor.cpp \
+ po_locationseditor.cpp \
+ templatereader.cpp
+
+# The following line was inserted by qt3to4
+QT += sql \
+ qt3support
+
+# The following line was inserted by qt3to4
CONFIG += uic3
-
+FORMS +=
+OTHER_FILES += ../templates/DocumentHeader.html \
+ ../templates/ReportHeader.html \
+ ../templates/IngredientLine.html \
+ ../templates/GroupHeader.html \
+ ../templates/ItemLine.html \
+ ../templates/ReportFooter.html \
+ ../templates/AdvertBox.html \
+ ../templates/SloganBox.html
Added: trunk/src/templatereader.cpp
===================================================================
--- trunk/src/templatereader.cpp (rev 0)
+++ trunk/src/templatereader.cpp 2010-06-13 08:47:15 UTC (rev 51)
@@ -0,0 +1,38 @@
+#include "templatereader.h"
+#include <QDir>
+#include <QTextStream>
+#include <QRegExp>
+
+TemplateReader::TemplateReader(const QString &name, QObject *parent)
+ : QFile(parent), cachedSource()
+{
+ QString path = QString("%1/.phoneorder/templates/%2").arg(QDir::homePath()).arg(name);
+ this->setFileName(path);
+}
+
+QString TemplateReader::getContents(const TemplatePlaceholders *placeholders)
+{
+ if (cachedSource.isNull())
+ {
+ if (!this->exists())
+ qFatal("phoneorder: cannot find template '%s'", qPrintable(this->fileName()));
+
+ if (!this->open(QIODevice::ReadOnly | QIODevice::Text))
+ qFatal("phoneorder: cannot read template '%s'", qPrintable(this->fileName()));
+
+ QTextStream html(this);
+ cachedSource = html.readAll();
+
+ this->close();
+ }
+
+ QString out = cachedSource;
+
+ foreach (QString key, placeholders->keys())
+ {
+ QRegExp subject(QString("<%=?\\s*").append(QRegExp::escape(key)).append("\\s*%>"));
+ out = out.replace(subject, placeholders->value(key));
+ }
+
+ return out;
+}
Added: trunk/src/templatereader.h
===================================================================
--- trunk/src/templatereader.h (rev 0)
+++ trunk/src/templatereader.h 2010-06-13 08:47:15 UTC (rev 51)
@@ -0,0 +1,20 @@
+#ifndef TEMPLATEREADER_H
+#define TEMPLATEREADER_H
+
+#include <QFile>
+#include <QHash>
+
+typedef QHash<QString,QString> TemplatePlaceholders;
+
+class TemplateReader : public QFile {
+
+private:
+ QString cachedSource;
+
+public:
+ TemplateReader(const QString &name, QObject *parent);
+ QString getContents(const TemplatePlaceholders *placeholders);
+
+};
+
+#endif // TEMPLATEREADER_H
Modified: trunk/src/widgets/historylineedit.cpp
===================================================================
--- trunk/src/widgets/historylineedit.cpp 2010-03-21 21:31:19 UTC (rev 50)
+++ trunk/src/widgets/historylineedit.cpp 2010-06-13 08:47:15 UTC (rev 51)
@@ -4,32 +4,32 @@
#include <QKeyEvent>
HistoryLineEdit::HistoryLineEdit (QWidget *parent, const char *name)
- : QLineEdit (parent, name)
+ : QLineEdit (parent, name)
{
}
void
HistoryLineEdit::focusInEvent (QFocusEvent* e)
{
- QLineEdit::focusInEvent (e);
- if (e->gotFocus ()) emit gotFocus ();
+ QLineEdit::focusInEvent (e);
+ if (e->gotFocus ()) emit gotFocus ();
}
void
HistoryLineEdit::keyPressEvent (QKeyEvent* e)
{
- switch (e->key ())
- {
- case Qt::Key_Up:
- qDebug ("HistoryLineEdit::keyPressEvent( Qt::Key_Up )");
- emit upArrowPressed ();
- break;
- case Qt::Key_Down:
- qDebug ("HistoryLineEdit::keyPressEvent( Qt::Key_Down )");
- emit downArrowPressed ();
- break;
- default:
- QLineEdit::keyPressEvent (e);
- break;
- }
+ switch (e->key ())
+ {
+ case Qt::Key_Up:
+ qDebug ("HistoryLineEdit::keyPressEvent( Qt::Key_Up )");
+ emit upArrowPressed ();
+ break;
+ case Qt::Key_Down:
+ qDebug ("HistoryLineEdit::keyPressEvent( Qt::Key_Down )");
+ emit downArrowPressed ();
+ break;
+ default:
+ QLineEdit::keyPressEvent (e);
+ break;
+ }
}
Added: trunk/templates/AdvertBox.html
===================================================================
--- trunk/templates/AdvertBox.html (rev 0)
+++ trunk/templates/AdvertBox.html 2010-06-13 08:47:15 UTC (rev 51)
@@ -0,0 +1 @@
+<center><i><font size="+2"><%=advertSlogan%></font></i></center><br/>
Added: trunk/templates/DocumentHeader.html
===================================================================
--- trunk/templates/DocumentHeader.html (rev 0)
+++ trunk/templates/DocumentHeader.html 2010-06-13 08:47:15 UTC (rev 51)
@@ -0,0 +1,39 @@
+<table width="100%" cellpadding="0" cellspacing="0">
+ <tr><td colspan="3"><font size="-2">Kd-Nr</font></td></tr>
+ <tr>
+ <td rowspan="2" valign="top">
+ <font size="+3"><%custnum%> <%name%></font><br>
+ <nobr>
+ <font size="+2"><%street%><br><%city%><br></font>
+ Telefon: <%phone%>
+ </nobr>
+ <%notes%>
+ </td>
+ <td> </td>
+ <td valign="top" align="right">
+ <table cellpadding="0" cellspacing="0">
+ <tr>
+ <td>
+ <nobr>
+ <font size="+2"><%companyname%></font><br>
+ <%companystreet%><br>
+ <%companycity%><br>
+ <font size="-1">
+ Telefon: <%companyphone%><br>
+ Telefax: <%companyfax%>
+ </font>
+ </nobr>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" align="right" valign="bottom">
+ <font size='+3'>Rechnung</font><br>
+ <nobr><%invoicenumber%></nobr><br>
+ <nobr><b><%date%></b></nobr>
+ </td>
+ </tr>
+ <tr><td colspan='3'><hr></td></tr>
+</table>
Added: trunk/templates/GroupHeader.html
===================================================================
--- trunk/templates/GroupHeader.html (rev 0)
+++ trunk/templates/GroupHeader.html 2010-06-13 08:47:15 UTC (rev 51)
@@ -0,0 +1,3 @@
+<tr>
+ <td colspan="4"><font size="+1"><u><i><%groupName%></i></u></font></td>
+</tr>
Added: trunk/templates/IngredientLine.html
===================================================================
--- trunk/templates/IngredientLine.html (rev 0)
+++ trunk/templates/IngredientLine.html 2010-06-13 08:47:15 UTC (rev 51)
@@ -0,0 +1,6 @@
+<tr>
+ <td> </td>
+ <td valign="top"><%itemCount%> <%itemName%></td>
+ <td valign="top" align="right"><%itemPrice%></td>
+ <td valign="top" align="right"><b><%linePrice%></b></td>
+</tr>
Added: trunk/templates/ItemLine.html
===================================================================
--- trunk/templates/ItemLine.html (rev 0)
+++ trunk/templates/ItemLine.html 2010-06-13 08:47:15 UTC (rev 51)
@@ -0,0 +1,6 @@
+<tr>
+ <td valign="top" align="right"><%itemCount%> </td>
+ <td valign="top"><%itemNumber%> <%itemName%></td>
+ <td valign="top" align="right"><%itemPrice%></td>
+ <td valign="top" align="right"><b><%linePrice%></b></td>
+</tr>
Added: trunk/templates/ReportFooter.html
===================================================================
--- trunk/templates/ReportFooter.html (rev 0)
+++ trunk/templates/ReportFooter.html 2010-06-13 08:47:15 UTC (rev 51)
@@ -0,0 +1,12 @@
+ <tr>
+ <td colspan="4"><hr></td>
+ </tr>
+ <tr>
+ <td colspan="2">Inkl. gesetzliche MwSt. 7%</td>
+ <td align="right"><%taxTotal%></td>
+ <td rowspan="2" align="right" valign="top"><font size="+2"> <b><u><%linesTotal%></u></b></font></td>
+ </tr>
+ <tr>
+ <td colspan="3"><b>Zu zahlende Summe in €</b></td>
+ </tr>
+</table>
Added: trunk/templates/ReportHeader.html
===================================================================
--- trunk/templates/ReportHeader.html (rev 0)
+++ trunk/templates/ReportHeader.html 2010-06-13 08:47:15 UTC (rev 51)
@@ -0,0 +1 @@
+<table width='100%' cellpadding='0' cellspacing='0'>
Added: trunk/templates/SloganBox.html
===================================================================
--- trunk/templates/SloganBox.html (rev 0)
+++ trunk/templates/SloganBox.html 2010-06-13 08:47:15 UTC (rev 51)
@@ -0,0 +1 @@
+<center><i><font size="+1"><%=companySlogan%></font></i></center>
Deleted: trunk/templates/cpp
===================================================================
--- trunk/templates/cpp 2010-03-21 21:31:19 UTC (rev 50)
+++ trunk/templates/cpp 2010-06-13 08:47:15 UTC (rev 51)
@@ -1,19 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2004 by Kai Krakow *
- * ka...@ka... *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
Deleted: trunk/templates/h
===================================================================
--- trunk/templates/h 2010-03-21 21:31:19 UTC (rev 50)
+++ trunk/templates/h 2010-06-13 08:47:15 UTC (rev 51)
@@ -1,19 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2004 by Kai Krakow *
- * ka...@ka... *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|