Skip to content

Commit

Permalink
Re-jigged SPVReader class
Browse files Browse the repository at this point in the history
Cleaned and broken up the class into more easierly read functions. Renamed functions and many vars to camel case to again make it easier to understand what is going on. Alos tweeked the Object tree view widget to show objects with blank/missing names as "Unknown 1, Unknown 2, ...".
  • Loading branch information
alanspencer committed Oct 30, 2018
1 parent 975d8c3 commit a18d691
Show file tree
Hide file tree
Showing 3 changed files with 976 additions and 945 deletions.
26 changes: 18 additions & 8 deletions SPIERSview/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ void MainWindow::StartTimer_fired()

QString shortfname = QString(PRODUCTNAME) + " v" + QString(SOFTWARE_VERSION) + " - " + fname.mid(qMax(fname.lastIndexOf("\\"), fname.lastIndexOf("/")) + 1);
this->setWindowTitle(shortfname);
SPVreader reader;
reader.ProcessFile(fname);
SPVReader reader;
reader.processFile(fname);

//qDebug() << "[Where I'm I?] In StartTimer_fired - about to call RefreshInfo()";
RefreshInfo();
Expand Down Expand Up @@ -840,8 +840,15 @@ void MainWindow::RefreshOneItem(QTreeWidgetItem *item, int i)
QTextStream rs(&ResampleSt);
rs << SVObjects[i]->Resample << "%";

item->setText(0, SVObjects[i]->Name);

// This forces models with blank or missing object names to have something
if (SVObjects[i]->Name.isEmpty() | SVObjects[i]->Name.isNull())
{
item->setText(0, QString ("Unknown %1").arg(i));
}
else
{
item->setText(0, SVObjects[i]->Name);
}

QLabel *show = new QLabel();
show->setAlignment(Qt::AlignCenter);
Expand Down Expand Up @@ -908,6 +915,9 @@ void MainWindow::RefreshOneItem(QTreeWidgetItem *item, int i)
if (SVObjects[i]->Shininess < 0) t.sprintf("Custom (%d%%)", 0 - SVObjects[i]->Shininess);
item->setText(8, t);
}

// Resize tree so name is fully shown
ui->treeWidget->resizeColumnToContents(0);
}

/**
Expand Down Expand Up @@ -2477,8 +2487,8 @@ void MainWindow::on_actionImport_SPV_triggered()
if (ifname.isNull()) return; //if nothing there, cancel

//OK, we have a file. Try
SPVreader r;
r.ProcessFile(ifname);
SPVReader r;
r.processFile(ifname);
isFileDirty = true;
RefreshInfo();
}
Expand Down Expand Up @@ -2607,8 +2617,8 @@ void MainWindow::on_actionImport_Replacement_triggered()
if (ifname.isNull()) return; //if nothing there, cancel

//OK, we have a file. Try
SPVreader r;
int retcode = r.ProcessFileReplacement(ifname, ui->PiecesList->currentRow());
SPVReader r;
int retcode = r.processFileReplacement(ifname, ui->PiecesList->currentRow());
if (retcode == -2) QMessageBox::warning(this, "Can't Replace", "Replacement file must contain a single piece only");
if (retcode == -3) QMessageBox::warning(this, "Can't Replace", "Replacement file format too old");

Expand Down

0 comments on commit a18d691

Please sign in to comment.