Ported to QT5

Anne Jan Brouwer [2016-03-16 23:20]
Ported to QT5
Filename
.gitignore
qtswarmtv/downloadedtablecontrol.cpp
qtswarmtv/main.cpp
qtswarmtv/qtswarmtv.pro
qtswarmtv/searchcontrol.cpp
qtswarmtv/simpleeditdialog.cpp
qtswarmtv/simpletablecontrol.cpp
qtswarmtv/sourcetablecontrol.cpp
qtswarmtv/testfilterdialog.cpp
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..29bb216
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,20 @@
+Makefile
+debian/qtswarmtv*
+debian/files
+build-stamp
+qtswarmtv.pro.user
+qtswarmtv.xcodeproj/project.xcworkspace/xcuserdata/*
+qtswarmtv.xcodeproj/xcuserdata/*
+qtswarmtv.xcworkspace/xcuserdata/*
+swarmtv.pro.user
+.DS_Store
+.qmake.stash
+*.o
+moc_*.cpp
+qrc_*.cpp
+ui_*.h
+MakeCache.txt
+CMakeFiles
+cmake_install.cmake
+libswarmtv.pc
+CMakeCache.txt
diff --git a/qtswarmtv/downloadedtablecontrol.cpp b/qtswarmtv/downloadedtablecontrol.cpp
index 9ff5690..7d43ebb 100644
--- a/qtswarmtv/downloadedtablecontrol.cpp
+++ b/qtswarmtv/downloadedtablecontrol.cpp
@@ -93,13 +93,25 @@ void downloadedTableControl::fillTable()
 void downloadedTableControl::initHeaders()
 {
   // Set title as filling
+#if QT_VERSION >= 0x050000
+  downtable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
+#else
   downtable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
+#endif

   // Set Size static
+#if QT_VERSION >= 0x050000
+  downtable->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
+#else
   downtable->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents);
+#endif

   // Set source static
+#if QT_VERSION >= 0x050000
+  downtable->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
+#else
   downtable->horizontalHeader()->setResizeMode(2, QHeaderView::ResizeToContents);
+#endif
 }

 void downloadedTableControl::delClicked()
diff --git a/qtswarmtv/main.cpp b/qtswarmtv/main.cpp
index a49b379..f0d7e61 100644
--- a/qtswarmtv/main.cpp
+++ b/qtswarmtv/main.cpp
@@ -1,5 +1,5 @@
 #include <QtDBus/QtDBus>
-#include <QtGui/QApplication>
+#include <QApplication>
 #include <QSplashScreen>
 #include <QSettings>
 #include "singleapplication.h"
diff --git a/qtswarmtv/qtswarmtv.pro b/qtswarmtv/qtswarmtv.pro
index e4e24d6..d96e47c 100644
--- a/qtswarmtv/qtswarmtv.pro
+++ b/qtswarmtv/qtswarmtv.pro
@@ -5,6 +5,7 @@
 #-------------------------------------------------

 QT       += core gui dbus network xml
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

 TARGET = qtswarmtv
 TEMPLATE = app
diff --git a/qtswarmtv/searchcontrol.cpp b/qtswarmtv/searchcontrol.cpp
index 6d5d641..feac938 100644
--- a/qtswarmtv/searchcontrol.cpp
+++ b/qtswarmtv/searchcontrol.cpp
@@ -134,16 +134,32 @@ void searchControl::initHeaders()
   }

   // Set title as filling
+#if QT_VERSION >= 0x050000
+  ui->searchTableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
+#else
   ui->searchTableWidget->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
+#endif

   // Set Size static
+#if QT_VERSION >= 0x050000
+  ui->searchTableWidget->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
+#else
   ui->searchTableWidget->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents);
+#endif

   // Set source static
+#if QT_VERSION >= 0x050000
+  ui->searchTableWidget->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
+#else
   ui->searchTableWidget->horizontalHeader()->setResizeMode(2, QHeaderView::ResizeToContents);
+#endif

   // Set metatype static
+#if QT_VERSION >= 0x050000
+  ui->searchTableWidget->horizontalHeader()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
+#else
   ui->searchTableWidget->horizontalHeader()->setResizeMode(3, QHeaderView::ResizeToContents);
+#endif
 }

 int searchControl::rowToId(int row)
diff --git a/qtswarmtv/simpleeditdialog.cpp b/qtswarmtv/simpleeditdialog.cpp
index 2e3039f..f5eca0d 100644
--- a/qtswarmtv/simpleeditdialog.cpp
+++ b/qtswarmtv/simpleeditdialog.cpp
@@ -202,15 +202,27 @@ void simpleEditDialog::getFromUi(simplefilter_struct &simple)
   simple.category = value;
   value = strdup(ui->sourceSimpleLineEdit->text().toUtf8().data());
   simple.source = value;
+#if QT_VERSION >= 0x050000
+  value = strdup(ui->nodupSimpleComboBox->currentText().toLatin1().data());
+#else
   value = strdup(ui->nodupSimpleComboBox->currentText().toAscii().data());
+#endif
   simple.nodup = value;

   // Convert sizes back to size_t
+#if QT_VERSION >= 0x050000
+  uiSizeStr = ui->minSizeSimpleLineEdit->text().toLatin1().data();
+#else
   uiSizeStr = ui->minSizeSimpleLineEdit->text().toAscii().data();
+#endif
   sizeconv.setSize(uiSizeStr);
   sizeconv.getSize(uisize);
   simple.minsize=uisize;
+#if QT_VERSION >= 0x050000
+  uiSizeStr = ui->maxSizeSimpleLineEdit->text().toLatin1().data();
+#else
   uiSizeStr = ui->maxSizeSimpleLineEdit->text().toAscii().data();
+#endif
   sizeconv.setSize(uiSizeStr);
   sizeconv.getSize(uisize);
   simple.maxsize=uisize;
diff --git a/qtswarmtv/simpletablecontrol.cpp b/qtswarmtv/simpletablecontrol.cpp
index 2a2cc3b..6260ec7 100644
--- a/qtswarmtv/simpletablecontrol.cpp
+++ b/qtswarmtv/simpletablecontrol.cpp
@@ -60,13 +60,25 @@ void simpleTableControl::initHeaders()
   }

   // Set name
+#if QT_VERSION >= 0x050000
+  table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
+#else
   table->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents);
+#endif

   // Set Filter Type
+#if QT_VERSION >= 0x050000
+  table->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
+#else
   table->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents);
+#endif

   // Set Last downloaded Title
+#if QT_VERSION >= 0x050000
+  table->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
+#else
   table->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
+#endif
 }

 void simpleTableControl::fillTable(lastdowned_container *container)
diff --git a/qtswarmtv/sourcetablecontrol.cpp b/qtswarmtv/sourcetablecontrol.cpp
index 305c921..ff5c235 100644
--- a/qtswarmtv/sourcetablecontrol.cpp
+++ b/qtswarmtv/sourcetablecontrol.cpp
@@ -63,16 +63,31 @@ void sourceTableControl::initHeaders()
   }

   // Name
+#if QT_VERSION >= 0x050000
+  table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
+#else
   table->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents);
-
+#endif
   // Parser
+#if QT_VERSION >= 0x050000
+  table->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
+#else
   table->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents);
+#endif

   // Meta type
+#if QT_VERSION >= 0x050000
+  table->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
+#else
   table->horizontalHeader()->setResizeMode(2, QHeaderView::ResizeToContents);
+#endif

   // URL
+#if QT_VERSION >= 0x050000
+  table->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Stretch);
+#else
   table->horizontalHeader()->setResizeMode(3, QHeaderView::Stretch);
+#endif
 }

 void sourceTableControl::fillTable(source_container *container)
@@ -174,7 +189,11 @@ void sourceTableControl::delButtonClicked(void)
   switch(ret) {
         case QMessageBox::Ok:
     //@DEBUG
+#if QT_VERSION >= 0x050000
+    std::cout << "deleting source '" << name.toLatin1().data() << "." << std::endl;
+#else
     std::cout << "deleting source '" << name.toAscii().data() << "." << std::endl;
+#endif
     rc = rsstdelsourceid(swarm->getHandle(), id);
     if(rc != 0) {
       QMessageBox::warning(this, tr("SwarmTv"),
diff --git a/qtswarmtv/testfilterdialog.cpp b/qtswarmtv/testfilterdialog.cpp
index dd20a49..dc10e60 100644
--- a/qtswarmtv/testfilterdialog.cpp
+++ b/qtswarmtv/testfilterdialog.cpp
@@ -105,15 +105,31 @@ void testFilterDialog::initHeaders()
   }

   // Set title as filling
+#if QT_VERSION >= 0x050000
+  ui->testTableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
+#else
   ui->testTableWidget->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
+#endif

   // Set Size static
+#if QT_VERSION >= 0x050000
+  ui->testTableWidget->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
+#else
   ui->testTableWidget->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents);
+#endif

   // Set source static
+#if QT_VERSION >= 0x050000
+  ui->testTableWidget->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
+#else
   ui->testTableWidget->horizontalHeader()->setResizeMode(2, QHeaderView::ResizeToContents);
+#endif

   // Set metatype static
+#if QT_VERSION >= 0x050000
+  ui->testTableWidget->horizontalHeader()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
+#else
   ui->testTableWidget->horizontalHeader()->setResizeMode(3, QHeaderView::ResizeToContents);
+#endif

 }