Skip to content

Commit

Permalink
Fixup for GoogleDrive on QT < 5.4
Browse files Browse the repository at this point in the history
.. rather than only build with Google Drive support if
   using QT5.4 just adapt the code to avoid issues with
   QJsonObject -> operator present in QT5.x < 5.4.

.. see https://bugreports.qt.io/browse/QTBUG-29573
  • Loading branch information
liversedge committed Mar 3, 2016
1 parent 4fa8828 commit 6025681
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/Cloud/GoogleDrive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ GoogleDrive::FileInfo* GoogleDrive::WalkFileInfo(const QString& path,
if (child == target->children.end()) {
// Directory doesn't exist!
printd("Bailing, because I couldn't find: %s in %s\n",
it->toStdString().c_str(),
(*it).toStdString().c_str(),
target->name.toStdString().c_str());
if (foo) {
return target;
Expand Down Expand Up @@ -338,11 +338,11 @@ QList<FileStoreEntry*> GoogleDrive::readdir(QString path, QStringList &errors) {
QJsonObject file = contents.at(i).toObject();
// Some paranoia.
QJsonObject::iterator it = file.find("trashed");
if (it != file.end() && it->toString() == "true") {
if (it != file.end() && (*it).toString() == "true") {
continue;
}
it = file.find("explicitlyTrashed");
if (it != file.end() && it->toString() == "true") {
if (it != file.end() && (*it).toString() == "true") {
continue;
}
QSharedPointer<FileInfo> fi(new FileInfo);
Expand All @@ -357,7 +357,7 @@ QList<FileStoreEntry*> GoogleDrive::readdir(QString path, QStringList &errors) {
fi->parent = GetRootDirId();
}
it = file.find("mimeType");
if (it != file.end() && it->toString() == kDirectoryMimeType) {
if (it != file.end() && (*it).toString() == kDirectoryMimeType) {
fi->is_dir = true;
} else {
fi->is_dir = false;
Expand Down
12 changes: 4 additions & 8 deletions src/Gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@
#include "CalendarDownload.h"
#if QT_VERSION > 0x050000
#include "Dropbox.h"
#endif
#if QT_VERSION >= 0x050400
#include "GoogleDrive.h"
#endif
#include "LocalFileStore.h"
Expand Down Expand Up @@ -560,11 +558,11 @@ MainWindow::MainWindow(const QDir &home)
shareMenu->addSeparator ();
shareMenu->addAction(tr("Upload to &Dropbox"), this, SLOT(uploadDropbox()), tr("Ctrl+R"));
shareMenu->addAction(tr("Synchronise Dropbox..."), this, SLOT(syncDropbox()), tr("Ctrl+O"));
#endif
#if QT_VERSION > 0x050400
shareMenu->addSeparator ();
shareMenu->addAction(tr("Upload to &GoogleDrive"), this, SLOT(uploadGoogleDrive()), tr(""));
shareMenu->addAction(tr("Synchronise GoogleDrive..."), this, SLOT(syncGoogleDrive()), tr("Ctrl+P"));
shareMenu->addAction(tr("Upload to &GoogleDrive"), this,
SLOT(uploadGoogleDrive()), tr(""));
shareMenu->addAction(tr("Synchronise GoogleDrive..."), this,
SLOT(syncGoogleDrive()), tr("Ctrl+P"));
#endif
#ifdef GC_HAVE_SOAP
shareMenu->addSeparator ();
Expand Down Expand Up @@ -2071,9 +2069,7 @@ MainWindow::syncDropbox()
FileStoreSyncDialog upload(currentTab->context, &db);
upload.exec();
}
#endif

#if QT_VERSION > 0x050400
void
MainWindow::uploadGoogleDrive()
{
Expand Down
2 changes: 0 additions & 2 deletions src/Gui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,7 @@ class MainWindow : public QMainWindow
#if QT_VERSION > 0x050000
void uploadDropbox();
void syncDropbox();
#endif

#if QT_VERSION >= 0x050400
void uploadGoogleDrive();
void syncGoogleDrive();
#endif
Expand Down
10 changes: 3 additions & 7 deletions src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -519,17 +519,13 @@ equals(CloudDB, active) {

greaterThan(QT_MAJOR_VERSION, 4) {

# Features that only work with QT5.0 or higher
# Features that only work with QT5 or higher
SOURCES += Cloud/Dropbox.cpp
HEADERS += Cloud/Dropbox.h
SOURCES += Cloud/GoogleDrive.cpp
HEADERS += Cloud/GoogleDrive.h
SOURCES += Train/Monark.cpp Train/MonarkController.cpp Train/MonarkConnection.cpp
HEADERS += Train/Monark.h Train/MonarkController.h Train/MonarkConnection.h

# GoogleDrive needs QT5.4 or higher
greaterThan(QT_MINOR_VERSION, 3) {
SOURCES += Cloud/GoogleDrive.cpp
HEADERS += Cloud/GoogleDrive.h
}
}


Expand Down

0 comments on commit 6025681

Please sign in to comment.