Skip to content

Commit

Permalink
Update to Qt6.5
Browse files Browse the repository at this point in the history
  • Loading branch information
mortbopet committed Apr 16, 2023
1 parent 8fd0bce commit a7f17ba
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 26 deletions.
9 changes: 2 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,9 @@ set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

# Find Qt5Core and Qt5Widgets
find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets CONFIG REQUIRED)
find_package(Qt6 COMPONENTS Core Widgets REQUIRED)
find_package(Threads REQUIRED)

# Finding Qt includes
include_directories(${Qt5Widgets_INCLUDE_DIRS})
include_directories(${Qt5Core_INCLUDE_DIRS})

include_directories(SYSTEM external/cereal/include)
include_directories(SYSTEM external/Signals)

Expand Down Expand Up @@ -72,6 +67,6 @@ option(VSRTL_BUILD_APP "Build the VSRTL standalone application" ON)
if(VSRTL_BUILD_APP)
set(APP_NAME VSRTL)
add_executable(${APP_NAME} app.cpp)
target_link_libraries(${APP_NAME} Qt5::Core Qt5::Widgets)
target_link_libraries(${APP_NAME} Qt6::Core Qt6::Widgets)
target_link_libraries(${APP_NAME} ${VSRTL_CORE_LIB} ${VSRTL_GRAPHICS_LIB} ${VSRTL_COMPONENTS_LIB})
endif()
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ make -j$(nproc)
* C++17 toolchain
* CMake
* **Graphics**
* Qt 5.14+: https://www.qt.io/download
* Qt 6.5.0+: https://www.qt.io/download

---
In papers and reports, please refer to VSRTL as follows: 'Morten Borup Petersen. VSRTL. https://github.com/mortbopet/VSRTL', e.g. using the following BibTeX code:
Expand Down
4 changes: 4 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ file(GLOB LIB_HEADERS *.h)

add_library(${VSRTL_CORE_LIB} STATIC ${LIB_SOURCES} ${LIB_HEADERS} )
target_include_directories (${VSRTL_CORE_LIB} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
if(${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
# https://doc.qt.io/qt-6/wasm.html#asyncify
target_link_options(${VSRTL_CORE_LIB} PUBLIC -sASYNCIFY -Os)
endif()

if(VSRTL_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_link_libraries(${VSRTL_CORE_LIB} ${COVERAGE_LIB} ${VSRTL_INTERFACE_LIB})
Expand Down
7 changes: 6 additions & 1 deletion graphics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if(VSRTL_DEBUG_DRAWING)
target_compile_definitions(${VSRTL_GRAPHICS_LIB} PRIVATE VSRTL_DEBUG_DRAW=1)
endif()

target_link_libraries(${VSRTL_GRAPHICS_LIB} Qt5::Core Qt5::Widgets)
target_link_libraries(${VSRTL_GRAPHICS_LIB} Qt6::Core Qt6::Widgets)

target_include_directories(${VSRTL_GRAPHICS_LIB} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

Expand All @@ -31,6 +31,11 @@ include_directories("../core/")
set_target_properties(${VSRTL_GRAPHICS_LIB} PROPERTIES LINKER_LANGUAGE CXX)

target_link_libraries(${VSRTL_GRAPHICS_LIB} ${VSRTL_CORE} ${VSRTL_INTERFACE_LIB} ${CMAKE_THREAD_LIBS_INIT})
if(${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
# https://doc.qt.io/qt-6/wasm.html#asyncify
target_link_options(${VSRTL_GRAPHICS_LIB} PUBLIC -sASYNCIFY -Os)
endif()


if(VSRTL_COVERAGE)
target_link_libraries(${VSRTL_GRAPHICS_LIB} ${COVERAGE_LIB})
Expand Down
6 changes: 3 additions & 3 deletions graphics/vsrtl_componentgraphic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <QGraphicsProxyWidget>
#include <QGraphicsScene>
#include <QGraphicsSceneHoverEvent>
#include <QMatrix>
#include <QMatrix4x4>
#include <QMenu>
#include <QMessageBox>
#include <QPainter>
Expand Down Expand Up @@ -371,10 +371,10 @@ void ComponentGraphic::updateGeometry() {
// Next, separately apply the scaling through a secondary matrix (The transformation gets a lot simpler like
// this, rather than composing translation + rotation +translation + scaling in a single matrix.
QTransform t;
QMatrix mat;
QMatrix4x4 mat;
mat.scale(sceneRect.width(), sceneRect.height());
t.translate(0.5, 0.5).rotate(gridRotation()).translate(-0.5, -0.5);
m_shape = mat.map(ShapeRegister::getTypeShape(m_component->getGraphicsType(), t));
m_shape = mat.toTransform().map(ShapeRegister::getTypeShape(m_component->getGraphicsType(), t));

// Position the expand-button
if (hasSubcomponents()) {
Expand Down
10 changes: 5 additions & 5 deletions graphics/vsrtl_netlistdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace vsrtl {
NetlistDelegate::NetlistDelegate(QObject* parent) : QStyledItemDelegate(parent) {
// The validator does not concern itself whether the value is actually writeable to the register. Any hex input is
// accepted. When a register is forced to a value, the value is truncated to the bit width of the register.
m_validator = new QRegExpValidator(this);
m_validator = new QRegularExpressionValidator(this);
}

QWidget* NetlistDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem&, const QModelIndex&) const {
Expand All @@ -33,19 +33,19 @@ void NetlistDelegate::setEditorData(QWidget* e, const QModelIndex& index) const

switch (treeItem->m_radix) {
case Radix::Binary: {
m_validator->setRegExp(binRegex);
m_validator->setRegularExpression(binRegex);
break;
}
case Radix::Hex: {
m_validator->setRegExp(hexRegex);
m_validator->setRegularExpression(hexRegex);
break;
}
case Radix::Unsigned: {
m_validator->setRegExp(unsignedRegex);
m_validator->setRegularExpression(unsignedRegex);
break;
}
case Radix::Signed: {
m_validator->setRegExp(signedRegex);
m_validator->setRegularExpression(signedRegex);
break;
}
case Radix::Enum: {
Expand Down
4 changes: 2 additions & 2 deletions graphics/vsrtl_netlistdelegate.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef VSRTL_NETLISTDELEGATE_H
#define VSRTL_NETLISTDELEGATE_H

#include <QRegExpValidator>
#include <QRegularExpressionValidator>
#include <QStyledItemDelegate>

namespace vsrtl {
Expand All @@ -14,7 +14,7 @@ class NetlistDelegate : public QStyledItemDelegate {
void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override;

private:
QRegExpValidator* m_validator;
QRegularExpressionValidator* m_validator;
};
} // namespace vsrtl

Expand Down
1 change: 1 addition & 0 deletions graphics/vsrtl_radix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "../interface/vsrtl_interface.h"

#include <QAction>
#include <QActionGroup>
#include <QMenu>
#include <QObject>
#include <QString>
Expand Down
10 changes: 5 additions & 5 deletions graphics/vsrtl_radix.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef VSRTL_Radix_H
#define VSRTL_Radix_H

#include <QRegExp>
#include <QRegularExpression>
#include "../interface/vsrtl_defines.h"

QT_FORWARD_DECLARE_CLASS(QString)
Expand All @@ -11,10 +11,10 @@ namespace vsrtl {
class SimPort;
enum class Radix { Hex, Unsigned, Signed, Binary, Enum };

static const auto hexRegex = QRegExp("0[xX][0-9a-fA-F]+");
static const auto binRegex = QRegExp("0[bB][0-1]+");
static const auto unsignedRegex = QRegExp("[0-9]+");
static const auto signedRegex = QRegExp("[-]*[0-9]+");
static const auto hexRegex = QRegularExpression("0[xX][0-9a-fA-F]+");
static const auto binRegex = QRegularExpression("0[bB][0-1]+");
static const auto unsignedRegex = QRegularExpression("[0-9]+");
static const auto signedRegex = QRegularExpression("[-]*[0-9]+");

VSRTL_VT_U decodePortRadixValue(const SimPort& port, const Radix type, const QString& valueString);
QString encodePortRadixValue(const SimPort* port, const Radix type);
Expand Down
4 changes: 2 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ cmake_minimum_required(VERSION 3.9)

file(GLOB TST_SOURCES *.cpp)

find_package(Qt5Test REQUIRED)
find_package(Qt6 COMPONENTS Test REQUIRED)

macro(create_qtest name)
add_executable(${name} ${name}.cpp)
add_test(${name} ${name})
target_link_libraries(${name} Qt5::Core Qt5::Widgets Qt5::Test)
target_link_libraries(${name} Qt6::Core Qt6::Widgets Qt6::Test)
target_link_libraries(${name} ${VSRTL_CORE_LIB} ${VSRTL_GRAPHICS_LIB} ${VSRTL_COMPONENTS_LIB})
if (COVERAGE)
target_link_libraries(${name} ${COVERAGE_LIB})
Expand Down

0 comments on commit a7f17ba

Please sign in to comment.