Mercurial > public > ostc_companion
comparison editlogdialog.cpp @ 8:21ce6187d32e
Minor changes done by automatic style checker
| author | Ideenmodellierer |
|---|---|
| date | Mon, 12 Jan 2026 13:51:17 +0000 |
| parents | 0b3630a29ad8 |
| children |
comparison
equal
deleted
inserted
replaced
| 7:0969ef86c42d | 8:21ce6187d32e |
|---|---|
| 1 #include "editlogdialog.h" | 1 #include "editlogdialog.h" |
| 2 #include "MainWindow.h" // Needed to propagare retranslate() | |
| 3 #include "Utils/Log.h" | |
| 2 #include "ui_LogEditor.h" | 4 #include "ui_LogEditor.h" |
| 3 #include "MainWindow.h" // Needed to propagare retranslate() | |
| 4 #include "Utils/Log.h" | |
| 5 | 5 |
| 6 #include "HardwareOperations.h" | 6 #include "HardwareOperations.h" |
| 7 | 7 |
| 8 #include <QApplication> | 8 #include <QApplication> |
| 9 #include <QDialogButtonBox> | 9 #include <QDialogButtonBox> |
| 10 #include <QDir> | 10 #include <QDir> |
| 11 #include <QLibraryInfo> | 11 #include <QLibraryInfo> |
| 12 #include <QPushButton> | 12 #include <QPushButton> |
| 13 #include <QTableWidget> | |
| 13 #include <QTranslator> | 14 #include <QTranslator> |
| 14 #include <QTableWidget> | |
| 15 | |
| 16 | 15 |
| 17 #ifdef Q_OS_WIN | 16 #ifdef Q_OS_WIN |
| 18 # define NOMINMAX 1 | 17 #define NOMINMAX 1 |
| 19 # include <Windows.h> | 18 #include <Windows.h> |
| 20 # undef NOMINMAX | 19 #undef NOMINMAX |
| 21 #endif | 20 #endif |
| 22 #define HEADER2OFFSET 0x400 | 21 #define HEADER2OFFSET 0x400 |
| 23 | 22 |
| 24 EditLogDialog::EditLogDialog(QWidget* parent, HardwareOperations *op) | 23 EditLogDialog::EditLogDialog(QWidget *parent, HardwareOperations *op) |
| 25 : QDialog(parent), | 24 : QDialog(parent) |
| 26 _ui(new Ui::editLogWnd), | 25 , _ui(new Ui::editLogWnd) |
| 27 _op(op) | 26 , _op(op) |
| 28 { | 27 { |
| 29 uint32_t index, index2; | 28 uint32_t index, index2; |
| 30 uint32_t sizeY = 0; | 29 uint32_t sizeY = 0; |
| 31 _ui->setupUi(this); | 30 _ui->setupUi(this); |
| 32 QTableWidget* headerView = _ui->SectorView; | 31 QTableWidget *headerView = _ui->SectorView; |
| 33 QTableWidget* sampleView = _ui->SampleView; | 32 QTableWidget *sampleView = _ui->SampleView; |
| 34 | 33 |
| 35 _ui->textBrowser_2->setTabStopDistance( | 34 _ui->textBrowser_2->setTabStopDistance( |
| 36 QFontMetricsF(_ui->textBrowser_2->font()).horizontalAdvance(' ') * 4 | 35 QFontMetricsF(_ui->textBrowser_2->font()).horizontalAdvance(' ') * 4); |
| 37 ); | |
| 38 headerView->horizontalHeader()->setMinimumSectionSize(8); | 36 headerView->horizontalHeader()->setMinimumSectionSize(8); |
| 39 headerView->verticalHeader()->setMinimumSectionSize(8); | 37 headerView->verticalHeader()->setMinimumSectionSize(8); |
| 40 headerView->horizontalHeader()->setDefaultSectionSize(8); | 38 headerView->horizontalHeader()->setDefaultSectionSize(8); |
| 41 headerView->verticalHeader()->setDefaultSectionSize(8); | 39 headerView->verticalHeader()->setDefaultSectionSize(8); |
| 42 headerView->setColumnWidth(0,8); | 40 headerView->setColumnWidth(0, 8); |
| 43 headerView->setRowHeight(0,8); | 41 headerView->setRowHeight(0, 8); |
| 44 headerView->horizontalHeader()->hide(); | 42 headerView->horizontalHeader()->hide(); |
| 45 headerView->verticalHeader()->hide(); | 43 headerView->verticalHeader()->hide(); |
| 46 | 44 |
| 47 sampleView->horizontalHeader()->setMinimumSectionSize(8); | 45 sampleView->horizontalHeader()->setMinimumSectionSize(8); |
| 48 sampleView->verticalHeader()->setMinimumSectionSize(8); | 46 sampleView->verticalHeader()->setMinimumSectionSize(8); |
| 49 sampleView->horizontalHeader()->setDefaultSectionSize(8); | 47 sampleView->horizontalHeader()->setDefaultSectionSize(8); |
| 50 sampleView->verticalHeader()->setDefaultSectionSize(8); | 48 sampleView->verticalHeader()->setDefaultSectionSize(8); |
| 51 sampleView->setColumnWidth(0,8); | 49 sampleView->setColumnWidth(0, 8); |
| 52 sampleView->setRowHeight(0,8); | 50 sampleView->setRowHeight(0, 8); |
| 53 sampleView->horizontalHeader()->hide(); | 51 sampleView->horizontalHeader()->hide(); |
| 54 sampleView->verticalHeader()->hide(); | 52 sampleView->verticalHeader()->hide(); |
| 55 | 53 |
| 56 headerView->setRowCount(16); | 54 headerView->setRowCount(16); |
| 57 headerView->setColumnCount(16); | 55 headerView->setColumnCount(16); |
| 58 | 56 |
| 59 sampleView->setRowCount(12); | 57 sampleView->setRowCount(12); |
| 60 sampleView->setColumnCount(16); | 58 sampleView->setColumnCount(16); |
| 61 | 59 |
| 62 | 60 HeaderBuffer = new unsigned char[0x8000 * 8 + 1]; // 64k Headerbuffer + lastDiveindex |
| 63 HeaderBuffer = new unsigned char[0x8000*8 + 1]; // 64k Headerbuffer + lastDiveindex | 61 SampleBuffer = new unsigned char[0xC00000 + 4]; // 12MB Samplebuffer + nextSampleAddr |
| 64 SampleBuffer = new unsigned char[0xC00000 + 4]; // 12MB Samplebuffer + nextSampleAddr | 62 |
| 65 | 63 headerView->resize(8 * 16 + 2, 8 * 16 + 2); |
| 66 headerView->resize(8*16+2,8*16+2); | 64 sampleView->resize(8 * 16 + 2, 8 * 12 + 2); |
| 67 sampleView->resize(8*16+2,8*12+2); | 65 sizeY = (uint32_t) (headerView->geometry().width()) / 16; |
| 68 sizeY = (uint32_t)(headerView->geometry().width()) / 16; | 66 |
| 69 | 67 if (sizeY < 8) { |
| 70 if(sizeY < 8) | |
| 71 { | |
| 72 sizeY = 8; | 68 sizeY = 8; |
| 73 } | 69 } |
| 74 | 70 |
| 75 for(index = 0; index <16; index++) | 71 for (index = 0; index < 16; index++) { |
| 76 { | 72 headerView->setColumnWidth(index, sizeY); |
| 77 headerView->setColumnWidth(index,sizeY); | 73 headerView->setRowHeight(index, sizeY); |
| 78 headerView->setRowHeight(index,sizeY); | 74 for (index2 = 0; index2 < 16; index2++) { |
| 79 for(index2 = 0; index2 < 16; index2++) | |
| 80 { | |
| 81 | |
| 82 item[index * 16 + index2] = new QTableWidgetItem(" "); | 75 item[index * 16 + index2] = new QTableWidgetItem(" "); |
| 83 headerView->setItem(index, index2, item[index * 16 + index2]); | 76 headerView->setItem(index, index2, item[index * 16 + index2]); |
| 84 } | 77 } |
| 85 } | 78 } |
| 86 | 79 |
| 87 for(index = 0; index <12; index++) | 80 for (index = 0; index < 12; index++) { |
| 88 { | 81 sampleView->setColumnWidth(index, sizeY); |
| 89 sampleView->setColumnWidth(index,sizeY); | 82 sampleView->setRowHeight(index, sizeY); |
| 90 sampleView->setRowHeight(index,sizeY); | 83 for (index2 = 0; index2 < 16; index2++) { |
| 91 for(index2 = 0; index2 < 16; index2++) | |
| 92 { | |
| 93 | |
| 94 sampleitem[index * 16 + index2] = new QTableWidgetItem(" "); | 84 sampleitem[index * 16 + index2] = new QTableWidgetItem(" "); |
| 95 sampleView->setItem(index, index2, sampleitem[index * 16 + index2]); | 85 sampleView->setItem(index, index2, sampleitem[index * 16 + index2]); |
| 96 } | 86 } |
| 97 } | 87 } |
| 98 | 88 |
| 99 headerView->show(); | 89 headerView->show(); |
| 100 headerView->setShowGrid(true); | 90 headerView->setShowGrid(true); |
| 101 | 91 |
| 102 sampleView->show(); | 92 sampleView->show(); |
| 103 sampleView->setShowGrid(true); | 93 sampleView->setShowGrid(true); |
| 104 | |
| 105 } | 94 } |
| 106 | 95 |
| 107 EditLogDialog::~EditLogDialog() | 96 EditLogDialog::~EditLogDialog() |
| 108 { | 97 { |
| 109 uint32_t index; | 98 uint32_t index; |
| 110 | 99 |
| 111 for(index = 0; index <256; index++) | 100 for (index = 0; index < 256; index++) { |
| 112 { | |
| 113 delete item[index]; | 101 delete item[index]; |
| 114 } | 102 } |
| 115 for(index = 0; index <192; index++) | 103 for (index = 0; index < 192; index++) { |
| 116 { | |
| 117 delete sampleitem[index]; | 104 delete sampleitem[index]; |
| 118 } | 105 } |
| 119 delete _ui; | 106 delete _ui; |
| 120 delete HeaderBuffer; | 107 delete HeaderBuffer; |
| 121 delete SampleBuffer; | 108 delete SampleBuffer; |
| 122 } | 109 } |
| 123 | 110 |
| 124 | |
| 125 void EditLogDialog::on_WriteAllHeader_clicked() | 111 void EditLogDialog::on_WriteAllHeader_clicked() |
| 126 { | 112 { |
| 127 _op->writeAllHeader(HeaderBuffer); | 113 _op->writeAllHeader(HeaderBuffer); |
| 128 } | 114 } |
| 129 | 115 |
| 130 void EditLogDialog::on_pushButton_clicked() | 116 void EditLogDialog::on_pushButton_clicked() |
| 131 { | 117 { |
| 132 Q_ASSERT( _op ); | 118 Q_ASSERT(_op); |
| 133 | 119 |
| 134 HeaderBuffer[0] = 0; | 120 HeaderBuffer[0] = 0; |
| 135 | 121 |
| 136 try { | 122 try { |
| 137 LOG_INFO(tr("Request All Headers...")); | 123 LOG_INFO(tr("Request All Headers...")); |
| 138 _op->getAllHeader(HeaderBuffer); | 124 _op->getAllHeader(HeaderBuffer); |
| 139 } | 125 } catch (const std::exception &e) { |
| 140 catch(const std::exception& e) { | 126 LOG_INFO( |
| 141 LOG_INFO( QString("<bg><font color='red'>%1</font></color>: %2") | 127 QString("<bg><font color='red'>%1</font></color>: %2").arg(tr("Error")).arg(e.what())); |
| 142 .arg(tr("Error")) | 128 } |
| 143 .arg(e.what()) ); | 129 if (HeaderBuffer[0] != 0) { |
| 144 } | |
| 145 if(HeaderBuffer[0] != 0) | |
| 146 { | |
| 147 LOG_INFO(tr("Got something")); | 130 LOG_INFO(tr("Got something")); |
| 148 updateHeaderStatus(); | 131 updateHeaderStatus(); |
| 149 } | 132 } |
| 150 } | 133 } |
| 151 | 134 |
| 152 | 135 void EditLogDialog::on_HeaderUsage_valueChanged(int value) {} |
| 153 | |
| 154 void EditLogDialog::on_HeaderUsage_valueChanged(int value) | |
| 155 { | |
| 156 | |
| 157 } | |
| 158 | 136 |
| 159 void EditLogDialog::on_ReadAllSamples_clicked() | 137 void EditLogDialog::on_ReadAllSamples_clicked() |
| 160 { | 138 { |
| 161 try { | 139 try { |
| 162 LOG_INFO(tr("Request All Samples...")); | 140 LOG_INFO(tr("Request All Samples...")); |
| 163 _op->getAllSamples(SampleBuffer); | 141 _op->getAllSamples(SampleBuffer); |
| 164 } | 142 } catch (const std::exception &e) { |
| 165 catch(const std::exception& e) { | 143 LOG_INFO( |
| 166 LOG_INFO( QString("<bg><font color='red'>%1</font></color>: %2") | 144 QString("<bg><font color='red'>%1</font></color>: %2").arg(tr("Error")).arg(e.what())); |
| 167 .arg(tr("Error")) | |
| 168 .arg(e.what()) ); | |
| 169 } | 145 } |
| 170 } | 146 } |
| 171 | 147 |
| 172 void EditLogDialog::on_WriteAllSamples_clicked() | 148 void EditLogDialog::on_WriteAllSamples_clicked() |
| 173 { | 149 { |
| 174 try { | 150 try { |
| 175 LOG_INFO(tr("Request All Samples...")); | 151 LOG_INFO(tr("Request All Samples...")); |
| 176 _op->writeAllSamples(SampleBuffer); | 152 _op->writeAllSamples(SampleBuffer); |
| 177 } | 153 } catch (const std::exception &e) { |
| 178 catch(const std::exception& e) { | 154 LOG_INFO( |
| 179 LOG_INFO( QString("<bg><font color='red'>%1</font></color>: %2") | 155 QString("<bg><font color='red'>%1</font></color>: %2").arg(tr("Error")).arg(e.what())); |
| 180 .arg(tr("Error")) | |
| 181 .arg(e.what()) ); | |
| 182 } | 156 } |
| 183 } | 157 } |
| 184 | 158 |
| 185 void EditLogDialog::on_pushButton_2_clicked() | 159 void EditLogDialog::on_pushButton_2_clicked() |
| 186 { | 160 { |
| 187 qint64 length; | 161 qint64 length; |
| 188 QFile dumpFile; | 162 QFile dumpFile; |
| 189 dumpFile.setFileName("Log_Dump.bin"); | 163 dumpFile.setFileName("Log_Dump.bin"); |
| 190 if( ! dumpFile.open(QIODevice::WriteOnly) ) | 164 if (!dumpFile.open(QIODevice::WriteOnly)) { |
| 191 { | 165 LOG_THROW("Cannot create dump file "); |
| 192 LOG_THROW( "Cannot create dump file " ); | 166 } else { |
| 193 } | 167 length = 0x8000 * 8 + 1; |
| 194 else | 168 dumpFile.write((const char *) HeaderBuffer, length); |
| 195 { | |
| 196 length = 0x8000*8 + 1; | |
| 197 dumpFile.write((const char*)HeaderBuffer,length); | |
| 198 length = 0xC00000 + 4; | 169 length = 0xC00000 + 4; |
| 199 dumpFile.write((const char*)SampleBuffer,length); | 170 dumpFile.write((const char *) SampleBuffer, length); |
| 200 dumpFile.close(); | 171 dumpFile.close(); |
| 201 } | 172 } |
| 202 } | 173 } |
| 203 | 174 |
| 204 void EditLogDialog::on_LoadDump_clicked() | 175 void EditLogDialog::on_LoadDump_clicked() |
| 205 { | 176 { |
| 206 qint64 length; | 177 qint64 length; |
| 207 QFile dumpFile; | 178 QFile dumpFile; |
| 208 dumpFile.setFileName("Log_Dump.bin"); | 179 dumpFile.setFileName("Log_Dump.bin"); |
| 209 if( ! dumpFile.open(QIODevice::ReadOnly) ) | 180 if (!dumpFile.open(QIODevice::ReadOnly)) { |
| 210 { | 181 LOG_THROW("Cannot read dump file "); |
| 211 LOG_THROW( "Cannot read dump file " ); | 182 } else { |
| 212 } | 183 length = 0x8000 * 8 + 1; |
| 213 else | 184 dumpFile.read((char *) HeaderBuffer, length); |
| 214 { | |
| 215 length = 0x8000*8 + 1; | |
| 216 dumpFile.read((char*)HeaderBuffer,length); | |
| 217 length = 0xC00000 + 4; | 185 length = 0xC00000 + 4; |
| 218 dumpFile.read((char*)SampleBuffer,length); | 186 dumpFile.read((char *) SampleBuffer, length); |
| 219 dumpFile.close(); | 187 dumpFile.close(); |
| 220 | 188 |
| 221 updateHeaderStatus(); | 189 updateHeaderStatus(); |
| 222 updateSampleStatus(); | 190 updateSampleStatus(); |
| 223 } | 191 } |
| 224 } | 192 } |
| 225 | 193 |
| 226 void EditLogDialog::updateHeaderStatus() | 194 void EditLogDialog::updateHeaderStatus() |
| 227 { | 195 { |
| 228 QProgressBar* w = _ui->HeaderUsage; | 196 QProgressBar *w = _ui->HeaderUsage; |
| 229 QTableWidget* sv = _ui->SectorView; | 197 QTableWidget *sv = _ui->SectorView; |
| 230 SLogbookHeader* LogInfo; | 198 SLogbookHeader *LogInfo; |
| 231 SSmallHeader* smallHeader; | 199 SSmallHeader *smallHeader; |
| 232 unsigned char HeaderInUse = 0; | 200 unsigned char HeaderInUse = 0; |
| 233 uint32_t index, index2; | 201 uint32_t index, index2; |
| 234 uint32_t sampleStartAddr, sampleEndAddr, sampleLength; | 202 uint32_t sampleStartAddr, sampleEndAddr, sampleLength; |
| 235 int row; | 203 int row; |
| 236 int colum; | 204 int colum; |
| 237 | 205 |
| 238 for(index = 0; index < 16; index++) | 206 for (index = 0; index < 16; index++) { |
| 239 { | 207 for (index2 = 0; index2 < 16; index2++) { |
| 240 for(index2 = 0; index2 < 16; index2++) | 208 if ((HeaderBuffer[(0x800 * (index * 16 + index2)) + HEADER2OFFSET] == 0xFA) |
| 241 { | 209 && (HeaderBuffer[(0x800 * (index * 16 + index2)) + HEADER2OFFSET + 1] == 0xFA)) { |
| 242 if((HeaderBuffer[(0x800 * (index * 16 + index2 )) + HEADER2OFFSET] == 0xFA) | |
| 243 && (HeaderBuffer[(0x800 * (index * 16 + index2 )) + HEADER2OFFSET + 1] == 0xFA)) | |
| 244 { | |
| 245 HeaderInUse++; | 210 HeaderInUse++; |
| 246 LogInfo = (SLogbookHeader*)(HeaderBuffer+(0x800 * (index*16+index2))+0x400); | 211 LogInfo = (SLogbookHeader *) (HeaderBuffer + (0x800 * (index * 16 + index2)) |
| 247 sampleEndAddr = (LogInfo->profileLength[2]<<16) + (LogInfo->profileLength[1]<<8) + LogInfo->profileLength[0]; | 212 + 0x400); |
| 248 if( sampleEndAddr == 0) | 213 sampleEndAddr = (LogInfo->profileLength[2] << 16) + (LogInfo->profileLength[1] << 8) |
| 249 { | 214 + LogInfo->profileLength[0]; |
| 250 sv->item(index,index2)->setBackground(Qt::black); | 215 if (sampleEndAddr == 0) { |
| 251 } | 216 sv->item(index, index2)->setBackground(Qt::black); |
| 252 else | 217 } else { |
| 253 { | 218 LogInfo = (SLogbookHeader *) (HeaderBuffer + (0x800 * (index * 16 + index2))); |
| 254 LogInfo = (SLogbookHeader*)(HeaderBuffer+(0x800 * (index*16+index2))); | 219 sampleStartAddr = (LogInfo->pBeginProfileData[2] << 16) |
| 255 sampleStartAddr = (LogInfo->pBeginProfileData[2]<<16) + (LogInfo->pBeginProfileData[1]<<8) + LogInfo->pBeginProfileData[0]; | 220 + (LogInfo->pBeginProfileData[1] << 8) |
| 256 smallHeader = (SSmallHeader*) &SampleBuffer[sampleStartAddr-0x100000]; | 221 + LogInfo->pBeginProfileData[0]; |
| 257 sampleLength = (smallHeader->profileLength[2] << 16)+ (smallHeader->profileLength[1] << 8) + smallHeader->profileLength[0]; | 222 smallHeader = (SSmallHeader *) &SampleBuffer[sampleStartAddr - 0x100000]; |
| 258 if(sampleLength == sampleEndAddr) // - sampleStartAddr)) | 223 sampleLength = (smallHeader->profileLength[2] << 16) |
| 224 + (smallHeader->profileLength[1] << 8) | |
| 225 + smallHeader->profileLength[0]; | |
| 226 if (sampleLength == sampleEndAddr) // - sampleStartAddr)) | |
| 259 { | 227 { |
| 260 sv->item(index,index2)->setBackground(Qt::green); | 228 sv->item(index, index2)->setBackground(Qt::green); |
| 261 } | 229 } else { |
| 262 else { | 230 sv->item(index, index2)->setBackground(Qt::red); |
| 263 sv->item(index,index2)->setBackground(Qt::red); | |
| 264 } | 231 } |
| 265 } | 232 } |
| 266 | 233 |
| 234 } else { | |
| 235 sv->item(index, index2)->setBackground(Qt::white); | |
| 267 } | 236 } |
| 268 else | 237 } |
| 269 { | 238 } |
| 270 sv->item(index,index2)->setBackground(Qt::white); | 239 row = (HeaderBuffer[(0x8000 * 8)]) / 16; |
| 271 } | 240 colum = (HeaderBuffer[(0x8000 * 8)] % 16); |
| 272 } | 241 sv->item(row, colum)->setBackground(Qt::blue); |
| 273 } | 242 w->setMaximum(256); |
| 274 row =(HeaderBuffer[(0x8000 * 8)])/16; | 243 w->setValue(HeaderInUse); |
| 275 colum =(HeaderBuffer[(0x8000 * 8)] % 16); | 244 } |
| 276 sv->item(row,colum)->setBackground(Qt::blue); | 245 |
| 277 w->setMaximum(256); | 246 void EditLogDialog::on_SectorView_cellClicked(int row, int column) {} |
| 278 w->setValue(HeaderInUse); | |
| 279 } | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 void EditLogDialog::on_SectorView_cellClicked(int row, int column) | |
| 286 { | |
| 287 | |
| 288 } | |
| 289 | 247 |
| 290 void EditLogDialog::updateSampleStatus() | 248 void EditLogDialog::updateSampleStatus() |
| 291 { | 249 { |
| 292 uint8_t row,colum; | 250 uint8_t row, colum; |
| 293 uint32_t index; | 251 uint32_t index; |
| 294 QTableWidget* sv = _ui->SampleView; | 252 QTableWidget *sv = _ui->SampleView; |
| 295 QProgressBar* w = _ui->SampleUsage; | 253 QProgressBar *w = _ui->SampleUsage; |
| 296 uint8_t SamplesInUse = 0; | 254 uint8_t SamplesInUse = 0; |
| 297 | 255 |
| 298 for(index = 0; index < 192; index++) | 256 for (index = 0; index < 192; index++) { |
| 299 { | |
| 300 row = index / 16; | 257 row = index / 16; |
| 301 colum =index % 16; | 258 colum = index % 16; |
| 302 | 259 |
| 303 if(SampleBuffer[index * 0x10000] != 0xFF) /* used */ | 260 if (SampleBuffer[index * 0x10000] != 0xFF) /* used */ |
| 304 { | 261 { |
| 305 SamplesInUse++; | 262 SamplesInUse++; |
| 306 if(SampleBuffer[index * 0x10000 + 0xFFFF] == 0xFF) /* open */ | 263 if (SampleBuffer[index * 0x10000 + 0xFFFF] == 0xFF) /* open */ |
| 307 { | 264 { |
| 308 sv->item(row,colum)->setBackground(Qt::blue); | 265 sv->item(row, colum)->setBackground(Qt::blue); |
| 266 } else { | |
| 267 sv->item(row, colum)->setBackground(Qt::green); /* closed */ | |
| 309 } | 268 } |
| 310 else | 269 } else { |
| 311 { | 270 sv->item(row, colum)->setBackground(Qt::white); /* empty */ |
| 312 sv->item(row,colum)->setBackground(Qt::green); /* closed */ | |
| 313 } | |
| 314 } | |
| 315 else | |
| 316 { | |
| 317 sv->item(row,colum)->setBackground(Qt::white); /* empty */ | |
| 318 } | 271 } |
| 319 } | 272 } |
| 320 w->setMaximum(192); | 273 w->setMaximum(192); |
| 321 w->setValue(SamplesInUse); | 274 w->setValue(SamplesInUse); |
| 322 } | 275 } |
| 323 | 276 |
| 324 | 277 void EditLogDialog::on_SectorView_currentCellChanged(int currentRow, |
| 325 | 278 int currentColumn, |
| 326 void EditLogDialog::on_SectorView_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn) | 279 int previousRow, |
| 327 { | 280 int previousColumn) |
| 328 SLogbookHeader* LogInfo; | 281 { |
| 329 SLogbookHeader* LogInfo2nd; | 282 SLogbookHeader *LogInfo; |
| 330 QTextEdit* tf = _ui->textBrowser_2; | 283 SLogbookHeader *LogInfo2nd; |
| 284 QTextEdit *tf = _ui->textBrowser_2; | |
| 331 QString InfoText; | 285 QString InfoText; |
| 332 QTableWidget* sv = _ui->SampleView; | 286 QTableWidget *sv = _ui->SampleView; |
| 333 uint32_t sampleAddrStart = 0; | 287 uint32_t sampleAddrStart = 0; |
| 334 uint32_t sampleAddrEnd = 0; | 288 uint32_t sampleAddrEnd = 0; |
| 335 uint8_t rowidx, columidx; | 289 uint8_t rowidx, columidx; |
| 336 | 290 |
| 337 tf->setReadOnly(true); | 291 tf->setReadOnly(true); |
| 338 | 292 |
| 339 LogInfo = (SLogbookHeader*)(HeaderBuffer+(0x800 * (currentRow*16+currentColumn))); | 293 LogInfo = (SLogbookHeader *) (HeaderBuffer + (0x800 * (currentRow * 16 + currentColumn))); |
| 340 LogInfo2nd = (SLogbookHeader*)(HeaderBuffer+(0x800 * (currentRow*16+currentColumn)) +0x400); | 294 LogInfo2nd = (SLogbookHeader *) (HeaderBuffer + (0x800 * (currentRow * 16 + currentColumn)) |
| 295 + 0x400); | |
| 341 | 296 |
| 342 updateSampleStatus(); | 297 updateSampleStatus(); |
| 343 | 298 |
| 344 if(LogInfo->diveHeaderStart == 0xFAFA) | 299 if (LogInfo->diveHeaderStart == 0xFAFA) { |
| 345 { | 300 sampleAddrStart = (LogInfo->pBeginProfileData[2] << 16) |
| 346 sampleAddrStart = (LogInfo->pBeginProfileData[2]<<16) + (LogInfo->pBeginProfileData[1]<<8) + LogInfo->pBeginProfileData[0]; | 301 + (LogInfo->pBeginProfileData[1] << 8) + LogInfo->pBeginProfileData[0]; |
| 347 sampleAddrEnd = (LogInfo2nd->pEndProfileData[2]<<16) + (LogInfo2nd->pEndProfileData[1]<<8) + LogInfo2nd->pEndProfileData[0]; | 302 sampleAddrEnd = (LogInfo2nd->pEndProfileData[2] << 16) |
| 348 | 303 + (LogInfo2nd->pEndProfileData[1] << 8) + LogInfo2nd->pEndProfileData[0]; |
| 349 // InfoText.sprintf("Header: %d \nNummer: %d\nSamplestart 0x%x\nSampleend 0x%x", currentRow*16+currentColumn, LogInfo->diveNumber,sampleAddrStart,sampleAddrEnd); | 304 |
| 350 InfoText = QString::asprintf( | 305 // InfoText.sprintf("Header: %d \nNummer: %d\nSamplestart 0x%x\nSampleend 0x%x", currentRow*16+currentColumn, LogInfo->diveNumber,sampleAddrStart,sampleAddrEnd); |
| 351 "Header: %d \nNummer: %d\nSamplestart 0x%x\nSampleend 0x%x", | 306 InfoText = QString::asprintf("Header: %d \nNummer: %d\nSamplestart 0x%x\nSampleend 0x%x", |
| 352 currentRow*16 + currentColumn, | 307 currentRow * 16 + currentColumn, |
| 353 LogInfo->diveNumber, | 308 LogInfo->diveNumber, |
| 354 sampleAddrStart, | 309 sampleAddrStart, |
| 355 sampleAddrEnd | 310 sampleAddrEnd); |
| 356 ); | 311 sampleAddrStart = (LogInfo->pBeginProfileData[2] << 16) |
| 357 sampleAddrStart = (LogInfo->pBeginProfileData[2]<<16) + (LogInfo->pBeginProfileData[1]<<8) + LogInfo->pBeginProfileData[0]; | 312 + (LogInfo->pBeginProfileData[1] << 8) + LogInfo->pBeginProfileData[0]; |
| 358 if(sampleAddrStart != 0) | 313 if (sampleAddrStart != 0) { |
| 359 { | |
| 360 sampleAddrStart -= 0x100000; /* substract memory offset */ | 314 sampleAddrStart -= 0x100000; /* substract memory offset */ |
| 361 sampleAddrStart /= 0x10000; /* calc sector */ | 315 sampleAddrStart /= 0x10000; /* calc sector */ |
| 362 sv->item(sampleAddrStart / 16, sampleAddrStart % 16)->setBackground(Qt::magenta); | 316 sv->item(sampleAddrStart / 16, sampleAddrStart % 16)->setBackground(Qt::magenta); |
| 363 } | 317 } else { |
| 364 else | |
| 365 { | |
| 366 sv->item(0, 0)->setBackground(Qt::black); | 318 sv->item(0, 0)->setBackground(Qt::black); |
| 367 } | 319 } |
| 368 } | 320 } else { |
| 369 else | |
| 370 { | |
| 371 InfoText = QString::asprintf("Empty"); | 321 InfoText = QString::asprintf("Empty"); |
| 372 } | 322 } |
| 373 tf->setPlainText((InfoText)); | 323 tf->setPlainText((InfoText)); |
| 374 } | 324 } |
| 375 | 325 |
| 376 | 326 void EditLogDialog::on_SampleView_currentCellChanged(int currentRow, |
| 377 | 327 int currentColumn, |
| 378 | 328 int previousRow, |
| 379 | 329 int previousColumn) |
| 380 void EditLogDialog::on_SampleView_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn) | |
| 381 { | 330 { |
| 382 uint16_t sampleSector; | 331 uint16_t sampleSector; |
| 383 uint8_t headerRow, headerColumn; | 332 uint8_t headerRow, headerColumn; |
| 384 SLogbookHeader* LogInfo; | 333 SLogbookHeader *LogInfo; |
| 385 SLogbookHeader* LogInfo2nd; | 334 SLogbookHeader *LogInfo2nd; |
| 386 uint32_t sectorStart, sectorEnd; | 335 uint32_t sectorStart, sectorEnd; |
| 387 uint32_t sampleAddrStart, sampleAddrEnd; | 336 uint32_t sampleAddrStart, sampleAddrEnd; |
| 388 QTableWidget* headerView = _ui->SectorView; | 337 QTableWidget *headerView = _ui->SectorView; |
| 389 | 338 |
| 390 sampleSector = currentRow * 16 + currentColumn; | 339 sampleSector = currentRow * 16 + currentColumn; |
| 391 sectorStart = sampleSector * 0x10000 + 0x100000; | 340 sectorStart = sampleSector * 0x10000 + 0x100000; |
| 392 sectorEnd = sectorStart +0xFFFF; | 341 sectorEnd = sectorStart + 0xFFFF; |
| 393 if(SampleBuffer[sectorStart - 0x100000] != 0xFF) // is buffer used? | 342 if (SampleBuffer[sectorStart - 0x100000] != 0xFF) // is buffer used? |
| 394 { | 343 { |
| 395 updateHeaderStatus(); | 344 updateHeaderStatus(); |
| 396 for(headerRow = 0; headerRow < 16; headerRow++) | 345 for (headerRow = 0; headerRow < 16; headerRow++) { |
| 397 { | 346 for (headerColumn = 0; headerColumn < 16; headerColumn++) { |
| 398 for(headerColumn = 0; headerColumn < 16; headerColumn++) | 347 LogInfo = (SLogbookHeader *) (HeaderBuffer |
| 399 { | 348 + (0x800 * (headerRow * 16 + headerColumn))); |
| 400 LogInfo = (SLogbookHeader*)(HeaderBuffer+(0x800 * (headerRow*16+headerColumn))); | 349 LogInfo2nd = (SLogbookHeader *) (HeaderBuffer |
| 401 LogInfo2nd = (SLogbookHeader*)(HeaderBuffer+(0x800 * (headerRow*16+headerColumn)) +0x400); | 350 + (0x800 * (headerRow * 16 + headerColumn)) |
| 402 sampleAddrStart = (LogInfo->pBeginProfileData[2]<<16) + (LogInfo->pBeginProfileData[1]<<8) + LogInfo->pBeginProfileData[0]; | 351 + 0x400); |
| 403 sampleAddrEnd = (LogInfo2nd->pEndProfileData[2]<<16) + (LogInfo2nd->pEndProfileData[1]<<8) + LogInfo2nd->pEndProfileData[0]; | 352 sampleAddrStart = (LogInfo->pBeginProfileData[2] << 16) |
| 404 | 353 + (LogInfo->pBeginProfileData[1] << 8) |
| 405 if(((sampleAddrStart >= sectorStart)&&(sampleAddrStart < sectorEnd) | 354 + LogInfo->pBeginProfileData[0]; |
| 406 || (sampleAddrEnd >= sectorStart)&&(sampleAddrEnd < sectorEnd))) | 355 sampleAddrEnd = (LogInfo2nd->pEndProfileData[2] << 16) |
| 407 { | 356 + (LogInfo2nd->pEndProfileData[1] << 8) |
| 357 + LogInfo2nd->pEndProfileData[0]; | |
| 358 | |
| 359 if (((sampleAddrStart >= sectorStart) && (sampleAddrStart < sectorEnd) | |
| 360 || (sampleAddrEnd >= sectorStart) && (sampleAddrEnd < sectorEnd))) { | |
| 408 headerView->item(headerRow, headerColumn)->setBackground(Qt::magenta); | 361 headerView->item(headerRow, headerColumn)->setBackground(Qt::magenta); |
| 409 } | 362 } |
| 410 } | 363 } |
| 411 } | 364 } |
| 412 } | 365 } |
