Continue creation logging system.

--HG--
branch : develop
This commit is contained in:
dismine 2014-11-24 15:51:07 +02:00
parent 9ef9df1b59
commit f62324b1b0
4 changed files with 42 additions and 5 deletions

View File

@ -34,6 +34,9 @@
#include "../../xml/vstandardmeasurements.h" #include "../../xml/vstandardmeasurements.h"
#include "../../core/vapplication.h" #include "../../core/vapplication.h"
#include "../../container/vcontainer.h" #include "../../container/vcontainer.h"
#include <QLoggingCategory>
Q_LOGGING_CATEGORY(vStMeasur, "v.st.measurements")
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogStandardMeasurements::DialogStandardMeasurements(VContainer *data, const QString &patternPieceName, DialogStandardMeasurements::DialogStandardMeasurements(VContainer *data, const QString &patternPieceName,
@ -57,6 +60,7 @@ DialogStandardMeasurements::DialogStandardMeasurements(VContainer *data, const Q
connect(bCansel, &QPushButton::clicked, this, &DialogStandardMeasurements::DialogRejected); connect(bCansel, &QPushButton::clicked, this, &DialogStandardMeasurements::DialogRejected);
} }
qCDebug(vStMeasur)<<"Pattern piece name"<<_name;
ui->lineEditName->setText(_name); ui->lineEditName->setText(_name);
LoadStandardTables(); LoadStandardTables();
@ -143,6 +147,7 @@ void DialogStandardMeasurements::CheckState()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogStandardMeasurements::LoadStandardTables() void DialogStandardMeasurements::LoadStandardTables()
{ {
qCDebug(vStMeasur)<<"Loading standard table.";
QStringList filters{"*.vst"}; QStringList filters{"*.vst"};
QDir tablesDir(qApp->pathToTables()); QDir tablesDir(qApp->pathToTables());
tablesDir.setNameFilters(filters); tablesDir.setNameFilters(filters);
@ -151,11 +156,13 @@ void DialogStandardMeasurements::LoadStandardTables()
const QStringList allFiles = tablesDir.entryList(QDir::NoDotAndDotDot | QDir::Files); const QStringList allFiles = tablesDir.entryList(QDir::NoDotAndDotDot | QDir::Files);
if (allFiles.isEmpty() == true) if (allFiles.isEmpty() == true)
{ {
qCDebug(vStMeasur)<<"Can't find standard measurements in path"<<qApp->pathToTables();
ui->comboBoxTables->clear(); ui->comboBoxTables->clear();
CheckState(); CheckState();
return; return;
} }
qCDebug(vStMeasur)<<"Was found"<<allFiles.size()<<"tables.";
for (int i = 0; i < allFiles.size(); ++i) for (int i = 0; i < allFiles.size(); ++i)
{ {
QFileInfo fi(allFiles.at(i)); QFileInfo fi(allFiles.at(i));
@ -166,24 +173,27 @@ void DialogStandardMeasurements::LoadStandardTables()
m.setContent(fi.absoluteFilePath()); m.setContent(fi.absoluteFilePath());
if (m.MUnit() == Unit::Inch) if (m.MUnit() == Unit::Inch)
{ {
qWarning()<<"We do not support inches for standard table. Ignore table"<<fi.absoluteFilePath()<<"."; qCWarning(vStMeasur)<<"We do not support inches for standard table. Ignore table"
<<fi.absoluteFilePath()<<".";
} }
else else
{ {
const QString trDesc = qApp->STDescription(m.Id()); const QString trDesc = qApp->STDescription(m.Id());
if (trDesc.isEmpty() == false) if (trDesc.isEmpty() == false)
{ {
qCDebug(vStMeasur)<<"Adding user table from"<<fi.absoluteFilePath();
ui->comboBoxTables->addItem(trDesc, QVariant(fi.absoluteFilePath())); ui->comboBoxTables->addItem(trDesc, QVariant(fi.absoluteFilePath()));
} }
else if (m.Description().isEmpty() == false) else if (m.Description().isEmpty() == false)
{ {
qCDebug(vStMeasur)<<"Adding table with id"<<m.Id()<<"from"<<fi.absoluteFilePath();
ui->comboBoxTables->addItem(m.Description(), QVariant(fi.absoluteFilePath())); ui->comboBoxTables->addItem(m.Description(), QVariant(fi.absoluteFilePath()));
} }
} }
} }
catch (VException &e) catch (VException &e)
{ {
qDebug()<<"File error."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO; qCDebug(vStMeasur)<<"File error."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
continue; continue;
} }
} }

View File

@ -140,23 +140,30 @@ MainWindow::MainWindow(QWidget *parent)
*/ */
void MainWindow::ActionNewPP() void MainWindow::ActionNewPP()
{ {
qCDebug(vMainWindow)<<"New PP.";
QString patternPieceName = QString(tr("Pattern piece %1")).arg(comboBoxDraws->count()+1); QString patternPieceName = QString(tr("Pattern piece %1")).arg(comboBoxDraws->count()+1);
qCDebug(vMainWindow)<<"Generated PP name:"<<patternPieceName;
QString path; QString path;
if (comboBoxDraws->count() == 0) if (comboBoxDraws->count() == 0)
{ {
qCDebug(vMainWindow)<<"First PP";
DialogMeasurements measurements(this); DialogMeasurements measurements(this);
if (measurements.exec() == QDialog::Rejected) if (measurements.exec() == QDialog::Rejected)
{ {
qCDebug(vMainWindow)<<"Creation PP was canceled";
return; return;
} }
if (measurements.type() == MeasurementsType::Standard) if (measurements.type() == MeasurementsType::Standard)
{ {
qCDebug(vMainWindow)<<"PP with standard measurements";
qApp->setPatternType(MeasurementsType::Standard); qApp->setPatternType(MeasurementsType::Standard);
DialogStandardMeasurements stMeasurements(pattern, patternPieceName, this); DialogStandardMeasurements stMeasurements(pattern, patternPieceName, this);
if (stMeasurements.exec() == QDialog::Accepted) if (stMeasurements.exec() == QDialog::Accepted)
{ {
patternPieceName = stMeasurements.name(); patternPieceName = stMeasurements.name();
qCDebug(vMainWindow)<<"PP name:"<<patternPieceName;
path = stMeasurements.tablePath(); path = stMeasurements.tablePath();
qCDebug(vMainWindow)<<"Table path:"<<path;
VStandardMeasurements m(pattern); VStandardMeasurements m(pattern);
m.setContent(path); m.setContent(path);
m.SetSize(); m.SetSize();
@ -165,11 +172,13 @@ void MainWindow::ActionNewPP()
} }
else else
{ {
qCDebug(vMainWindow)<<"Selection standard measurements canceled.";
return; return;
} }
} }
else else
{ {
qCDebug(vMainWindow)<<"PP with individual measurements.";
QMessageBox::StandardButton ret; QMessageBox::StandardButton ret;
ret = QMessageBox::question(this, tr("Individual measurements is under development"), ret = QMessageBox::question(this, tr("Individual measurements is under development"),
tr("There is no way create individual measurements file independent on the " tr("There is no way create individual measurements file independent on the "
@ -186,13 +195,16 @@ void MainWindow::ActionNewPP()
if (indMeasurements.exec() == QDialog::Accepted) if (indMeasurements.exec() == QDialog::Accepted)
{ {
patternPieceName = indMeasurements.name(); patternPieceName = indMeasurements.name();
qCDebug(vMainWindow)<<"PP name:"<<patternPieceName;
path = indMeasurements.tablePath(); path = indMeasurements.tablePath();
qCDebug(vMainWindow)<<"Table path:"<<path;
VIndividualMeasurements m(pattern); VIndividualMeasurements m(pattern);
m.setContent(path); m.setContent(path);
m.Measurements(); m.Measurements();
} }
else else
{ {
qCDebug(vMainWindow)<<"Selection individual measurements canceled.";
return; return;
} }
} }
@ -204,16 +216,19 @@ void MainWindow::ActionNewPP()
} }
else else
{ {
qCDebug(vMainWindow)<<"PP count"<<comboBoxDraws->count();
patternPieceName = PatternPieceName(patternPieceName); patternPieceName = PatternPieceName(patternPieceName);
qCDebug(vMainWindow)<<"PP name:"<<patternPieceName;
if (patternPieceName.isEmpty()) if (patternPieceName.isEmpty())
{ {
qCDebug(vMainWindow)<<"Name empty.";
return; return;
} }
path = doc->MPath(); path = doc->MPath();
} }
if (doc->appendPP(patternPieceName) == false) if (doc->appendPP(patternPieceName) == false)
{ {
qDebug()<<"Error creating pattern piece with the name "<<patternPieceName<<"."; qCDebug(vMainWindow)<<"Error creating pattern piece with the name "<<patternPieceName<<".";
return; return;
} }
comboBoxDraws->blockSignals(true); comboBoxDraws->blockSignals(true);

View File

@ -375,7 +375,14 @@ void VDomDocument::ValidateXML(const QString &schema, const QString &fileName)
MessageHandler messageHandler; MessageHandler messageHandler;
QXmlSchema sch; QXmlSchema sch;
sch.setMessageHandler(&messageHandler); sch.setMessageHandler(&messageHandler);
sch.load(&fileSchema, QUrl::fromLocalFile(fileSchema.fileName())); if (sch.load(&fileSchema, QUrl::fromLocalFile(fileSchema.fileName()))==false)
{
pattern.close();
fileSchema.close();
const QString errorMsg(tr("Could not load schema file.").arg(fileSchema.fileName()));
throw VException(errorMsg);
}
qCDebug(vXML)<<"Schema loaded.";
bool errorOccurred = false; bool errorOccurred = false;
if (sch.isValid() == false) if (sch.isValid() == false)

View File

@ -2463,13 +2463,16 @@ QString VPattern::GenerateLabel(const LabelType &type) const
} }
++i; ++i;
} }
qCDebug(vXML)<<"Point label:"<<name;
return name; return name;
} }
else if (type == LabelType::NewLabel) else if (type == LabelType::NewLabel)
{ {
if (drawList.isEmpty()) if (drawList.isEmpty())
{ {
return GetLabelBase(0); const QString label = GetLabelBase(0);
qCDebug(vXML)<<"Point label:"<<label;
return label;
} }
int index = 0; int index = 0;
@ -2496,8 +2499,10 @@ QString VPattern::GenerateLabel(const LabelType &type) const
break; break;
} }
} while (data->IsUnique(name) == false); } while (data->IsUnique(name) == false);
qCDebug(vXML)<<"Point label:"<<name;
return name; return name;
} }
qCDebug(vXML)<<"Got unknow type"<<static_cast<char>(type);
return QString(); return QString();
} }