Code fixes for Qt 6

This commit is contained in:
Marcus Huderle 2021-02-05 18:43:49 -06:00 committed by huderlem
parent 39648eed41
commit 6f394ce39c
16 changed files with 34 additions and 36 deletions

View file

@ -194,7 +194,7 @@ private slots:
void on_actionExport_Stitched_Map_Image_triggered();
void on_actionExport_Map_Timelapse_Image_triggered();
void on_comboBox_ConnectionDirection_currentIndexChanged(const QString &arg1);
void on_comboBox_ConnectionDirection_currentTextChanged(const QString &arg1);
void on_spinBox_ConnectionOffset_valueChanged(int offset);
void on_comboBox_ConnectedMap_currentTextChanged(const QString &mapName);
void on_pushButton_AddConnection_clicked();

View file

@ -118,8 +118,8 @@ private slots:
void on_action_Import_CityMap_ImageTiles_triggered();
void on_tabWidget_Region_Map_currentChanged(int);
void on_pushButton_RM_Options_delete_clicked();
void on_comboBox_RM_ConnectedMap_activated(const QString &);
void on_comboBox_RM_Entry_MapSection_activated(const QString &);
void on_comboBox_RM_ConnectedMap_textActivated(const QString &);
void on_comboBox_RM_Entry_MapSection_textActivated(const QString &);
void on_spinBox_RM_Entry_x_valueChanged(int);
void on_spinBox_RM_Entry_y_valueChanged(int);
void on_spinBox_RM_Entry_width_valueChanged(int);

View file

@ -2,6 +2,7 @@
#define SHORTCUT_H
#include <QObject>
#include <QWidget>
#include <QKeySequence>
#include <QShortcut>

View file

@ -79,7 +79,7 @@ private slots:
void on_actionRedo_triggered();
void on_comboBox_metatileBehaviors_activated(const QString &arg1);
void on_comboBox_metatileBehaviors_textActivated(const QString &arg1);
void on_lineEdit_metatileLabel_editingFinished();

View file

@ -37,7 +37,6 @@ void KeyValueConfigBase::load() {
}
QTextStream in(&file);
in.setCodec("UTF-8");
QList<QString> configLines;
QRegularExpression re("^(?<key>[^=]+)=(?<value>.*)$");
while (!in.atEnd()) {

View file

@ -34,7 +34,6 @@ QString ParseUtil::readTextFile(const QString &path) {
return QString();
}
QTextStream in(&file);
in.setCodec("UTF-8");
QString text = "";
while (!in.atEnd()) {
text += in.readLine() + '\n';
@ -65,9 +64,9 @@ QList<QStringList> ParseUtil::parseAsm(const QString &filename) {
// There should not be anything else on the line.
// gas will raise a syntax error if there is.
} else {
int index = trimmedLine.indexOf(QRegExp("\\s+"));
int index = trimmedLine.indexOf(QRegularExpression("\\s+"));
const QString macro = trimmedLine.left(index);
QStringList params(trimmedLine.right(trimmedLine.length() - index).trimmed().split(QRegExp("\\s*,\\s*")));
QStringList params(trimmedLine.right(trimmedLine.length() - index).trimmed().split(QRegularExpression("\\s*,\\s*")));
params.prepend(macro);
parsed.append(params);
}
@ -227,15 +226,16 @@ QString ParseUtil::readCIncbin(const QString &filename, const QString &label) {
text = readTextFile(root + "/" + filename);
QRegExp *re = new QRegExp(QString(
QRegularExpression re(QString(
"\\b%1\\b"
"\\s*\\[?\\s*\\]?\\s*=\\s*"
"INCBIN_[US][0-9][0-9]?"
"\\(\\s*\"([^\"]*)\"\\s*\\)").arg(label));
int pos = re->indexIn(text);
QRegularExpressionMatch match;
qsizetype pos = text.indexOf(re, 0, &match);
if (pos != -1) {
path = re->cap(1);
path = match.captured(1);
}
return path;

View file

@ -134,7 +134,6 @@ bool RegionMap::readLayout() {
bool mapNamesQualified = false, mapEntriesQualified = false;
QTextStream in(&file);
in.setCodec("UTF-8");
while (!in.atEnd()) {
QString line = in.readLine();
if (line.contains(QRegularExpression(".*sMapName.*="))) {

View file

@ -425,7 +425,7 @@ void MainWindow::on_lineEdit_filterBox_textChanged(const QString &arg1)
void MainWindow::applyMapListFilter(QString filterText)
{
mapListProxyModel->setFilterRegExp(QRegExp(filterText, Qt::CaseInsensitive, QRegExp::FixedString));
mapListProxyModel->setFilterRegularExpression(QRegularExpression(filterText, QRegularExpression::CaseInsensitiveOption));
if (filterText.isEmpty()) {
ui->mapList->collapseAll();
} else {
@ -629,7 +629,7 @@ bool MainWindow::setMap(QString map_name, bool scrollTreeView) {
if (scrollTreeView) {
// Make sure we clear the filter first so we actually have a scroll target
mapListProxyModel->setFilterRegExp(QString());
mapListProxyModel->setFilterRegularExpression(QString());
ui->mapList->setCurrentIndex(mapListProxyModel->mapFromSource(mapListIndexes.value(map_name)));
ui->mapList->scrollTo(ui->mapList->currentIndex(), QAbstractItemView::PositionAtCenter);
}
@ -2694,7 +2694,7 @@ void MainWindow::showExportMapImageWindow(ImageExporterMode mode) {
}
}
void MainWindow::on_comboBox_ConnectionDirection_currentIndexChanged(const QString &direction)
void MainWindow::on_comboBox_ConnectionDirection_currentTextChanged(const QString &direction)
{
editor->updateCurrentConnectionDirection(direction);
}

View file

@ -642,8 +642,8 @@ void Project::setNewMapLayout(Map* map) {
layout->name = QString("%1_Layout").arg(map->name);
layout->width = QString::number(getDefaultMapSize());
layout->height = QString::number(getDefaultMapSize());
layout->border_width = DEFAULT_BORDER_WIDTH;
layout->border_height = DEFAULT_BORDER_HEIGHT;
layout->border_width = QString::number(DEFAULT_BORDER_WIDTH);
layout->border_height = QString::number(DEFAULT_BORDER_HEIGHT);
layout->border_path = QString("data/layouts/%1/border.bin").arg(map->name);
layout->blockdata_path = QString("data/layouts/%1/map.bin").arg(map->name);
layout->tileset_primary_label = tilesetLabels["primary"].value(0, "gTileset_General");
@ -1512,10 +1512,10 @@ void Project::loadTilesetAssets(Tileset* tileset) {
QString path = tileset->palettePaths.value(i);
QString text = parser.readTextFile(path);
if (!text.isNull()) {
QStringList lines = text.split(QRegExp("[\r\n]"), Qt::SkipEmptyParts);
QStringList lines = text.split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts);
if (lines.length() == 19 && lines[0] == "JASC-PAL" && lines[1] == "0100" && lines[2] == "16") {
for (int j = 0; j < 16; j++) {
QStringList rgb = lines[j + 3].split(QRegExp(" "), Qt::SkipEmptyParts);
QStringList rgb = lines[j + 3].split(QRegularExpression(" "), Qt::SkipEmptyParts);
if (rgb.length() != 3) {
logWarn(QString("Invalid tileset palette RGB value: '%1'").arg(lines[j + 3]));
palette.append(qRgb((j - 3) * 16, (j - 3) * 16, (j - 3) * 16));
@ -2327,13 +2327,13 @@ bool Project::readEventScriptLabels() {
}
QString Project::fixPalettePath(QString path) {
path = path.replace(QRegExp("\\.gbapal$"), ".pal");
path = path.replace(QRegularExpression("\\.gbapal$"), ".pal");
return path;
}
QString Project::fixGraphicPath(QString path) {
path = path.replace(QRegExp("\\.lz$"), "");
path = path.replace(QRegExp("\\.[1248]bpp$"), ".png");
path = path.replace(QRegularExpression("\\.lz$"), "");
path = path.replace(QRegularExpression("\\.[1248]bpp$"), ".png");
return path;
}
@ -2445,7 +2445,7 @@ void Project::loadEventPixmaps(QList<Event*> objects) {
QString dimensions_label = gfx_info.value(11);
QString subsprites_label = gfx_info.value(12);
QString gfx_label = parser.readCArray("src/data/object_events/object_event_pic_tables.h", pic_label).value(0);
gfx_label = gfx_label.section(QRegExp("[\\(\\)]"), 1, 1);
gfx_label = gfx_label.section(QRegularExpression("[\\(\\)]"), 1, 1);
QString path = parser.readCIncbin("src/data/object_events/object_event_graphics.h", gfx_label);
if (!path.isNull()) {

View file

@ -24,7 +24,7 @@ CustomAttributesTable::CustomAttributesTable(Event *event, QWidget *parent) :
buttonsFrame->layout()->addWidget(addButton);
buttonsFrame->layout()->addWidget(deleteButton);
buttonsFrame->layout()->addItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Fixed));
buttonsFrame->layout()->setMargin(0);
buttonsFrame->layout()->setContentsMargins(0, 0, 0, 0);
layout->addWidget(buttonsFrame);
this->table = new QTableWidget(this);

View file

@ -9,7 +9,7 @@ FilterChildrenProxyModel::FilterChildrenProxyModel(QObject *parent) :
bool FilterChildrenProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
// custom behaviour :
if(filterRegExp().isEmpty() == false)
if(filterRegularExpression().pattern().isEmpty() == false)
{
// get source-model index for current row
QModelIndex source_index = sourceModel()->index(source_row, this->filterKeyColumn(), source_parent) ;
@ -27,7 +27,7 @@ bool FilterChildrenProxyModel::filterAcceptsRow(int source_row, const QModelInde
// check current index itself
QString key = sourceModel()->data(source_index, filterRole()).toString();
QString parentKey = sourceModel()->data(source_parent, filterRole()).toString();
return key.contains(filterRegExp()) || parentKey.contains(filterRegExp());
return key.contains(filterRegularExpression()) || parentKey.contains(filterRegularExpression());
}
}
// parent call for initial behaviour

View file

@ -4,7 +4,6 @@
#include "editcommands.h"
#include <QFileDialog>
#include <QMatrix>
#include <QImage>
#include <QPainter>
#include <QPoint>

View file

@ -11,8 +11,8 @@ NewTilesetDialog::NewTilesetDialog(Project* project, QWidget *parent) :
this->setFixedSize(this->width(), this->height());
this->project = project;
//only allow characters valid for a symbol
QRegExp expression("[_A-Za-z0-9]+$");
QRegExpValidator *validator = new QRegExpValidator(expression);
QRegularExpression expression("[_A-Za-z0-9]+$");
QRegularExpressionValidator *validator = new QRegularExpressionValidator(expression);
this->ui->nameLineEdit->setValidator(validator);
connect(this->ui->nameLineEdit, &QLineEdit::textChanged, this, &NewTilesetDialog::NameOrSecondaryChanged);

View file

@ -10,7 +10,7 @@ NoScrollComboBox::NoScrollComboBox(QWidget *parent)
// Make speed a priority when loading comboboxes.
setMinimumContentsLength(24);// an arbitrary limit
setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
// Allow items to be searched by any part of the word, displaying all matches.
setEditable(true);// can set to false manually when using

View file

@ -550,13 +550,13 @@ void RegionMapEditor::on_tabWidget_Region_Map_currentChanged(int index) {
}
}
void RegionMapEditor::on_comboBox_RM_ConnectedMap_activated(const QString &mapsec) {
this->ui->lineEdit_RM_MapName->setText(this->project->mapSecToMapHoverName.value(mapsec));
void RegionMapEditor::on_comboBox_RM_ConnectedMap_textActivated(const QString &mapsec) {
this->ui->lineEdit_RM_MapName->setText(this->project->mapSecToMapHoverName->value(mapsec));
onRegionMapLayoutSelectedTileChanged(this->currIndex);// re-draw layout image
this->hasUnsavedChanges = true;// sometimes this is called for unknown reasons
}
void RegionMapEditor::on_comboBox_RM_Entry_MapSection_activated(const QString &text) {
void RegionMapEditor::on_comboBox_RM_Entry_MapSection_textActivated(const QString &text) {
this->activeEntry = text;
this->region_map_entries_item->currentSection = activeEntry;
updateRegionMapEntryOptions(activeEntry);

View file

@ -149,8 +149,8 @@ void TilesetEditor::setVersionSpecificUi() {
void TilesetEditor::setMetatileLabelValidator() {
//only allow characters valid for a symbol
QRegExp expression("[_A-Za-z0-9]*$");
QRegExpValidator *validator = new QRegExpValidator(expression);
QRegularExpression expression("[_A-Za-z0-9]*$");
QRegularExpressionValidator *validator = new QRegularExpressionValidator(expression);
this->ui->lineEdit_metatileLabel->setValidator(validator);
}
@ -463,7 +463,7 @@ void TilesetEditor::on_checkBox_yFlip_stateChanged(int checked)
this->metatileLayersItem->clearLastModifiedCoords();
}
void TilesetEditor::on_comboBox_metatileBehaviors_activated(const QString &metatileBehavior)
void TilesetEditor::on_comboBox_metatileBehaviors_textActivated(const QString &metatileBehavior)
{
if (this->metatile) {
Metatile *prevMetatile = new Metatile(*this->metatile);