mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-19 10:20:17 -06:00
qt5: full qt5 compability
ifdef rest of the code which can't be ported 100% add CMake option USE_QT5 to use qt5 ;) Thanks to stretchtiberius for initial patch
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
project(sqlitebrowser)
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
cmake_minimum_required(VERSION 2.8.9)
|
||||
|
||||
OPTION(USE_QT5 FALSE "Build with qt5")
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
@@ -11,10 +13,15 @@ set(QHEXEDIT_DIR libs/qhexedit)
|
||||
add_subdirectory(${ANTLR_DIR})
|
||||
add_subdirectory(${QHEXEDIT_DIR})
|
||||
|
||||
find_package(Qt4 COMPONENTS QtCore QtGui QtNetwork REQUIRED)
|
||||
|
||||
include(${QT_USE_FILE})
|
||||
add_definitions(${QT_DEFINITIONS})
|
||||
if(USE_QT5)
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
else()
|
||||
find_package(Qt4 COMPONENTS QtCore QtGui QtNetwork REQUIRED)
|
||||
include(${QT_USE_FILE})
|
||||
add_definitions(${QT_DEFINITIONS})
|
||||
endif()
|
||||
|
||||
set(SQLB_HDR
|
||||
src/gen_version.h
|
||||
@@ -85,9 +92,14 @@ set(SQLB_RESOURCES
|
||||
src/icons/icons.qrc
|
||||
)
|
||||
|
||||
QT4_WRAP_CPP(SQLB_MOC ${SQLB_MOC_HDR})
|
||||
QT4_WRAP_UI(SQLB_FORM_HDR ${SQLB_FORMS})
|
||||
QT4_ADD_RESOURCES(SQLB_RESOURCES_RCC ${SQLB_RESOURCES})
|
||||
if(USE_QT5)
|
||||
qt5_wrap_ui(SQLB_FORM_HDR ${SQLB_FORMS})
|
||||
qt5_add_resources(SQLB_RESOURCES_RCC ${SQLB_RESOURCES})
|
||||
else()
|
||||
QT4_WRAP_CPP(SQLB_MOC ${SQLB_MOC_HDR})
|
||||
QT4_WRAP_UI(SQLB_FORM_HDR ${SQLB_FORMS})
|
||||
QT4_ADD_RESOURCES(SQLB_RESOURCES_RCC ${SQLB_RESOURCES})
|
||||
endif()
|
||||
|
||||
# get git version hash
|
||||
if(EXISTS ${CMAKE_SOURCE_DIR}/.git)
|
||||
@@ -128,6 +140,10 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR} ${ANTLR_DIR} ${QHEXEDIT_DIR} src
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SQLB_HDR} ${SQLB_SRC} ${SQLB_FORM_HDR} ${SQLB_MOC} ${SQLB_RESOURCES_RCC})
|
||||
|
||||
if(USE_QT5)
|
||||
qt5_use_modules(${PROJECT_NAME} Gui Widgets Network Test)
|
||||
set(QT_LIBRARIES "")
|
||||
endif()
|
||||
add_dependencies(${PROJECT_NAME} antlr qhexedit)
|
||||
|
||||
link_directories(${CMAKE_CURRENT_BINARY_DIR}/${ANTLR_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${QHEXEDIT_DIR})
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
cmake_minimum_required(VERSION 2.8.9)
|
||||
|
||||
find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED)
|
||||
|
||||
include(${QT_USE_FILE})
|
||||
add_definitions(${QT_DEFINITIONS})
|
||||
if(USE_QT5)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
else()
|
||||
find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED)
|
||||
include(${QT_USE_FILE})
|
||||
add_definitions(${QT_DEFINITIONS})
|
||||
endif()
|
||||
|
||||
set(QHEXEDIT_SRC
|
||||
src/commands.cpp
|
||||
@@ -22,7 +27,13 @@ set(QHEXEDIT_MOC_HDR
|
||||
src/qhexedit_p.h
|
||||
)
|
||||
|
||||
QT4_WRAP_CPP(QHEXEDIT_MOC ${QHEXEDIT_MOC_HDR})
|
||||
if(NOT USE_QT5)
|
||||
QT4_WRAP_CPP(QHEXEDIT_MOC ${QHEXEDIT_MOC_HDR})
|
||||
endif()
|
||||
|
||||
add_library(qhexedit ${QHEXEDIT_SRC} ${QHEXEDIT_HDR} ${QHEXEDIT_MOC})
|
||||
|
||||
if(USE_QT5)
|
||||
qt5_use_modules(qhexedit Widgets)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
#define QHEXEDIT_H
|
||||
|
||||
#include <QtGui>
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QtWidgets>
|
||||
#endif
|
||||
#include "qhexedit_p.h"
|
||||
|
||||
/** \mainpage
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#include <QtGui>
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QtWidgets>
|
||||
#endif
|
||||
|
||||
#include "qhexedit_p.h"
|
||||
#include "commands.h"
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
|
||||
|
||||
#include <QtGui>
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QtWidgets>
|
||||
#endif
|
||||
#include "xbytearray.h"
|
||||
|
||||
class QHexEditPrivate : public QWidget
|
||||
|
||||
@@ -8,7 +8,11 @@ FilterTableHeader::FilterTableHeader(QTableView* parent) :
|
||||
QHeaderView(Qt::Horizontal, parent)
|
||||
{
|
||||
// Activate the click signals to allow sorting
|
||||
#if QT_VERSION >= 0x050000
|
||||
setSectionsClickable(true);
|
||||
#else
|
||||
setClickable(true);
|
||||
#endif
|
||||
|
||||
// Do some connects: Basically just resize and reposition the input widgets whenever anything changes
|
||||
connect(this, SIGNAL(sectionResized(int,int,int)), this, SLOT(adjustPositions()));
|
||||
|
||||
@@ -80,9 +80,11 @@ int main( int argc, char ** argv )
|
||||
a.setApplicationName("SQLite Database Browser");
|
||||
|
||||
// Set character encoding to UTF8
|
||||
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
|
||||
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
|
||||
#if QT_VERSION < 0x050000
|
||||
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
|
||||
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
|
||||
#endif
|
||||
|
||||
// Enable translation
|
||||
QTranslator translator;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
project(sqlb-unittests)
|
||||
cmake_minimum_required(VERSION 2.8.9)
|
||||
|
||||
OPTION(USE_QT5 FALSE "Build with qt5")
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
endif()
|
||||
@@ -8,10 +10,15 @@ endif()
|
||||
set(ANTLR_DIR ../libs/antlr-2.7.7)
|
||||
add_subdirectory(${ANTLR_DIR} ${CMAKE_CURRENT_BINARY_DIR}/antlr)
|
||||
|
||||
find_package(Qt4 COMPONENTS QtCore QtTest REQUIRED)
|
||||
|
||||
include(${QT_USE_FILE})
|
||||
add_definitions(${QT_DEFINITIONS})
|
||||
if(USE_QT5)
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
else()
|
||||
find_package(Qt4 COMPONENTS QtCore QtTest REQUIRED)
|
||||
include(${QT_USE_FILE})
|
||||
add_definitions(${QT_DEFINITIONS})
|
||||
endif()
|
||||
|
||||
set(SQLB_SRC
|
||||
../src/sqlitetypes.cpp
|
||||
@@ -28,11 +35,19 @@ set(SQLB_HDR
|
||||
set(SQLB_MOC_HDR
|
||||
../src/tests/testsqlobjects.h)
|
||||
|
||||
QT4_WRAP_CPP(SQLB_MOC ${SQLB_MOC_HDR})
|
||||
if(NOT USE_QT5)
|
||||
QT4_WRAP_CPP(SQLB_MOC ${SQLB_MOC_HDR})
|
||||
endif()
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/${ANTLR_DIR})
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SQLB_MOC} ${SQLB_HDR} ${SQLB_SRC})
|
||||
|
||||
if(USE_QT5)
|
||||
qt5_use_modules(${PROJECT_NAME} Test)
|
||||
set(QT_LIBRARIES "")
|
||||
endif()
|
||||
|
||||
add_dependencies(${PROJECT_NAME} antlr)
|
||||
target_link_libraries(${PROJECT_NAME} antlr ${QT_LIBRARIES})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user