81 lines
1.5 KiB
C++
Executable File
81 lines
1.5 KiB
C++
Executable File
#include "AddLine.h"
|
|
|
|
#include "ui_AddLinesUi.h"
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
AddLines::AddLines(QWidget* parent)
|
|
: QDialog(parent)
|
|
, m_ui(new Ui::AddLines)
|
|
{
|
|
qRegisterMetaType<AddModel*>("AddModel*");
|
|
|
|
m_ui->setupUi(this);
|
|
|
|
m_ui->dataView->setModel(&addModel);
|
|
|
|
connect(m_ui->pbDone, &QPushButton::clicked,
|
|
this, &AddLines::slotAddLines);
|
|
|
|
connect(m_ui->pbAbort, &QPushButton::clicked,
|
|
this, &AddLines::close);
|
|
|
|
connect(m_ui->pbDelete, &QPushButton::clicked,
|
|
this, &AddLines::slotDeleteLines);
|
|
|
|
connect(m_ui->pbClear, &QPushButton::clicked,
|
|
this, &AddLines::slotClear);
|
|
}
|
|
|
|
|
|
AddLines::~AddLines()
|
|
{
|
|
delete m_ui;
|
|
}
|
|
|
|
|
|
void AddLines::slotDeleteLines()
|
|
{
|
|
//qWarning() << "slotDeleteLines";
|
|
|
|
while (m_ui->dataView->selectionModel()->selectedRows().count())
|
|
{
|
|
const QModelIndexList selectedRows = m_ui->dataView->selectionModel()->selectedRows();
|
|
|
|
if (selectedRows.at(0).row() == addModel.rowCount()-1) // do not delete empty row!
|
|
{
|
|
return; // In hope that the selectedRows list is sorted.....
|
|
}
|
|
|
|
addModel.removeRow(selectedRows.at(0).row());
|
|
}
|
|
}
|
|
|
|
|
|
void AddLines::slotClear()
|
|
{
|
|
//qWarning() << "slotClear";
|
|
addModel.clear();
|
|
}
|
|
|
|
|
|
void AddLines::reject()
|
|
{
|
|
emit signalAddLines(nullptr);
|
|
}
|
|
|
|
|
|
void AddLines::copyDataFromModel(DataModel* dataModel)
|
|
{
|
|
addModel.setHeaderList(dataModel->getHeaderList());
|
|
addModel.setTablename(dataModel->getTableName());
|
|
}
|
|
|
|
|
|
void AddLines::slotAddLines()
|
|
{
|
|
this->hide(); // hide until in work..
|
|
emit signalAddLines(&addModel);
|
|
}
|