more on seller dialog
This commit is contained in:
parent
90e132bcc8
commit
e06458b419
3 changed files with 16 additions and 3 deletions
|
@ -18,6 +18,7 @@ void SellerDialog::on_newButton_clicked()
|
|||
{
|
||||
ui_.tableView->model()->insertRows(ui_.tableView->model()->rowCount(), 1);
|
||||
ui_.tableView->scrollToBottom();
|
||||
ui_.tableView->selectRow(ui_.tableView->model()->rowCount() - 1);
|
||||
}
|
||||
|
||||
void SellerDialog::accept()
|
||||
|
|
|
@ -5,6 +5,14 @@
|
|||
<property name="windowModality">
|
||||
<enum>Qt::NonModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -38,7 +46,7 @@
|
|||
<item>
|
||||
<widget class="QPushButton" name="newButton">
|
||||
<property name="text">
|
||||
<string>Neu</string>
|
||||
<string>&Neu</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -22,6 +22,10 @@ QVariant SellerModel::data(const QModelIndex& index, int role) const
|
|||
return QVariant();
|
||||
|
||||
Seller* seller = marketplace_->getSellers().at(index.row()).get();
|
||||
|
||||
if (seller->getState() == Seller::State::DELETE)
|
||||
return QVariant::Invalid;
|
||||
|
||||
switch (index.column()) {
|
||||
case 0:
|
||||
return seller->getUuidAsString().c_str();
|
||||
|
@ -117,12 +121,12 @@ bool SellerModel::setData(const QModelIndex& index, const QVariant& value, int r
|
|||
|
||||
bool SellerModel::insertRows(int row, int count, const QModelIndex& parent)
|
||||
{
|
||||
beginInsertRows(parent, row, row + count - 1);
|
||||
emit beginInsertRows(parent, row, row + count - 1);
|
||||
auto seller = std::make_unique<Seller>();
|
||||
seller->createUuid();
|
||||
seller->setSellerNo(marketplace_->getNextSellerNo());
|
||||
marketplace_->getSellers().push_back(std::move(seller));
|
||||
endInsertRows();
|
||||
emit endInsertRows();
|
||||
|
||||
return true;
|
||||
}
|
Loading…
Reference in a new issue