void AsciiOpenDlg::autoFindBestSeparator() { QList<QChar> separators; separators << QChar(' '); separators << QChar('\t'); separators << QChar(','); separators << QChar(';'); //We try all default separators... for (int i=0; i<separators.size(); ++i) { m_ui->lineEditSeparator->setText(separators[i]); //this calls 'updateTable' //...until we find one that gives us at least 3 colums if (getColumnsCount() > 2) return; } }
AsciiOpenDlg::AsciiOpenDlg(QString filename, QWidget* parent) : QDialog(parent) , Ui::AsciiOpenDialog() , m_skippedLines(0) , m_separator(' ') , m_averageLineSize(-1.0) , m_filename(filename) , m_invalidColumns(true) , m_columnsCount(0) { setupUi(this); //spinBoxSkipLines->setValue(0); connect(buttonBox, SIGNAL(accepted()), this, SLOT(testBeforeAccept())); connect(lineEditSeparator, SIGNAL(textChanged(const QString &)), this, SLOT(updateTable(const QString &))); connect(spinBoxSkipLines, SIGNAL(valueChanged(int)), this, SLOT(setSkippedLines(int))); //shortcut buttons connect(toolButtonShortcutESP, SIGNAL(clicked()), this, SLOT(shortcutButtonPressed())); connect(toolButtonShortcutTAB, SIGNAL(clicked()), this, SLOT(shortcutButtonPressed())); connect(toolButtonShortcutComma, SIGNAL(clicked()), this, SLOT(shortcutButtonPressed())); connect(toolButtonShortcutDotcomma, SIGNAL(clicked()), this, SLOT(shortcutButtonPressed())); lineEditFileName->setText(m_filename); QList<QChar> separators; separators << QChar(' '); separators << QChar('\t'); separators << QChar(','); separators << QChar(';'); //We try all default separators... for (int i=0; i<separators.size(); ++i) { lineEditSeparator->setText(separators[i]); //this calls 'updateTable' //...until we find one that gives us at least 3 colums if (getColumnsCount()>2) break; } }