Some updates for dialog.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-11-23 14:50:30 +02:00
parent bb39410296
commit 6793bb69f1
3 changed files with 53 additions and 4 deletions

View File

@ -74,6 +74,8 @@ enum class PieceNodeAngle : unsigned char
BySecondEdgeRightAngle BySecondEdgeRightAngle
}; };
enum class PiecePathType : unsigned char {CutomSeamAllowance, InternalPath};
typedef unsigned char ToolVisHolderType; typedef unsigned char ToolVisHolderType;
enum class Tool : ToolVisHolderType enum class Tool : ToolVisHolderType
{ {

View File

@ -42,12 +42,16 @@ DialogPiecePath::DialogPiecePath(const VContainer *data, quint32 toolId, QWidget
ui->setupUi(this); ui->setupUi(this);
InitOkCancel(ui); InitOkCancel(ui);
connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogPiecePath::NameChanged);
InitPathTypes();
connect(ui->comboBoxType, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
[this](){ValidObjects(PathIsValid());});
flagName = true;//We have default name of piece. flagName = true;//We have default name of piece.
flagError = PathIsValid(); flagError = PathIsValid();
CheckState(); CheckState();
connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogPiecePath::NameChanged);
if (not m_showMode) if (not m_showMode)
{ {
vis = new VisToolPiecePath(data); vis = new VisToolPiecePath(data);
@ -155,7 +159,7 @@ void DialogPiecePath::SaveData()
void DialogPiecePath::CheckState() void DialogPiecePath::CheckState()
{ {
SCASSERT(bOk != nullptr); SCASSERT(bOk != nullptr);
bOk->setEnabled(flagName && flagError && ui->comboBoxPiece->count() > 0); bOk->setEnabled(flagName && flagError);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -228,6 +232,13 @@ void DialogPiecePath::NameChanged()
CheckState(); CheckState();
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::InitPathTypes()
{
ui->comboBoxType->addItem(tr("Custom seam allowance"), static_cast<int>(PiecePathType::CutomSeamAllowance));
//ui->comboBoxType->addItem(tr("Internal path"), static_cast<int>(PiecePathType::InternalPath));
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPiecePath DialogPiecePath::GetPiecePath() const VPiecePath DialogPiecePath::GetPiecePath() const
{ {
@ -248,6 +259,29 @@ void DialogPiecePath::SetPiecePath(const VPiecePath &path)
ListChanged(); ListChanged();
} }
//---------------------------------------------------------------------------------------------------------------------
PiecePathType DialogPiecePath::GetType() const
{
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
const PiecePathType type =
static_cast<PiecePathType>(ui->comboBoxType->itemData(ui->comboBoxType->currentIndex()).toInt());
#else
const PiecePathType type = static_cast<PiecePathType>(ui->comboBoxType->currentData().toInt());
#endif
return type;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::SetType(PiecePathType type)
{
const qint32 index = ui->comboBoxType->findData(static_cast<int>(type));
if (index != -1)
{
ui->comboBoxType->setCurrentIndex(index);
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPiecePath DialogPiecePath::CreatePath() const VPiecePath DialogPiecePath::CreatePath() const
{ {
@ -274,7 +308,7 @@ bool DialogPiecePath::PathIsValid() const
} }
else else
{ {
if (FirstPointEqualLast(ui->listWidget)) if (GetType() == PiecePathType::CutomSeamAllowance && FirstPointEqualLast(ui->listWidget))
{ {
url += tr("First point cannot be equal to the last point!"); url += tr("First point cannot be equal to the last point!");
ui->helpLabel->setText(url); ui->helpLabel->setText(url);
@ -287,6 +321,14 @@ bool DialogPiecePath::PathIsValid() const
return false; return false;
} }
} }
if (m_showMode && ui->comboBoxPiece->count() <= 0)
{
url += tr("List of pieces is empty!");
ui->helpLabel->setText(url);
return false;
}
ui->helpLabel->setText(tr("Ready!")); ui->helpLabel->setText(tr("Ready!"));
return true; return true;
} }

View File

@ -48,6 +48,9 @@ public:
VPiecePath GetPiecePath() const; VPiecePath GetPiecePath() const;
void SetPiecePath(const VPiecePath &path); void SetPiecePath(const VPiecePath &path);
PiecePathType GetType() const;
void SetType(PiecePathType type);
public slots: public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE; virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE;
virtual void ShowDialog(bool click) Q_DECL_OVERRIDE; virtual void ShowDialog(bool click) Q_DECL_OVERRIDE;
@ -67,6 +70,8 @@ private:
Ui::DialogPiecePath *ui; Ui::DialogPiecePath *ui;
bool m_showMode; bool m_showMode;
void InitPathTypes();
VPiecePath CreatePath() const; VPiecePath CreatePath() const;
bool PathIsValid() const; bool PathIsValid() const;