|
|
|
@ -15,6 +15,11 @@
|
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
#include "sheetbuilderdialog.h"
|
|
|
|
|
#include "sheetbuilder.h"
|
|
|
|
|
#include "sheetbuilderconfgdialog.h"
|
|
|
|
|
#include "../core/icore.h"
|
|
|
|
|
#include "../core/core_constants.h"
|
|
|
|
|
|
|
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QLayout>
|
|
|
|
@ -23,13 +28,9 @@
|
|
|
|
|
#include <QTreeWidget>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
|
|
#include "sheetbuilder.h"
|
|
|
|
|
#include "sheetbuilderconfgdialog.h"
|
|
|
|
|
|
|
|
|
|
SheetBuilderDialog::SheetBuilderDialog(QWidget *parent) :
|
|
|
|
|
QDialog(parent)
|
|
|
|
|
SheetBuilderDialog::SheetBuilderDialog(QWidget *parent)
|
|
|
|
|
: QDialog(parent)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
QPushButton *btnOk = new QPushButton(tr("Make sheet"));
|
|
|
|
|
connect(btnOk, SIGNAL(clicked()), SLOT(buildSheet()));
|
|
|
|
|
|
|
|
|
@ -81,7 +82,8 @@ void SheetBuilderDialog::showConfig()
|
|
|
|
|
|
|
|
|
|
void SheetBuilderDialog::detailsShowHide()
|
|
|
|
|
{
|
|
|
|
|
if (!detailsVisible) {
|
|
|
|
|
if (!detailsVisible)
|
|
|
|
|
{
|
|
|
|
|
defHeight = height();
|
|
|
|
|
defWidth = width();
|
|
|
|
|
}
|
|
|
|
@ -89,7 +91,8 @@ void SheetBuilderDialog::detailsShowHide()
|
|
|
|
|
detailsVisible = !detailsVisible;
|
|
|
|
|
txtOutput->setVisible(detailsVisible);
|
|
|
|
|
|
|
|
|
|
if (!detailsVisible) {
|
|
|
|
|
if (!detailsVisible)
|
|
|
|
|
{
|
|
|
|
|
adjustSize();
|
|
|
|
|
resize(defWidth, defHeight);
|
|
|
|
|
}
|
|
|
|
@ -106,16 +109,20 @@ void SheetBuilderDialog::buildSheet()
|
|
|
|
|
QString outputFile;
|
|
|
|
|
QStringList extensions;
|
|
|
|
|
|
|
|
|
|
QSettings settings("ovqt_sheet_builder.ini", QSettings::IniFormat);
|
|
|
|
|
paths = settings.value("SheetPaths").toStringList();
|
|
|
|
|
outputFile = settings.value("SheetOutputFile").toString();
|
|
|
|
|
extensions = settings.value("ExtensionsAllowed").toStringList();
|
|
|
|
|
// read settings
|
|
|
|
|
QSettings *settings = Core::ICore::instance()->settings();
|
|
|
|
|
settings->beginGroup("SheetBuilder");
|
|
|
|
|
paths = settings->value("SheetPaths").toStringList();
|
|
|
|
|
outputFile = settings->value("SheetOutputFile").toString();
|
|
|
|
|
extensions = settings->value("ExtensionsAllowed").toStringList();
|
|
|
|
|
settings->endGroup();
|
|
|
|
|
|
|
|
|
|
bool clean = chckClean->isChecked();
|
|
|
|
|
string configFileName("ovqt_sheet_builder.ini");
|
|
|
|
|
|
|
|
|
|
string outputFileName(outputFile.toStdString());
|
|
|
|
|
|
|
|
|
|
if (outputFileName.empty()) {
|
|
|
|
|
if (outputFileName.empty())
|
|
|
|
|
{
|
|
|
|
|
displayInfo("Error: Output file is not specified");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -124,18 +131,10 @@ void SheetBuilderDialog::buildSheet()
|
|
|
|
|
Q_FOREACH (QString str, paths)
|
|
|
|
|
inputDirs.push_back(str.toStdString());
|
|
|
|
|
|
|
|
|
|
// load the config files
|
|
|
|
|
CConfigFile configFile;
|
|
|
|
|
if(!CFile::fileExists(configFileName))
|
|
|
|
|
{
|
|
|
|
|
displayInfo(QString("Config file '%1' not found, working whithout filter").arg(configFileName.c_str()) );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Q_FOREACH (QString str, extensions)
|
|
|
|
|
{
|
|
|
|
|
Q_FOREACH (QString str, extensions) {
|
|
|
|
|
ExtensionsAllowed.insert(str.toStdString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// get the current associations (read the sheet_id and fill the working structures)
|
|
|
|
|
readFormId( outputFileName );
|
|
|
|
@ -152,7 +151,7 @@ void SheetBuilderDialog::buildSheet()
|
|
|
|
|
if( clean )
|
|
|
|
|
{
|
|
|
|
|
if( ExtensionsAllowed.empty() )
|
|
|
|
|
displayInfo("None extension list provided, the input will not be cleaned");
|
|
|
|
|
displayInfo(tr("None extension list provided, the input will not be cleaned"));
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
map<TFormId,string>::iterator itSheets;
|
|
|
|
@ -176,9 +175,10 @@ void SheetBuilderDialog::buildSheet()
|
|
|
|
|
displayInfo("The file has been cleaned");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setCursor(Qt::WaitCursor);
|
|
|
|
|
// make the ids
|
|
|
|
|
makeId( inputDirs );
|
|
|
|
|
setCursor(Qt::ArrowCursor);
|
|
|
|
|
|
|
|
|
|
// save the new map
|
|
|
|
|
COFile f( outputFileName );
|
|
|
|
@ -188,7 +188,7 @@ void SheetBuilderDialog::buildSheet()
|
|
|
|
|
COFile output;
|
|
|
|
|
if( !output.open(sheetListFileName,false,true) )
|
|
|
|
|
{
|
|
|
|
|
displayInfo(QString("Can't open output file %1").arg(sheetListFileName.c_str()));
|
|
|
|
|
displayInfo(tr("Can't open output file %1").arg(sheetListFileName.c_str()));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
map<TFormId,string>::iterator it1;
|
|
|
|
@ -198,13 +198,13 @@ void SheetBuilderDialog::buildSheet()
|
|
|
|
|
output.serialBuffer((uint8*)(const_cast<char*>(outputLine.data())),(uint)outputLine.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
displayInfo ("------------- results ----------------");
|
|
|
|
|
displayInfo (QString("%1 files added in '%2'").arg(NbFilesAdded).arg(outputFileName.c_str()));
|
|
|
|
|
displayInfo (QString("%1 files discarded because they are empty, begin with .# _ and so on").arg(NbFilesDiscarded));
|
|
|
|
|
displayInfo (QString("%1 files skipped because don't have extension").arg(NbFilesUnknownType));
|
|
|
|
|
displayInfo (QString("%1 types added in '%1'").arg(NbTypesAdded).arg(outputFileName.c_str()));
|
|
|
|
|
displayInfo (tr("------------- results ----------------"));
|
|
|
|
|
displayInfo (tr("%1 files added in '%2'").arg(NbFilesAdded).arg(outputFileName.c_str()));
|
|
|
|
|
displayInfo (tr("%1 files discarded because they are empty, begin with .# _ and so on").arg(NbFilesDiscarded));
|
|
|
|
|
displayInfo (tr("%1 files skipped because don't have extension").arg(NbFilesUnknownType));
|
|
|
|
|
displayInfo (tr("%1 types added in '%1'").arg(NbTypesAdded).arg(outputFileName.c_str()));
|
|
|
|
|
|
|
|
|
|
displayInfo (QString("%1 supported file types :").arg(FileTypeToId.size()));
|
|
|
|
|
displayInfo (tr("%1 supported file types :").arg(FileTypeToId.size()));
|
|
|
|
|
for ( map<string,uint8>::iterator it = FileTypeToId.begin(); it != FileTypeToId.end(); ++it )
|
|
|
|
|
{
|
|
|
|
|
displayInfo(QString("%1").arg((*it).first.c_str()));
|
|
|
|
|