Qt6 migration
This commit is contained in:
parent
87553b2554
commit
423043d431
19 changed files with 64 additions and 87 deletions
|
|
@ -7,8 +7,8 @@
|
|||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QStatusBar>
|
||||
#include <QStringConverter>
|
||||
#include <QTabWidget>
|
||||
#include <QTextCodec>
|
||||
#include <QTextDocumentFragment>
|
||||
#include <QTextStream>
|
||||
#include <QClipboard>
|
||||
|
|
@ -90,12 +90,9 @@ bool QueryTool::load(const QString &filename)
|
|||
QFile file(filename);
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
QByteArray ba = file.readAll();
|
||||
const char *ptr = ba.constData();
|
||||
|
||||
QTextCodec *codec = QTextCodec::codecForUtfText(ba, QTextCodec::codecForName("utf-8"));
|
||||
QTextCodec::ConverterState state;
|
||||
QString text = codec->toUnicode(ptr, ba.size(), &state);
|
||||
if (state.invalidChars > 0) {
|
||||
auto toUtf16 = QStringDecoder(QStringDecoder::Utf8);
|
||||
QString text = toUtf16(ba);
|
||||
if (toUtf16.hasError()) {
|
||||
file.reset();
|
||||
QTextStream stream(&file);
|
||||
text = stream.readAll();
|
||||
|
|
@ -280,8 +277,9 @@ bool QueryTool::saveSqlTo(const QString &filename)
|
|||
QFile file(filename);
|
||||
if (file.open(QIODevice::WriteOnly)) {
|
||||
QTextStream stream(&file);
|
||||
stream.setCodec("utf-8");
|
||||
QString text = ui->queryEdit->toPlainText();
|
||||
//stream.setCodec("utf-8");
|
||||
stream.setEncoding(QStringConverter::Utf8);
|
||||
QString text = ui->queryEdit->toPlainText();
|
||||
stream << text;
|
||||
|
||||
stream.flush();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue