Skip to content

Commit

Permalink
csvimport: Set filename as default table name
Browse files Browse the repository at this point in the history
See issue #376.
  • Loading branch information
MKleusberg committed Jul 3, 2015
1 parent 42583a3 commit b08cead
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ImportCsvDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <QTextStream>
#include <QSettings>
#include <QDebug>
#include <QFileInfo>
#include <memory>

ImportCsvDialog::ImportCsvDialog(const QString& filename, DBBrowserDB* db, QWidget* parent)
Expand All @@ -25,20 +26,27 @@ ImportCsvDialog::ImportCsvDialog(const QString& filename, DBBrowserDB* db, QWidg
{
ui->setupUi(this);

// Get the actual file name out of the provided path and use it as the default table name for import
QFileInfo file(filename);
ui->editName->setText(file.baseName());

// Create a list of all available encodings and create an auto completion list from them
QStringList encodingList;
foreach(QString enc, QTextCodec::availableCodecs())
encodingList.push_back(enc);
encodingCompleter = new QCompleter(encodingList, this);
encodingCompleter->setCaseSensitivity(Qt::CaseInsensitive);
ui->editCustomEncoding->setCompleter(encodingCompleter);

// Load last used settings and apply them
QSettings settings(QApplication::organizationName(), QApplication::organizationName());
ui->checkboxHeader->setChecked(settings.value("importcsv/firstrowheader", false).toBool());
ui->checkBoxTrimFields->setChecked(settings.value("importcsv/trimfields", true).toBool());
setSeparatorChar(QChar(settings.value("importcsv/separator", ',').toInt()));
setQuoteChar(QChar(settings.value("importcsv/quotecharacter", '"').toInt()));
setEncoding(settings.value("importcsv/encoding", "UTF-8").toString());

// Initialise user interface
checkInput();
updatePreview();
}
Expand Down

0 comments on commit b08cead

Please sign in to comment.