Gradation fields.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-07-21 16:18:10 +03:00
parent 1506acf581
commit 08d46c1809
3 changed files with 120 additions and 1 deletions

View File

@ -35,6 +35,7 @@
#include <QFileDialog>
#include <QFileInfo>
#include <QMessageBox>
#include <QComboBox>
//---------------------------------------------------------------------------------------------------------------------
TMainWindow::TMainWindow(QWidget *parent)
@ -44,11 +45,17 @@ TMainWindow::TMainWindow(QWidget *parent)
data(nullptr),
mUnit(Unit::Cm),
mType(MeasurementsType::Individual),
curFile()
curFile(),
gradationHeights(nullptr),
gradationSizes(nullptr)
{
ui->setupUi(this);
ui->tabWidget->setVisible(false);
ui->mainToolBar->setContextMenuPolicy(Qt::PreventContextMenu);
ui->toolBarGradation->setContextMenuPolicy(Qt::PreventContextMenu);
ui->toolBarGradation->setVisible(false);
SetupMenu();
setWindowTitle(tr("untitled"));
@ -84,6 +91,8 @@ void TMainWindow::FileNew()
mType = measurements.Type();
data = new VContainer(qApp->TrVars(), &mUnit);
data->SetHeight(measurements.BaseHeight());
data->SetSize(measurements.BaseSize());
if (mType == MeasurementsType::Standard)
{
@ -397,6 +406,20 @@ void TMainWindow::AddKnown()
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::ChangedSize(const QString &text)
{
data->SetSize(text.toInt());
RefreshData();
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::ChangedHeight(const QString &text)
{
data->SetHeight(text.toInt());
RefreshData();
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SetupMenu()
{
@ -468,6 +491,20 @@ void TMainWindow::InitWindow()
delete ui->comboBoxSex;
delete ui->labelEmail;
delete ui->lineEditEmail;
ui->toolBarGradation->setVisible(true);
const QStringList listHeights = VMeasurement::WholeListHeights(mUnit);
const QStringList listSizes = VMeasurement::WholeListSizes(mUnit);
gradationHeights = SetGradationList(tr("Height: "), listHeights);
SetDefaultHeight(static_cast<int>(data->height()));
connect(gradationHeights, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &TMainWindow::ChangedHeight);
gradationSizes = SetGradationList(tr("Size: "), listSizes);
SetDefaultSize(static_cast<int>(data->size()));
connect(gradationSizes, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &TMainWindow::ChangedSize);
}
else
{
@ -623,3 +660,49 @@ void TMainWindow::AddCell(const QString &text, int row, int column, int id)
ui->tableWidget->setItem(row, column, item);
}
//---------------------------------------------------------------------------------------------------------------------
QComboBox *TMainWindow::SetGradationList(const QString &label, const QStringList &list)
{
ui->toolBarGradation->addWidget(new QLabel(label));
QComboBox *comboBox = new QComboBox;
comboBox->addItems(list);
ui->toolBarGradation->addWidget(comboBox);
return comboBox;
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SetDefaultHeight(int value)
{
const qint32 index = gradationHeights->findText(QString("%1").arg(value));
if (index != -1)
{
gradationHeights->setCurrentIndex(index);
}
else
{
data->SetHeight(gradationHeights->currentText().toInt());
}
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SetDefaultSize(int value)
{
const qint32 index = gradationSizes->findText(QString("%1").arg(value));
if (index != -1)
{
gradationSizes->setCurrentIndex(index);
}
else
{
data->SetSize(gradationSizes->currentText().toInt());
}
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::RefreshData()
{
}

View File

@ -39,6 +39,8 @@ namespace Ui
class TMainWindow;
}
class QComboBox;
class TMainWindow : public QMainWindow
{
Q_OBJECT
@ -71,6 +73,9 @@ private slots:
void AddCustom();
void AddKnown();
void ChangedSize(const QString &text);
void ChangedHeight(const QString & text);
private:
Q_DISABLE_COPY(TMainWindow)
Ui::TMainWindow *ui;
@ -79,6 +84,8 @@ private:
Unit mUnit;
MeasurementsType mType;
QString curFile;
QComboBox *gradationHeights;
QComboBox *gradationSizes;
void SetupMenu();
void InitWindow();
@ -91,6 +98,12 @@ private:
bool MaybeSave();
void AddCell(const QString &text, int row, int column, int id = -1);
QComboBox *SetGradationList(const QString &label, const QStringList &list);
void SetDefaultHeight(int value);
void SetDefaultSize(int value);
void RefreshData();
};
#endif // TMAINWINDOW_H

View File

@ -602,6 +602,9 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="windowTitle">
<string>Menu</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
@ -619,6 +622,26 @@
<addaction name="actionReadOnly"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<widget class="QToolBar" name="toolBarGradation">
<property name="windowTitle">
<string>Gradation</string>
</property>
<property name="movable">
<bool>false</bool>
</property>
<property name="allowedAreas">
<set>Qt::AllToolBarAreas</set>
</property>
<property name="floatable">
<bool>false</bool>
</property>
<attribute name="toolBarArea">
<enum>BottomToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<action name="actionOpen">
<property name="icon">
<iconset theme="document-open">