From 6ec76defdb6622d379e68ee4a4d45f8c9758bb1f Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Tue, 28 Sep 2021 10:23:10 +0200 Subject: New upstream version 2.5.0+repack --- map65/mainwindow.cpp | 83 ++++++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 39 deletions(-) (limited to 'map65/mainwindow.cpp') diff --git a/map65/mainwindow.cpp b/map65/mainwindow.cpp index 48eaf946..5814dca2 100644 --- a/map65/mainwindow.cpp +++ b/map65/mainwindow.cpp @@ -1864,6 +1864,8 @@ void MainWindow::doubleClickOnMessages(QString hiscall, QString t2, bool ctrl) void MainWindow::genStdMsgs(QString rpt) //genStdMsgs() { + if(rpt.left(2)==" -") rpt="-0"+rpt.mid(2,1); + if(rpt.left(2)==" +") rpt="+0"+rpt.mid(2,1); QString hiscall=ui->dxCallEntry->text().toUpper().trimmed(); ui->dxCallEntry->setText(hiscall); QString t0=hiscall + " " + m_myCall + " "; @@ -1968,58 +1970,61 @@ void MainWindow::on_addButton_clicked() //Add button << endl #endif ; - f1.close(); - f1.open(QIODevice::ReadOnly | QIODevice::Text); + f1.seek (0); } QString tmpFile = m_appDir + "/CALL3.TMP"; QFile f2(tmpFile); - if(!f2.open(QIODevice::WriteOnly | QIODevice::Text)) { + if(!f2.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text)) { msgBox("Cannot open " + tmpFile); return; } - QTextStream in(&f1); - QTextStream out(&f2); - QString hc=hiscall; - QString hc1=""; - QString hc2="000000"; - QString s; - do { - s=in.readLine(); - hc1=hc2; - if(s.mid(0,2)=="//") { - out << s + "\n"; - } else { - int i1=s.indexOf(","); - hc2=s.mid(0,i1); - if(hc>hc1 && hchc1 && hchc1 && !m_call3Modified) out << newEntry + "\n"; + } while(!s.isNull()); + if(hc>hc1 && !m_call3Modified) out << newEntry + "\n"; + } + if(m_call3Modified) { - QFile f0(m_appDir + "/CALL3.OLD"); - if(f0.exists()) f0.remove(); - QFile f1(m_appDir + "/CALL3.TXT"); - f1.rename(m_appDir + "/CALL3.OLD"); - f2.rename(m_appDir + "/CALL3.TXT"); - f2.close(); + auto const& old_path = m_appDir + "/CALL3.OLD"; + QFile f0 {old_path}; + if (f0.exists ()) f0.remove (); + f1.copy (old_path); // copying as we want to preserve + // symlinks + f1.open (QFile::WriteOnly | QFile::Text); // truncates + f2.seek (0); + f1.write (f2.readAll ()); // copy contents + f2.remove (); } } -- cgit v1.2.3