multi-check system
This commit is contained in:
@@ -7,23 +7,30 @@
|
||||
#include <iostream>
|
||||
|
||||
CheckListViewWidget::CheckListViewWidget(QWidget *parent, Check check) : QWidget(parent), check(check) {
|
||||
mw = (MainWindow*) parent;
|
||||
|
||||
std::cout << "I was created with check with date " << check.get_date() << std::endl;
|
||||
QHBoxLayout *layout = new QHBoxLayout;
|
||||
|
||||
QLabel *label1 = new QLabel(QString::fromStdString(check.get_date()));
|
||||
QLabel *label2 = new QLabel("Text 2");
|
||||
QLabel *label3 = new QLabel("Text 3");
|
||||
QLabel *date_label = new QLabel(QString::fromStdString(check.get_date()));
|
||||
QLabel *summ_label = new QLabel(QString::number(check.get_total()));
|
||||
|
||||
QPushButton *deleteButton = new QPushButton(tr("Delete"));
|
||||
|
||||
deleteButton->connect(deleteButton, &QPushButton::clicked, this, &CheckListViewWidget::deleteButtonPressed);
|
||||
deleteButton->connect(deleteButton, &QPushButton::clicked, this, &CheckListViewWidget::delete_button_pressed);
|
||||
|
||||
layout->addWidget(label1);
|
||||
layout->addWidget(label2);
|
||||
layout->addWidget(label3);
|
||||
layout->addWidget(date_label);
|
||||
layout->addWidget(summ_label);
|
||||
layout->addSpacing(10);
|
||||
layout->addWidget(deleteButton);
|
||||
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
Check &CheckListViewWidget::get_check(){
|
||||
return check;
|
||||
}
|
||||
|
||||
void CheckListViewWidget::delete_button_pressed() {
|
||||
emit mw->deleteCheckFromList(this->check);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include <mainwindow.h>
|
||||
|
||||
#include <check/check.h>
|
||||
|
||||
@@ -10,9 +11,12 @@ class CheckListViewWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Check check;
|
||||
MainWindow* mw;
|
||||
public:
|
||||
explicit CheckListViewWidget(QWidget *parent = nullptr, Check check = Check());
|
||||
|
||||
Check &get_check();
|
||||
void delete_button_pressed();
|
||||
signals:
|
||||
Check deleteButtonPressed();
|
||||
};
|
||||
|
||||
@@ -7,6 +7,56 @@
|
||||
|
||||
TableWidgetMovable::TableWidgetMovable(QWidget *parent) : QTableWidget(parent) { }
|
||||
|
||||
// void TableWidgetMovable::dropEvent(QDropEvent *event) {
|
||||
// if (event->source() == this) {
|
||||
// // Get the index of the row being dragged
|
||||
// QModelIndex sourceIndex = currentIndex();
|
||||
// if (!sourceIndex.isValid()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // Get the index of the target row
|
||||
// QModelIndex targetIndex = indexAt(event->pos());
|
||||
// if (!targetIndex.isValid()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// int sourceRow = sourceIndex.row();
|
||||
// int targetRow = targetIndex.row();
|
||||
|
||||
// // Swap rows
|
||||
// if (sourceRow != targetRow) {
|
||||
// // Store the data of the source row
|
||||
// QList<QTableWidgetItem*> itemsSource;
|
||||
// for (int col = 0; col < columnCount(); ++col) {
|
||||
// itemsSource.append(takeItem(sourceRow, col));
|
||||
// }
|
||||
|
||||
// QList<QTableWidgetItem*> itemsTarget;
|
||||
// for (int col = 0; col < columnCount(); ++col) {
|
||||
// itemsTarget.append(takeItem(targetRow, col));
|
||||
// }
|
||||
|
||||
// // Insert the items into the target row
|
||||
// for (int col = 0; col < columnCount(); ++col) {
|
||||
// setItem(targetRow, col, itemsSource[col]);
|
||||
// setItem(sourceRow, col, itemsTarget[col]);
|
||||
// }
|
||||
|
||||
// // for (int col = 0; col < columnCount(); ++col) {
|
||||
|
||||
// // }
|
||||
|
||||
// // Remove the original row
|
||||
// // removeRow(sourceRow < targetRow ? sourceRow : sourceRow + 1);
|
||||
// }
|
||||
|
||||
// event->acceptProposedAction();
|
||||
// } else {
|
||||
// QTableWidget::dropEvent(event);
|
||||
// }
|
||||
// }
|
||||
|
||||
// TOOD: fix None of these works. WIP
|
||||
|
||||
// void TableWidgetMovable::dropEvent(QDropEvent *event) {
|
||||
|
||||
Reference in New Issue
Block a user