diff --git a/src/core/CsvParser.cpp b/src/core/CsvParser.cpp index 0ab7f28c..7f0443aa 100644 --- a/src/core/CsvParser.cpp +++ b/src/core/CsvParser.cpp @@ -315,7 +315,7 @@ bool CsvParser::isCRLF(const QChar &c) const { } bool CsvParser::isSpace(const QChar &c) const { - return (c == 0x20); + return (c == ' '); } bool CsvParser::isTab(const QChar &c) const { diff --git a/src/gui/AboutDialog.ui b/src/gui/AboutDialog.ui index bfa27689..a853c041 100644 --- a/src/gui/AboutDialog.ui +++ b/src/gui/AboutDialog.ui @@ -162,7 +162,6 @@ <li>louib</li> <li>phoerious</li> <li>thezero</li> -<li>seatedscribe</li> </ul> diff --git a/src/gui/csvImport/CsvImportWidget.cpp b/src/gui/csvImport/CsvImportWidget.cpp index 2c782b89..38eb09b9 100644 --- a/src/gui/csvImport/CsvImportWidget.cpp +++ b/src/gui/csvImport/CsvImportWidget.cpp @@ -20,6 +20,7 @@ #include #include +#include #include "gui/MessageBox.h" #include "gui/MessageWidget.h" @@ -52,13 +53,13 @@ CsvImportWidget::CsvImportWidget(QWidget *parent) m_ui->comboBoxFieldSeparator->addItems(QStringList() <<"," <<";" <<"-" <<":" <<"."); m_ui->comboBoxTextQualifier->addItems(QStringList() <<"\"" <<"'" <<":" <<"." <<"|"); m_ui->comboBoxComment->addItems(QStringList() <<"#" <<";" <<":" <<"@"); - m_ui->tableViewFields->setSelectionMode(QAbstractItemView::NoSelection); m_ui->tableViewFields->setFocusPolicy(Qt::NoFocus); + m_ui->messageWidget->setHidden(true); for (int i = 0; i < m_columnHeader.count(); ++i) { QLabel* label = new QLabel(m_columnHeader.at(i), this); - label->setFixedWidth(label->minimumSizeHint().width()); + label->setAlignment(Qt::AlignRight | Qt::AlignVCenter); QFont font = label->font(); font.setBold(false); label->setFont(font); @@ -78,6 +79,8 @@ CsvImportWidget::CsvImportWidget(QWidget *parent) int y = 2 * (i / combo_rows); m_ui->gridLayout_combos->addWidget(label, x, y); m_ui->gridLayout_combos->addWidget(combo, x, y+1); + QSpacerItem *item = new QSpacerItem(1,1, QSizePolicy::Expanding, QSizePolicy::Fixed); + m_ui->gridLayout_combos->addItem(item, x, y+2); } m_parserModel->setHeaderLabels(m_columnHeader); @@ -169,13 +172,11 @@ void CsvImportWidget::parse() { bool good = m_parserModel->parse(); updatePreview(); QApplication::restoreOverrideCursor(); - if (good) - //four newline are provided to avoid resizing at every Positive/Warning switch - m_ui->messageWidget->showMessage(QString("\n\n").append(tr("CSV syntax seems in good shape !")) - .append("\n\n"), MessageWidget::Positive); - else + if (!good) m_ui->messageWidget->showMessage(tr("Error(s) detected in CSV file !").append("\n") .append(formatStatusText()), MessageWidget::Warning); + else + m_ui->messageWidget->setHidden(true); QWidget::adjustSize(); } @@ -183,12 +184,12 @@ void CsvImportWidget::parse() { QString CsvImportWidget::formatStatusText() const { QString text = m_parserModel->getStatus(); int items = text.count('\n'); - if (items > 3) - return text.section('\n', 0, 2) - .append("\n[").append(QString::number(items - 3)) + if (items > 2) + return text.section('\n', 0, 1) + .append("\n[").append(QString::number(items - 2)) .append(tr(" more messages skipped]")); else - for (int i = 0; i < 3 - items; i++) + for (int i = 0; i < 2 - items; i++) text.append(QString("\n")); return text; } diff --git a/src/gui/csvImport/CsvImportWidget.ui b/src/gui/csvImport/CsvImportWidget.ui index 82ee68dd..1b4bed72 100644 --- a/src/gui/csvImport/CsvImportWidget.ui +++ b/src/gui/csvImport/CsvImportWidget.ui @@ -14,474 +14,6 @@ - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 758 - 24 - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - false - - - - - - - - 0 - 137 - - - - - 75 - true - - - - Encoding - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 114 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 114 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 114 - 20 - - - - - - - - - 50 - false - - - - Text is qualified by - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 114 - 20 - - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - - 50 - false - - - - false - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 114 - 20 - - - - - - - - Qt::Horizontal - - - - 114 - 20 - - - - - - - - - 50 - false - - - - Codec - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Horizontal - - - - 114 - 20 - - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - - 50 - false - - - - false - - - - - - - - 50 - false - - - - Fields are separated by - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 50 - false - - - - Comments start with - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - - 50 - false - - - - false - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - - 50 - false - - - - false - - - - - - - Qt::Horizontal - - - - 114 - 20 - - - - - - - - - 50 - false - - - - Consider '\' as escape character - - - - - - - - - - 50 - false - - - - Skip first - - - - - - - - 50 - false - - - - - - - - - 50 - false - - - - rows - - - - - - - - - - 50 - false - true - - - - - - - - - - - - - - - 75 - true - - - - Column layout - - - - - - 0 - - - - - - - - - - - 0 - 0 - - - - - 0 - 200 - - - - - 75 - true - - - - Preview - - - false - - - - - - - 0 - 0 - - - - - 50 - false - - - - true - - - - - - @@ -535,6 +67,508 @@ + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 75 + true + + + + Encoding + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 114 + 20 + + + + + + + + Qt::Horizontal + + + + 114 + 20 + + + + + + + + + 50 + false + + + + Consider '\' an escape character + + + + + + + + 50 + false + + + + Codec + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 50 + false + true + + + + + + + + + + + + 50 + false + + + + Fields are separated by + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 50 + false + + + + false + + + + + + + + 50 + false + + + + Comments start with + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 114 + 20 + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 50 + false + + + + false + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 114 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 114 + 20 + + + + + + + + + 50 + false + + + + Text is qualified by + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 50 + false + + + + false + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 114 + 20 + + + + + + + + + + + 50 + false + + + + Skip first + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 50 + false + + + + + + + + + 50 + false + + + + rows + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 50 + false + + + + false + + + + + + + Qt::Horizontal + + + + 114 + 20 + + + + + + + + Qt::Horizontal + + + + 114 + 20 + + + + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Column layout + + + + + + 6 + + + 6 + + + 0 + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 758 + 24 + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + false + + + + + + + + 0 + 0 + + + + + 0 + 200 + + + + + 75 + true + + + + Preview + + + false + + + + + + + 0 + 0 + + + + + 50 + false + + + + true + + + + + +