Qt6 migration

This commit is contained in:
eelke 2021-03-06 13:13:31 +01:00
parent 87553b2554
commit 423043d431
19 changed files with 64 additions and 87 deletions

View file

@ -6,7 +6,6 @@
#include "ConnectionConfig.h"
#include <QProcess>
class QStringList;
class QLabel;
class QPushButton;

View file

@ -298,9 +298,9 @@ QVariant ColumnTableModel::data(const QModelIndex &index, int role) const
QVariant v;
int col = index.column();
if (col == NullCol || col >= colCount)
v = Qt::AlignCenter + Qt::AlignVCenter;
v = int(Qt::AlignCenter | Qt::AlignVCenter);
else
v = Qt::AlignLeft + Qt::AlignVCenter;
v = int(Qt::AlignLeft | Qt::AlignVCenter);
return v;
}
return BaseTableModel::data(index, role);

View file

@ -141,21 +141,21 @@ void DatabaseWindow::createActions()
icon.addFile(QString::fromUtf8(":/icons/page_white_delete.png"), QSize(), QIcon::Normal, QIcon::On);
auto action = actionClose = new QAction(icon, tr("Close"), this);
action->setObjectName("actionClose");
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W));
action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_W));
}
{
QIcon icon;
icon.addFile(QString::fromUtf8(":/icons/page_white_copy.png"), QSize(), QIcon::Normal, QIcon::On);
auto action = actionCopy = new QAction(icon, tr("Copy"), this);
action->setObjectName("actionCopy");
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C));
action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_C));
}
{
QIcon icon;
icon.addFile(QString::fromUtf8(":/icons/token_shortland_character.png"), QSize(), QIcon::Normal, QIcon::On);
auto action = actionCopyAsCString = new QAction(icon, tr("Copy as C string"), this);
action->setObjectName("actionCopyAsCString");
action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C));
action->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_C));
}
{
QIcon icon;
@ -184,7 +184,7 @@ void DatabaseWindow::createActions()
icon.addFile(QString::fromUtf8(":/icons/lightbulb.png"), QSize(), QIcon::Normal, QIcon::On);
auto action = actionExplainAnalyze = new QAction(icon, tr("Explain analyze"), this);
action->setObjectName("actionExplainAnalyze");
action->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_F7));
action->setShortcut(QKeySequence(Qt::SHIFT | Qt::Key_F7));
}
{
QIcon icon;
@ -219,21 +219,21 @@ void DatabaseWindow::createActions()
icon.addFile(QString::fromUtf8(":/icons/new_query_tab.png"), QSize(), QIcon::Normal, QIcon::On);
auto action = actionNewSql = new QAction(icon, tr("New Query"), this);
action->setObjectName("actionNewSql");
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N));
action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_N));
}
{
QIcon icon;
icon.addFile(QString::fromUtf8(":/icons/folder.png"), QSize(), QIcon::Normal, QIcon::On);
auto action = actionOpenSql = new QAction(icon, tr("Open Query"), this);
action->setObjectName("actionOpenSql");
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O));
action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_O));
}
{
QIcon icon;
//icon.addFile(QString::fromUtf8(":/icons/folder.png"), QSize(), QIcon::Normal, QIcon::On);
auto action = actionPasteLangString = new QAction(icon, tr("Paste lang string"), this);
action->setObjectName("actionPasteLangString");
action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_V));
action->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_V));
}
{
QIcon icon;
@ -253,7 +253,7 @@ void DatabaseWindow::createActions()
icon.addFile(QString::fromUtf8(":/icons/script_save.png"), QSize(), QIcon::Normal, QIcon::On);
auto action = actionSaveSql = new QAction(icon, tr("Save query"), this);
action->setObjectName("actionSaveSql");
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_S));
}
{
auto action = actionSaveSqlAs = new QAction(tr("Save query as"), this);

View file

@ -103,10 +103,10 @@ void PgLabItemDelegate::initStyleOption(QStyleOptionViewItem *option,
option->text = FormatBoolForDisplay(value.toBool());
else {
auto str = value.toString();
auto s = str.leftRef(100);
auto s = str.left(100);
// auto f = s.indexOf('\n');
// option->text = ((f > 0) ? s.left(f) : s).toString();
option->text = s.toString();
option->text = s;
}
}
else {

View file

@ -54,13 +54,13 @@ if (role == Qt::DisplayRole) {
}
else if (role == Qt::TextAlignmentRole) {
if (col == c_ColumnNode || col == c_ColumnDetails) {
result = Qt::AlignLeft + Qt::AlignVCenter;
result = int(Qt::AlignLeft | Qt::AlignVCenter);
}
else {
result = Qt::AlignRight + Qt::AlignVCenter;
result = int(Qt::AlignRight | Qt::AlignVCenter);
}
}
else if (role == Qt::BackgroundColorRole) {
else if (role == Qt::BackgroundRole) {
if (col == c_ColumnExclusive || col == c_ColumnInclusive) {
float t = col == 1 ? item->exclusiveTime() : item->inclusiveTime();
float tt = explain->plan->inclusiveTime();

View file

@ -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();

View file

@ -8,7 +8,7 @@ using namespace Pgsql;
Qt::Alignment GetDefaultAlignmentForType(Oid o)
{
int r;
Qt::Alignment r;
switch (o) {
case int2_oid:
case int4_oid:

View file

@ -34,7 +34,7 @@ public:
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
void setCatalog(std::shared_ptr<const PgDatabaseCatalog> cat);
void SequenceModel::setNamespaceFilter(NamespaceFilter filter);
void setNamespaceFilter(NamespaceFilter filter);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;

View file

@ -10,7 +10,6 @@ UserConfiguration* UserConfiguration::instance()
UserConfiguration::UserConfiguration()
: m_settings(nullptr)
{
m_settings.setIniCodec("UTF-8");
}
QFont UserConfiguration::codeFont() const