From ec04ed1f6f7e24ceaff59563089afcd7e08cdc07 Mon Sep 17 00:00:00 2001 From: leo Date: Sun, 26 Jan 2014 06:56:36 +0000 Subject: [PATCH] Added support for Qt5. --- leocad.pro | 2 +- qt/lc_qpropertiesdialog.cpp | 5 +++++ qt/lc_qpropertiestree.cpp | 5 +++++ qt/lc_qutils.cpp | 12 ++++++++++++ qt/qtmain.cpp | 6 +++++- 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/leocad.pro b/leocad.pro index f359b7f4..80b5e607 100644 --- a/leocad.pro +++ b/leocad.pro @@ -3,7 +3,7 @@ TEMPLATE = app greaterThan(QT_MAJOR_VERSION, 4) { # DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 -# QT *= printsupport + QT *= printsupport } INCLUDEPATH += qt common diff --git a/qt/lc_qpropertiesdialog.cpp b/qt/lc_qpropertiesdialog.cpp index e1b497f2..e96241e8 100644 --- a/qt/lc_qpropertiesdialog.cpp +++ b/qt/lc_qpropertiesdialog.cpp @@ -96,7 +96,12 @@ lcQPropertiesDialog::lcQPropertiesDialog(QWidget *parent, void *data) : table->setColumnCount(numColors + 1); table->setRowCount(numInfos); table->setHorizontalHeaderLabels(horizontalLabels); + +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) + table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents); +#else table->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents); +#endif for (int rowIdx = 0; rowIdx < partNames.size(); rowIdx++) table->setItem(rowIdx, 0, new QTableWidgetItem(partNames[rowIdx])); diff --git a/qt/lc_qpropertiestree.cpp b/qt/lc_qpropertiestree.cpp index 0995127c..a5f4b962 100644 --- a/qt/lc_qpropertiestree.cpp +++ b/qt/lc_qpropertiestree.cpp @@ -253,8 +253,13 @@ lcQPropertiesTree::lcQPropertiesTree(QWidget *parent) : labels.append(tr("Property")); labels.append(tr("Value")); setHeaderLabels(labels); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) + header()->setSectionsMovable(false); + header()->setSectionResizeMode(QHeaderView::ResizeToContents); +#else header()->setMovable(false); header()->setResizeMode(QHeaderView::ResizeToContents); +#endif header()->setVisible(false); setAlternatingRowColors(true); setRootIsDecorated(false); diff --git a/qt/lc_qutils.cpp b/qt/lc_qutils.cpp index 6caab100..cfb7f8b5 100644 --- a/qt/lc_qutils.cpp +++ b/qt/lc_qutils.cpp @@ -21,18 +21,30 @@ bool lcQTreeWidgetColumnStretcher::eventFilter(QObject *obj, QEvent *ev) { QHeaderView *hv = qobject_cast(obj); for (int i = 0; i < hv->count(); ++i) +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) + hv->setSectionResizeMode(i, QHeaderView::Interactive); +#else hv->setResizeMode(i, QHeaderView::Interactive); +#endif } else if (ev->type() == QEvent::Hide) { QHeaderView *hv = qobject_cast(obj); for (int i = 0; i < hv->count(); ++i) +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) + hv->setSectionResizeMode(i, i == m_columnToStretch ? QHeaderView::Stretch : QHeaderView::ResizeToContents); +#else hv->setResizeMode(i, i == m_columnToStretch ? QHeaderView::Stretch : QHeaderView::ResizeToContents); +#endif } else if (ev->type() == QEvent::Resize) { QHeaderView *hv = qobject_cast(obj); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) + if (hv->sectionResizeMode(m_columnToStretch) == QHeaderView::Interactive) +#else if (hv->resizeMode(m_columnToStretch) == QHeaderView::Interactive) +#endif { QResizeEvent *re = static_cast(ev); int diff = re->size().width() - re->oldSize().width() ; diff --git a/qt/qtmain.cpp b/qt/qtmain.cpp index 3aac7f03..483d4f81 100644 --- a/qt/qtmain.cpp +++ b/qt/qtmain.cpp @@ -154,8 +154,12 @@ int main(int argc, char *argv[]) const char* libPath = LC_INSTALL_PREFIX"/share/leocad/"; #endif - +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) + QStringList cachePathList = QStandardPaths::standardLocations(QStandardPaths::CacheLocation); + QString cachePath = cachePathList.first(); +#else QString cachePath = QDesktopServices::storageLocation(QDesktopServices::CacheLocation); +#endif QDir dir; dir.mkdir(cachePath);