Additional controls to cover issue with Internal move. ref #824.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-03-23 11:16:23 +02:00
parent 2cb7c4c603
commit 3d8cdb6630
10 changed files with 317 additions and 15 deletions

View File

@ -717,6 +717,62 @@ void DialogTool::InitNodeAngles(QComboBox *box)
box->addItem(tr("by second edge right angle"), static_cast<unsigned char>(PieceNodeAngle::BySecondEdgeRightAngle)); box->addItem(tr("by second edge right angle"), static_cast<unsigned char>(PieceNodeAngle::BySecondEdgeRightAngle));
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogTool::MoveListRowTop(QListWidget *list)
{
SCASSERT(list != nullptr)
const int currentIndex = list->currentRow();
if (QListWidgetItem *currentItem = list->takeItem(currentIndex))
{
list->insertItem(0, currentItem);
list->setCurrentRow(0);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogTool::MoveListRowUp(QListWidget *list)
{
SCASSERT(list != nullptr)
int currentIndex = list->currentRow();
if (QListWidgetItem *currentItem = list->takeItem(currentIndex--))
{
if (currentIndex < 0)
{
currentIndex = 0;
}
list->insertItem(currentIndex, currentItem);
list->setCurrentRow(currentIndex);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogTool::MoveListRowDown(QListWidget *list)
{
SCASSERT(list != nullptr)
int currentIndex = list->currentRow();
if (QListWidgetItem *currentItem = list->takeItem(currentIndex++))
{
if (currentIndex > list->count())
{
currentIndex = list->count();
}
list->insertItem(currentIndex, currentItem);
list->setCurrentRow(currentIndex);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogTool::MoveListRowBottom(QListWidget *list)
{
SCASSERT(list != nullptr)
const int currentIndex = list->currentRow();
if (QListWidgetItem *currentItem = list->takeItem(currentIndex))
{
list->insertItem(list->count(), currentItem);
list->setCurrentRow(list->count()-1);
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool DialogTool::IsSplinePath(const QSharedPointer<VGObject> &obj) const bool DialogTool::IsSplinePath(const QSharedPointer<VGObject> &obj) const
{ {

View File

@ -282,6 +282,11 @@ protected:
void NewNodeItem(QListWidget *listWidget, const VPieceNode &node); void NewNodeItem(QListWidget *listWidget, const VPieceNode &node);
void InitNodeAngles(QComboBox *box); void InitNodeAngles(QComboBox *box);
void MoveListRowTop(QListWidget *list);
void MoveListRowUp(QListWidget *list);
void MoveListRowDown(QListWidget *list);
void MoveListRowBottom(QListWidget *list);
private: private:
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const; void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;

View File

@ -346,6 +346,7 @@ void DialogPiecePath::ListChanged()
InitPassmarksList(); InitPassmarksList();
InitNodesList(); InitNodesList();
SetMoveControls();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -833,6 +834,36 @@ void DialogPiecePath::DeployVisibleFormulaTextEdit()
DeployFormula(ui->plainTextEditFormulaVisible, ui->pushButtonGrowVisible, m_formulaBaseVisible); DeployFormula(ui->plainTextEditFormulaVisible, ui->pushButtonGrowVisible, m_formulaBaseVisible);
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::SetMoveControls()
{
ui->toolButtonTop->setEnabled(false);
ui->toolButtonUp->setEnabled(false);
ui->toolButtonDown->setEnabled(false);
ui->toolButtonBottom->setEnabled(false);
if (ui->listWidget->count() >= 2)
{
if (ui->listWidget->currentRow() == 0)
{
ui->toolButtonDown->setEnabled(true);
ui->toolButtonBottom->setEnabled(true);
}
else if (ui->listWidget->currentRow() == ui->listWidget->count()-1)
{
ui->toolButtonTop->setEnabled(true);
ui->toolButtonUp->setEnabled(true);
}
else
{
ui->toolButtonTop->setEnabled(true);
ui->toolButtonUp->setEnabled(true);
ui->toolButtonDown->setEnabled(true);
ui->toolButtonBottom->setEnabled(true);
}
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::InitPathTab() void DialogPiecePath::InitPathTab()
{ {
@ -853,6 +884,13 @@ void DialogPiecePath::InitPathTab()
ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu); ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->listWidget, &QListWidget::customContextMenuRequested, this, &DialogPiecePath::ShowContextMenu); connect(ui->listWidget, &QListWidget::customContextMenuRequested, this, &DialogPiecePath::ShowContextMenu);
connect(ui->listWidget->model(), &QAbstractItemModel::rowsMoved, this, &DialogPiecePath::ListChanged);
connect(ui->listWidget, &QListWidget::itemSelectionChanged, this, &DialogPiecePath::SetMoveControls);
connect(ui->toolButtonTop, &QToolButton::clicked, this, [this](){MoveListRowTop(ui->listWidget);});
connect(ui->toolButtonUp, &QToolButton::clicked, this, [this](){MoveListRowUp(ui->listWidget);});
connect(ui->toolButtonDown, &QToolButton::clicked, this, [this](){MoveListRowDown(ui->listWidget);});
connect(ui->toolButtonBottom, &QToolButton::clicked, this, [this](){MoveListRowBottom(ui->listWidget);});
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -97,6 +97,8 @@ private slots:
void DeployWidthAfterFormulaTextEdit(); void DeployWidthAfterFormulaTextEdit();
void DeployVisibleFormulaTextEdit(); void DeployVisibleFormulaTextEdit();
void SetMoveControls();
private: private:
Q_DISABLE_COPY(DialogPiecePath) Q_DISABLE_COPY(DialogPiecePath)
Ui::DialogPiecePath *ui; Ui::DialogPiecePath *ui;

View File

@ -102,6 +102,91 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QToolButton" name="toolButtonTop">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Move on top</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="go-top">
<normaloff>../../../../../app/tape</normaloff>../../../../../app/tape</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonUp">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Move up</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="go-up">
<normaloff>../../../../../app/tape</normaloff>../../../../../app/tape</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonDown">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Move down</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff>../../../../../app/tape</normaloff>../../../../../app/tape</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonBottom">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Move on bottom</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="go-bottom">
<normaloff>../../../../../app/tape</normaloff>../../../../../app/tape</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5000</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item> <item>
<widget class="QCheckBox" name="checkBoxCut"> <widget class="QCheckBox" name="checkBoxCut">
<property name="toolTip"> <property name="toolTip">

View File

@ -906,6 +906,7 @@ void DialogSeamAllowance::ListChanged()
InitNodesList(); InitNodesList();
InitPassmarksList(); InitPassmarksList();
CustomSAChanged(uiTabPaths->listWidgetCustomSA->currentRow()); CustomSAChanged(uiTabPaths->listWidgetCustomSA->currentRow());
SetMoveControls();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -2681,6 +2682,17 @@ void DialogSeamAllowance::InitMainPathTab()
&DialogSeamAllowance::ShowMainPathContextMenu); &DialogSeamAllowance::ShowMainPathContextMenu);
connect(uiTabPaths->listWidgetMainPath->model(), &QAbstractItemModel::rowsMoved, this, connect(uiTabPaths->listWidgetMainPath->model(), &QAbstractItemModel::rowsMoved, this,
&DialogSeamAllowance::ListChanged); &DialogSeamAllowance::ListChanged);
connect(uiTabPaths->listWidgetMainPath, &QListWidget::itemSelectionChanged, this,
&DialogSeamAllowance::SetMoveControls);
connect(uiTabPaths->toolButtonTop, &QToolButton::clicked, this,
[this](){MoveListRowTop(uiTabPaths->listWidgetMainPath);});
connect(uiTabPaths->toolButtonUp, &QToolButton::clicked, this,
[this](){MoveListRowUp(uiTabPaths->listWidgetMainPath);});
connect(uiTabPaths->toolButtonDown, &QToolButton::clicked, this,
[this](){MoveListRowDown(uiTabPaths->listWidgetMainPath);});
connect(uiTabPaths->toolButtonBottom, &QToolButton::clicked, this,
[this](){MoveListRowBottom(uiTabPaths->listWidgetMainPath);});
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -3301,3 +3313,33 @@ QString DialogSeamAllowance::GetDefaultPieceName() const
} }
return name; return name;
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetMoveControls()
{
uiTabPaths->toolButtonTop->setEnabled(false);
uiTabPaths->toolButtonUp->setEnabled(false);
uiTabPaths->toolButtonDown->setEnabled(false);
uiTabPaths->toolButtonBottom->setEnabled(false);
if (uiTabPaths->listWidgetMainPath->count() >= 2)
{
if (uiTabPaths->listWidgetMainPath->currentRow() == 0)
{
uiTabPaths->toolButtonDown->setEnabled(true);
uiTabPaths->toolButtonBottom->setEnabled(true);
}
else if (uiTabPaths->listWidgetMainPath->currentRow() == uiTabPaths->listWidgetMainPath->count()-1)
{
uiTabPaths->toolButtonTop->setEnabled(true);
uiTabPaths->toolButtonUp->setEnabled(true);
}
else
{
uiTabPaths->toolButtonTop->setEnabled(true);
uiTabPaths->toolButtonUp->setEnabled(true);
uiTabPaths->toolButtonDown->setEnabled(true);
uiTabPaths->toolButtonBottom->setEnabled(true);
}
}
}

View File

@ -156,6 +156,7 @@ private slots:
void PatternPinPointChanged(); void PatternPinPointChanged();
void EditLabel(); void EditLabel();
void SetMoveControls();
private: private:
Q_DISABLE_COPY(DialogSeamAllowance) Q_DISABLE_COPY(DialogSeamAllowance)

View File

@ -134,6 +134,91 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item alignment="Qt::AlignLeft">
<widget class="QToolButton" name="toolButtonTop">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Move on top</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="go-top">
<normaloff>../../../../../../app/tape</normaloff>../../../../../../app/tape</iconset>
</property>
</widget>
</item>
<item alignment="Qt::AlignLeft">
<widget class="QToolButton" name="toolButtonUp">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Move up</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="go-up">
<normaloff>../../../../../../app/tape</normaloff>../../../../../../app/tape</iconset>
</property>
</widget>
</item>
<item alignment="Qt::AlignLeft">
<widget class="QToolButton" name="toolButtonDown">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Move down</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff>../../../../../../app/tape</normaloff>../../../../../../app/tape</iconset>
</property>
</widget>
</item>
<item alignment="Qt::AlignLeft">
<widget class="QToolButton" name="toolButtonBottom">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Move on bottom</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="go-bottom">
<normaloff>../../../../../../app/tape</normaloff>../../../../../../app/tape</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5000</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item> <item>
<widget class="QLabel" name="helpLabel"> <widget class="QLabel" name="helpLabel">
<property name="text"> <property name="text">
@ -947,11 +1032,7 @@
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_7">
<item> <item>
<widget class="QListWidget" name="listWidgetInternalPaths"> <widget class="QListWidget" name="listWidgetInternalPaths"/>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>

View File

@ -19,11 +19,7 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QListWidget" name="listWidgetPins"> <widget class="QListWidget" name="listWidgetPins"/>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>

View File

@ -15,11 +15,7 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QListWidget" name="listWidgetPlaceLabels"> <widget class="QListWidget" name="listWidgetPlaceLabels"/>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>