Replace std::cout and std::cerr with qDebug and qWarning.

This commit is contained in:
Jim Evins
2014-09-26 21:44:33 -04:00
parent 3d9875545c
commit f402599b8a
9 changed files with 162 additions and 179 deletions
+4 -5
View File
@@ -26,8 +26,7 @@
#include "XmlLabel.h" #include "XmlLabel.h"
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QDebug>
#include <iostream>
namespace glabels namespace glabels
{ {
@@ -92,7 +91,7 @@ namespace glabels
} }
else else
{ {
std::cout << "ACTION: file->Save: " << window->model()->filename().toStdString() << std::endl; qDebug() << "ACTION: file->Save: " << window->model()->filename();
return true; return true;
} }
} }
@@ -111,7 +110,7 @@ namespace glabels
); );
if ( !fileName.isEmpty() ) if ( !fileName.isEmpty() )
{ {
std::cout << "ACTION: file->SaveAs: " << fileName.toStdString() << std::endl; qDebug() << "ACTION: file->SaveAs: " << fileName;
return true; return true;
} }
@@ -124,7 +123,7 @@ namespace glabels
/// ///
void File::print( MainWindow *window ) void File::print( MainWindow *window )
{ {
std::cout << "ACTION: file->print" << std::endl; qDebug() << "ACTION: file->print";
} }
+37 -35
View File
@@ -29,7 +29,7 @@
#include <QMenu> #include <QMenu>
#include <QToolBar> #include <QToolBar>
#include <QLabel> #include <QLabel>
#include <iostream> #include <QDebug>
#include "libglabels/Db.h" #include "libglabels/Db.h"
#include "View.h" #include "View.h"
@@ -97,6 +97,8 @@ namespace glabels
{ {
mModel = label; mModel = label;
mView->setModel( mModel ); mView->setModel( mModel );
setDocVerbsEnabled( true );
} }
@@ -122,7 +124,7 @@ namespace glabels
/// ///
void MainWindow::closeEvent( QCloseEvent *event ) void MainWindow::closeEvent( QCloseEvent *event )
{ {
std::cout << "CLOSE EVENT" << std::endl; qDebug() << "CLOSE EVENT";
writeSettings(); writeSettings();
event->accept(); event->accept();
} }
@@ -780,7 +782,7 @@ namespace glabels
/// ///
void MainWindow::fileProperties() void MainWindow::fileProperties()
{ {
std::cout << "ACTION: file->Properties" << std::endl; qDebug() << "ACTION: file->Properties";
} }
@@ -789,7 +791,7 @@ namespace glabels
/// ///
void MainWindow::fileTemplateDesigner() void MainWindow::fileTemplateDesigner()
{ {
std::cout << "ACTION: file->Template Designer" << std::endl; qDebug() << "ACTION: file->Template Designer";
} }
@@ -816,7 +818,7 @@ namespace glabels
/// ///
void MainWindow::editUndo() void MainWindow::editUndo()
{ {
std::cout << "ACTION: edit->Undo" << std::endl; qDebug() << "ACTION: edit->Undo";
} }
@@ -825,7 +827,7 @@ namespace glabels
/// ///
void MainWindow::editRedo() void MainWindow::editRedo()
{ {
std::cout << "ACTION: edit->Redo" << std::endl; qDebug() << "ACTION: edit->Redo";
} }
@@ -834,7 +836,7 @@ namespace glabels
/// ///
void MainWindow::editCut() void MainWindow::editCut()
{ {
std::cout << "ACTION: edit->Cut" << std::endl; qDebug() << "ACTION: edit->Cut";
} }
@@ -843,7 +845,7 @@ namespace glabels
/// ///
void MainWindow::editCopy() void MainWindow::editCopy()
{ {
std::cout << "ACTION: edit->Copy" << std::endl; qDebug() << "ACTION: edit->Copy";
} }
@@ -852,7 +854,7 @@ namespace glabels
/// ///
void MainWindow::editPaste() void MainWindow::editPaste()
{ {
std::cout << "ACTION: edit->Paste" << std::endl; qDebug() << "ACTION: edit->Paste";
} }
@@ -861,7 +863,7 @@ namespace glabels
/// ///
void MainWindow::editDelete() void MainWindow::editDelete()
{ {
std::cout << "ACTION: edit->Delete" << std::endl; qDebug() << "ACTION: edit->Delete";
} }
@@ -870,7 +872,7 @@ namespace glabels
/// ///
void MainWindow::editSelectAll() void MainWindow::editSelectAll()
{ {
std::cout << "ACTION: edit->Select All" << std::endl; qDebug() << "ACTION: edit->Select All";
} }
@@ -879,7 +881,7 @@ namespace glabels
/// ///
void MainWindow::editUnSelectAll() void MainWindow::editUnSelectAll()
{ {
std::cout << "ACTION: edit->Un-select All" << std::endl; qDebug() << "ACTION: edit->Un-select All";
} }
@@ -888,7 +890,7 @@ namespace glabels
/// ///
void MainWindow::editPreferences() void MainWindow::editPreferences()
{ {
std::cout << "ACTION: edit->Preferences" << std::endl; qDebug() << "ACTION: edit->Preferences";
} }
@@ -987,7 +989,7 @@ namespace glabels
/// ///
void MainWindow::objectsArrowMode() void MainWindow::objectsArrowMode()
{ {
std::cout << "ACTION: objects->Select Mode" << std::endl; qDebug() << "ACTION: objects->Select Mode";
} }
@@ -996,7 +998,7 @@ namespace glabels
/// ///
void MainWindow::objectsCreateText() void MainWindow::objectsCreateText()
{ {
std::cout << "ACTION: objects->Create->Text" << std::endl; qDebug() << "ACTION: objects->Create->Text";
} }
@@ -1005,7 +1007,7 @@ namespace glabels
/// ///
void MainWindow::objectsCreateBox() void MainWindow::objectsCreateBox()
{ {
std::cout << "ACTION: objects->Create->Box" << std::endl; qDebug() << "ACTION: objects->Create->Box";
} }
@@ -1014,7 +1016,7 @@ namespace glabels
/// ///
void MainWindow::objectsCreateLine() void MainWindow::objectsCreateLine()
{ {
std::cout << "ACTION: objects->Create->Line" << std::endl; qDebug() << "ACTION: objects->Create->Line";
} }
@@ -1023,7 +1025,7 @@ namespace glabels
/// ///
void MainWindow::objectsCreateEllipse() void MainWindow::objectsCreateEllipse()
{ {
std::cout << "ACTION: objects->Create->Ellipse" << std::endl; qDebug() << "ACTION: objects->Create->Ellipse";
} }
@@ -1032,7 +1034,7 @@ namespace glabels
/// ///
void MainWindow::objectsCreateImage() void MainWindow::objectsCreateImage()
{ {
std::cout << "ACTION: objects->Create->Image" << std::endl; qDebug() << "ACTION: objects->Create->Image";
} }
@@ -1041,7 +1043,7 @@ namespace glabels
/// ///
void MainWindow::objectsCreateBarcode() void MainWindow::objectsCreateBarcode()
{ {
std::cout << "ACTION: objects->Create->Barcode" << std::endl; qDebug() << "ACTION: objects->Create->Barcode";
} }
@@ -1050,7 +1052,7 @@ namespace glabels
/// ///
void MainWindow::objectsOrderRaise() void MainWindow::objectsOrderRaise()
{ {
std::cout << "ACTION: objects->Order->Bring to front" << std::endl; qDebug() << "ACTION: objects->Order->Bring to front";
} }
@@ -1059,7 +1061,7 @@ namespace glabels
/// ///
void MainWindow::objectsOrderLower() void MainWindow::objectsOrderLower()
{ {
std::cout << "ACTION: objects->Order->Send to back" << std::endl; qDebug() << "ACTION: objects->Order->Send to back";
} }
@@ -1068,7 +1070,7 @@ namespace glabels
/// ///
void MainWindow::objectsXformRotateLeft() void MainWindow::objectsXformRotateLeft()
{ {
std::cout << "ACTION: objects->Rotate/Flip->Rotate Left" << std::endl; qDebug() << "ACTION: objects->Rotate/Flip->Rotate Left";
} }
@@ -1077,7 +1079,7 @@ namespace glabels
/// ///
void MainWindow::objectsXformRotateRight() void MainWindow::objectsXformRotateRight()
{ {
std::cout << "ACTION: objects->Rotate/Flip->Rotate Right" << std::endl; qDebug() << "ACTION: objects->Rotate/Flip->Rotate Right";
} }
@@ -1086,7 +1088,7 @@ namespace glabels
/// ///
void MainWindow::objectsXformFlipHoriz() void MainWindow::objectsXformFlipHoriz()
{ {
std::cout << "ACTION: objects->Rotate/Flip->Flip Horizontally" << std::endl; qDebug() << "ACTION: objects->Rotate/Flip->Flip Horizontally";
} }
@@ -1095,7 +1097,7 @@ namespace glabels
/// ///
void MainWindow::objectsXformFlipVert() void MainWindow::objectsXformFlipVert()
{ {
std::cout << "ACTION: objects->Rotate/Flip->Flip Vertically" << std::endl; qDebug() << "ACTION: objects->Rotate/Flip->Flip Vertically";
} }
@@ -1104,7 +1106,7 @@ namespace glabels
/// ///
void MainWindow::objectsAlignLeft() void MainWindow::objectsAlignLeft()
{ {
std::cout << "ACTION: objects->Align->Left" << std::endl; qDebug() << "ACTION: objects->Align->Left";
} }
@@ -1113,7 +1115,7 @@ namespace glabels
/// ///
void MainWindow::objectsAlignHCenter() void MainWindow::objectsAlignHCenter()
{ {
std::cout << "ACTION: objects->Align->Center Horizontally" << std::endl; qDebug() << "ACTION: objects->Align->Center Horizontally";
} }
@@ -1122,7 +1124,7 @@ namespace glabels
/// ///
void MainWindow::objectsAlignRight() void MainWindow::objectsAlignRight()
{ {
std::cout << "ACTION: objects->Align->Right" << std::endl; qDebug() << "ACTION: objects->Align->Right";
} }
@@ -1131,7 +1133,7 @@ namespace glabels
/// ///
void MainWindow::objectsAlignTop() void MainWindow::objectsAlignTop()
{ {
std::cout << "ACTION: objects->Align->Top" << std::endl; qDebug() << "ACTION: objects->Align->Top";
} }
@@ -1140,7 +1142,7 @@ namespace glabels
/// ///
void MainWindow::objectsAlignVCenter() void MainWindow::objectsAlignVCenter()
{ {
std::cout << "ACTION: objects->Align->Center Vertically" << std::endl; qDebug() << "ACTION: objects->Align->Center Vertically";
} }
@@ -1149,7 +1151,7 @@ namespace glabels
/// ///
void MainWindow::objectsAlignBottom() void MainWindow::objectsAlignBottom()
{ {
std::cout << "ACTION: objects->Align->Bottom" << std::endl; qDebug() << "ACTION: objects->Align->Bottom";
} }
@@ -1158,7 +1160,7 @@ namespace glabels
/// ///
void MainWindow::objectsCenterHoriz() void MainWindow::objectsCenterHoriz()
{ {
std::cout << "ACTION: objects->Center->Horizontally" << std::endl; qDebug() << "ACTION: objects->Center->Horizontally";
} }
@@ -1167,7 +1169,7 @@ namespace glabels
/// ///
void MainWindow::objectsCenterVert() void MainWindow::objectsCenterVert()
{ {
std::cout << "ACTION: objects->Center->Vertically" << std::endl; qDebug() << "ACTION: objects->Center->Vertically";
} }
@@ -1176,7 +1178,7 @@ namespace glabels
/// ///
void MainWindow::objectsMergeProperties() void MainWindow::objectsMergeProperties()
{ {
std::cout << "ACTION: objects->Merge Properties..." << std::endl; qDebug() << "ACTION: objects->Merge Properties...";
} }
+49 -53
View File
@@ -21,7 +21,7 @@
#include "Db.h" #include "Db.h"
#include <QApplication> #include <QApplication>
#include <iostream> #include <QtDebug>
#include "Config.h" #include "Config.h"
#include "StrUtil.h" #include "StrUtil.h"
@@ -77,7 +77,7 @@ namespace libglabels
} }
else else
{ {
qDebug( "Duplicate paper ID: \"%s\".", qPrintable(paper->id()) ); qWarning() << "Duplicate paper ID: " << paper->id();
} }
} }
@@ -86,7 +86,7 @@ namespace libglabels
{ {
if ( name.isNull() || name.isEmpty() ) if ( name.isNull() || name.isEmpty() )
{ {
qDebug( "NULL paper name." ); qWarning() << "NULL paper name.";
return mPapers.first(); return mPapers.first();
} }
@@ -98,7 +98,7 @@ namespace libglabels
} }
} }
qDebug( "Unknown paper name: \"%s\".", qPrintable(name) ); qWarning() << "Unknown paper name: " << name;
return NULL; return NULL;
} }
@@ -107,7 +107,7 @@ namespace libglabels
{ {
if ( id.isNull() || id.isEmpty() ) if ( id.isNull() || id.isEmpty() )
{ {
qDebug( "NULL paper ID." ); qWarning() << "NULL paper ID.";
return mPapers.first(); return mPapers.first();
} }
@@ -119,7 +119,7 @@ namespace libglabels
} }
} }
qDebug( "Unknown paper ID: \"%s\".", qPrintable(id) ); qWarning() << "Unknown paper ID: " << id;
return NULL; return NULL;
} }
@@ -135,7 +135,7 @@ namespace libglabels
} }
} }
qDebug( "Unknown paper name: \"%s\".", qPrintable(name) ); qWarning() << "Unknown paper name: " << name;
return mEmpty; return mEmpty;
} }
@@ -156,7 +156,7 @@ namespace libglabels
} }
} }
qDebug( "Unknown paper id: \"%s\".", qPrintable(id) ); qWarning() << "Unknown paper id: " << id;
return mEmpty; return mEmpty;
} }
@@ -191,7 +191,7 @@ namespace libglabels
} }
else else
{ {
qDebug( "Duplicate category ID: \"%s\".", qPrintable(category->id()) ); qWarning() << "Duplicate category ID: " << category->id();
} }
} }
@@ -200,7 +200,7 @@ namespace libglabels
{ {
if ( name.isNull() || name.isEmpty() ) if ( name.isNull() || name.isEmpty() )
{ {
qDebug( "NULL category name." ); qWarning() << "NULL category name.";
return mCategories.first(); return mCategories.first();
} }
@@ -212,7 +212,7 @@ namespace libglabels
} }
} }
qDebug( "Unknown category name: \"%s\".", qPrintable(name) ); qWarning() << "Unknown category name: \"%s\"." << name;
return NULL; return NULL;
} }
@@ -221,7 +221,7 @@ namespace libglabels
{ {
if ( id.isNull() || id.isEmpty() ) if ( id.isNull() || id.isEmpty() )
{ {
qDebug( "NULL category ID." ); qDebug() << "NULL category ID.";
return mCategories.first(); return mCategories.first();
} }
@@ -233,7 +233,7 @@ namespace libglabels
} }
} }
qDebug( "Unknown category ID: \"%s\".", qPrintable(id) ); qWarning() << "Unknown category ID: " << id;
return NULL; return NULL;
} }
@@ -249,7 +249,7 @@ namespace libglabels
} }
} }
qDebug( "Unknown category name: \"%s\".", qPrintable(name) ); qWarning() << "Unknown category name: " << name;
return mEmpty; return mEmpty;
} }
@@ -265,7 +265,7 @@ namespace libglabels
} }
} }
qDebug( "Unknown category id: \"%s\".", qPrintable(id) ); qWarning() << "Unknown category id: " << id;
return mEmpty; return mEmpty;
} }
@@ -293,7 +293,7 @@ namespace libglabels
} }
else else
{ {
qDebug( "Duplicate vendor name: \"%s\".", qPrintable(vendor->name()) ); qWarning() << "Duplicate vendor name: " << vendor->name();
} }
} }
@@ -302,7 +302,7 @@ namespace libglabels
{ {
if ( name.isNull() || name.isEmpty() ) if ( name.isNull() || name.isEmpty() )
{ {
qDebug( "NULL vendor name." ); qWarning() << "NULL vendor name.";
return mVendors.first(); return mVendors.first();
} }
@@ -314,7 +314,7 @@ namespace libglabels
} }
} }
qDebug( "Unknown vendor name: \"%s\".", qPrintable(name) ); qWarning() << "Unknown vendor name: " << name;
return NULL; return NULL;
} }
@@ -330,7 +330,7 @@ namespace libglabels
} }
} }
qDebug( "Unknown vendor name: \"%s\".", qPrintable(name) ); qWarning() << "Unknown vendor name: " << name;
return mEmpty; return mEmpty;
} }
@@ -358,7 +358,7 @@ namespace libglabels
} }
else else
{ {
qDebug( "Duplicate template name: \"%s\".", qPrintable(tmplate->name()) ); qWarning() << "Duplicate template name: " << tmplate->name();
} }
} }
@@ -367,7 +367,7 @@ namespace libglabels
{ {
if ( name.isNull() || name.isEmpty() ) if ( name.isNull() || name.isEmpty() )
{ {
qDebug( "NULL template name." ); qWarning() << "NULL template name.";
return mTemplates.first(); return mTemplates.first();
} }
@@ -379,7 +379,7 @@ namespace libglabels
} }
} }
qDebug( "Unknown template name: \"%s\".", qPrintable(name) ); qWarning() << "Unknown template name: " << name;
return NULL; return NULL;
} }
@@ -388,7 +388,7 @@ namespace libglabels
{ {
if ( brand.isNull() || brand.isEmpty() || part.isNull() || part.isEmpty() ) if ( brand.isNull() || brand.isEmpty() || part.isNull() || part.isEmpty() )
{ {
qDebug( "NULL template brand and/or part." ); qWarning() << "NULL template brand and/or part.";
return mTemplates.first(); return mTemplates.first();
} }
@@ -400,7 +400,7 @@ namespace libglabels
} }
} }
qDebug( "Unknown template brand, part: \"%s\", \"%s\".", qPrintable(brand), qPrintable(part) ); qWarning() << "Unknown template brand, part: " << brand << ", " << part;
return NULL; return NULL;
} }
@@ -426,7 +426,7 @@ namespace libglabels
const Template *tmplate1 = lookupTemplateFromName( name ); const Template *tmplate1 = lookupTemplateFromName( name );
if ( tmplate1 == NULL ) if ( tmplate1 == NULL )
{ {
qDebug( "Unknown template name: \"%s\".", qPrintable(name) ); qWarning() << "Unknown template name: " << name;
return list; return list;
} }
@@ -465,69 +465,65 @@ namespace libglabels
void Db::printKnownPapers() void Db::printKnownPapers()
{ {
std::cout << "KNOWN PAPERS:" << std::endl; qDebug() << "KNOWN PAPERS:";
foreach ( Paper *paper, mPapers ) foreach ( Paper *paper, mPapers )
{ {
std::cout << "paper " qDebug() << "paper "
<< "id='" << qPrintable(paper->id()) << "', " << "id=" << paper->id() << ", "
<< "name='" << qPrintable(paper->name()) << "', " << "name=" << paper->name() << ", "
<< "width=" << paper->width() << "pts, " << "width=" << paper->width() << "pts, "
<< "height=" << paper->height() << "pts, " << "height=" << paper->height() << "pts, "
<< "pwg_size=" << qPrintable(paper->pwgSize()) << "pwg_size=" << paper->pwgSize();
<< std::endl;
} }
std::cout << std::endl; qDebug();
} }
void Db::printKnownCategories() void Db::printKnownCategories()
{ {
std::cout << "KNOWN CATEGORIES:" << std::endl; qDebug() << "KNOWN CATEGORIES:";
foreach ( Category *category, mCategories ) foreach ( Category *category, mCategories )
{ {
std::cout << "category " qDebug() << "category "
<< "id='" << category->id().toStdString() << "', " << "id=" << category->id() << ", "
<< "name='" << category->name().toStdString() << "', " << "name=" << category->name();
<< std::endl;
} }
std::cout << std::endl; qDebug();
} }
void Db::printKnownVendors() void Db::printKnownVendors()
{ {
std::cout << "KNOWN VENDORS:" << std::endl; qDebug() << "KNOWN VENDORS:";
foreach ( Vendor *vendor, mVendors ) foreach ( Vendor *vendor, mVendors )
{ {
std::cout << "vendor " qDebug() << "vendor "
<< "name='" << vendor->name().toStdString() << "', " << "name='" << vendor->name() << ", "
<< "url='" << vendor->url().toStdString() << "'" << "url='" << vendor->url();
<< std::endl;
} }
std::cout << std::endl; qDebug();
} }
void Db::printKnownTemplates() void Db::printKnownTemplates()
{ {
std::cout << "KNOWN TEMPLATES:" << std::endl; qDebug() << "KNOWN TEMPLATES:";
foreach ( Template *tmplate, mTemplates ) foreach ( Template *tmplate, mTemplates )
{ {
std::cout << "template " qDebug() << "template "
<< "brand='" << tmplate->brand().toStdString() << "', " << "brand=" << tmplate->brand() << ", "
<< "part='" << tmplate->part().toStdString() << "', " << "part=" << tmplate->part() << ", "
<< "description='" << tmplate->description().toStdString() << "'" << "description=" << tmplate->description();
<< std::endl;
} }
std::cout << std::endl; qDebug();
} }
+4 -5
View File
@@ -20,7 +20,7 @@
#include "Template.h" #include "Template.h"
#include <iostream> #include <QtDebug>
#include "Db.h" #include "Db.h"
@@ -109,10 +109,9 @@ namespace libglabels
} }
else else
{ {
std::cerr << "Error: cannot create equivalent template for " qWarning() << "Error: cannot create equivalent template for "
<< qPrintable(brand) << ", " << qPrintable(equivPart) << brand << ", " << equivPart
<< ". Forward references not supported." << ". Forward references not supported.";
<< std::endl;
return NULL; return NULL;
} }
} }
+10 -12
View File
@@ -23,7 +23,7 @@
#include <QFile> #include <QFile>
#include <QDomDocument> #include <QDomDocument>
#include <QDomNode> #include <QDomNode>
#include <iostream> #include <QtDebug>
#include "Category.h" #include "Category.h"
#include "XmlUtil.h" #include "XmlUtil.h"
@@ -39,9 +39,8 @@ namespace libglabels
if ( !file.open( QFile::ReadOnly | QFile::Text) ) if ( !file.open( QFile::ReadOnly | QFile::Text) )
{ {
std::cerr << "Error: Cannot read file " << qPrintable(fileName) qWarning() << "Error: Cannot read file " << fileName
<< ": " << qPrintable(file.errorString()) << ": " << file.errorString();
<< std::endl;
return false; return false;
} }
@@ -53,17 +52,16 @@ namespace libglabels
if ( !doc.setContent( &file, false, &errorString, &errorLine, &errorColumn ) ) if ( !doc.setContent( &file, false, &errorString, &errorLine, &errorColumn ) )
{ {
std::cerr << "Error: Parse error at line " << errorLine qWarning() << "Error: Parse error at line " << errorLine
<< "column " << errorColumn << "column " << errorColumn
<< ": " << qPrintable(errorString) << ": " << errorString;
<< std::endl;
return false; return false;
} }
QDomElement root = doc.documentElement(); QDomElement root = doc.documentElement();
if ( root.tagName() != "Glabels-categories" ) if ( root.tagName() != "Glabels-categories" )
{ {
std::cerr << "Error: Not a Glabels-categories file" << std::endl; qWarning() << "Error: Not a Glabels-categories file.";
return false; return false;
} }
@@ -82,9 +80,9 @@ namespace libglabels
} }
else if ( !child.isComment() ) else if ( !child.isComment() )
{ {
std::cerr << "Warning: bad element: " << qPrintable(child.toElement().tagName()) qWarning() << "Warning: bad element: "
<< ", Ignored" << child.toElement().tagName()
<< std::endl; << ", Ignored.";
} }
} }
} }
+10 -12
View File
@@ -23,7 +23,7 @@
#include <QFile> #include <QFile>
#include <QDomDocument> #include <QDomDocument>
#include <QDomNode> #include <QDomNode>
#include <iostream> #include <QtDebug>
#include "Paper.h" #include "Paper.h"
#include "XmlUtil.h" #include "XmlUtil.h"
@@ -39,9 +39,8 @@ namespace libglabels
if ( !file.open( QFile::ReadOnly | QFile::Text) ) if ( !file.open( QFile::ReadOnly | QFile::Text) )
{ {
std::cerr << "Error: Cannot read file " << qPrintable(fileName) qWarning() << "Error: Cannot read file " << fileName
<< ": " << qPrintable(file.errorString()) << ": " << file.errorString();
<< std::endl;
return false; return false;
} }
@@ -53,17 +52,16 @@ namespace libglabels
if ( !doc.setContent( &file, false, &errorString, &errorLine, &errorColumn ) ) if ( !doc.setContent( &file, false, &errorString, &errorLine, &errorColumn ) )
{ {
std::cerr << "Error: Parse error at line " << errorLine qWarning() << "Error: Parse error at line " << errorLine
<< "column " << errorColumn << "column " << errorColumn
<< ": " << qPrintable(errorString) << ": " << errorString;
<< std::endl;
return false; return false;
} }
QDomElement root = doc.documentElement(); QDomElement root = doc.documentElement();
if ( root.tagName() != "Glabels-paper-sizes" ) if ( root.tagName() != "Glabels-paper-sizes" )
{ {
std::cerr << "Error: Not a Glabels-paper-sizes file" << std::endl; qWarning() << "Error: Not a Glabels-paper-sizes file.";
return false; return false;
} }
@@ -82,9 +80,9 @@ namespace libglabels
} }
else if ( !child.isComment() ) else if ( !child.isComment() )
{ {
std::cerr << "Warning: bad element: " << qPrintable(child.toElement().tagName()) qWarning() << "Warning: bad element: "
<< ", Ignored" << child.toElement().tagName()
<< std::endl; << ", Ignored.";
} }
} }
} }
+22 -24
View File
@@ -23,7 +23,7 @@
#include <QFile> #include <QFile>
#include <QDomDocument> #include <QDomDocument>
#include <QDomNode> #include <QDomNode>
#include <iostream> #include <QtDebug>
#include "Template.h" #include "Template.h"
#include "XmlUtil.h" #include "XmlUtil.h"
@@ -45,9 +45,8 @@ namespace libglabels
if ( !file.open( QFile::ReadOnly | QFile::Text) ) if ( !file.open( QFile::ReadOnly | QFile::Text) )
{ {
std::cerr << "Error: Cannot read file " << qPrintable(fileName) qWarning() << "Error: Cannot read file " << fileName
<< ": " << qPrintable(file.errorString()) << ": " << file.errorString();
<< std::endl;
return false; return false;
} }
@@ -59,17 +58,16 @@ namespace libglabels
if ( !doc.setContent( &file, false, &errorString, &errorLine, &errorColumn ) ) if ( !doc.setContent( &file, false, &errorString, &errorLine, &errorColumn ) )
{ {
std::cerr << "Error: Parse error at line " << errorLine qWarning() << "Error: Parse error at line " << errorLine
<< "column " << errorColumn << "column " << errorColumn
<< ": " << qPrintable(errorString) << ": " << errorString;
<< std::endl;
return false; return false;
} }
QDomElement root = doc.documentElement(); QDomElement root = doc.documentElement();
if ( root.tagName() != "Glabels-templates" ) if ( root.tagName() != "Glabels-templates" )
{ {
std::cerr << "Error: Not a Glabels-templates file" << std::endl; qWarning() << "Error: Not a Glabels-templates file";
return false; return false;
} }
@@ -91,14 +89,14 @@ namespace libglabels
} }
else else
{ {
std::cerr << "Warning: could not create template, Ignored." << std::endl; qWarning() << "Warning: could not create template, Ignored.";
} }
} }
else if ( !child.isComment() ) else if ( !child.isComment() )
{ {
std::cerr << "Warning: bad element: " << qPrintable(child.toElement().tagName()) qWarning() << "Warning: bad element: "
<< ", Ignored" << child.toElement().tagName()
<< std::endl; << ", Ignored.";
} }
} }
} }
@@ -121,7 +119,7 @@ namespace libglabels
} }
else else
{ {
std::cerr << "Error: missing name or brand/part attributes." << std::endl; qWarning() << "Error: missing name or brand/part attributes.";
return NULL; return NULL;
} }
} }
@@ -142,9 +140,9 @@ namespace libglabels
} }
else if ( !child.isComment() ) else if ( !child.isComment() )
{ {
std::cerr << "Warning: bad element: " << qPrintable(child.toElement().tagName()) qWarning() << "Warning: bad element: "
<< ", Ignored" << child.toElement().tagName()
<< std::endl; << ", Ignored.";
} }
} }
} }
@@ -158,7 +156,7 @@ namespace libglabels
const Paper *paper = Db::lookupPaperFromId( paperId ); const Paper *paper = Db::lookupPaperFromId( paperId );
if ( paper == NULL ) if ( paper == NULL )
{ {
std::cerr << "Error: unknown paper ID: " << qPrintable( paperId ) << std::endl; qWarning() << "Error: unknown paper ID: " << paperId;
return NULL; return NULL;
} }
@@ -197,9 +195,9 @@ namespace libglabels
} }
else if ( !child.isComment() ) else if ( !child.isComment() )
{ {
std::cerr << "Warning: bad element: " << qPrintable(child.toElement().tagName()) qWarning() << "Warning: bad element: "
<< ", Ignored" << child.toElement().tagName()
<< std::endl; << ", Ignored.";
} }
} }
} }
@@ -333,9 +331,9 @@ namespace libglabels
} }
else if ( !child.isComment() ) else if ( !child.isComment() )
{ {
std::cerr << "Warning: bad element: " << qPrintable(child.toElement().tagName()) qWarning() << "Warning: bad element: "
<< ", Ignored" << child.toElement().tagName()
<< std::endl; << ", Ignored.";
} }
} }
} }
+16 -21
View File
@@ -21,7 +21,7 @@
#include "XmlUtil.h" #include "XmlUtil.h"
#include <QTextStream> #include <QTextStream>
#include <iostream> #include <QtDebug>
namespace libglabels namespace libglabels
@@ -50,10 +50,9 @@ namespace libglabels
if ( !ok ) if ( !ok )
{ {
std::cerr << "Error: bad double value in attribute " qWarning() << "Error: bad double value in attribute "
<< qPrintable( node.tagName() ) << ":" << qPrintable( name ) << node.tagName() << ":" << name
<< " : '" << qPrintable( valueString ) << "'" << " : " << valueString;
<< std:: endl;
return default_value; return default_value;
} }
@@ -89,10 +88,9 @@ namespace libglabels
return false; return false;
} }
std::cerr << "Error: bad boolean value in attribute " qWarning() << "Error: bad boolean value in attribute "
<< qPrintable( node.tagName() ) << ":" << qPrintable( name ) << node.tagName() << ":" << name
<< " : '" << qPrintable( valueString ) << "'" << " : " << valueString;
<< std:: endl;
return default_value; return default_value;
} }
@@ -112,10 +110,9 @@ namespace libglabels
if ( !ok ) if ( !ok )
{ {
std::cerr << "Error: bad integer value in attribute " qWarning() << "Error: bad integer value in attribute "
<< qPrintable( node.tagName() ) << ":" << qPrintable( name ) << node.tagName() << ":" << name
<< " : '" << qPrintable( valueString ) << "'" << " : " << valueString;
<< std:: endl;
return default_value; return default_value;
} }
@@ -139,10 +136,9 @@ namespace libglabels
if ( !ok ) if ( !ok )
{ {
std::cerr << "Error: bad unsigned integer value in attribute " qWarning() << "Error: bad unsigned integer value in attribute "
<< qPrintable( node.tagName() ) << ":" << qPrintable( name ) << node.tagName() << ":" << name
<< " : '" << qPrintable( valueString ) << "'" << " : " << valueString;
<< std:: endl;
return default_value; return default_value;
} }
@@ -184,10 +180,9 @@ namespace libglabels
if ( !Units::isIdValid( unitsString ) ) if ( !Units::isIdValid( unitsString ) )
{ {
std::cerr << "Error: bad length value in attribute " qWarning() << "Error: bad length value in attribute "
<< qPrintable( node.tagName() ) << ":" << qPrintable( name ) << node.tagName() << ":" << name
<< " : '" << qPrintable( valueString ) << "'" << " : " << valueString;
<< std:: endl;
return default_value; return default_value;
} }
+10 -12
View File
@@ -23,7 +23,7 @@
#include <QFile> #include <QFile>
#include <QDomDocument> #include <QDomDocument>
#include <QDomNode> #include <QDomNode>
#include <iostream> #include <QtDebug>
#include "Vendor.h" #include "Vendor.h"
#include "XmlUtil.h" #include "XmlUtil.h"
@@ -39,9 +39,8 @@ namespace libglabels
if ( !file.open( QFile::ReadOnly | QFile::Text) ) if ( !file.open( QFile::ReadOnly | QFile::Text) )
{ {
std::cerr << "Error: Cannot read file " << qPrintable(fileName) qWarning() << "Error: Cannot read file " << fileName
<< ": " << qPrintable(file.errorString()) << ": " << file.errorString();
<< std::endl;
return false; return false;
} }
@@ -53,17 +52,16 @@ namespace libglabels
if ( !doc.setContent( &file, false, &errorString, &errorLine, &errorColumn ) ) if ( !doc.setContent( &file, false, &errorString, &errorLine, &errorColumn ) )
{ {
std::cerr << "Error: Parse error at line " << errorLine qWarning() << "Error: Parse error at line " << errorLine
<< "column " << errorColumn << "column " << errorColumn
<< ": " << qPrintable(errorString) << ": " << errorString;
<< std::endl;
return false; return false;
} }
QDomElement root = doc.documentElement(); QDomElement root = doc.documentElement();
if ( root.tagName() != "Glabels-vendors" ) if ( root.tagName() != "Glabels-vendors" )
{ {
std::cerr << "Error: Not a Glabels-vendors file" << std::endl; qWarning() << "Error: Not a Glabels-vendors file.";
return false; return false;
} }
@@ -82,9 +80,9 @@ namespace libglabels
} }
else if ( !child.isComment() ) else if ( !child.isComment() )
{ {
std::cerr << "Warning: bad element: " << qPrintable(child.toElement().tagName()) qWarning() << "Warning: bad element: "
<< ", Ignored" << child.toElement().tagName()
<< std::endl; << ", Ignored.";
} }
} }
} }