Almost implemented dialog standard measurements.
--HG-- branch : feature
This commit is contained in:
parent
fc427a04c4
commit
41c80d040f
|
@ -28,15 +28,108 @@
|
|||
|
||||
#include "dialogstandardmeasurements.h"
|
||||
#include "ui_dialogstandardmeasurements.h"
|
||||
#include <QDir>
|
||||
|
||||
DialogStandardMeasurements::DialogStandardMeasurements(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DialogStandardMeasurements)
|
||||
QDialog(parent), ui(new Ui::DialogStandardMeasurements), _name(QString()), _tablePath(QString())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
{
|
||||
const QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||
Q_CHECK_PTR(bOk);
|
||||
connect(bOk, &QPushButton::clicked, this, &DialogStandardMeasurements::Accepted);
|
||||
}
|
||||
{
|
||||
const QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
|
||||
Q_CHECK_PTR(bCansel);
|
||||
connect(bCansel, &QPushButton::clicked, this, &DialogStandardMeasurements::Rejected);
|
||||
}
|
||||
|
||||
LoadStandardTables();
|
||||
|
||||
CheckState();
|
||||
}
|
||||
|
||||
DialogStandardMeasurements::~DialogStandardMeasurements()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QString DialogStandardMeasurements::name() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
QString DialogStandardMeasurements::tablePath() const
|
||||
{
|
||||
return _tablePath;
|
||||
}
|
||||
|
||||
void DialogStandardMeasurements::Accepted()
|
||||
{
|
||||
_name = ui->lineEditName->text();
|
||||
_tablePath = "path";
|
||||
accept();
|
||||
}
|
||||
|
||||
void DialogStandardMeasurements::Rejected()
|
||||
{
|
||||
_name = "";
|
||||
_tablePath = "";
|
||||
reject();
|
||||
}
|
||||
|
||||
void DialogStandardMeasurements::CheckState()
|
||||
{
|
||||
bool flagName = false;
|
||||
if (ui->lineEditName->text().isEmpty() == false)
|
||||
{
|
||||
flagName = true;
|
||||
}
|
||||
|
||||
bool flagTable = false;
|
||||
{
|
||||
const QComboBox *box = ui->comboBoxTables;
|
||||
Q_CHECK_PTR(box);
|
||||
if (box->count() > 0 && box->currentIndex() != -1)
|
||||
{
|
||||
flagTable = true;
|
||||
}
|
||||
}
|
||||
|
||||
QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||
Q_CHECK_PTR(bOk);
|
||||
bOk->setEnabled(flagTable && flagName);
|
||||
}
|
||||
|
||||
void DialogStandardMeasurements::LoadStandardTables()
|
||||
{
|
||||
#ifdef Q_OS_WIN32
|
||||
const QString pathToTables = QString("/standard_tables");
|
||||
#else
|
||||
#ifdef QT_DEBUG
|
||||
const QString pathToTables = QString("/standard_tables");
|
||||
#else
|
||||
const QString pathToTables = QString("/usr/share/valentina/standard_tables");
|
||||
#endif
|
||||
#endif
|
||||
QDir tablesDir(pathToTables);
|
||||
{
|
||||
QStringList filters;
|
||||
filters << "*.cpp";
|
||||
tablesDir.setNameFilters(filters);
|
||||
}
|
||||
const QStringList allFiles = tablesDir.entryList(QDir::NoDotAndDotDot | QDir::Files);
|
||||
if (allFiles.isEmpty() == true)
|
||||
{
|
||||
ui->comboBoxTables->clear();
|
||||
CheckState();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < allFiles.size(); ++i)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,13 +38,20 @@ class DialogStandardMeasurements;
|
|||
class DialogStandardMeasurements : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DialogStandardMeasurements(QWidget *parent = 0);
|
||||
~DialogStandardMeasurements();
|
||||
|
||||
QString name() const;
|
||||
QString tablePath() const;
|
||||
private:
|
||||
Q_DISABLE_COPY(DialogStandardMeasurements)
|
||||
Ui::DialogStandardMeasurements *ui;
|
||||
QString _name;
|
||||
QString _tablePath;
|
||||
void Accepted();
|
||||
void Rejected();
|
||||
void CheckState();
|
||||
void LoadStandardTables();
|
||||
};
|
||||
|
||||
#endif // DIALOGSTANDARDMEASUREMENTS_H
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
<widget class="QLineEdit" name="lineEditName"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
@ -53,7 +53,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox"/>
|
||||
<widget class="QComboBox" name="comboBoxTables"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
|
Loading…
Reference in New Issue
Block a user