diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp
index c1c1769..0ecf7b4 100644
--- a/ui/mainwindow.cpp
+++ b/ui/mainwindow.cpp
@@ -194,6 +194,27 @@ void MainWindow::MF_onTypeChanged(int id, bool st)
typeBtnGroup->blockSignals(false);
}
+void MainWindow::on_MF_checkAllBox_stateChanged(int arg1)
+{
+ ui->MF_dataWidget->blockSignals(true);
+ ui->MF_checkAllBox->blockSignals(true);
+ if(arg1 == Qt::PartiallyChecked)
+ {
+ ui->MF_checkAllBox->setTristate(false);
+ ui->MF_checkAllBox->setCheckState(Qt::Checked);
+ }
+ for(int i = 0; i < mifare->cardType.blocks; i++)
+ {
+ ui->MF_dataWidget->item(i, 1)->setCheckState(ui->MF_checkAllBox->checkState());
+ }
+ for(int i = 0; i < mifare->cardType.sectors; i++)
+ {
+ ui->MF_dataWidget->item(mifare->cardType.blks[i], 0)->setCheckState(ui->MF_checkAllBox->checkState());
+ }
+ ui->MF_dataWidget->blockSignals(false);
+ ui->MF_checkAllBox->blockSignals(false);
+}
+
void MainWindow::on_MF_data2KeyBotton_clicked()
{
mifare->data_data2Key();
@@ -218,8 +239,81 @@ void MainWindow::on_MF_fontButton_clicked()
void MainWindow::on_MF_dataWidget_itemChanged(QTableWidgetItem *item)
{
+ ui->MF_dataWidget->blockSignals(true);
+ ui->MF_checkAllBox->blockSignals(true);
+ if(item->column() == 0)
+ {
+ int selectedSectors = 0;
+ for(int i = 0; i < mifare->cardType.blk[item->row() / 4]; i++)
+ {
+ ui->MF_dataWidget->item(i + item->row(), 1)->setCheckState(item->checkState());
+ qDebug() << i << mifare->cardType.blk[item->row()] << i + item->row() << ui->MF_dataWidget->item(i + item->row(), 1)->text();
+ }
+ for(int i = 0; i < mifare->cardType.sectors; i++)
+ {
+ if(ui->MF_dataWidget->item(mifare->cardType.blks[i], 0)->checkState() == Qt::Checked)
+ {
+ selectedSectors++;
+ }
+ }
+ if(selectedSectors == 0)
+ {
+ ui->MF_checkAllBox->setCheckState(Qt::Unchecked);
+ }
+ else if(selectedSectors == mifare->cardType.sectors)
+ {
+ ui->MF_checkAllBox->setCheckState(Qt::Checked);
+ }
+ else
+ {
+ ui->MF_checkAllBox->setCheckState(Qt::PartiallyChecked);
+ }
+ }
+ else if(item->column() == 1)
+ {
+ int selectedSubBlocks = 0;
+ int selectedBlocks = 0;
- if(item->column() == 2)
+ for(int i = 0; i < mifare->cardType.blocks; i++)
+ {
+ if(ui->MF_dataWidget->item(i, 1)->checkState() == Qt::Checked)
+ {
+ selectedBlocks++;
+ }
+ }
+ for(int i = 0; i < mifare->cardType.blk[item->row() / 4]; i++)
+ {
+ if(ui->MF_dataWidget->item(i + mifare->cardType.blks[item->row() / 4], 1)->checkState() == Qt::Checked)
+ {
+ selectedSubBlocks++;
+ }
+ }
+ if(selectedBlocks == 0)
+ {
+ ui->MF_checkAllBox->setCheckState(Qt::Unchecked);
+ }
+ else if(selectedBlocks == mifare->cardType.blocks)
+ {
+ ui->MF_checkAllBox->setCheckState(Qt::Checked);
+ }
+ else
+ {
+ ui->MF_checkAllBox->setCheckState(Qt::PartiallyChecked);
+ }
+ if(selectedSubBlocks == 0)
+ {
+ ui->MF_dataWidget->item(mifare->cardType.blks[item->row() / 4], 0)->setCheckState(Qt::Unchecked);
+ }
+ else if(selectedSubBlocks == mifare->cardType.blk[item->row() / 4])
+ {
+ ui->MF_dataWidget->item(mifare->cardType.blks[item->row() / 4], 0)->setCheckState(Qt::Checked);
+ }
+ else
+ {
+ ui->MF_dataWidget->item(mifare->cardType.blks[item->row() / 4], 0)->setCheckState(Qt::PartiallyChecked);
+ }
+ }
+ else if(item->column() == 2)
{
QString data = item->text().replace(" ", "").toUpper();
if(data == "" || mifare->data_isDataValid(data) == Mifare::DATA_NOSPACE)
@@ -232,6 +326,8 @@ void MainWindow::on_MF_dataWidget_itemChanged(QTableWidgetItem *item)
}
mifare->data_syncWithDataWidget(false, item->row());
}
+ ui->MF_dataWidget->blockSignals(false);
+ ui->MF_checkAllBox->blockSignals(false);
}
void MainWindow::on_MF_keyWidget_itemChanged(QTableWidgetItem *item)
@@ -563,6 +659,9 @@ void MainWindow::MF_widgetReset()
ui->MF_keyWidget->setRowCount(secs);
ui->MF_dataWidget->setRowCount(blks);
+ ui->MF_dataWidget->blockSignals(true);
+ ui->MF_checkAllBox->blockSignals(true);
+
for(int i = 0; i < blks; i++)
{
setTableItem(ui->MF_dataWidget, i, 0, "");
@@ -578,7 +677,12 @@ void MainWindow::MF_widgetReset()
setTableItem(ui->MF_keyWidget, i, 1, "");
setTableItem(ui->MF_keyWidget, i, 2, "");
setTableItem(ui->MF_dataWidget, mifare->cardType.blks[i], 0, QString::number(i));
+ ui->MF_dataWidget->item(mifare->cardType.blks[i], 0)->setCheckState(Qt::Checked);
}
+ ui->MF_checkAllBox->setCheckState(Qt::Checked);
+
+ ui->MF_dataWidget->blockSignals(false);
+ ui->MF_checkAllBox->blockSignals(false);
}
// ************************************************
@@ -604,7 +708,7 @@ void MainWindow::uiInit()
ui->MF_dataWidget->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Blk")));
ui->MF_dataWidget->setHorizontalHeaderItem(2, new QTableWidgetItem(tr("Data")));
ui->MF_dataWidget->verticalHeader()->setVisible(false);
- ui->MF_dataWidget->setColumnWidth(0, 35);
+ ui->MF_dataWidget->setColumnWidth(0, 45);
ui->MF_dataWidget->setColumnWidth(1, 55);
ui->MF_dataWidget->setColumnWidth(2, 430);
diff --git a/ui/mainwindow.h b/ui/mainwindow.h
index 17bf42c..0fb94b3 100644
--- a/ui/mainwindow.h
+++ b/ui/mainwindow.h
@@ -137,6 +137,8 @@ private slots:
void on_GroupBox_clicked(bool checked);
+ void on_MF_checkAllBox_stateChanged(int arg1);
+
private:
Ui::MainWindow* ui;
QButtonGroup* typeBtnGroup;
diff --git a/ui/mainwindow.ui b/ui/mainwindow.ui
index fe05683..5a6d38e 100644
--- a/ui/mainwindow.ui
+++ b/ui/mainwindow.ui
@@ -105,6 +105,9 @@
0
+
+ 0
+
Mifare
@@ -182,7 +185,10 @@
-
- All
+ Check All
+
+
+ false
@@ -606,28 +612,28 @@
-
- Read Block
+ Read One
-
- Write Block
+ Write One
-
- Read Selected
+ Read Checked
-
- Write Selected
+ Write Checked
@@ -698,28 +704,28 @@
-
- Read Block
+ Read One
-
- Write Block
+ Write One
-
- Read Selected
+ Read Checked
-
- Write Selected
+ Write Checked