Merge with develop.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-05-17 13:25:33 +03:00
commit b377042125
5 changed files with 100 additions and 27 deletions

View File

@ -21,6 +21,7 @@
- [#385] Add 'Open Recent' option in Tape.exe, 'File' dropdown menu. - [#385] Add 'Open Recent' option in Tape.exe, 'File' dropdown menu.
- [#471] Add a 'Show/Hide' button for measurement diagram in Tape. - [#471] Add a 'Show/Hide' button for measurement diagram in Tape.
- [#478] Rename 'Print preview tiled' to 'Preview Tiled PDF'. - [#478] Rename 'Print preview tiled' to 'Preview Tiled PDF'.
- [#472] Add 'Full Name' column to Formula dialog.
# Version 0.4.5 # Version 0.4.5
- [#435] Valentina doesn't change the cursor. - [#435] Valentina doesn't change the cursor.

View File

@ -31,6 +31,8 @@
#include "../../../vpatterndb/vcontainer.h" #include "../../../vpatterndb/vcontainer.h"
#include "../../../vpatterndb/vtranslatevars.h" #include "../../../vpatterndb/vtranslatevars.h"
enum {ColumnName = 0, ColumnFullName};
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogEditWrongFormula), formula(QString()), formulaBaseHeight(0), :DialogTool(data, toolId, parent), ui(new Ui::DialogEditWrongFormula), formula(QString()), formulaBaseHeight(0),
@ -47,7 +49,7 @@ DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const qui
CheckState(); CheckState();
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogEditWrongFormula::PutHere); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogEditWrongFormula::PutHere);
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogEditWrongFormula::PutVal); connect(ui->tableWidget, &QTableWidget::itemDoubleClicked, this, &DialogEditWrongFormula::PutVal);
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogEditWrongFormula::FormulaChanged); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogEditWrongFormula::FormulaChanged);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogEditWrongFormula::DeployFormulaTextEdit); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogEditWrongFormula::DeployFormulaTextEdit);
@ -63,6 +65,10 @@ DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const qui
} }
} }
#endif #endif
ui->tableWidget->setColumnCount(2);
ui->tableWidget->setEditTriggers(QTableWidget::NoEditTriggers);
ui->tableWidget->verticalHeader()->hide();
ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -109,17 +115,17 @@ void DialogEditWrongFormula::EvalFormula()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief ValChenged show description when current variable changed * @brief ValChanged show description when current variable changed
* @param row number of row * @param row number of row
*/ */
void DialogEditWrongFormula::ValChenged(int row) void DialogEditWrongFormula::ValChanged(int row)
{ {
if (ui->listWidget->count() == 0) if (ui->tableWidget->rowCount() == 0)
{ {
ui->labelDescription->setText(""); ui->labelDescription->setText("");
return; return;
} }
QListWidgetItem *item = ui->listWidget->item( row ); QTableWidgetItem *item = ui->tableWidget->item( row, ColumnName );
if (ui->radioButtonStandardTable->isChecked()) if (ui->radioButtonStandardTable->isChecked())
{ {
const QString name = qApp->TrVars()->VarFromUser(item->text()); const QString name = qApp->TrVars()->VarFromUser(item->text());
@ -178,11 +184,11 @@ void DialogEditWrongFormula::ValChenged(int row)
*/ */
void DialogEditWrongFormula::PutHere() void DialogEditWrongFormula::PutHere()
{ {
const QListWidgetItem *item = ui->listWidget->currentItem(); const QTableWidgetItem *item = ui->tableWidget->currentItem();
if (item != nullptr) if (item != nullptr)
{ {
QTextCursor cursor = ui->plainTextEditFormula->textCursor(); QTextCursor cursor = ui->plainTextEditFormula->textCursor();
cursor.insertText(item->text()); cursor.insertText(ui->tableWidget->item(item->row(), ColumnName)->text());
ui->plainTextEditFormula->setTextCursor(cursor); ui->plainTextEditFormula->setTextCursor(cursor);
ui->plainTextEditFormula->setFocus(); ui->plainTextEditFormula->setFocus();
} }
@ -191,13 +197,13 @@ void DialogEditWrongFormula::PutHere()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief PutVal put variable into edit * @brief PutVal put variable into edit
* @param item chosen item of list widget * @param item chosen item of table widget
*/ */
void DialogEditWrongFormula::PutVal(QListWidgetItem *item) void DialogEditWrongFormula::PutVal(QTableWidgetItem *item)
{ {
SCASSERT(item != nullptr); SCASSERT(item != nullptr);
QTextCursor cursor = ui->plainTextEditFormula->textCursor(); QTextCursor cursor = ui->plainTextEditFormula->textCursor();
cursor.insertText(item->text()); cursor.insertText(ui->tableWidget->item(item->row(), ColumnName)->text());
ui->plainTextEditFormula->setTextCursor(cursor); ui->plainTextEditFormula->setTextCursor(cursor);
} }
@ -208,7 +214,7 @@ void DialogEditWrongFormula::PutVal(QListWidgetItem *item)
void DialogEditWrongFormula::Measurements() void DialogEditWrongFormula::Measurements()
{ {
ui->checkBoxHideEmpty->setEnabled(true); ui->checkBoxHideEmpty->setEnabled(true);
ShowVariable(data->DataMeasurements()); ShowMeasurements(data->DataMeasurements());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -324,7 +330,7 @@ QString DialogEditWrongFormula::GetFormula() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::InitVariables() void DialogEditWrongFormula::InitVariables()
{ {
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogEditWrongFormula::ValChenged); connect(ui->tableWidget, &QTableWidget::currentCellChanged, this, &DialogEditWrongFormula::ValChanged);
ui->radioButtonStandardTable->setChecked(true); ui->radioButtonStandardTable->setChecked(true);
Measurements(); Measurements();
@ -355,8 +361,10 @@ void DialogEditWrongFormula::SetDescription(const QString &name, qreal value, co
template <class key, class val> template <class key, class val>
void DialogEditWrongFormula::ShowVariable(const QMap<key, val> &var) void DialogEditWrongFormula::ShowVariable(const QMap<key, val> &var)
{ {
ui->listWidget->blockSignals(true); ui->tableWidget->blockSignals(true);
ui->listWidget->clear(); ui->tableWidget->clearContents();
ui->tableWidget->setRowCount(0);
ui->tableWidget->setColumnHidden(ColumnFullName, true);
ui->labelDescription->setText(""); ui->labelDescription->setText("");
QMapIterator<key, val> iMap(var); QMapIterator<key, val> iMap(var);
@ -369,11 +377,62 @@ void DialogEditWrongFormula::ShowVariable(const QMap<key, val> &var)
} }
if (iMap.value()->Filter(toolId) == false) if (iMap.value()->Filter(toolId) == false)
{// If we create this variable don't show {// If we create this variable don't show
QListWidgetItem *item = new QListWidgetItem(iMap.key()); ui->tableWidget->setRowCount(ui->tableWidget->rowCount() + 1);
QTableWidgetItem *item = new QTableWidgetItem(iMap.key());
item->setFont(QFont("Times", 12, QFont::Bold)); item->setFont(QFont("Times", 12, QFont::Bold));
ui->listWidget->addItem(item); ui->tableWidget->setItem(ui->tableWidget->rowCount()-1, ColumnName, item);
} }
} }
ui->listWidget->blockSignals(false); ui->tableWidget->blockSignals(false);
ui->listWidget->setCurrentRow (0); ui->tableWidget->selectRow(0);
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowMeasurements show measurements in table
* @param var container with measurements
*/
void DialogEditWrongFormula::ShowMeasurements(const QMap<QString, QSharedPointer<VMeasurement> > &var)
{
ui->tableWidget->blockSignals(true);
ui->tableWidget->clearContents();
ui->tableWidget->setRowCount(0);
ui->tableWidget->setColumnHidden(ColumnFullName, false);
ui->labelDescription->setText("");
QMapIterator<QString, QSharedPointer<VMeasurement>> iMap(var);
while (iMap.hasNext())
{
iMap.next();
if (ui->checkBoxHideEmpty->isEnabled() && ui->checkBoxHideEmpty->isChecked() && iMap.value()->IsNotUsed())
{
continue; //skip this measurement
}
if (iMap.value()->Filter(toolId) == false)
{// If we create this variable don't show
ui->tableWidget->setRowCount(ui->tableWidget->rowCount() + 1);
QTableWidgetItem *itemName = new QTableWidgetItem(iMap.key());
itemName->setFont(QFont("Times", 12, QFont::Bold));
itemName->setToolTip(itemName->text());
QTableWidgetItem *itemFullName = new QTableWidgetItem();
itemFullName->setFont(QFont("Times", 12, QFont::Bold));
if (iMap.value()->IsCustom())
{
itemFullName->setText(iMap.value()->GetGuiText());
}
else
{
itemFullName->setText(qApp->TrVars()->GuiText(iMap.value()->GetName()));
}
itemFullName->setToolTip(itemFullName->text());
ui->tableWidget->setItem(ui->tableWidget->rowCount()-1, ColumnName, itemName);
ui->tableWidget->setItem(ui->tableWidget->rowCount()-1, ColumnFullName, itemFullName);
}
}
ui->tableWidget->blockSignals(false);
ui->tableWidget->selectRow(0);
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
} }

View File

@ -30,6 +30,7 @@
#define DIALOGEDITWRONGFORMULA_H #define DIALOGEDITWRONGFORMULA_H
#include "../tools/dialogtool.h" #include "../tools/dialogtool.h"
#include <QTableWidgetItem>
namespace Ui namespace Ui
{ {
@ -63,9 +64,9 @@ public slots:
*/ */
void DeployFormulaTextEdit(); void DeployFormulaTextEdit();
virtual void EvalFormula() Q_DECL_OVERRIDE; virtual void EvalFormula() Q_DECL_OVERRIDE;
void ValChenged(int row); void ValChanged(int row);
void PutHere(); void PutHere();
void PutVal(QListWidgetItem * item); void PutVal(QTableWidgetItem * item);
void Measurements(); void Measurements();
void LengthLines(); void LengthLines();
@ -96,6 +97,7 @@ private:
template <class key, class val> template <class key, class val>
void ShowVariable(const QMap<key, val> &var); void ShowVariable(const QMap<key, val> &var);
void ShowMeasurements(const QMap<QString, QSharedPointer<VMeasurement> > &var);
void SetDescription(const QString &name, qreal value, const QString &unit, const QString &description); void SetDescription(const QString &name, qreal value, const QString &unit, const QString &description);
}; };

View File

@ -192,8 +192,7 @@
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="go-down"> <iconset theme="go-down">
<normaloff/> <normaloff>.</normaloff>.</iconset>
</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
@ -347,10 +346,23 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QListWidget" name="listWidget"> <widget class="QTableWidget" name="tableWidget">
<property name="toolTip"> <property name="minimumSize">
<string>Double click for add to formula</string> <size>
<width>0</width>
<height>0</height>
</size>
</property> </property>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Full name</string>
</property>
</column>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -389,7 +401,6 @@
<tabstop>radioButtonLengthSpline</tabstop> <tabstop>radioButtonLengthSpline</tabstop>
<tabstop>radioButtonAngleLine</tabstop> <tabstop>radioButtonAngleLine</tabstop>
<tabstop>checkBoxHideEmpty</tabstop> <tabstop>checkBoxHideEmpty</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>buttonBox</tabstop> <tabstop>buttonBox</tabstop>
</tabstops> </tabstops>
<resources> <resources>