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 "../../core/vapplication.h"
#include "../../container/vcontainer.h"
#include <QLoggingCategory>
Q_LOGGING_CATEGORY(vStMeasur, "v.st.measurements")
//---------------------------------------------------------------------------------------------------------------------
DialogStandardMeasurements::DialogStandardMeasurements(VContainer *data, const QString &patternPieceName,
@ -57,6 +60,7 @@ DialogStandardMeasurements::DialogStandardMeasurements(VContainer *data, const Q
connect(bCansel, &QPushButton::clicked, this, &DialogStandardMeasurements::DialogRejected);
}
qCDebug(vStMeasur)<<"Pattern piece name"<<_name;
ui->lineEditName->setText(_name);
LoadStandardTables();
@ -143,6 +147,7 @@ void DialogStandardMeasurements::CheckState()
//---------------------------------------------------------------------------------------------------------------------
void DialogStandardMeasurements::LoadStandardTables()
{
qCDebug(vStMeasur)<<"Loading standard table.";
QStringList filters{"*.vst"};
QDir tablesDir(qApp->pathToTables());
tablesDir.setNameFilters(filters);
@ -151,11 +156,13 @@ void DialogStandardMeasurements::LoadStandardTables()
const QStringList allFiles = tablesDir.entryList(QDir::NoDotAndDotDot | QDir::Files);
if (allFiles.isEmpty() == true)
{
qCDebug(vStMeasur)<<"Can't find standard measurements in path"<<qApp->pathToTables();
ui->comboBoxTables->clear();
CheckState();
return;
}
qCDebug(vStMeasur)<<"Was found"<<allFiles.size()<<"tables.";
for (int i = 0; i < allFiles.size(); ++i)
{
QFileInfo fi(allFiles.at(i));
@ -166,24 +173,27 @@ void DialogStandardMeasurements::LoadStandardTables()
m.setContent(fi.absoluteFilePath());
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
{
const QString trDesc = qApp->STDescription(m.Id());
if (trDesc.isEmpty() == false)
{
qCDebug(vStMeasur)<<"Adding user table from"<<fi.absoluteFilePath();
ui->comboBoxTables->addItem(trDesc, QVariant(fi.absoluteFilePath()));
}
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()));
}
}
}
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;
}
}

View File

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

View File

@ -375,7 +375,14 @@ void VDomDocument::ValidateXML(const QString &schema, const QString &fileName)
MessageHandler messageHandler;
QXmlSchema sch;
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;
if (sch.isValid() == false)

View File

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