Change in dialog individual measurements.

--HG--
branch : feature
This commit is contained in:
dismine 2014-05-15 12:29:12 +03:00
parent 9e81a2865b
commit e95b886eb4
11 changed files with 51 additions and 152 deletions

View File

@ -20,3 +20,22 @@ defineTest(minQtVersion) {
}
return(false)
}
# Copies the given files to the destination directory
defineTest(copyToDestdir) {
files = $$1
DDIR = $$2
mkpath($$DDIR)
for(FILE, files) {
# Replace slashes in paths with backslashes for Windows
win32{
FILE ~= s,/,\\,g
DDIR ~= s,/,\\,g
}
QMAKE_POST_LINK += $$QMAKE_COPY $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t)
}
export(QMAKE_POST_LINK)
}

View File

@ -6,6 +6,8 @@
# Use out-of-source builds (shadow builds)
include(../../Valentina.pri)
QT += core gui widgets xml svg printsupport xmlpatterns
TEMPLATE = app
@ -155,16 +157,15 @@ QMAKE_DISTCLEAN += $${DESTDIR}/* \
$${RCC_DIR}/* \
$$PWD/share/translations/valentina_*.qm
INSTALL_TRANSLATIONS += share/translations/valentina_ru.qm \
INSTALL_TRANSLATIONS += \
share/translations/valentina_ru.qm \
share/translations/valentina_uk.qm \
share/translations/valentina_de.qm \
share/translations/valentina_cs.qm \
share/translations/valentina_he_IL.qm \
share/translations/valentina_fr.qm
INSTALL_STANDARD_MEASHUREMENTS += share/tables/standard/GOST_man_ru.vst
INSTALL_INDIVIDUAL_MEASHUREMENTS += share/tables/individual/indivindual_ru.vit
INSTALL_STANDARD_MEASHUREMENTS += share/resources/tables/standard/GOST_man_ru.vst
unix {
#VARIABLES
@ -184,14 +185,12 @@ translations.path = $$DATADIR/$${TARGET}/translations/
translations.files = $$INSTALL_TRANSLATIONS
standard.path = $$DATADIR/$${TARGET}/tables/standard/
standard.files = $$INSTALL_STANDARD_MEASHUREMENTS
individual.path = $$DATADIR/$${TARGET}/tables/individual/
individual.files = $$INSTALL_INDIVIDUAL_MEASHUREMENTS
INSTALLS += target \
INSTALLS += \
target \
desktop \
pixmaps \
translations \
standard \
individual
standard
}
!isEmpty(TRANSLATIONS): {
@ -202,25 +201,6 @@ INSTALLS += target \
}
}
# Copies the given files to the destination directory
defineTest(copyToDestdir) {
files = $$1
DDIR = $$2
mkpath($$DDIR)
for(FILE, files) {
# Replace slashes in paths with backslashes for Windows
win32{
FILE ~= s,/,\\,g
DDIR ~= s,/,\\,g
}
QMAKE_POST_LINK += $$QMAKE_COPY $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t)
}
export(QMAKE_POST_LINK)
}
for(DIR, INSTALL_TRANSLATIONS) {
#add these absolute paths to a variable which
#ends up as 'mkcommands = path1 path2 path3 ...'
@ -237,14 +217,6 @@ for(DIR, INSTALL_STANDARD_MEASHUREMENTS) {
copyToDestdir($$st_path, $$shell_path($$OUT_PWD/$$DESTDIR/tables/standard))
for(DIR, INSTALL_INDIVIDUAL_MEASHUREMENTS) {
#add these absolute paths to a variable which
#ends up as 'mkcommands = path1 path2 path3 ...'
ind_path += $$PWD/$$DIR
}
copyToDestdir($$ind_path, $$shell_path($$OUT_PWD/$$DESTDIR/tables/individual))
win32:CONFIG(release, debug|release): LIBS += -L../libs/qmuparser/bin -lqmuparser2
else:win32:CONFIG(debug, debug|release): LIBS += -L../libs/qmuparser/bin -lqmuparser2
else:unix: LIBS += -L../libs/qmuparser/bin -lqmuparser

View File

@ -57,9 +57,7 @@ DialogIndividualMeasurements::DialogIndividualMeasurements(VContainer *data, con
ui->lineEditName->setText(_name);
LoadIndividualTables();
InitUnits();
CheckState();
connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogIndividualMeasurements::CheckState);
connect(ui->buttonGroupPath, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this,
@ -91,9 +89,10 @@ void DialogIndividualMeasurements::DialogAccepted()
table.remove();
}
const qint32 index = ui->comboBoxLang->currentIndex();
QString path = ui->comboBoxLang->itemData(index).toString();
QFile iMeasur(path);
//just in case
VDomDocument::ValidateXML("://schema/individual_measurements.xsd", "://tables/individual/individual.vit");
QFile iMeasur("://tables/individual/individual.vit");
//TODO maybe make copy save?
if ( iMeasur.copy(_tablePath) == false )
{
QMessageBox::warning(this, tr("Could not create measurements file"), tr("Please try again or change file"));
@ -153,7 +152,6 @@ void DialogIndividualMeasurements::CheckState()
ui->lineEditPathNewM->setEnabled(false);
ui->toolButtonOpenNew->setEnabled(false);
ui->comboBoxLang->setEnabled(false);
ui->comboBoxUnits->setEnabled(false);
if (ui->lineEditPathExistM->text().isEmpty() == false)
@ -165,7 +163,6 @@ void DialogIndividualMeasurements::CheckState()
{
ui->lineEditPathNewM->setEnabled(true);
ui->toolButtonOpenNew->setEnabled(true);
ui->comboBoxLang->setEnabled(true);
ui->comboBoxUnits->setEnabled(true);
ui->toolButtonOpenExist->setEnabled(false);
@ -177,69 +174,10 @@ void DialogIndividualMeasurements::CheckState()
}
}
bool flagLang = false;
{
const QComboBox *box = ui->comboBoxLang;
Q_CHECK_PTR(box);
if (box->count() > 0 && box->currentIndex() != -1)
{
flagLang = true;
}
}
QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
Q_CHECK_PTR(bOk);
bOk->setEnabled(flagName && flagPath && flagLang);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogIndividualMeasurements::LoadIndividualTables()
{
QStringList filters;
filters << "*.vit";
QDir tablesDir(qApp->pathToTables());
tablesDir.setNameFilters(filters);
tablesDir.setCurrent(qApp->pathToTables());
const QStringList allFiles = tablesDir.entryList(QDir::NoDotAndDotDot | QDir::Files);
if (allFiles.isEmpty() == true)
{
ui->comboBoxLang->clear();
CheckState();
return;
}
for (int i = 0; i < allFiles.size(); ++i)
{
QFileInfo fi(allFiles.at(i));
try
{
VDomDocument::ValidateXML("://schema/individual_measurements.xsd", fi.absoluteFilePath());
VIndividualMeasurements m(data);
m.setContent(fi.absoluteFilePath());
const QString lang = QLocale(m.Language()).nativeLanguageName();
ui->comboBoxLang->addItem(lang, QVariant(fi.absoluteFilePath()));
}
catch (VException &e)
{
qDebug()<<"File error."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
continue;
}
}
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(),
QApplication::applicationName());
QString defaultLocale = QLocale::system().name(); // e.g. "de_DE"
defaultLocale.truncate(defaultLocale.lastIndexOf('_')); // e.g. "de"
QString checkedLocale = settings.value("configuration/locale", defaultLocale).toString();
//TODO make sure this part work.
// set default translators and language checked
qint32 index = ui->comboBoxLang->findData(checkedLocale);
if (index != -1)
{
ui->comboBoxLang->setCurrentIndex(index);
}
bOk->setEnabled(flagName && flagPath);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -57,7 +57,6 @@ private:
QString _name;
QString _tablePath;
VContainer *data;
void LoadIndividualTables();
void InitUnits();
};

View File

@ -90,33 +90,6 @@
</attribute>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Language:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxLang">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>

View File

@ -1,3 +1,5 @@
<RCC>
<qresource prefix="/"/>
<qresource prefix="/">
<file>tables/individual/individual.vit</file>
</qresource>
</RCC>

View File

@ -4,7 +4,6 @@
<xs:complexType>
<xs:sequence>
<xs:element name="version" type="formatVersion"></xs:element>
<xs:element name="lang" type="xs:string"></xs:element>
<xs:element name="personal">
<xs:complexType>
<xs:sequence>

View File

@ -1,7 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<vit>
<version>0.1.0</version>
<lang>en-us</lang>
<personal>
<family-name/>
<given-name/>

View File

@ -24,10 +24,7 @@ MOC_DIR = moc
OBJECTS_DIR = obj
# files created rcc
RCC_DIR = rcc
# files created uic
UI_DIR = uic
#RCC_DIR = rcc
SOURCES += \
qmuparser.cpp \
@ -73,8 +70,8 @@ CONFIG(debug, debug|release){
# Debug
unix {
*-g++{
QMAKE_CXXFLAGS += -isystem "/usr/include/qt5" -isystem "/usr/include/qt5/QtCore" -isystem "$${UI_DIR}" \
-isystem "$${MOC_DIR}" -isystem "$${RCC_DIR}" \
QMAKE_CXXFLAGS += -isystem "/usr/include/qt5" -isystem "/usr/include/qt5/QtCore" -isystem "$${MOC_DIR}" \
#-isystem "$${RCC_DIR}" \
-O0 -Wall -Wextra -pedantic -Weffc++ -Woverloaded-virtual -Wctor-dtor-privacy \
-Wnon-virtual-dtor -Wold-style-cast -Wconversion -Winit-self -Wstack-protector \
-Wunreachable-code -Wcast-align -Wcast-qual -Wdisabled-optimization -Wfloat-equal \
@ -101,8 +98,9 @@ CONFIG(debug, debug|release){
}
# Remove generated files at cleaning
QMAKE_DISTCLEAN += $${DESTDIR}/* \
QMAKE_DISTCLEAN += \
$${DESTDIR}/* \
$${OBJECTS_DIR}/* \
$${UI_DIR}/* \
$${MOC_DIR}/* \
$${RCC_DIR}/*
#$${RCC_DIR}/* \
$${MOC_DIR}/*

View File

@ -4,11 +4,11 @@ SUBDIRS = \
sub_app \
sub_lib_qmuparser
sub_lib_qmuparser.subdir = libs/qmuparser
#sub_lib_qmuparser.subdir = libs/qmuparser
sub_lib_qmuparser.file = libs/qmuparser/qmuparser.pro
#sub_tests.file = tests/proj.pro
#sub_tests.depends = sub_lib
sub_app.subdir = app
#sub_app.subdir = app
sub_app.file = app/app.pro
sub_app.depends = sub_lib_qmuparser