2015-08-01 11:39:32 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file dialogmdatabase.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 26 7, 2015
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2015 Valentina project
|
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
|
|
**
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#include "dialogmdatabase.h"
|
|
|
|
#include "ui_dialogmdatabase.h"
|
|
|
|
#include "../mapplication.h"
|
|
|
|
|
2015-10-08 12:59:24 +02:00
|
|
|
#include <QKeyEvent>
|
2015-10-09 13:17:24 +02:00
|
|
|
#include <QMenu>
|
2015-11-15 16:48:48 +01:00
|
|
|
#include <QSvgRenderer>
|
|
|
|
#include <QtSvg>
|
2015-10-08 12:59:24 +02:00
|
|
|
|
2015-08-01 11:39:32 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
DialogMDataBase::DialogMDataBase(const QStringList &list, QWidget *parent)
|
|
|
|
:QDialog(parent),
|
|
|
|
ui(new Ui::DialogMDataBase),
|
|
|
|
selectMode(true),
|
2015-08-08 16:33:37 +02:00
|
|
|
list(list),
|
|
|
|
groupA(nullptr),
|
|
|
|
groupB(nullptr),
|
|
|
|
groupC(nullptr),
|
|
|
|
groupD(nullptr),
|
|
|
|
groupE(nullptr),
|
|
|
|
groupF(nullptr),
|
|
|
|
groupG(nullptr),
|
|
|
|
groupH(nullptr),
|
|
|
|
groupI(nullptr),
|
|
|
|
groupJ(nullptr),
|
|
|
|
groupK(nullptr),
|
|
|
|
groupL(nullptr),
|
|
|
|
groupM(nullptr),
|
|
|
|
groupN(nullptr),
|
|
|
|
groupO(nullptr),
|
|
|
|
groupP(nullptr),
|
|
|
|
groupQ(nullptr)
|
2015-08-01 11:39:32 +02:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
InitDataBase(list);
|
|
|
|
|
2015-10-08 12:59:24 +02:00
|
|
|
ui->treeWidget->installEventFilter(this);
|
|
|
|
|
2015-08-01 11:39:32 +02:00
|
|
|
connect(ui->treeWidget, &QTreeWidget::itemChanged, this, &DialogMDataBase::UpdateChecks);
|
|
|
|
connect(ui->treeWidget, &QTreeWidget::itemClicked, this, &DialogMDataBase::ShowDescription);
|
2015-10-08 15:20:07 +02:00
|
|
|
connect(ui->treeWidget, &QTreeWidget::customContextMenuRequested, this, &DialogMDataBase::TreeMenu);
|
2015-08-01 19:09:10 +02:00
|
|
|
|
|
|
|
ReadSettings();
|
2015-08-01 11:39:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
DialogMDataBase::DialogMDataBase(QWidget *parent)
|
|
|
|
:QDialog(parent),
|
|
|
|
ui(new Ui::DialogMDataBase),
|
|
|
|
selectMode(false),
|
2015-08-08 16:33:37 +02:00
|
|
|
list(),
|
|
|
|
groupA(nullptr),
|
|
|
|
groupB(nullptr),
|
|
|
|
groupC(nullptr),
|
|
|
|
groupD(nullptr),
|
|
|
|
groupE(nullptr),
|
|
|
|
groupF(nullptr),
|
|
|
|
groupG(nullptr),
|
|
|
|
groupH(nullptr),
|
|
|
|
groupI(nullptr),
|
|
|
|
groupJ(nullptr),
|
|
|
|
groupK(nullptr),
|
|
|
|
groupL(nullptr),
|
|
|
|
groupM(nullptr),
|
|
|
|
groupN(nullptr),
|
|
|
|
groupO(nullptr),
|
|
|
|
groupP(nullptr),
|
|
|
|
groupQ(nullptr)
|
2015-08-01 11:39:32 +02:00
|
|
|
|
|
|
|
{
|
2015-08-01 15:56:37 +02:00
|
|
|
ui->setupUi(this);
|
2015-08-01 11:39:32 +02:00
|
|
|
InitDataBase();
|
|
|
|
|
2015-10-08 12:59:24 +02:00
|
|
|
ui->treeWidget->installEventFilter(this);
|
|
|
|
|
2015-08-01 11:39:32 +02:00
|
|
|
connect(ui->treeWidget, &QTreeWidget::itemClicked, this, &DialogMDataBase::ShowDescription);
|
2015-10-08 15:20:07 +02:00
|
|
|
connect(ui->treeWidget, &QTreeWidget::customContextMenuRequested, this, &DialogMDataBase::TreeMenu);
|
|
|
|
connect(ui->treeWidget, &QTreeWidget::itemActivated, this, &DialogMDataBase::ShowDescription);
|
2015-08-01 19:09:10 +02:00
|
|
|
|
|
|
|
ReadSettings();
|
2015-08-01 11:39:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
DialogMDataBase::~DialogMDataBase()
|
|
|
|
{
|
2015-08-01 19:09:10 +02:00
|
|
|
WriteSettings();
|
2015-08-01 11:39:32 +02:00
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2015-08-01 13:25:05 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QStringList DialogMDataBase::GetNewNames() const
|
|
|
|
{
|
|
|
|
if (selectMode)
|
|
|
|
{
|
|
|
|
QStringList newNames;
|
|
|
|
QTreeWidgetItemIterator it(ui->treeWidget,
|
|
|
|
QTreeWidgetItemIterator::NoChildren | QTreeWidgetItemIterator::Checked );
|
|
|
|
while (*it)
|
|
|
|
{
|
|
|
|
const QString name = (*it)->data(0, Qt::UserRole).toString();
|
|
|
|
if (not list.contains(name))
|
|
|
|
{
|
|
|
|
newNames.append(name);
|
|
|
|
}
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
return newNames;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return QStringList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-08 16:33:37 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMDataBase::RetranslateGroups()
|
|
|
|
{
|
|
|
|
RetranslateGroup(groupA, "A. " + tr("Direct Height", "Measurement section"), ListGroupA());
|
|
|
|
RetranslateGroup(groupB, "B. " + tr("Direct Width", "Measurement section"), ListGroupB());
|
|
|
|
RetranslateGroup(groupC, "C. " + tr("Indentation", "Measurement section"), ListGroupC());
|
2015-09-25 10:16:25 +02:00
|
|
|
RetranslateGroup(groupD, "D. " + tr("Hand", "Measurement section"), ListGroupD());
|
|
|
|
RetranslateGroup(groupE, "E. " + tr("Foot", "Measurement section"), ListGroupE());
|
|
|
|
RetranslateGroup(groupF, "F. " + tr("Head", "Measurement section"), ListGroupF());
|
|
|
|
RetranslateGroup(groupG, "G. " + tr("Circumference and Arc", "Measurement section"), ListGroupG());
|
|
|
|
RetranslateGroup(groupH, "H. " + tr("Vertical", "Measurement section"), ListGroupH());
|
|
|
|
RetranslateGroup(groupI, "I. " + tr("Horizontal", "Measurement section"), ListGroupI());
|
|
|
|
RetranslateGroup(groupJ, "J. " + tr("Bust", "Measurement section"), ListGroupJ());
|
|
|
|
RetranslateGroup(groupK, "K. " + tr("Balance", "Measurement section"), ListGroupK());
|
|
|
|
RetranslateGroup(groupL, "L. " + tr("Arm", "Measurement section"), ListGroupL());
|
|
|
|
RetranslateGroup(groupM, "M. " + tr("Leg", "Measurement section"), ListGroupM());
|
|
|
|
RetranslateGroup(groupN, "N. " + tr("Crotch and Rise", "Measurement section"), ListGroupN());
|
2015-08-08 16:33:37 +02:00
|
|
|
RetranslateGroup(groupO, "O. " + tr("Men & Tailoring", "Measurement section"), ListGroupO());
|
|
|
|
RetranslateGroup(groupP, "P. " + tr("Historical & Specialty", "Measurement section"), ListGroupP());
|
|
|
|
RetranslateGroup(groupQ, "Q. " + tr("Patternmaking measurements", "Measurement section"), ListGroupQ());
|
|
|
|
|
2015-08-08 17:30:15 +02:00
|
|
|
ShowDescription(ui->treeWidget->currentItem(), 0);
|
2015-08-08 16:33:37 +02:00
|
|
|
}
|
|
|
|
|
2015-11-15 16:48:48 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString DialogMDataBase::ImgTag(const QString &number)
|
|
|
|
{
|
|
|
|
QString imgUrl("<img src=\"wrong.png\" align=\"center\"/>"); // In case of error
|
|
|
|
const QString filePath = QString("://diagrams/%1.svg").arg(MapDiagrams(number));
|
|
|
|
if (QFileInfo(filePath).exists())
|
|
|
|
{
|
|
|
|
// Load your SVG
|
|
|
|
QSvgRenderer renderer;
|
|
|
|
const bool ok = renderer.load(filePath);
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
const QScreen *screen = QApplication::screens().at(0);
|
|
|
|
if (screen)
|
|
|
|
{
|
|
|
|
const QSize defSize = renderer.defaultSize();
|
|
|
|
|
|
|
|
// Prepare a QImage with desired characteritisc
|
|
|
|
QImage image(defSize, QImage::Format_RGB32);
|
|
|
|
image.fill(Qt::white);
|
|
|
|
|
|
|
|
const QRect geometry = screen->geometry();
|
|
|
|
const int baseHeight = 1440;
|
|
|
|
const int imgHeight = geometry.height() * defSize.height() / baseHeight;
|
|
|
|
|
|
|
|
QImage scaledImg = image.scaledToHeight(imgHeight);
|
|
|
|
|
|
|
|
// Get QPainter that paints to the image
|
|
|
|
QPainter painter(&scaledImg);
|
|
|
|
renderer.render(&painter);
|
|
|
|
|
|
|
|
QByteArray byteArray;
|
|
|
|
QBuffer buffer(&byteArray);
|
|
|
|
scaledImg.save(&buffer, "PNG");
|
|
|
|
imgUrl = QString("<img src=\"data:image/png;base64,") + byteArray.toBase64() + "\" align=\"center\"/>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return imgUrl;
|
|
|
|
}
|
|
|
|
|
2015-08-08 16:33:37 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMDataBase::changeEvent(QEvent *event)
|
|
|
|
{
|
|
|
|
if (event->type() == QEvent::LanguageChange)
|
|
|
|
{
|
|
|
|
// retranslate designer form (single inheritance approach)
|
|
|
|
ui->retranslateUi(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// remember to call base class implementation
|
|
|
|
QDialog::changeEvent(event);
|
|
|
|
}
|
|
|
|
|
2015-10-08 12:59:24 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool DialogMDataBase::eventFilter(QObject *target, QEvent *event)
|
|
|
|
{
|
|
|
|
if (target == ui->treeWidget)
|
|
|
|
{
|
|
|
|
if (event->type() == QEvent::KeyPress)
|
|
|
|
{
|
|
|
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
|
|
|
switch(keyEvent->key())
|
|
|
|
{
|
|
|
|
case Qt::Key_Up:
|
|
|
|
{
|
|
|
|
const QModelIndex model = ui->treeWidget->indexAbove(ui->treeWidget->currentIndex());
|
|
|
|
QTreeWidgetItem *item = ui->treeWidget->itemAbove(ui->treeWidget->currentItem());
|
2015-10-08 15:20:07 +02:00
|
|
|
ShowDescription(item, model.column());
|
2015-10-08 12:59:24 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Qt::Key_Down:
|
|
|
|
{
|
|
|
|
const QModelIndex model = ui->treeWidget->indexBelow(ui->treeWidget->currentIndex());
|
|
|
|
QTreeWidgetItem *item = ui->treeWidget->itemBelow(ui->treeWidget->currentItem());
|
2015-10-08 15:20:07 +02:00
|
|
|
ShowDescription(item, model.column());
|
2015-10-08 12:59:24 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return QDialog::eventFilter(target, event);
|
|
|
|
}
|
|
|
|
|
2015-08-01 11:39:32 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMDataBase::UpdateChecks(QTreeWidgetItem *item, int column)
|
|
|
|
{
|
|
|
|
bool diff = false;
|
|
|
|
if (column != 0 && column != -1)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item->childCount() != 0 && item->checkState(0) != Qt::PartiallyChecked && column != -1)
|
|
|
|
{
|
2015-08-01 14:22:24 +02:00
|
|
|
bool flag = false; // Check if we could change atleast one children
|
2015-08-01 11:39:32 +02:00
|
|
|
Qt::CheckState checkState = item->checkState(0);
|
|
|
|
for (int i = 0; i < item->childCount(); ++i)
|
|
|
|
{
|
|
|
|
if (not list.contains(item->child(i)->data(0, Qt::UserRole).toString()))
|
|
|
|
{
|
|
|
|
item->child(i)->setCheckState(0, checkState);
|
2015-08-01 14:22:24 +02:00
|
|
|
flag = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flag == false) // All child in the list
|
|
|
|
{
|
|
|
|
item->setCheckState(0, Qt::Checked);
|
2015-08-01 11:39:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (item->childCount() == 0 || column == -1)
|
|
|
|
{
|
2015-10-28 15:22:36 +01:00
|
|
|
QTreeWidgetItem *parent = item->parent();
|
|
|
|
if (parent == nullptr)
|
2015-08-01 11:39:32 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-10-28 15:22:36 +01:00
|
|
|
for (int j = 0; j < parent->childCount(); ++j)
|
2015-08-01 11:39:32 +02:00
|
|
|
{
|
2015-10-28 15:22:36 +01:00
|
|
|
if (j != parent->indexOfChild(item)
|
|
|
|
&& item->checkState(0) != parent->child(j)->checkState(0))
|
2015-08-01 11:39:32 +02:00
|
|
|
{
|
|
|
|
diff = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (diff)
|
|
|
|
{
|
2015-10-28 15:22:36 +01:00
|
|
|
parent->setCheckState(0, Qt::PartiallyChecked);
|
2015-08-01 11:39:32 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-10-28 15:22:36 +01:00
|
|
|
parent->setCheckState(0, item->checkState(0));
|
2015-08-01 11:39:32 +02:00
|
|
|
}
|
|
|
|
|
2015-10-28 15:22:36 +01:00
|
|
|
UpdateChecks(parent, -1);
|
2015-08-01 11:39:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMDataBase::ShowDescription(QTreeWidgetItem *item, int column)
|
|
|
|
{
|
|
|
|
if (column != 0 && column != -1)
|
|
|
|
{
|
|
|
|
ui->textEdit->clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-08-08 16:33:37 +02:00
|
|
|
if (item == nullptr)
|
|
|
|
{
|
|
|
|
ui->textEdit->clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-08-01 12:12:03 +02:00
|
|
|
if (item->childCount() != 0)
|
|
|
|
{
|
|
|
|
ui->textEdit->clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-08-01 11:39:32 +02:00
|
|
|
const QString name = item->data(0, Qt::UserRole).toString();
|
2015-10-28 15:22:36 +01:00
|
|
|
const VTranslateVars *trv = qApp->TrVars();
|
|
|
|
const QString number = trv->MNumber(name);
|
2015-11-15 16:48:48 +01:00
|
|
|
|
|
|
|
const QString text = QString("<p align=\"center\" style=\"font-variant: normal; font-style: normal; font-weight: "
|
|
|
|
"normal\"> %1 <br clear=\"left\"><b>%2</b>. <i>%3</i></p>"
|
|
|
|
"<p align=\"left\" style=\"font-variant: normal; font-style: normal; font-weight: "
|
|
|
|
"normal\">%4</p>")
|
|
|
|
.arg(ImgTag(number))
|
2015-08-01 11:39:32 +02:00
|
|
|
.arg(number)
|
2015-10-28 15:22:36 +01:00
|
|
|
.arg(trv->GuiText(name))
|
|
|
|
.arg(trv->Description(name));
|
2015-08-01 11:39:32 +02:00
|
|
|
|
|
|
|
ui->textEdit->setHtml(text);
|
|
|
|
}
|
|
|
|
|
2015-10-08 15:20:07 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMDataBase::TreeMenu(const QPoint &pos)
|
|
|
|
{
|
|
|
|
// Because item also will be selected need to show description
|
|
|
|
const QModelIndex model = ui->treeWidget->currentIndex();
|
|
|
|
QTreeWidgetItem *item = ui->treeWidget->currentItem();
|
|
|
|
ShowDescription(item, model.column());
|
|
|
|
|
|
|
|
QAction *actionCollapseAll = new QAction(tr("Collapse All"), this);
|
|
|
|
connect(actionCollapseAll, &QAction::triggered, ui->treeWidget, &QTreeWidget::collapseAll);
|
|
|
|
|
|
|
|
QAction *actionExpandeAll = new QAction(tr("Expand All"), this);
|
|
|
|
connect(actionExpandeAll, &QAction::triggered, ui->treeWidget, &QTreeWidget::expandAll);
|
|
|
|
|
|
|
|
QMenu menu(this);
|
|
|
|
menu.addAction(actionCollapseAll);
|
|
|
|
menu.addAction(actionExpandeAll);
|
2015-11-12 11:47:00 +01:00
|
|
|
|
|
|
|
if (selectMode)
|
|
|
|
{
|
|
|
|
QString actionName;
|
|
|
|
GlobalCheckState() == Qt::Checked ? actionName = tr("Check all") : actionName = tr("Uncheck all");
|
|
|
|
|
|
|
|
QAction *actionRecheck = new QAction(actionName, this);
|
|
|
|
connect(actionRecheck, &QAction::triggered, this, &DialogMDataBase::Recheck);
|
|
|
|
|
|
|
|
menu.addAction(actionRecheck);
|
|
|
|
}
|
2015-10-08 15:20:07 +02:00
|
|
|
menu.exec(ui->treeWidget->mapToGlobal(pos));
|
|
|
|
}
|
|
|
|
|
2015-11-12 11:47:00 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMDataBase::Recheck()
|
|
|
|
{
|
|
|
|
if (selectMode)
|
|
|
|
{
|
|
|
|
const Qt::CheckState check = GlobalCheckState();
|
|
|
|
|
|
|
|
ChangeCheckState(groupA, check);
|
|
|
|
ChangeCheckState(groupB, check);
|
|
|
|
ChangeCheckState(groupC, check);
|
|
|
|
ChangeCheckState(groupD, check);
|
|
|
|
ChangeCheckState(groupE, check);
|
|
|
|
ChangeCheckState(groupF, check);
|
|
|
|
ChangeCheckState(groupG, check);
|
|
|
|
ChangeCheckState(groupH, check);
|
|
|
|
ChangeCheckState(groupI, check);
|
|
|
|
ChangeCheckState(groupJ, check);
|
|
|
|
ChangeCheckState(groupK, check);
|
|
|
|
ChangeCheckState(groupL, check);
|
|
|
|
ChangeCheckState(groupM, check);
|
|
|
|
ChangeCheckState(groupN, check);
|
|
|
|
ChangeCheckState(groupO, check);
|
|
|
|
ChangeCheckState(groupP, check);
|
|
|
|
ChangeCheckState(groupQ, check);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-01 11:39:32 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMDataBase::InitDataBase(const QStringList &list)
|
|
|
|
{
|
2015-11-12 11:47:00 +01:00
|
|
|
InitGroup(&groupA, "A. " + tr("Direct Height", "Measurement section"), ListGroupA(), list);
|
|
|
|
InitGroup(&groupB, "B. " + tr("Direct Width", "Measurement section"), ListGroupB(), list);
|
|
|
|
InitGroup(&groupC, "C. " + tr("Indentation", "Measurement section"), ListGroupC(), list);
|
|
|
|
InitGroup(&groupD, "D. " + tr("Hand", "Measurement section"), ListGroupD(), list);
|
|
|
|
InitGroup(&groupE, "E. " + tr("Foot", "Measurement section"), ListGroupE(), list);
|
|
|
|
InitGroup(&groupF, "F. " + tr("Head", "Measurement section"), ListGroupF(), list);
|
|
|
|
InitGroup(&groupG, "G. " + tr("Circumference and Arc", "Measurement section"), ListGroupG(), list);
|
|
|
|
InitGroup(&groupH, "H. " + tr("Vertical", "Measurement section"), ListGroupH(), list);
|
|
|
|
InitGroup(&groupI, "I. " + tr("Horizontal", "Measurement section"), ListGroupI(), list);
|
|
|
|
InitGroup(&groupJ, "J. " + tr("Bust", "Measurement section"), ListGroupJ(), list);
|
|
|
|
InitGroup(&groupK, "K. " + tr("Balance", "Measurement section"), ListGroupK(), list);
|
|
|
|
InitGroup(&groupL, "L. " + tr("Arm", "Measurement section"), ListGroupL(), list);
|
|
|
|
InitGroup(&groupM, "M. " + tr("Leg", "Measurement section"), ListGroupM(), list);
|
|
|
|
InitGroup(&groupN, "N. " + tr("Crotch and Rise", "Measurement section"), ListGroupN(), list);
|
|
|
|
InitGroup(&groupO, "O. " + tr("Men & Tailoring", "Measurement section"), ListGroupO(), list);
|
|
|
|
InitGroup(&groupP, "P. " + tr("Historical & Specialty", "Measurement section"), ListGroupP(), list);
|
|
|
|
InitGroup(&groupQ, "Q. " + tr("Patternmaking measurements", "Measurement section"), ListGroupQ(), list);
|
2015-08-01 11:39:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-12 11:47:00 +01:00
|
|
|
void DialogMDataBase::InitGroup(QTreeWidgetItem **group, const QString &groupName, const QStringList &mList,
|
2015-08-08 16:33:37 +02:00
|
|
|
const QStringList &list)
|
2015-08-01 11:39:32 +02:00
|
|
|
{
|
2015-11-12 11:47:00 +01:00
|
|
|
*group = AddGroup(groupName);
|
2015-08-08 16:33:37 +02:00
|
|
|
for (int i=0; i < mList.size(); ++i)
|
|
|
|
{
|
2015-11-12 11:47:00 +01:00
|
|
|
AddMeasurement(*group, mList.at(i), list);
|
2015-08-08 16:33:37 +02:00
|
|
|
}
|
2015-08-01 11:39:32 +02:00
|
|
|
}
|
|
|
|
|
2015-08-01 13:44:41 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QTreeWidgetItem *DialogMDataBase::AddGroup(const QString &text)
|
|
|
|
{
|
|
|
|
QTreeWidgetItem *group = new QTreeWidgetItem(ui->treeWidget);
|
|
|
|
group->setText(0, text);
|
|
|
|
group->setToolTip(0, text);
|
2015-10-08 13:10:56 +02:00
|
|
|
group->setExpanded(true);
|
2015-08-01 13:44:41 +02:00
|
|
|
if (selectMode)
|
|
|
|
{
|
|
|
|
group->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
|
|
|
|
group->setCheckState(0, Qt::Unchecked);
|
2015-08-01 14:22:24 +02:00
|
|
|
group->setBackground(0, QBrush(Qt::lightGray));
|
2015-08-01 13:44:41 +02:00
|
|
|
}
|
|
|
|
return group;
|
|
|
|
}
|
|
|
|
|
2015-08-01 11:39:32 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMDataBase::AddMeasurement(QTreeWidgetItem *group, const QString &name, const QStringList &list)
|
|
|
|
{
|
|
|
|
QTreeWidgetItem *m = new QTreeWidgetItem(group);
|
|
|
|
|
|
|
|
if (selectMode)
|
|
|
|
{
|
|
|
|
if (list.contains(name))
|
|
|
|
{
|
|
|
|
m->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
|
|
|
m->setCheckState(0, Qt::Checked);
|
2015-08-01 14:22:24 +02:00
|
|
|
m->setBackground(0, QBrush(Qt::yellow));
|
2015-08-01 11:39:32 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m->setCheckState(0, Qt::Unchecked);
|
|
|
|
}
|
|
|
|
|
2015-08-01 15:56:37 +02:00
|
|
|
UpdateChecks(m, 0);
|
|
|
|
}
|
2015-08-01 14:22:24 +02:00
|
|
|
|
2015-08-01 13:44:41 +02:00
|
|
|
const QString text = qApp->TrVars()->MNumber(name) + ". " + qApp->TrVars()->MToUser(name);
|
|
|
|
m->setText(0, text);
|
|
|
|
m->setToolTip(0, text);
|
2015-08-01 11:39:32 +02:00
|
|
|
m->setData(0, Qt::UserRole, name);
|
|
|
|
}
|
|
|
|
|
2015-08-01 19:09:10 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMDataBase::ReadSettings()
|
|
|
|
{
|
|
|
|
restoreGeometry(qApp->TapeSettings()->GetDataBaseGeometry());
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMDataBase::WriteSettings()
|
|
|
|
{
|
|
|
|
qApp->TapeSettings()->SetDataBaseGeometry(saveGeometry());
|
|
|
|
}
|
2015-08-08 16:33:37 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMDataBase::RetranslateGroup(QTreeWidgetItem *group, const QString &groupText, const QStringList &list)
|
|
|
|
{
|
|
|
|
group->setText(0, groupText);
|
|
|
|
group->setToolTip(0, groupText);
|
|
|
|
|
|
|
|
for (int i=0; i<list.size(); ++i)
|
|
|
|
{
|
|
|
|
RetranslateMeasurement(group, i, list.at(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMDataBase::RetranslateMeasurement(QTreeWidgetItem *group, int index, const QString &name)
|
|
|
|
{
|
|
|
|
const QString text = qApp->TrVars()->MNumber(name) + ". " + qApp->TrVars()->MToUser(name);
|
|
|
|
|
|
|
|
QTreeWidgetItem *m = group->child(index);
|
|
|
|
m->setText(0, text);
|
|
|
|
m->setToolTip(0, text);
|
|
|
|
}
|
2015-11-12 11:47:00 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMDataBase::ChangeCheckState(QTreeWidgetItem *group, Qt::CheckState check)
|
|
|
|
{
|
|
|
|
SCASSERT(group != nullptr)
|
|
|
|
group->setCheckState(0, check);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Qt::CheckState DialogMDataBase::GlobalCheckState() const
|
|
|
|
{
|
|
|
|
SCASSERT(groupA != nullptr)
|
|
|
|
SCASSERT(groupB != nullptr)
|
|
|
|
SCASSERT(groupC != nullptr)
|
|
|
|
SCASSERT(groupD != nullptr)
|
|
|
|
SCASSERT(groupE != nullptr)
|
|
|
|
SCASSERT(groupF != nullptr)
|
|
|
|
SCASSERT(groupG != nullptr)
|
|
|
|
SCASSERT(groupH != nullptr)
|
|
|
|
SCASSERT(groupI != nullptr)
|
|
|
|
SCASSERT(groupJ != nullptr)
|
|
|
|
SCASSERT(groupK != nullptr)
|
|
|
|
SCASSERT(groupL != nullptr)
|
|
|
|
SCASSERT(groupM != nullptr)
|
|
|
|
SCASSERT(groupN != nullptr)
|
|
|
|
SCASSERT(groupO != nullptr)
|
|
|
|
SCASSERT(groupP != nullptr)
|
|
|
|
SCASSERT(groupQ != nullptr)
|
|
|
|
|
|
|
|
if (selectMode)
|
|
|
|
{
|
|
|
|
if (groupA->checkState(0) == Qt::Unchecked &&
|
|
|
|
groupB->checkState(0) == Qt::Unchecked &&
|
|
|
|
groupC->checkState(0) == Qt::Unchecked &&
|
|
|
|
groupD->checkState(0) == Qt::Unchecked &&
|
|
|
|
groupE->checkState(0) == Qt::Unchecked &&
|
|
|
|
groupF->checkState(0) == Qt::Unchecked &&
|
|
|
|
groupG->checkState(0) == Qt::Unchecked &&
|
|
|
|
groupH->checkState(0) == Qt::Unchecked &&
|
|
|
|
groupI->checkState(0) == Qt::Unchecked &&
|
|
|
|
groupJ->checkState(0) == Qt::Unchecked &&
|
|
|
|
groupK->checkState(0) == Qt::Unchecked &&
|
|
|
|
groupL->checkState(0) == Qt::Unchecked &&
|
|
|
|
groupM->checkState(0) == Qt::Unchecked &&
|
|
|
|
groupN->checkState(0) == Qt::Unchecked &&
|
|
|
|
groupO->checkState(0) == Qt::Unchecked &&
|
|
|
|
groupP->checkState(0) == Qt::Unchecked &&
|
|
|
|
groupQ->checkState(0) == Qt::Unchecked)
|
|
|
|
{
|
|
|
|
return Qt::Checked;
|
|
|
|
}
|
|
|
|
else if (groupA->checkState(0) == Qt::Checked &&
|
|
|
|
groupB->checkState(0) == Qt::Checked &&
|
|
|
|
groupC->checkState(0) == Qt::Checked &&
|
|
|
|
groupD->checkState(0) == Qt::Checked &&
|
|
|
|
groupE->checkState(0) == Qt::Checked &&
|
|
|
|
groupF->checkState(0) == Qt::Checked &&
|
|
|
|
groupG->checkState(0) == Qt::Checked &&
|
|
|
|
groupH->checkState(0) == Qt::Checked &&
|
|
|
|
groupI->checkState(0) == Qt::Checked &&
|
|
|
|
groupJ->checkState(0) == Qt::Checked &&
|
|
|
|
groupK->checkState(0) == Qt::Checked &&
|
|
|
|
groupL->checkState(0) == Qt::Checked &&
|
|
|
|
groupM->checkState(0) == Qt::Checked &&
|
|
|
|
groupN->checkState(0) == Qt::Checked &&
|
|
|
|
groupO->checkState(0) == Qt::Checked &&
|
|
|
|
groupP->checkState(0) == Qt::Checked &&
|
|
|
|
groupQ->checkState(0) == Qt::Checked)
|
|
|
|
{
|
|
|
|
return Qt::Unchecked;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return Qt::Checked;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Qt::Unchecked;
|
|
|
|
}
|