93 lines
2.7 KiB
C++
93 lines
2.7 KiB
C++
|
|
#include "Curve2DKeySelcetBar.h"
|
||
|
|
#include "DataChosenListDialog.h"
|
||
|
|
#include <QModelIndexList>
|
||
|
|
|
||
|
|
namespace pst
|
||
|
|
{
|
||
|
|
|
||
|
|
Curve2DKeySelcetBar::Curve2DKeySelcetBar(QWidget* parent)
|
||
|
|
: ElaScrollArea(parent)
|
||
|
|
, m_dataChosenListDialog(nullptr)
|
||
|
|
, m_text(nullptr)
|
||
|
|
, m_lineEdit(nullptr)
|
||
|
|
, m_button(nullptr)
|
||
|
|
, m_selectedIndexs()
|
||
|
|
{
|
||
|
|
this->setObjectName("Curve2DKeySelcetBar");
|
||
|
|
this->setGeometry(0, 0, 100, 100);
|
||
|
|
auto layout = new QHBoxLayout(this);
|
||
|
|
m_text = new ElaText(this);
|
||
|
|
m_lineEdit = new ElaLineEdit(this);
|
||
|
|
//m_lineEdit->setText(" ");
|
||
|
|
m_lineEdit->setEnabled(false);
|
||
|
|
m_button = new ElaPushButton("...");
|
||
|
|
layout->addWidget(m_text);
|
||
|
|
layout->addWidget(m_lineEdit);
|
||
|
|
//layout->addStretch();
|
||
|
|
layout->addWidget(m_button);
|
||
|
|
|
||
|
|
connect(m_button, &ElaPushButton::clicked, this,
|
||
|
|
&Curve2DKeySelcetBar::slot_selectDataButtonClicked);
|
||
|
|
}
|
||
|
|
|
||
|
|
void Curve2DKeySelcetBar::setData(
|
||
|
|
const QString& keyName, const QList<double>& values)
|
||
|
|
{
|
||
|
|
m_text->setText(keyName);
|
||
|
|
m_values = values;
|
||
|
|
}
|
||
|
|
|
||
|
|
QList<int> Curve2DKeySelcetBar::getSelectedIndex()
|
||
|
|
{
|
||
|
|
return m_selectedIndexs;
|
||
|
|
}
|
||
|
|
|
||
|
|
void Curve2DKeySelcetBar::slot_sentChosenDataIds(
|
||
|
|
const QModelIndexList& chosenID)
|
||
|
|
{
|
||
|
|
m_selectedIndexs.clear();
|
||
|
|
auto count = chosenID.count();
|
||
|
|
QString strText{};
|
||
|
|
for (int i = 0; i < count; ++i)
|
||
|
|
{
|
||
|
|
auto chosenData = chosenID.at(i);
|
||
|
|
if (chosenData.isValid())
|
||
|
|
{
|
||
|
|
auto str = chosenData.data().toString();
|
||
|
|
strText += str + ",";
|
||
|
|
|
||
|
|
auto index = chosenID.at(i).row();
|
||
|
|
m_selectedIndexs.append(index);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
m_lineEdit->setText(strText);
|
||
|
|
}
|
||
|
|
|
||
|
|
void Curve2DKeySelcetBar::slot_selectDataButtonClicked()
|
||
|
|
{
|
||
|
|
if (m_dataChosenListDialog == nullptr)
|
||
|
|
{
|
||
|
|
m_dataChosenListDialog = new DataChosenListDialog();
|
||
|
|
m_dataChosenListDialog->setFixedSize(400, 400);
|
||
|
|
m_dataChosenListDialog->moveToCenter();
|
||
|
|
QList<QString> data{};
|
||
|
|
for (const auto& v : m_values)
|
||
|
|
{
|
||
|
|
data.append(QString::number(v));
|
||
|
|
}
|
||
|
|
m_dataChosenListDialog->setData(data);
|
||
|
|
m_dataChosenListDialog->show();
|
||
|
|
m_dataChosenListDialog->updateUI();
|
||
|
|
//m_dataChosenListDialog->setSelctedIndexs(m_selectedIndexs);
|
||
|
|
|
||
|
|
connect(m_dataChosenListDialog,
|
||
|
|
&DataChosenListDialog::signal_sentChosenDataIds,
|
||
|
|
this, &Curve2DKeySelcetBar::slot_sentChosenDataIds);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
m_dataChosenListDialog->show();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|