mainwindow.cpp 21.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QTimer>
#include <QDateTime>
#include <QCompleter>
#include <QFileDialog>
#include <QMessageBox>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    nrs(001),
    datetime(),
    band("70cm"),
    callList(new QStringList),
    excList(new QStringList),
    workedVhf(new QStringList),
    workedUhf(new QStringList),
    multVhf(new QStringList),
    multUhf(new QStringList),
    logfile()
{
    ui->setupUi(this);

    // QAction CTRL+Q to quit the app
    QAction *quit = new QAction(this);
    quit->setShortcut(Qt::Key_Q | Qt::CTRL);
    connect(quit, SIGNAL(triggered()), this, SLOT(close()));
    this->addAction(quit);

    // QAction CTRL+B to change the band
    QAction *changeBandShortcut = new QAction(this);
    changeBandShortcut->setShortcut(Qt::Key_B | Qt::CTRL);
    connect(changeBandShortcut, SIGNAL(triggered()), this, SLOT(changeBand()));
    this->addAction(changeBandShortcut);

    // QAction CTRL+C to save log file
    QAction *saveLogfileShortcut = new QAction(this);
    saveLogfileShortcut->setShortcut(Qt::Key_S | Qt::CTRL);
    connect(saveLogfileShortcut, SIGNAL(triggered()), this, SLOT(saveLogfile()));
    this->addAction(saveLogfileShortcut);

    // Regexes für Call, No-R, Exc
    QRegExp regexCall("[0-9A-Za-z/-]{3,20}[ ]?");
    ui->lineEdit_call->setValidator(new QRegExpValidator(regexCall, 0));
    ui->lineEdit_myCall->setValidator(new QRegExpValidator(regexCall, 0));
    QRegExp regexNrr("[0-9]{0,5}");
    ui->lineEdit_nrr->setValidator(new QRegExpValidator(regexNrr, 0));
    QRegExp regexExc("[A-Za-z-]{0,6}[ ]?");
    ui->lineEdit_exc->setValidator(new QRegExpValidator(regexExc, 0));
    ui->lineEdit_myExc->setValidator(new QRegExpValidator(regexExc, 0));

    // UTC
    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(updateTime()));
    timer->start(1000);

    // Table resizing & order
    ui->tableWidget->setColumnWidth(0,45);
    ui->tableWidget->setColumnWidth(1,45);
    ui->tableWidget->setColumnWidth(2,45);
    ui->tableWidget->setColumnWidth(3,90);
    ui->tableWidget->setColumnWidth(4,45);
    ui->tableWidget->setColumnWidth(5,100);
    ui->tableWidget->setColumnWidth(6,40);
    ui->tableWidget->setColumnWidth(7,60);
    ui->tableWidget->setColumnWidth(8,100);
    ui->tableWidget->setColumnWidth(9,40);
    ui->tableWidget->setColumnWidth(10,60);
    ui->tableWidget->setColumnWidth(11,45);
    ui->tableWidget->setColumnWidth(12,20);
    ui->tableWidget->setColumnWidth(13,20);
    ui->tableWidget->sortByColumn(0,Qt::DescendingOrder);

    // data completer for input fields
    completerSetData();

}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::changeBand()
{
    if(band == "70cm") {
        band = "2m";
    }
    else {
        band = "70cm";
    }

    ui->label_band->setText(band);
    checkDupes();
    checkMultis();

}

void MainWindow::updateTime()
{
    datetime = QDateTime::currentDateTimeUtc();
    ui->label_utc->setText(datetime.toString("hh:mm"));
}

void MainWindow::on_lineEdit_call_textChanged()
{
    //QLineEdit *le = qobject_cast<QLineEdit *>(sender());
    //if (!le)
    //    return;
    //QLineEdit *le = ui->lineEdit_call;
    //int cursorPos = le->cursorPosition();
    //le->setText(arg1.toUpper());
    //le->setCursorPosition(cursorPos);

    setLineUppercase(ui->lineEdit_call);
    checkSpace(ui->lineEdit_call);
    checkDupes();

}

void MainWindow::on_lineEdit_exc_textChanged()
{
    setLineUppercase(ui->lineEdit_exc);
    checkSpace(ui->lineEdit_exc);
    checkMultis();
}

void MainWindow::on_lineEdit_myExc_textChanged()
{
    QLineEdit *le = ui->lineEdit_myExc;
    setLineUppercase(le);
    if(le->text() != "")
        le->setStyleSheet("background-color: rgb(230, 230, 230);");
    else le->setStyleSheet("color: rgb(255, 0, 0);");
}

void MainWindow::on_lineEdit_myCall_textChanged()
{
    QLineEdit *le = ui->lineEdit_myCall;
    setLineUppercase(le);
    if(le->text() != "")
        le->setStyleSheet("background-color: rgb(230, 230, 230);");
    else le->setStyleSheet("color: rgb(255, 0, 0);");
}


void MainWindow::on_lineEdit_myOperators_textChanged()
{
    QLineEdit *le = ui->lineEdit_myOperators;
    if(le->text() != "")
        le->setStyleSheet("background-color: rgb(230, 230, 230);");
    else le->setStyleSheet("color: rgb(255, 0, 0);");
}

void MainWindow::setLineUppercase(QLineEdit *le) {
    int cursorPos = le->cursorPosition();
    le->setText(le->text().toUpper());
    le->setCursorPosition(cursorPos);
}

void MainWindow::checkSpace(QLineEdit *le) {
    QString txt = le->text();
    if(txt.size()>=1 && txt[txt.size()-1] == ' ') {
        le->setText(txt.trimmed());
        le->nextInFocusChain()->setFocus();
    }
}

void MainWindow::on_lineEdit_call_returnPressed()
{
    saveQso();
}

void MainWindow::on_lineEdit_nrr_returnPressed()
{
    saveQso();
}

void MainWindow::on_lineEdit_exc_returnPressed()
{
    saveQso();
}

// save QSO to QTableWidget

void MainWindow::saveQso()
{

    if(ui->lineEdit_call->text().size() < 3) {
        return;
    }
    if(ui->lineEdit_logfile->text() == "") {
        QMessageBox messageBox;
        messageBox.critical(0,"Error","Logging not possible without log file path!");
        return;
    }

    ui->tableWidget->insertRow(nrs-1);
    // TODO sauber implementieren

    QTableWidgetItem *newItem0=new QTableWidgetItem();
    QTableWidgetItem *newItem1=new QTableWidgetItem();
    QTableWidgetItem *newItem2=new QTableWidgetItem();
    QTableWidgetItem *newItem3=new QTableWidgetItem();
    QTableWidgetItem *newItem4=new QTableWidgetItem();
    QTableWidgetItem *newItem5=new QTableWidgetItem();
    QTableWidgetItem *newItem6=new QTableWidgetItem();
    QTableWidgetItem *newItem7=new QTableWidgetItem();
    QTableWidgetItem *newItem8=new QTableWidgetItem();
    QTableWidgetItem *newItem9=new QTableWidgetItem();
    QTableWidgetItem *newItem10=new QTableWidgetItem();
    QTableWidgetItem *newItem11=new QTableWidgetItem();
    QTableWidgetItem *newItem12=new QTableWidgetItem();
    QTableWidgetItem *newItem13=new QTableWidgetItem();

    newItem0->setData(Qt::DisplayRole, nrs);
    if(ui->label_band->text() == "70cm")
        newItem1->setText("432");
    else
        newItem1->setText("144");
    newItem2->setText("FM");
    newItem3->setText(datetime.toString("yyyy-MM-dd"));
    newItem4->setText(datetime.toString("hhmm"));
    newItem5->setText(ui->lineEdit_myCall->text());
    newItem6->setText("59");
    newItem7->setText(ui->lineEdit_myExc->text());
    newItem8->setText(ui->lineEdit_call->text());
    newItem9->setText("59");
    newItem10->setText(ui->lineEdit_exc->text());
    newItem11->setText(ui->lineEdit_nrr->text());
    newItem12->setText("0");
    newItem13->data(Qt::CheckStateRole);
    newItem13->setCheckState(Qt::Unchecked);

    ui->tableWidget->setSortingEnabled(false);
    ui->tableWidget->setItem(nrs-1,0,newItem0);
    ui->tableWidget->setItem(nrs-1,1,newItem1);
    ui->tableWidget->setItem(nrs-1,2,newItem2);
    ui->tableWidget->setItem(nrs-1,3,newItem3);
    ui->tableWidget->setItem(nrs-1,4,newItem4);
    ui->tableWidget->setItem(nrs-1,5,newItem5);
    ui->tableWidget->setItem(nrs-1,6,newItem6);
    ui->tableWidget->setItem(nrs-1,7,newItem7);
    ui->tableWidget->setItem(nrs-1,8,newItem8);
    ui->tableWidget->setItem(nrs-1,9,newItem9);
    ui->tableWidget->setItem(nrs-1,10,newItem10);
    ui->tableWidget->setItem(nrs-1,11,newItem11);
    ui->tableWidget->setItem(nrs-1,12,newItem12);
    ui->tableWidget->setItem(nrs-1,13,newItem13);
    ui->tableWidget->setSortingEnabled(true);

    saveLogfile();

    nrs += 1;
    ui->label_nrs->setText(QString::number(nrs));

    ui->lineEdit_call->setText("");
    ui->lineEdit_nrr->setText("");
    ui->lineEdit_exc->setText("");

    ui->lineEdit_call->setFocus();
}

void MainWindow::saveLogfile() {

    // there must be a log file
    if(logfile == "") {
        on_pushButton_clicked();
        return;
    }

    // open file and write header
    QFile file(logfile);
    QTextStream out(&file);
    if (!file.open(QFile::WriteOnly | QFile::Text))
        return;
    out << "START-OF-LOG: 3.0\n";
    out << "CALLSIGN: " + ui->lineEdit_myCall->text() + "\n";
    out << "LOCATION: " + ui->lineEdit_myExc->text() + "\n";
    out << "CONTEST: CQ-TU-FM\n";
    out << "CLAIMED-SCORE: " + QString::number(getScore()) + "\n";
    out << "CREATED-BY: CQ TU Logger\n";
    out << "OPERATORS: " + ui->lineEdit_myOperators->text() + "\n";

    // write QSO list
    QTableWidget *tb = ui->tableWidget;
    tb->setSortingEnabled(false);
    tb->sortItems(0);
    for (int i = 0; i < tb->rowCount(); ++i) {

        if (tb->item(i, tb->columnCount()-1)->checkState() == Qt::Checked)
            out << "X-";

        out << "QSO: ";

        for (int j = 1; j < tb->columnCount()-1; ++j) {

            QTableWidgetItem *cell = tb->item(i, j);
            QString cellText = cell->text();
            int cellSize = 0;

            switch(j) {
            case 1: cellSize = 5; break;
            case 2: cellSize = 2; break;
            case 3: cellSize = 10; break;
            case 4: cellSize = 4; break;
            case 5: cellSize = 13; break;
            case 6: cellSize = 3; break;
            case 7: cellSize = 6; break;
            case 8: cellSize = 13; break;
            case 9: cellSize = 3; break;
            case 10: cellSize = 6; break;
            case 11: cellSize = 0; break;
            case 12: cellSize = 1; break;
            }

            cellText = cellText.leftJustified(cellSize, ' ', true);
            if(j<=10)
                cellText = cellText + " ";
            out << cellText;

        }

        out << "\n";

    }

    tb->sortItems(0,Qt::DescendingOrder);
    tb->setSortingEnabled(true);
    //for (int row = 0; row < contactTable->rowCount(); ++row) {
    //QStringList contact;
    //stream << contact.join(",") << "\n";
    //}

    // write footer and close file
    out << "END-OF-LOG:\n";
    file.close();

    ui->statusBar->showMessage("Log file saved", 1000);
}

void MainWindow::on_pushButton_clicked()
{
    QString myCall = ui->lineEdit_myCall->text();
    QString myOperators = ui->lineEdit_myOperators->text();
    QString myExc = ui->lineEdit_myExc->text();

    QMessageBox::StandardButton reply;
    reply = QMessageBox::question(this, "Log file",
                                  "Open existing Cabrillo logfile?",
                                  QMessageBox::Yes|QMessageBox::No);

    if (reply == QMessageBox::Yes) {

        // open existing log file and rad log data
        logfile = QFileDialog::getOpenFileName(this, "Open log file", "", "*.cbr");
        QFile file(logfile);
        QTextStream in(&file);
        if (!file.open(QFile::ReadOnly | QFile::Text))
            return;
        QString str = in.readAll();
        QStringList rows = str.split('\n');
        ui->tableWidget->setRowCount(0);
        nrs = 1;

        //setRowCount(rows.count());
        //setColumnCount(numColumns);

        for (int i = 0; i < rows.count(); ++i) {
            if(rows[i].mid(0,10) == "CALLSIGN: ")
                ui->lineEdit_myCall->setText(rows[i].mid(10,rows[i].length()));
            if(rows[i].mid(0,10) == "LOCATION: ")
                ui->lineEdit_myExc->setText(rows[i].mid(10,rows[i].length()));
            if(rows[i].mid(0,11) == "OPERATORS: ")
                ui->lineEdit_myOperators->setText(rows[i].mid(11,rows[i].length()));

            if((rows[i].mid(0,5) == "QSO: " && rows[i].size() >= 81)
                    || (rows[i].mid(0,7) == "X-QSO: " && rows[i].size() >= 83)) {

                int offset = 0;

                if(rows[i].mid(0,7) == "X-QSO: " )
                    offset = 2;

                ui->tableWidget->insertRow(nrs-1);

                QTableWidgetItem *newItem0=new QTableWidgetItem();
                QTableWidgetItem *newItem1=new QTableWidgetItem();
                QTableWidgetItem *newItem2=new QTableWidgetItem();
                QTableWidgetItem *newItem3=new QTableWidgetItem();
                QTableWidgetItem *newItem4=new QTableWidgetItem();
                QTableWidgetItem *newItem5=new QTableWidgetItem();
                QTableWidgetItem *newItem6=new QTableWidgetItem();
                QTableWidgetItem *newItem7=new QTableWidgetItem();
                QTableWidgetItem *newItem8=new QTableWidgetItem();
                QTableWidgetItem *newItem9=new QTableWidgetItem();
                QTableWidgetItem *newItem10=new QTableWidgetItem();
                QTableWidgetItem *newItem11=new QTableWidgetItem();
                QTableWidgetItem *newItem12=new QTableWidgetItem();
                QTableWidgetItem *newItem13=new QTableWidgetItem();

                newItem0->setData(Qt::DisplayRole, nrs);
                newItem0->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
                newItem1->setText(rows[i].mid(5+offset,5).trimmed());
                newItem2->setText(rows[i].mid(11+offset,2));
                newItem3->setText(rows[i].mid(14+offset,10));
                newItem4->setText(rows[i].mid(25+offset,4));
                newItem5->setText(rows[i].mid(30+offset,13).trimmed());
                newItem6->setText(rows[i].mid(44+offset,3).trimmed());
                newItem7->setText(rows[i].mid(48+offset,6).trimmed());
                newItem8->setText(rows[i].mid(55+offset,13).trimmed());
                newItem9->setText(rows[i].mid(69+offset,3).trimmed());
                newItem10->setText(rows[i].mid(73+offset,6).trimmed());
                newItem12->setText(rows[i].mid(80+offset,1).trimmed());
                newItem13->data(Qt::CheckStateRole);
                if(offset == 0)
                    newItem13->setCheckState(Qt::Unchecked);
                else
                    newItem13->setCheckState(Qt::Checked);

                ui->tableWidget->setSortingEnabled(false);
                ui->tableWidget->setItem(nrs-1,0,newItem0);
                ui->tableWidget->setItem(nrs-1,1,newItem1);
                ui->tableWidget->setItem(nrs-1,2,newItem2);
                ui->tableWidget->setItem(nrs-1,3,newItem3);
                ui->tableWidget->setItem(nrs-1,4,newItem4);
                ui->tableWidget->setItem(nrs-1,5,newItem5);
                ui->tableWidget->setItem(nrs-1,6,newItem6);
                ui->tableWidget->setItem(nrs-1,7,newItem7);
                ui->tableWidget->setItem(nrs-1,8,newItem8);
                ui->tableWidget->setItem(nrs-1,9,newItem9);
                ui->tableWidget->setItem(nrs-1,10,newItem10);
                ui->tableWidget->setItem(nrs-1,11,newItem11);
                ui->tableWidget->setItem(nrs-1,12,newItem12);
                ui->tableWidget->setItem(nrs-1,13,newItem13);
                ui->tableWidget->setSortingEnabled(true);

                nrs++;

            }

            ui->label_nrs->setText(QString::number(nrs));

        }

        file.close();


    } else {
        // Save to new log file
        if(myCall != "" && myExc != "") {
            QString year = datetime.toString("yyyy");
            logfile = QFileDialog::getSaveFileName(this, "Set log file", "cqtu_fm_" + year + "_" + myCall.replace('/','-') + ".cbr", "*.cbr");
        }
        else {
            QMessageBox errorBox;
            errorBox.critical(0,"Error","For logging at least Callsign and Exchange is needed!");
        }
    }

    if(logfile != "") {
        ui->lineEdit_logfile->setText(logfile);
        ui->lineEdit_logfile->setStyleSheet("font-weight: normal;");
        ui->statusBar->showMessage("Log file set", 5000);
    }

}

void MainWindow::completerSetData() {

    // set data for callCompleter

    *excList << "DX";
    *excList << "A" << "A-F" << "AM"<< "AMP"<< "B"<< "BA"<< "BEL"<< "BH-A"<< "BH-N"<< "BIB"<< "C"<< "E"<< "E-N"
             << "EB"<< "EMH"<< "ER"<< "EW"<< "F"<< "FH"<< "H"<< "HBS"<< "HE"<< "HF"<< "HF-LA"<< "HFT"<< "HL"<< "K"
             << "KF"<< "KT"<< "KWT"<< "L"<< "M"<< "MA"<< "MAR"<< "MB"<< "MS"<< "PC"<< "PTZ"<< "RDH"<< "SE-RH"<< "SG"<< "ST"
             << "TA"<< "TAP"<< "TC"<< "TEL"<< "TEM"<< "TK"<< "V"<< "VWS"<< "W"<< "WF"<< "Z";
    *callList << "DK0TU";
    *callList << "DN3GD" << "DN4RF" << "DN1THW" << "DN1CGL" << "DN4BA" << "DN4SE" << "DN3MO" << "DN1SVT" << "DN1FTW" << "DN1BER";
    *callList << "DB2TO"
              << "DB4UM"
              << "DC7QC"
              << "DD0OM"
              << "DD1AX"
              << "DD1PO"
              << "DD4TA"
              << "DF3DS"
              << "DF5GX"
              << "DK4VW"
              << "DK9GD"
              << "DL7JC"
              << "DL7WC"
              << "DL7XJ"
              << "DL7ZN"
              << "DM1RI"
              << "DM7MD"
              << "DB9MAT"
              << "DF4NEN"
              << "DG1TAL"
              << "DJ1MBB"
              << "DJ4KOB"
              << "DL5AMS"
              << "DL5BBN"
              << "DL6TRW"
              << "DL7AIA"
              << "DL7BST"
              << "DL7BUR"
              << "DL7HJS"
              << "DL7HXB"
              << "DL7MTX"
              << "DL7SBA"
              << "DL7SVT"
              << "DL7TKI"
              << "DO2KSG"
              << "VK1XYZ";

    QCompleter* callCompleter = new QCompleter(*callList);
    QCompleter* excCompleter = new QCompleter(*excList);
    ui->lineEdit_call->setCompleter(callCompleter);
    ui->lineEdit_myCall->setCompleter(callCompleter);
    ui->lineEdit_exc->setCompleter(excCompleter);
    ui->lineEdit_myExc->setCompleter(excCompleter);

}

void MainWindow::on_tableWidget_cellChanged(int row, int column)
{
    QTableWidget *tb = ui->tableWidget;
    QTableWidgetItem *cell = tb->item(row, column);

    // correct uppercase writing
    cell->setText(cell->text().toUpper());

    // amend logged calls to lists if a call has changed
    if(column == 8) {

        // callCompleter list
        if(cell->text() != "" && !callList->contains(cell->text())) {
            qDebug() << "Found unknown call: " + cell->text();
            *callList << cell->text();
            QCompleter* callCompleter = new QCompleter(*callList);
            ui->lineEdit_call->setCompleter(callCompleter);
            ui->lineEdit_myCall->setCompleter(callCompleter);
        }

        // worked calls lists
        workedVhf->clear();
        workedUhf->clear();
        QTableWidget *tb = ui->tableWidget;
        for (int i = 0; i < tb->rowCount(); ++i) {
553

554 555
            QTableWidgetItem *cell1 = tb->item(i, 1);
            QString band = cell1->text();
556 557 558 559 560 561 562 563
            QTableWidgetItem *cell8 = tb->item(i, column);
            QString call = cell8->text();
            QTableWidgetItem *cell13 = tb->item(i, 13);
            bool deleted = false;
            if(cell13)
                deleted = tb->item(i, 13)->checkState();

            if(!deleted && call != "" && band == "144" && !workedVhf->contains(call))
564
                *workedVhf << call;
565
            if(!deleted && call != "" && band == "432" && !workedUhf->contains(call))
566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587
                *workedUhf << call;

        }

    }

    // amend logged multis to lists if a exchange has changed
    if(column == 10) {

        // excCompleter list
        if(cell->text() != "" && !excList->contains(cell->text())) {
            qDebug() << "Found unknown exchange: " + cell->text();
            *excList << cell->text();
            QCompleter* excCompleter = new QCompleter(*excList);
            ui->lineEdit_exc->setCompleter(excCompleter);
            ui->lineEdit_myExc->setCompleter(excCompleter);
        }

        // worked multis lists
        multVhf->clear();
        multUhf->clear();
        for (int i = 0; i < tb->rowCount(); ++i) {
588

589 590
            QTableWidgetItem *cell1 = tb->item(i, 1);
            QString band = cell1->text();
591 592 593 594 595 596 597 598
            QTableWidgetItem *cell10 = tb->item(i, column);
            QString exc = cell10->text();
            QTableWidgetItem *cell13 = tb->item(i, 13);
            bool deleted = false;
            if(cell13)
                deleted = tb->item(i, 13)->checkState();

            if(!deleted && exc != "" && band == "144" && !multVhf->contains(exc))
599
                *multVhf << exc;
600
            if(!deleted && exc != "" && band == "432" && !multUhf->contains(exc))
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673
                *multUhf << exc;
        }

    }

    // mark X-QSO lines as deleted
    if(column == 13) {

        for (int i = 0; i < tb->columnCount()-1; ++i) {

            QTableWidgetItem *striker = tb->item(row, i);
            QFont font = striker->font();

            if(cell->checkState()) {
                font.setStrikeOut(true);
                font.setWeight(0);
            }
            else {
                font.setStrikeOut(false);
                font.setWeight(QFont::Normal);
            }

            striker->setFont(font);

        }

    }

    ui->label_score->setText("Score: " + QString::number(getScore()) + " pts");

}

void MainWindow::checkDupes() {

    QString call = ui->lineEdit_call->text();

    if((band == "2m" && workedVhf->contains(call)) || (band == "70cm" && workedUhf->contains(call))) {
        ui->label_call->setText("Call (dupe)");
        ui->label_call->setStyleSheet("background-color: red;");
    }
    else if ((band == "70cm" && workedVhf->contains(call)) || (band == "2m" && workedUhf->contains(call))) {
        ui->label_call->setText("Call (worked)");
        ui->label_call->setStyleSheet("background-color: lightgreen;");
    }
    else if (call.size() >= 3) {
        ui->label_call->setText("Call (new)");
        ui->label_call->setStyleSheet("background-color: lightgreen;");
    }
    else {
        ui->label_call->setText("Call");
        ui->label_call->setStyleSheet("");
    }

}

void MainWindow::checkMultis() {

    QString exc = ui->lineEdit_exc->text();

    if (exc.size() >= 1 && ((band == "70cm" && !multUhf->contains(exc)) || (band == "2m" && !multVhf->contains(exc)))) {
        ui->label_exc->setText("Multi!");
        ui->label_exc->setStyleSheet("background-color: lightgreen;");
    }
    else {
        ui->label_exc->setText("Exch");
        ui->label_exc->setStyleSheet("");
    }

}

int MainWindow::getScore() {
    return (workedVhf->size() + workedUhf->size()) * (multVhf->size() + multUhf->size());
}