Resolved issue #376. Add buttons in Tape.exe to move measurement to top or

bottom of list.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-10-12 17:57:11 +03:00
parent c2e563a65c
commit 3b4c4e8261
12 changed files with 122 additions and 0 deletions

View File

@ -731,6 +731,24 @@ void TMainWindow::Remove()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::MoveTop()
{
const int row = ui->tableWidget->currentRow();
if (row == -1)
{
return;
}
const QTableWidgetItem *nameField = ui->tableWidget->item(row, ColumnName);
m->MoveTop(nameField->data(Qt::UserRole).toString());
MeasurementsWasSaved(false);
RefreshData();
search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->selectRow(0);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::MoveUp() void TMainWindow::MoveUp()
{ {
@ -767,6 +785,24 @@ void TMainWindow::MoveDown()
ui->tableWidget->selectRow(row+1); ui->tableWidget->selectRow(row+1);
} }
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::MoveBottom()
{
const int row = ui->tableWidget->currentRow();
if (row == -1)
{
return;
}
const QTableWidgetItem *nameField = ui->tableWidget->item(row, ColumnName);
m->MoveBottom(nameField->data(Qt::UserRole).toString());
MeasurementsWasSaved(false);
RefreshData();
search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->selectRow(ui->tableWidget->rowCount()-1);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::Fx() void TMainWindow::Fx()
{ {
@ -1712,8 +1748,10 @@ void TMainWindow::InitWindow()
#endif #endif
connect(ui->toolButtonRemove, &QToolButton::clicked, this, &TMainWindow::Remove); connect(ui->toolButtonRemove, &QToolButton::clicked, this, &TMainWindow::Remove);
connect(ui->toolButtonTop, &QToolButton::clicked, this, &TMainWindow::MoveTop);
connect(ui->toolButtonUp, &QToolButton::clicked, this, &TMainWindow::MoveUp); connect(ui->toolButtonUp, &QToolButton::clicked, this, &TMainWindow::MoveUp);
connect(ui->toolButtonDown, &QToolButton::clicked, this, &TMainWindow::MoveDown); connect(ui->toolButtonDown, &QToolButton::clicked, this, &TMainWindow::MoveDown);
connect(ui->toolButtonBottom, &QToolButton::clicked, this, &TMainWindow::MoveBottom);
connect(ui->lineEditName, &QLineEdit::editingFinished, this, &TMainWindow::SaveMName); connect(ui->lineEditName, &QLineEdit::editingFinished, this, &TMainWindow::SaveMName);
connect(ui->plainTextEditDescription, &QPlainTextEdit::textChanged, this, &TMainWindow::SaveMDescription); connect(ui->plainTextEditDescription, &QPlainTextEdit::textChanged, this, &TMainWindow::SaveMDescription);
@ -2020,8 +2058,10 @@ void TMainWindow::Controls()
if (m->ReadOnly()) if (m->ReadOnly())
{ {
ui->toolButtonRemove->setEnabled(false); ui->toolButtonRemove->setEnabled(false);
ui->toolButtonTop->setEnabled(false);
ui->toolButtonUp->setEnabled(false); ui->toolButtonUp->setEnabled(false);
ui->toolButtonDown->setEnabled(false); ui->toolButtonDown->setEnabled(false);
ui->toolButtonBottom->setEnabled(false);
return; return;
} }
@ -2038,24 +2078,32 @@ void TMainWindow::Controls()
{ {
if (ui->tableWidget->currentRow() == 0) if (ui->tableWidget->currentRow() == 0)
{ {
ui->toolButtonTop->setEnabled(false);
ui->toolButtonUp->setEnabled(false); ui->toolButtonUp->setEnabled(false);
ui->toolButtonDown->setEnabled(true); ui->toolButtonDown->setEnabled(true);
ui->toolButtonBottom->setEnabled(true);
} }
else if (ui->tableWidget->currentRow() == ui->tableWidget->rowCount()-1) else if (ui->tableWidget->currentRow() == ui->tableWidget->rowCount()-1)
{ {
ui->toolButtonTop->setEnabled(true);
ui->toolButtonUp->setEnabled(true); ui->toolButtonUp->setEnabled(true);
ui->toolButtonDown->setEnabled(false); ui->toolButtonDown->setEnabled(false);
ui->toolButtonBottom->setEnabled(false);
} }
else else
{ {
ui->toolButtonTop->setEnabled(true);
ui->toolButtonUp->setEnabled(true); ui->toolButtonUp->setEnabled(true);
ui->toolButtonDown->setEnabled(true); ui->toolButtonDown->setEnabled(true);
ui->toolButtonBottom->setEnabled(true);
} }
} }
else else
{ {
ui->toolButtonTop->setEnabled(false);
ui->toolButtonUp->setEnabled(false); ui->toolButtonUp->setEnabled(false);
ui->toolButtonDown->setEnabled(false); ui->toolButtonDown->setEnabled(false);
ui->toolButtonBottom->setEnabled(false);
} }
} }

View File

@ -89,8 +89,10 @@ private slots:
void ReadOnly(bool ro); void ReadOnly(bool ro);
void Remove(); void Remove();
void MoveTop();
void MoveUp(); void MoveUp();
void MoveDown(); void MoveDown();
void MoveBottom();
void Fx(); void Fx();
void AddCustom(); void AddCustom();

View File

@ -326,6 +326,19 @@
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="toolButtonTop">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="go-top"/>
</property>
</widget>
</item>
<item alignment="Qt::AlignLeft"> <item alignment="Qt::AlignLeft">
<widget class="QToolButton" name="toolButtonUp"> <widget class="QToolButton" name="toolButtonUp">
<property name="enabled"> <property name="enabled">
@ -362,6 +375,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QToolButton" name="toolButtonBottom">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="go-bottom"/>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">

View File

@ -137,6 +137,25 @@ void VMeasurements::Remove(const QString &name)
list.at(0).removeChild(FindM(name)); list.at(0).removeChild(FindM(name));
} }
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::MoveTop(const QString &name)
{
const QDomElement node = FindM(name);
if (not node.isNull())
{
const QDomNodeList mList = elementsByTagName(TagMeasurement);
if (mList.size() >= 2)
{
const QDomNode top = mList.at(0);
if (not top.isNull())
{
const QDomNodeList list = elementsByTagName(TagBodyMeasurements);
list.at(0).insertBefore(node, top);
}
}
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VMeasurements::MoveUp(const QString &name) void VMeasurements::MoveUp(const QString &name)
{ {
@ -167,6 +186,25 @@ void VMeasurements::MoveDown(const QString &name)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::MoveBottom(const QString &name)
{
const QDomElement node = FindM(name);
if (not node.isNull())
{
const QDomNodeList mList = elementsByTagName(TagMeasurement);
if (mList.size() >= 2)
{
const QDomNode bottom = mList.at(mList.size()-1);
if (not bottom.isNull())
{
const QDomNodeList list = elementsByTagName(TagBodyMeasurements);
list.at(0).insertAfter(node, bottom);
}
}
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VMeasurements::ReadMeasurements() const void VMeasurements::ReadMeasurements() const
{ {

View File

@ -48,8 +48,10 @@ public:
void AddEmpty(const QString &name, const QString &formula = QString()); void AddEmpty(const QString &name, const QString &formula = QString());
void AddEmptyAfter(const QString &after, const QString &name, const QString &formula = QString()); void AddEmptyAfter(const QString &after, const QString &name, const QString &formula = QString());
void Remove(const QString &name); void Remove(const QString &name);
void MoveTop(const QString &name);
void MoveUp(const QString &name); void MoveUp(const QString &name);
void MoveDown(const QString &name); void MoveDown(const QString &name);
void MoveBottom(const QString &name);
void ReadMeasurements() const; void ReadMeasurements() const;

Binary file not shown.

After

Width:  |  Height:  |  Size: 804 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -71,5 +71,11 @@
<file>icons/win.icon.theme/16x16/actions/go-up.png</file> <file>icons/win.icon.theme/16x16/actions/go-up.png</file>
<file>icons/win.icon.theme/24x24/actions/go-up.png</file> <file>icons/win.icon.theme/24x24/actions/go-up.png</file>
<file>icons/win.icon.theme/32x32/actions/go-up.png</file> <file>icons/win.icon.theme/32x32/actions/go-up.png</file>
<file>icons/win.icon.theme/16x16/actions/go-top.png</file>
<file>icons/win.icon.theme/24x24/actions/go-top.png</file>
<file>icons/win.icon.theme/32x32/actions/go-top.png</file>
<file>icons/win.icon.theme/16x16/actions/go-bottom.png</file>
<file>icons/win.icon.theme/24x24/actions/go-bottom.png</file>
<file>icons/win.icon.theme/32x32/actions/go-bottom.png</file>
</qresource> </qresource>
</RCC> </RCC>