Compare commits
2 Commits
3faf4bc642
...
7e872ef9b4
Author | SHA1 | Date | |
---|---|---|---|
7e872ef9b4 | |||
67dc640c26 |
|
@ -34,15 +34,19 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
ui->actionSave->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
|
ui->actionSave->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
|
||||||
|
|
||||||
// 添加 "Convert" 菜单
|
// 添加 "Convert" 菜单
|
||||||
QMenu* convertMenu = menuBar()->addMenu(tr("Convert"));
|
QMenu* convertMenu = menuBar()->addMenu(tr("转换(&C)"));
|
||||||
|
|
||||||
// 添加 "Text to SQLite" 子菜单项,并关联槽函数
|
// 添加 "Text to SQLite" 子菜单项,并关联槽函数
|
||||||
QAction* textToSqliteAction = convertMenu->addAction(tr("Text to SQLite"));
|
QAction* textToSqliteAction = convertMenu->addAction(tr("txt 转 SQLite"));
|
||||||
connect(textToSqliteAction, &QAction::triggered, this, &MainWindow::convertTextToSqlite);
|
connect(textToSqliteAction, &QAction::triggered, this, &MainWindow::convertTextToSqlite);
|
||||||
|
|
||||||
// 添加 "SQLite to Text" 子菜单项,并关联槽函数
|
// 添加 "SQLite to Text" 子菜单项,并关联槽函数
|
||||||
QAction* sqliteToTextAction = convertMenu->addAction(tr("SQLite to Text"));
|
QAction* sqliteToTextAction = convertMenu->addAction(tr("SQLite 转 txt"));
|
||||||
connect(sqliteToTextAction, &QAction::triggered, this, &MainWindow::convertSqliteToText);
|
connect(sqliteToTextAction, &QAction::triggered, this, &MainWindow::convertSqliteToText);
|
||||||
|
|
||||||
|
QIcon convertIcon = QApplication::style()->standardIcon(QStyle::SP_ArrowRight);
|
||||||
|
textToSqliteAction->setIcon(convertIcon);
|
||||||
|
sqliteToTextAction->setIcon(convertIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
@ -259,6 +263,13 @@ void MainWindow::convertTextToSqlite()
|
||||||
{
|
{
|
||||||
QString line = textStream.readLine();
|
QString line = textStream.readLine();
|
||||||
QStringList values = line.split("\t");
|
QStringList values = line.split("\t");
|
||||||
|
|
||||||
|
// 截断行内容,保证不超过列名的个数
|
||||||
|
if (values.size() > columnNames.size())
|
||||||
|
{
|
||||||
|
values = values.mid(0, columnNames.size());
|
||||||
|
}
|
||||||
|
|
||||||
data.append(values);
|
data.append(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user