|
|
|
|
@ -5,6 +5,7 @@
|
|
|
|
|
#include <QSettings>
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include "cdac.h"
|
|
|
|
|
|
|
|
|
|
library::library(QWidget *parent) :
|
|
|
|
|
QDialog(parent),
|
|
|
|
|
@ -13,6 +14,7 @@ library::library(QWidget *parent) :
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
unsaved=false;
|
|
|
|
|
speakerUnsaved=false;
|
|
|
|
|
dacUnsaved=false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
library::~library()
|
|
|
|
|
@ -51,6 +53,22 @@ cSpeaker *library::getSpeaker()
|
|
|
|
|
return m_pSpeaker;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void library::setDacPoint(cdac *dac, unsigned int dacCount)
|
|
|
|
|
{
|
|
|
|
|
m_pDac=dac;
|
|
|
|
|
m_dacCount=dacCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned int library::getDacCount()
|
|
|
|
|
{
|
|
|
|
|
return m_dacCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cdac *library::getDacs()
|
|
|
|
|
{
|
|
|
|
|
return m_pDac;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void library::open()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
@ -62,23 +80,15 @@ void library::open()
|
|
|
|
|
//qDebug() << settings.value("library/path","none").toString();
|
|
|
|
|
refreshAmpView();
|
|
|
|
|
refreshSpeakerView();
|
|
|
|
|
refreshDacView();
|
|
|
|
|
this->exec();
|
|
|
|
|
if (unsaved or speakerUnsaved){
|
|
|
|
|
QMessageBox::StandardButton reply;
|
|
|
|
|
reply = QMessageBox::question(this, "Unsaved Changes", "Save unsaved Changes?",
|
|
|
|
|
QMessageBox::Yes|QMessageBox::No);
|
|
|
|
|
if (reply == QMessageBox::Yes) {
|
|
|
|
|
on_pushButton_applyChanges_clicked();
|
|
|
|
|
on_pushButton_applySpeaker_clicked();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
saveLibraryToFile();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void library::on_pushButton_addAmp_clicked()
|
|
|
|
|
{
|
|
|
|
|
confirmAmpChanges();
|
|
|
|
|
m_cAmpCount+=1;
|
|
|
|
|
cAmp* tempAmps=new cAmp[m_cAmpCount];
|
|
|
|
|
for (unsigned int i=0;i<m_cAmpCount-1;i++){
|
|
|
|
|
@ -133,6 +143,14 @@ void library::refreshSpeakerView()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void library::refreshDacView()
|
|
|
|
|
{
|
|
|
|
|
ui->listWidget_dacView->clear();
|
|
|
|
|
for (unsigned int i=0;i<m_dacCount;i++){
|
|
|
|
|
ui->listWidget_dacView->addItem(QString::fromStdString(m_pDac[i].name()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int library::getCurrentAmpIndex()
|
|
|
|
|
{
|
|
|
|
|
return ui->listWidget_ampView->currentRow();
|
|
|
|
|
@ -148,6 +166,83 @@ int library::getCurrentSpeakerIndex()
|
|
|
|
|
return ui->listWidget_speakerView->currentRow();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int library::getCurrentDacIndex()
|
|
|
|
|
{
|
|
|
|
|
return ui->listWidget_dacView->currentRow();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void library::ampEdited()
|
|
|
|
|
{
|
|
|
|
|
if(unsaved==false){
|
|
|
|
|
ui->listWidget_ampView->currentItem()->setText(ui->listWidget_ampView->currentItem()->text()+QString::fromStdString("*"));
|
|
|
|
|
unsaved =true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void library::speakerEdited()
|
|
|
|
|
{
|
|
|
|
|
if (speakerUnsaved==false){
|
|
|
|
|
ui->listWidget_speakerView->currentItem()->setText(ui->listWidget_speakerView->currentItem()->text()+QString::fromStdString("*"));
|
|
|
|
|
speakerUnsaved =true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void library::dacEdited()
|
|
|
|
|
{
|
|
|
|
|
if (dacUnsaved==false){
|
|
|
|
|
ui->listWidget_dacView->currentItem()->setText(ui->listWidget_dacView->currentItem()->text()+QString::fromStdString("*"));
|
|
|
|
|
dacUnsaved =true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void library::confirmAmpChanges()
|
|
|
|
|
{
|
|
|
|
|
if (unsaved){
|
|
|
|
|
int selectedRow=getCurrentAmpIndex();
|
|
|
|
|
ui->tabWidget->setCurrentIndex(0);
|
|
|
|
|
QMessageBox::StandardButton reply;
|
|
|
|
|
reply = QMessageBox::question(this, "Unsaved Changes", "Save unsaved Changes?",
|
|
|
|
|
QMessageBox::Yes|QMessageBox::No);
|
|
|
|
|
if (reply == QMessageBox::Yes) {
|
|
|
|
|
on_pushButton_applyChanges_clicked();
|
|
|
|
|
}
|
|
|
|
|
refreshAmpView();
|
|
|
|
|
ui->listWidget_ampView->setCurrentRow(selectedRow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void library::confirmSpeakerChanges()
|
|
|
|
|
{
|
|
|
|
|
if (speakerUnsaved){
|
|
|
|
|
int selectedRow=getCurrentSpeakerIndex();
|
|
|
|
|
ui->tabWidget->setCurrentIndex(1);
|
|
|
|
|
QMessageBox::StandardButton reply;
|
|
|
|
|
reply = QMessageBox::question(this, "Unsaved Changes", "Save unsaved Changes?",
|
|
|
|
|
QMessageBox::Yes|QMessageBox::No);
|
|
|
|
|
if (reply == QMessageBox::Yes) {
|
|
|
|
|
on_pushButton_applySpeaker_clicked();
|
|
|
|
|
}
|
|
|
|
|
refreshSpeakerView();
|
|
|
|
|
ui->listWidget_speakerView->setCurrentRow(selectedRow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void library::confirmDacChanges()
|
|
|
|
|
{
|
|
|
|
|
if (dacUnsaved){
|
|
|
|
|
int selectedRow=getCurrentDacIndex();
|
|
|
|
|
ui->tabWidget->setCurrentIndex(2);
|
|
|
|
|
QMessageBox::StandardButton reply;
|
|
|
|
|
reply = QMessageBox::question(this, "Unsaved Changes", "Save unsaved Changes?",
|
|
|
|
|
QMessageBox::Yes|QMessageBox::No);
|
|
|
|
|
if (reply == QMessageBox::Yes) {
|
|
|
|
|
on_pushButton_Apply_clicked();
|
|
|
|
|
}
|
|
|
|
|
refreshDacView();
|
|
|
|
|
ui->listWidget_dacView->setCurrentRow(selectedRow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void library::printAllAmps()
|
|
|
|
|
{
|
|
|
|
|
std::cout << "Number of Amps: "<<m_cAmpCount<<std::endl<<std::endl;
|
|
|
|
|
@ -157,33 +252,6 @@ void library::printAllAmps()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void library::saveLibraryToFile()
|
|
|
|
|
{
|
|
|
|
|
QSettings settings("DKM-Tech","Pa-Calculator");
|
|
|
|
|
QString fileName = settings.value("library/path",QString::fromStdString("")).toString();
|
|
|
|
|
if (fileName.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
else {
|
|
|
|
|
QFile file(fileName);
|
|
|
|
|
if (!file.open(QIODevice::WriteOnly)) {
|
|
|
|
|
QMessageBox::information(this, tr("Unable to open file"),
|
|
|
|
|
file.errorString());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QDataStream out(&file);
|
|
|
|
|
out.setVersion(QDataStream::Qt_4_5);
|
|
|
|
|
out << (uint)m_cAmpCount;
|
|
|
|
|
for (unsigned int j=0;j<m_cAmpCount;j++){
|
|
|
|
|
out << m_pCamp[j];
|
|
|
|
|
}
|
|
|
|
|
out << (uint)m_SpeakerCount;
|
|
|
|
|
for (unsigned int j=0;j<m_SpeakerCount;j++){
|
|
|
|
|
out << m_pSpeaker[j];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void library::on_listWidget_ampView_currentRowChanged(int currentRow)
|
|
|
|
|
{
|
|
|
|
|
@ -227,6 +295,7 @@ void library::on_pushButton_applyChanges_clicked()
|
|
|
|
|
|
|
|
|
|
void library::on_comboBox_sensUnit_currentIndexChanged(int index)
|
|
|
|
|
{
|
|
|
|
|
ampEdited();
|
|
|
|
|
double oldValue=ui->doubleSpinBox_inputSensitivity->value();
|
|
|
|
|
if (index==0){
|
|
|
|
|
ui->doubleSpinBox_inputSensitivity->setSuffix(QString(" V"));
|
|
|
|
|
@ -257,7 +326,7 @@ void library::on_pushButton_deleteAmp_clicked()
|
|
|
|
|
m_pCamp=tempAmps;
|
|
|
|
|
|
|
|
|
|
refreshAmpView();
|
|
|
|
|
if (selectedRow-1<0 && m_cAmpCount>0){
|
|
|
|
|
if ((selectedRow<1) and (m_cAmpCount>0)){
|
|
|
|
|
ui->listWidget_ampView->setCurrentRow(0);
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
@ -302,7 +371,7 @@ void library::on_pushButton_deleteMode_clicked()
|
|
|
|
|
int selectedRow=getCurrentAmpModeIndex();
|
|
|
|
|
m_pCamp[getCurrentAmpIndex()].deleteAmpMode(getCurrentAmpModeIndex());
|
|
|
|
|
refreshModeOverview();
|
|
|
|
|
if (selectedRow-1<0 && m_pCamp[getCurrentAmpIndex()].getAmpModesCount()){
|
|
|
|
|
if ((selectedRow<1) && (m_pCamp[getCurrentAmpIndex()].getAmpModesCount())>0){
|
|
|
|
|
ui->listWidget_modeSelector->setCurrentRow(0);
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
@ -329,15 +398,13 @@ void library::on_pushButton_applyMode_clicked()
|
|
|
|
|
|
|
|
|
|
void library::on_lineEdit_ampName_textEdited(const QString &arg1)
|
|
|
|
|
{
|
|
|
|
|
if (unsaved==false){
|
|
|
|
|
ui->listWidget_ampView->currentItem()->setText(ui->listWidget_ampView->currentItem()->text()+QString::fromStdString("*"));
|
|
|
|
|
unsaved =true;
|
|
|
|
|
}
|
|
|
|
|
ampEdited();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void library::on_pushButton_addSpeaker_clicked()
|
|
|
|
|
{
|
|
|
|
|
confirmSpeakerChanges();
|
|
|
|
|
m_SpeakerCount+=1;
|
|
|
|
|
cSpeaker* tempSpeaker=new cSpeaker[m_SpeakerCount];
|
|
|
|
|
for (unsigned int i=0;i<m_SpeakerCount-1;i++){
|
|
|
|
|
@ -373,7 +440,7 @@ void library::on_listWidget_speakerView_currentRowChanged(int currentRow)
|
|
|
|
|
//ui->spinBox_speakerHPF->setEnabled(true);
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
//ui->lineEdit_speakerName->setEnabled(false);
|
|
|
|
|
ui->lineEdit_speakerName->setEnabled(false);
|
|
|
|
|
//ui->spinBox_speakerImp->setEnabled(false);
|
|
|
|
|
//ui->spinBox_speakerRMSPower->setEnabled(false);
|
|
|
|
|
//ui->spinBox_speakerPeakPower->setEnabled(false);
|
|
|
|
|
@ -399,7 +466,7 @@ void library::on_pushButton_deleteSpeaker_clicked()
|
|
|
|
|
m_pSpeaker=tempSpeaker;
|
|
|
|
|
|
|
|
|
|
refreshSpeakerView();
|
|
|
|
|
if (selectedRow-1<0 && m_SpeakerCount>0){
|
|
|
|
|
if ((selectedRow<1) and (m_SpeakerCount>0)){
|
|
|
|
|
ui->listWidget_speakerView->setCurrentRow(0);
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
@ -430,9 +497,123 @@ void library::on_pushButton_applySpeaker_clicked()
|
|
|
|
|
|
|
|
|
|
void library::on_lineEdit_speakerName_textEdited(const QString &arg1)
|
|
|
|
|
{
|
|
|
|
|
if (speakerUnsaved==false){
|
|
|
|
|
ui->listWidget_speakerView->currentItem()->setText(ui->listWidget_speakerView->currentItem()->text()+QString::fromStdString("*"));
|
|
|
|
|
speakerUnsaved =true;
|
|
|
|
|
speakerEdited();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void library::on_pushButton_dacAdd_clicked()
|
|
|
|
|
{
|
|
|
|
|
confirmDacChanges();
|
|
|
|
|
m_dacCount+=1;
|
|
|
|
|
cdac* tempDac=new cdac[m_dacCount];
|
|
|
|
|
for (unsigned int i=0;i<m_dacCount-1;i++){
|
|
|
|
|
tempDac[i].setName(m_pDac[i].name());
|
|
|
|
|
tempDac[i].setOutputLevel(m_pDac[i].outputLevel());
|
|
|
|
|
}
|
|
|
|
|
delete [] m_pDac;
|
|
|
|
|
m_pDac=tempDac;
|
|
|
|
|
m_pDac[m_dacCount-1].setName("Unnamed DAC");
|
|
|
|
|
m_pDac[m_dacCount-1].setOutputLevel(0);
|
|
|
|
|
refreshDacView();
|
|
|
|
|
ui->listWidget_dacView->setCurrentRow(m_dacCount-1);
|
|
|
|
|
ui->lineEdit_dacName->setFocus();
|
|
|
|
|
ui->lineEdit_dacName->selectAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void library::on_pushButton_deleteDac_clicked()
|
|
|
|
|
{
|
|
|
|
|
if (getCurrentDacIndex()>=0){
|
|
|
|
|
m_dacCount-=1;
|
|
|
|
|
cdac* tempdac=new cdac[m_dacCount];
|
|
|
|
|
unsigned int selectedRow=getCurrentDacIndex();
|
|
|
|
|
for (unsigned int i=0;i<selectedRow;i++){
|
|
|
|
|
tempdac[i]=m_pDac[i];
|
|
|
|
|
}
|
|
|
|
|
for (unsigned int i=selectedRow+1;i<m_dacCount+1;i++){
|
|
|
|
|
tempdac[i-1]=m_pDac[i];
|
|
|
|
|
}
|
|
|
|
|
delete [] m_pDac;
|
|
|
|
|
m_pDac=tempdac;
|
|
|
|
|
|
|
|
|
|
refreshDacView();
|
|
|
|
|
if ((selectedRow<1) and (m_dacCount>0)){
|
|
|
|
|
ui->listWidget_dacView->setCurrentRow(0);
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
ui->listWidget_dacView->setCurrentRow(selectedRow-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void library::on_pushButton_Apply_clicked()
|
|
|
|
|
{
|
|
|
|
|
if (getCurrentDacIndex()>=0){
|
|
|
|
|
dacUnsaved =false;
|
|
|
|
|
m_pDac[getCurrentDacIndex()].setName(ui->lineEdit_dacName->text().toStdString());
|
|
|
|
|
m_pDac[getCurrentDacIndex()].setOutputLevel(ui->spinBox_dacOutputLevel->value());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int selectedRow=getCurrentDacIndex();
|
|
|
|
|
refreshDacView();
|
|
|
|
|
ui->listWidget_dacView->setCurrentRow(selectedRow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void library::on_listWidget_dacView_currentRowChanged(int currentRow)
|
|
|
|
|
{
|
|
|
|
|
if (currentRow>=0){
|
|
|
|
|
ui->lineEdit_dacName->setText(QString::fromStdString(m_pDac[currentRow].name()));
|
|
|
|
|
ui->spinBox_dacOutputLevel->setValue(m_pDac[currentRow].outputLevel());
|
|
|
|
|
ui->lineEdit_dacName->setEnabled(true);
|
|
|
|
|
}else{
|
|
|
|
|
ui->lineEdit_dacName->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void library::on_lineEdit_dacName_textEdited(const QString &arg1)
|
|
|
|
|
{
|
|
|
|
|
//dacEdited();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void library::on_spinBox_dacOutputLevel_editingFinished()
|
|
|
|
|
{
|
|
|
|
|
//dacEdited();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void library::on_spinBox_speakerImp_editingFinished()
|
|
|
|
|
{
|
|
|
|
|
//speakerEdited();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void library::on_spinBox_speakerRMSPower_editingFinished()
|
|
|
|
|
{
|
|
|
|
|
//speakerEdited();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void library::on_spinBox_speakerPeakPower_editingFinished()
|
|
|
|
|
{
|
|
|
|
|
//speakerEdited();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void library::on_spinBox_speakerHPF_editingFinished()
|
|
|
|
|
{
|
|
|
|
|
//speakerEdited();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void library::on_doubleSpinBox_inputSensitivity_editingFinished()
|
|
|
|
|
{
|
|
|
|
|
//ampEdited();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|