Commit 1a7483ef authored by Allan Anderson's avatar Allan Anderson
Browse files

BUG:282763 - CSV Plugin crash on importing after continuing following error messages.

BUG:324491 - Correct situation in progressing following error messages.
parent 092f3a79
......@@ -284,6 +284,7 @@ void CSVDialog::init()
connect(m_pageLinesDate->ui->spinBox_skipToLast, SIGNAL(valueChanged(int)), this, SLOT(endLineChanged(int)));
connect(m_pageLinesDate->ui->comboBox_dateFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(dateFormatSelected(int)));
connect(m_pageLinesDate->ui->comboBox_dateFormat, SIGNAL(currentIndexChanged(int)), m_investProcessing, SLOT(dateFormatSelected(int)));
connect(m_pageLinesDate->ui->comboBox_dateFormat, SIGNAL(currentIndexChanged(int)), m_convertDate, SLOT(dateFormatSelected(int)));
connect(m_pageCompletion->ui->comboBox_decimalSymbol, SIGNAL(currentIndexChanged(int)), m_parse, SLOT(decimalSymbolSelected(int)));
......@@ -585,6 +586,7 @@ void CSVDialog::slotFileDialogClicked()
m_hScrollBarHeight = 0;
m_lastDelimiterIndex = 0;
m_errorColumn = -1;
m_accept = false;
QString profileName;
KSharedConfigPtr config = KSharedConfig::openConfig(KStandardDirs::locate("config", "csvimporterrc"));
......@@ -881,8 +883,10 @@ void CSVDialog::readFile(const QString& fname)
int ret = processQifLine(m_inBuffer); // parse a line
if (ret == KMessageBox::Ok) {
csvImportTransaction(st);
} else
} else {
m_importNow = false;
m_wizard->back(); // Have another try at the import
}
}
} // reached end of buffer
......@@ -1061,8 +1065,9 @@ int CSVDialog::processQifLine(QString& iBuff) // parse input line
QDate dat = m_convertDate->convertDate(txt); // Date column
if (dat == QDate()) {
KMessageBox::sorry(this, i18n("<center>An invalid date has been detected during import.</center>"
"<center><b>%1</b></center>"
"Please check that you have set the correct date format."
"<center><b>'%1'</b></center>"
"Please check that you have set the correct date format,\n"
"<center>and start and end lines.</center>"
, txt), i18n("CSV import"));
m_importError = true;
return KMessageBox::Cancel;
......@@ -1189,7 +1194,7 @@ int CSVDialog::processQifLine(QString& iBuff) // parse input line
QString errMsg = i18n("<center>The columns selected are invalid.</center>"
"There must an amount or debit and credit fields, plus date and payee fields.");
if (m_pageIntro->ui->checkBoxSkipSetup->isEnabled()) {
errMsg += i18n("<center>You probably need to reset 'Skip setup'.</center>");
errMsg += i18n("<center>You possibly need to check the start and end line settings, or reset 'Skip setup'.</center>");
}
KMessageBox::information(0, errMsg);
m_importError = true;
......@@ -2137,7 +2142,7 @@ void CSVDialog::updateDecimalSymbol(const QString& type, int col)
void CSVDialog::dateFormatSelected(int dF)
{
if (dF == -1) {
if (dF == -1 || m_fileType == "Invest") {
return;
}
m_dateFormatIndex = dF;
......@@ -3680,6 +3685,8 @@ bool LinesDatePage::validatePage()
int LinesDatePage::nextId() const
{
m_dlg->m_importError = false;
m_dlg->m_accept = false;
return CSVDialog::Page_Completion;
}
......@@ -3705,7 +3712,13 @@ void CompletionPage::initializePage()
{
m_dlg->m_firstPass = false; // Needs to be here when skipping setup.
QList<QWizard::WizardButton> layout;
if (m_dlg->m_importError) {
layout << QWizard::Stretch << QWizard::BackButton << QWizard::CancelButton;
wizard()->setButtonLayout(layout);
return;
}
if (!m_dlg->m_pageIntro->ui->checkBoxSkipSetup->isChecked()) {
layout.clear();
layout << QWizard::Stretch << QWizard::CustomButton3 << QWizard::CustomButton2 << QWizard::BackButton
<< QWizard::FinishButton << QWizard::CancelButton;
wizard()->setOption(QWizard::HaveCustomButton2, true);
......@@ -3726,16 +3739,6 @@ void CompletionPage::initializePage()
}
}
}
if (m_dlg->m_importError) {
layout.clear();
layout << QWizard::Stretch << QWizard::BackButton << QWizard::NextButton << QWizard::CancelButton;
wizard()->setButtonLayout(layout);
wizard()->button(QWizard::NextButton)->setDisabled(true);
wizard()->button(QWizard::NextButton)->setToolTip(i18n("To correct any error, you will need to uncheck the 'Skip setup' box"));
} else {
wizard()->button(QWizard::NextButton)->setDisabled(false);
wizard()->button(QWizard::NextButton)->setToolTip(QString());
}
}
void CompletionPage::slotImportValid()
......
......@@ -39,6 +39,7 @@
#include <KInputDialog>
#include <KSharedConfig>
#include <kmessagebox.h>
#include <kstdguiitem.h>
#include <KStandardDirs>
#include <KLocale>
#include <KIO/NetAccess>
......@@ -208,6 +209,7 @@ void InvestProcessing::slotFileDialogClicked()
m_listSecurities.clear();
m_csvDialog->m_delimiterError = false;
m_importCompleted = false;
m_csvDialog->m_accept = false;
KSharedConfigPtr config = KSharedConfig::openConfig(KStandardDirs::locate("config", "csvimporterrc"));
bool found = false;
......@@ -1009,6 +1011,7 @@ void InvestProcessing::readFile(const QString& fname)
}
} else {
m_importNow = false;
m_csvDialog->m_wizard->back(); // have another try at the import
}
} // finished parsing
m_csvDialog->m_pageLinesDate->ui->labelSet_skip->setEnabled(true);
......@@ -1134,6 +1137,25 @@ int InvestProcessing::processInvestLine(const QString& inBuffer)
m_brokerage = false;
memo.clear();
if (m_columnList.count() < m_endColumn) {
if (!m_csvDialog->m_accept) {
QString row = QString::number(m_row);
int ret = KMessageBox::questionYesNoCancel(0, i18n("<center>Row number %1 does not have the expected number of columns.</center>"
"<center>This might not be a problem, but it may be a header line.</center>"
"<center>You may accept all similar items, or just this one, or cancel.</center>",
row), i18n("CSV import"),
KGuiItem(i18n("Accept All")),
KGuiItem(i18n("Accept This")),
KGuiItem(i18n("Cancel")));
if (ret == KMessageBox::Cancel) {
return ret;
}
if (ret == KMessageBox::Yes) {
m_csvDialog->m_accept = true;
}
}
}
for (int i = 0; i < m_columnList.count(); i++) {
// Use actual column count for this line instead of m_endColumn, which could be greater.
if (m_columnTypeList[i] == "date") { // Date Col
......@@ -1142,7 +1164,11 @@ int InvestProcessing::processInvestLine(const QString& inBuffer)
txt = txt.remove('"');
QDate dat = m_convertDat->convertDate(txt);
if (dat == QDate()) {
KMessageBox::sorry(0, i18n("<center>An invalid date has been detected during import.</center> <center><b>%1</b></center> Please check that you have set the correct date format.", txt), i18n("CSV import"));
KMessageBox::sorry(0, i18n("<center>An invalid date has been detected during import.</center>"
"<center><b>'%1'</b></center>"
"Please check that you have set the correct date format,\n"
"<center>and start and end lines.</center>"
, txt), i18n("CSV import"));
m_csvDialog->m_importError = true;
return KMessageBox::Cancel;
}
......@@ -1402,7 +1428,9 @@ int InvestProcessing::processInvestLine(const QString& inBuffer)
return KMessageBox::Ok;
} else {
KMessageBox::sorry(0, i18n("<center>The columns selected are invalid.\n</center>"
"There must an amount or quantity fields, symbol or security name, plus date and type field."), i18n("CSV import"));
"There must an amount or quantity fields, symbol or security name, plus date and type field."
"<center>You possibly need to check the start and end line settings, or reset 'Skip setup'.</center>",
i18n("CSV import")));
return KMessageBox::Cancel;
}
return KMessageBox::Ok;
......@@ -1781,7 +1809,7 @@ void InvestProcessing::endLineChanged(int val)
void InvestProcessing::dateFormatSelected(int dF)
{
if (dF == -1) {
if (dF == -1 || m_csvDialog->m_fileType != "Invest") {
return;
}
m_dateFormatIndex = dF;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment