From cde36dc70d0b1c791cdbf89690c6a1b6149ded30 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 26 Jun 2014 16:06:28 -0700 Subject: [PATCH 01/15] Add user locations --- interface/src/UserLocationsModel.cpp | 229 +++++++++++++++++++++++ interface/src/UserLocationsModel.h | 81 ++++++++ interface/src/ui/UserLocationsWindow.cpp | 76 ++++++++ interface/src/ui/UserLocationsWindow.h | 35 ++++ interface/ui/userLocationsWindow.ui | 130 +++++++++++++ 5 files changed, 551 insertions(+) create mode 100644 interface/src/UserLocationsModel.cpp create mode 100644 interface/src/UserLocationsModel.h create mode 100644 interface/src/ui/UserLocationsWindow.cpp create mode 100644 interface/src/ui/UserLocationsWindow.h create mode 100644 interface/ui/userLocationsWindow.ui diff --git a/interface/src/UserLocationsModel.cpp b/interface/src/UserLocationsModel.cpp new file mode 100644 index 0000000000..4ad91bed73 --- /dev/null +++ b/interface/src/UserLocationsModel.cpp @@ -0,0 +1,229 @@ +// +// UserLocationsModel.cpp +// interface/src +// +// Created by Ryan Huffman on 06/24/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include +#include +#include +#include + +#include "AccountManager.h" +#include "Application.h" +#include "UserLocationsModel.h" + +static const QString PLACES_GET = "/api/v1/places"; +static const QString PLACES_UPDATE = "/api/v1/places/%1"; +static const QString PLACES_DELETE= "/api/v1/places/%1"; + +UserLocation::UserLocation(QString id, QString name, QString location) : + _id(id), + _name(name), + _location(location), + _previousName(name), + _updating(false) { +} + +void UserLocation::requestRename(const QString& newName) { + _updating = true; + + JSONCallbackParameters callbackParams; + callbackParams.jsonCallbackReceiver = this; + callbackParams.jsonCallbackMethod = "handleRenameResponse"; + callbackParams.errorCallbackReceiver = this; + callbackParams.errorCallbackMethod = "handleRenameError"; + QJsonObject jsonNameObject; + jsonNameObject.insert("name", QJsonValue(newName)); + QJsonDocument jsonDocument(jsonNameObject); + AccountManager::getInstance().authenticatedRequest(PLACES_UPDATE.arg(_id), + QNetworkAccessManager::PutOperation, + callbackParams, + jsonDocument.toJson()); + _previousName = _name; + _name = newName; + + emit updated(_name); +} + +void UserLocation::handleRenameResponse(const QJsonObject& responseData) { + _updating = false; + + qDebug() << responseData; + QJsonValue status = responseData["status"]; + if (status.isUndefined() || status.toString() != "success") { + _name = _previousName; + qDebug() << "There was an error renaming location '" + _name + "'"; + } + + emit updated(_name); +} + +void UserLocation::handleRenameError(QNetworkReply::NetworkError error, const QString& errorString) { + _updating = false; + + QString msg = "There was an error renaming location '" + _name + "': " + errorString; + qDebug() << msg; + QMessageBox::warning(Application::getInstance()->getWindow(), "Error", msg); + + emit updated(_name); +} + +void UserLocation::requestDelete() { + _updating = true; + + JSONCallbackParameters callbackParams; + callbackParams.jsonCallbackReceiver = this; + callbackParams.jsonCallbackMethod = "handleDeleteResponse"; + callbackParams.errorCallbackReceiver = this; + callbackParams.errorCallbackMethod = "handleDeleteError"; + AccountManager::getInstance().authenticatedRequest(PLACES_DELETE.arg(_id), + QNetworkAccessManager::DeleteOperation, + callbackParams); +} + +void UserLocation::handleDeleteResponse(const QJsonObject& responseData) { + _updating = false; + + QJsonValue status = responseData["status"]; + if (!status.isUndefined() && status.toString() == "success") { + emit deleted(_name); + } else { + qDebug() << "There was an error deleting location '" + _name + "'"; + } +} + +void UserLocation::handleDeleteError(QNetworkReply::NetworkError error, const QString& errorString) { + _updating = false; + + QString msg = "There was an error deleting location '" + _name + "': " + errorString; + qDebug() << msg; + QMessageBox::warning(Application::getInstance()->getWindow(), "Error", msg); +} + +UserLocationsModel::UserLocationsModel(QObject* parent) : + QAbstractListModel(parent), + _updating(false) { + + refresh(); +} + +void UserLocationsModel::update() { + beginResetModel(); + endResetModel(); +} + +void UserLocationsModel::deleteLocation(const QModelIndex& index) { + UserLocation* location = _locations[index.row()]; + location->requestDelete(); +} + +void UserLocationsModel::renameLocation(const QModelIndex& index, const QString& newName) { + UserLocation* location = _locations[index.row()]; + location->requestRename(newName); +} + +void UserLocationsModel::refresh() { + if (!_updating) { + beginResetModel(); + _locations.clear(); + _updating = true; + endResetModel(); + + JSONCallbackParameters callbackParams; + callbackParams.jsonCallbackReceiver = this; + callbackParams.jsonCallbackMethod = "handleLocationsResponse"; + AccountManager::getInstance().authenticatedRequest(PLACES_GET, + QNetworkAccessManager::GetOperation, + callbackParams); + } +} + +void UserLocationsModel::handleLocationsResponse(const QJsonObject& responseData) { + _updating = false; + + QJsonValue status = responseData["status"]; + if (!status.isUndefined() && status.toString() == "success") { + beginResetModel(); + QJsonArray locations = responseData["data"].toObject()["places"].toArray(); + for (QJsonArray::const_iterator it = locations.constBegin(); it != locations.constEnd(); it++) { + QJsonObject location = (*it).toObject(); + QJsonObject address = location["address"].toObject(); + UserLocation* userLocation = new UserLocation(location["id"].toString(), location["name"].toString(), + "hifi://" + address["domain"].toString() + "/" + address["position"].toString() + "/" + address["orientation"].toString()); + _locations.append(userLocation); + connect(userLocation, &UserLocation::deleted, this, &UserLocationsModel::removeLocation); + connect(userLocation, &UserLocation::updated, this, &UserLocationsModel::update); + } + endResetModel(); + } else { + qDebug() << "Error loading location data"; + } +} + +void UserLocationsModel::removeLocation(const QString& name) { + beginResetModel(); + for (QList::iterator it = _locations.begin(); it != _locations.end(); it++) { + if ((*it)->name() == name) { + _locations.erase(it); + break; + } + } + endResetModel(); +} + +int UserLocationsModel::rowCount(const QModelIndex& parent) const { + if (parent.isValid()) { + return 0; + } + + if (_updating) { + return 1; + } + + return _locations.length(); +} + +QVariant UserLocationsModel::data(const QModelIndex& index, int role) const { + if (role == Qt::DisplayRole) { + if (_updating) { + return QVariant("Updating..."); + } else if (index.row() > _locations.length()) { + return QVariant(); + } else if (index.column() == NameColumn) { + return _locations[index.row()]->name(); + } else if (index.column() == LocationColumn) { + return QVariant(_locations[index.row()]->location()); + } + } + + return QVariant(); + +} +QVariant UserLocationsModel::headerData(int section, Qt::Orientation orientation, int role) const { + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { + switch (section) { + case NameColumn: return "Name"; + case LocationColumn: return "Location"; + default: return QVariant(); + } + } + + return QVariant(); +} + +Qt::ItemFlags UserLocationsModel::flags(const QModelIndex& index) const { + if (index.row() < _locations.length()) { + UserLocation* ul = _locations[index.row()]; + if (ul->isUpdating()) { + return Qt::NoItemFlags; + } + } + + return QAbstractListModel::flags(index); +} diff --git a/interface/src/UserLocationsModel.h b/interface/src/UserLocationsModel.h new file mode 100644 index 0000000000..7cf984a8ac --- /dev/null +++ b/interface/src/UserLocationsModel.h @@ -0,0 +1,81 @@ +// +// UserLocationsModel.h +// interface/src +// +// Created by Ryan Huffman on 06/24/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_UserLocationsModel_h +#define hifi_UserLocationsModel_h + +#include +#include +#include + + +class UserLocation : public QObject { + Q_OBJECT +public: + UserLocation(QString id, QString name, QString location); + bool isUpdating() { return _updating; } + void requestRename(const QString& newName); + void requestDelete(); + + QString id() { return _id; } + QString name() { return _name; } + QString location() { return _location; } + +public slots: + void handleRenameResponse(const QJsonObject& responseData); + void handleRenameError(QNetworkReply::NetworkError error, const QString& errorString); + void handleDeleteResponse(const QJsonObject& responseData); + void handleDeleteError(QNetworkReply::NetworkError error, const QString& errorString); + +signals: + void updated(const QString& name); + void deleted(const QString& name); + +private: + QString _id; + QString _name; + QString _location; + QString _previousName; + bool _updating; + +}; + +class UserLocationsModel : public QAbstractListModel { + Q_OBJECT +public: + UserLocationsModel(QObject* parent = NULL); + + virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; + virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; + virtual int columnCount(const QModelIndex& parent = QModelIndex()) const { return 2; }; + virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + virtual Qt::ItemFlags flags(const QModelIndex& index) const; + + void deleteLocation(const QModelIndex& index); + void renameLocation(const QModelIndex& index, const QString& newName); + + enum Columns { + NameColumn = 0, + LocationColumn + }; + +public slots: + void refresh(); + void update(); + void handleLocationsResponse(const QJsonObject& responseData); + void removeLocation(const QString& name); + +private: + bool _updating; + QList _locations; +}; + +#endif // hifi_UserLocationsModel_h diff --git a/interface/src/ui/UserLocationsWindow.cpp b/interface/src/ui/UserLocationsWindow.cpp new file mode 100644 index 0000000000..7e4cc57248 --- /dev/null +++ b/interface/src/ui/UserLocationsWindow.cpp @@ -0,0 +1,76 @@ +// +// UserLocationsWindow.cpp +// interface/src/ui +// +// Created by Ryan Huffman on 06/24/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include +#include +#include + +#include "Menu.h" +#include "UserLocationsWindow.h" + +UserLocationsWindow::UserLocationsWindow(QWidget* parent) : + QWidget(parent, Qt::Window), + _ui(), + _proxyModel(this), + _userLocationsModel(this) { + + _ui.setupUi(this); + + _proxyModel.setSourceModel(&_userLocationsModel); + _proxyModel.setDynamicSortFilter(true); + + _ui.locationsTreeView->setModel(&_proxyModel); + _ui.locationsTreeView->setSortingEnabled(true); + + connect(_ui.locationsTreeView->selectionModel(), &QItemSelectionModel::selectionChanged, + this, &UserLocationsWindow::updateEnabled); + connect(&_userLocationsModel, &UserLocationsModel::modelReset, this, &UserLocationsWindow::updateEnabled); + connect(&_userLocationsModel, &UserLocationsModel::modelReset, &_proxyModel, &QSortFilterProxyModel::invalidate); + connect(_ui.locationsTreeView, &QTreeView::doubleClicked, this, &UserLocationsWindow::goToModelIndex); + + connect(_ui.deleteButton, &QPushButton::clicked, this, &UserLocationsWindow::deleteSelection); + connect(_ui.renameButton, &QPushButton::clicked, this, &UserLocationsWindow::renameSelection); + connect(_ui.refreshButton, &QPushButton::clicked, &_userLocationsModel, &UserLocationsModel::refresh); + + this->setWindowTitle("My Locations"); +} + +void UserLocationsWindow::updateEnabled() { + bool enabled = _ui.locationsTreeView->selectionModel()->hasSelection(); + _ui.renameButton->setEnabled(enabled); + _ui.deleteButton->setEnabled(enabled); +} + +void UserLocationsWindow::goToModelIndex(const QModelIndex& index) { + QVariant location = _proxyModel.data(index.sibling(index.row(), UserLocationsModel::LocationColumn)); + Menu::getInstance()->goToURL(location.toString()); +} + +void UserLocationsWindow::deleteSelection() { + QModelIndex selection = _ui.locationsTreeView->selectionModel()->currentIndex(); + selection = _proxyModel.mapToSource(selection); + if (selection.isValid()) { + _userLocationsModel.deleteLocation(selection); + } +} + +void UserLocationsWindow::renameSelection() { + QModelIndex selection = _ui.locationsTreeView->selectionModel()->currentIndex(); + selection = _proxyModel.mapToSource(selection); + if (selection.isValid()) { + bool ok; + QString name = _userLocationsModel.data(selection.sibling(selection.row(), UserLocationsModel::NameColumn)).toString(); + QString newName = QInputDialog::getText(this, "Rename '" + name + "'", "Set name to:", QLineEdit::Normal, name, &ok); + if (ok && !newName.isEmpty()) { + _userLocationsModel.renameLocation(selection, newName); + } + } +} diff --git a/interface/src/ui/UserLocationsWindow.h b/interface/src/ui/UserLocationsWindow.h new file mode 100644 index 0000000000..6188f396a2 --- /dev/null +++ b/interface/src/ui/UserLocationsWindow.h @@ -0,0 +1,35 @@ +// +// UserLocationsWindow.h +// interface/src/ui +// +// Created by Ryan Huffman on 06/24/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_UserLocationsWindow_h +#define hifi_UserLocationsWindow_h + +#include "ui_userLocationsWindow.h" +#include "UserLocationsModel.h" + +class UserLocationsWindow : public QWidget { + Q_OBJECT +public: + UserLocationsWindow(QWidget* parent = NULL); + +protected slots: + void updateEnabled(); + void goToModelIndex(const QModelIndex& index); + void deleteSelection(); + void renameSelection(); + +private: + Ui::UserLocationsWindow _ui; + QSortFilterProxyModel _proxyModel; + UserLocationsModel _userLocationsModel; +}; + +#endif // hifi_UserLocationsWindow_h diff --git a/interface/ui/userLocationsWindow.ui b/interface/ui/userLocationsWindow.ui new file mode 100644 index 0000000000..61bb0149f8 --- /dev/null +++ b/interface/ui/userLocationsWindow.ui @@ -0,0 +1,130 @@ + + + UserLocationsWindow + + + + 0 + 0 + 929 + 633 + + + + Form + + + + -1 + + + 12 + + + 12 + + + 12 + + + 12 + + + + + + + + font-size: 16px + + + My Locations + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Refresh + + + + + + + + + + 0 + + + false + + + + + + + + -1 + + + 12 + + + 12 + + + 12 + + + 12 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Rename + + + + + + + Delete + + + + + + + + + + + From 33e11be3e077b72427101bacf5a25a5ea7a53c61 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 26 Jun 2014 16:06:49 -0700 Subject: [PATCH 02/15] Add user locations to menu --- interface/src/Menu.cpp | 11 +++++++++++ interface/src/Menu.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index fa30e0382b..7c9356045c 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -45,6 +45,7 @@ #include "ui/ModelsBrowser.h" #include "ui/LoginDialog.h" #include "ui/NodeBounds.h" +#include "ui/UserLocationsWindow.h" #include "devices/OculusManager.h" @@ -165,6 +166,11 @@ Menu::Menu() : Qt::CTRL | Qt::Key_N, this, SLOT(nameLocation())); + addActionToQMenuAndActionHash(fileMenu, + MenuOption::MyLocations, + Qt::CTRL | Qt::Key_L, + this, + SLOT(showLocationList())); addActionToQMenuAndActionHash(fileMenu, MenuOption::GoTo, Qt::Key_At, @@ -1179,6 +1185,11 @@ void Menu::namedLocationCreated(LocationManager::NamedLocationCreateResponse res msgBox.exec(); } +void Menu::showLocationList() { + UserLocationsWindow* window = new UserLocationsWindow(); + window->show(); +} + void Menu::nameLocation() { // check if user is logged in or show login dialog if not diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 4d2174a448..e353b420dd 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -193,6 +193,7 @@ private slots: void goToDomainDialog(); void goToLocation(); void nameLocation(); + void showLocationList(); void bandwidthDetailsClosed(); void octreeStatsDetailsClosed(); void lodToolsClosed(); @@ -387,6 +388,7 @@ namespace MenuOption { const QString MoveWithLean = "Move with Lean"; const QString MuteAudio = "Mute Microphone"; const QString MuteEnvironment = "Mute Environment"; + const QString MyLocations = "My Locations..."; const QString NameLocation = "Name this location"; const QString NewVoxelCullingMode = "New Voxel Culling Mode"; const QString OctreeStats = "Voxel and Particle Statistics"; From 50e77be406195c50392a5aea1335386bda2f348b Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 26 Jun 2014 16:07:02 -0700 Subject: [PATCH 03/15] Add DELETE to AccountManager --- libraries/networking/src/AccountManager.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/networking/src/AccountManager.cpp b/libraries/networking/src/AccountManager.cpp index 918261a953..8800686178 100644 --- a/libraries/networking/src/AccountManager.cpp +++ b/libraries/networking/src/AccountManager.cpp @@ -204,6 +204,9 @@ void AccountManager::invokedRequest(const QString& path, QNetworkAccessManager:: } } + break; + case QNetworkAccessManager::DeleteOperation: + networkReply = _networkAccessManager->sendCustomRequest(authenticatedRequest, "DELETE"); break; default: // other methods not yet handled From 51e42221be651a6a504a48b162965c14b2d7ef08 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 30 Jun 2014 22:24:27 -0700 Subject: [PATCH 04/15] Update menu to toggle User Locations Menu --- interface/src/Menu.cpp | 18 ++++++++++++------ interface/src/Menu.h | 4 +++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 7c9356045c..ae3cc1b77c 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -45,7 +45,6 @@ #include "ui/ModelsBrowser.h" #include "ui/LoginDialog.h" #include "ui/NodeBounds.h" -#include "ui/UserLocationsWindow.h" #include "devices/OculusManager.h" @@ -92,6 +91,7 @@ Menu::Menu() : _jsConsole(NULL), _octreeStatsDialog(NULL), _lodToolsDialog(NULL), + _userLocationsWindow(NULL), _maxVoxels(DEFAULT_MAX_VOXELS_PER_SYSTEM), _voxelSizeScale(DEFAULT_OCTREE_SIZE_SCALE), _oculusUIAngularSize(DEFAULT_OCULUS_UI_ANGULAR_SIZE), @@ -168,9 +168,9 @@ Menu::Menu() : SLOT(nameLocation())); addActionToQMenuAndActionHash(fileMenu, MenuOption::MyLocations, - Qt::CTRL | Qt::Key_L, + Qt::CTRL | Qt::Key_K, this, - SLOT(showLocationList())); + SLOT(toggleLocationList())); addActionToQMenuAndActionHash(fileMenu, MenuOption::GoTo, Qt::Key_At, @@ -1185,9 +1185,15 @@ void Menu::namedLocationCreated(LocationManager::NamedLocationCreateResponse res msgBox.exec(); } -void Menu::showLocationList() { - UserLocationsWindow* window = new UserLocationsWindow(); - window->show(); +void Menu::toggleLocationList() { + if (!_userLocationsWindow) { + _userLocationsWindow = new UserLocationsWindow(); + } + if (_userLocationsWindow->isVisible()) { + _userLocationsWindow->hide(); + } else { + _userLocationsWindow->show(); + } } void Menu::nameLocation() { diff --git a/interface/src/Menu.h b/interface/src/Menu.h index e353b420dd..9a5e2f9d43 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -29,6 +29,7 @@ #include "ui/JSConsole.h" #include "ui/LoginDialog.h" #include "ui/ScriptEditorWindow.h" +#include "ui/UserLocationsWindow.h" const float ADJUST_LOD_DOWN_FPS = 40.0; const float ADJUST_LOD_UP_FPS = 55.0; @@ -193,7 +194,7 @@ private slots: void goToDomainDialog(); void goToLocation(); void nameLocation(); - void showLocationList(); + void toggleLocationList(); void bandwidthDetailsClosed(); void octreeStatsDetailsClosed(); void lodToolsClosed(); @@ -260,6 +261,7 @@ private: QDialog* _jsConsole; OctreeStatsDialog* _octreeStatsDialog; LodToolsDialog* _lodToolsDialog; + UserLocationsWindow* _userLocationsWindow; int _maxVoxels; float _voxelSizeScale; float _oculusUIAngularSize; From 15d60df4203f97b442c9df442fa9216194e3b441 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 30 Jun 2014 22:25:00 -0700 Subject: [PATCH 05/15] Update User Locations window to update name when it changes on update --- interface/src/UserLocationsModel.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/interface/src/UserLocationsModel.cpp b/interface/src/UserLocationsModel.cpp index 4ad91bed73..051b04eb95 100644 --- a/interface/src/UserLocationsModel.cpp +++ b/interface/src/UserLocationsModel.cpp @@ -56,9 +56,14 @@ void UserLocation::handleRenameResponse(const QJsonObject& responseData) { qDebug() << responseData; QJsonValue status = responseData["status"]; - if (status.isUndefined() || status.toString() != "success") { + if (!status.isUndefined() && status.toString() == "success") { + QString updatedName = responseData["data"].toObject()["name"].toString(); + _name = updatedName; + } else { _name = _previousName; - qDebug() << "There was an error renaming location '" + _name + "'"; + QString msg = "There was an error renaming location '" + _name + "'"; + qDebug() << msg; + QMessageBox::warning(Application::getInstance()->getWindow(), "Error", msg); } emit updated(_name); @@ -94,7 +99,9 @@ void UserLocation::handleDeleteResponse(const QJsonObject& responseData) { if (!status.isUndefined() && status.toString() == "success") { emit deleted(_name); } else { - qDebug() << "There was an error deleting location '" + _name + "'"; + QString msg = "There was an error deleting location '" + _name + "'"; + qDebug() << msg; + QMessageBox::warning(Application::getInstance()->getWindow(), "Error", msg); } } From a566f90820389d3a5443042f7266de01f9240b6e Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 30 Jun 2014 22:37:13 -0700 Subject: [PATCH 06/15] Update User Location update/delete to not work simultaneously --- interface/src/UserLocationsModel.cpp | 54 +++++++++++++++------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/interface/src/UserLocationsModel.cpp b/interface/src/UserLocationsModel.cpp index 051b04eb95..539f9197a4 100644 --- a/interface/src/UserLocationsModel.cpp +++ b/interface/src/UserLocationsModel.cpp @@ -31,24 +31,26 @@ UserLocation::UserLocation(QString id, QString name, QString location) : } void UserLocation::requestRename(const QString& newName) { - _updating = true; + if (!_updating) { + _updating = true; - JSONCallbackParameters callbackParams; - callbackParams.jsonCallbackReceiver = this; - callbackParams.jsonCallbackMethod = "handleRenameResponse"; - callbackParams.errorCallbackReceiver = this; - callbackParams.errorCallbackMethod = "handleRenameError"; - QJsonObject jsonNameObject; - jsonNameObject.insert("name", QJsonValue(newName)); - QJsonDocument jsonDocument(jsonNameObject); - AccountManager::getInstance().authenticatedRequest(PLACES_UPDATE.arg(_id), - QNetworkAccessManager::PutOperation, - callbackParams, - jsonDocument.toJson()); - _previousName = _name; - _name = newName; + JSONCallbackParameters callbackParams; + callbackParams.jsonCallbackReceiver = this; + callbackParams.jsonCallbackMethod = "handleRenameResponse"; + callbackParams.errorCallbackReceiver = this; + callbackParams.errorCallbackMethod = "handleRenameError"; + QJsonObject jsonNameObject; + jsonNameObject.insert("name", QJsonValue(newName)); + QJsonDocument jsonDocument(jsonNameObject); + AccountManager::getInstance().authenticatedRequest(PLACES_UPDATE.arg(_id), + QNetworkAccessManager::PutOperation, + callbackParams, + jsonDocument.toJson()); + _previousName = _name; + _name = newName; - emit updated(_name); + emit updated(_name); + } } void UserLocation::handleRenameResponse(const QJsonObject& responseData) { @@ -80,16 +82,18 @@ void UserLocation::handleRenameError(QNetworkReply::NetworkError error, const QS } void UserLocation::requestDelete() { - _updating = true; + if (!_updating) { + _updating = true; - JSONCallbackParameters callbackParams; - callbackParams.jsonCallbackReceiver = this; - callbackParams.jsonCallbackMethod = "handleDeleteResponse"; - callbackParams.errorCallbackReceiver = this; - callbackParams.errorCallbackMethod = "handleDeleteError"; - AccountManager::getInstance().authenticatedRequest(PLACES_DELETE.arg(_id), - QNetworkAccessManager::DeleteOperation, - callbackParams); + JSONCallbackParameters callbackParams; + callbackParams.jsonCallbackReceiver = this; + callbackParams.jsonCallbackMethod = "handleDeleteResponse"; + callbackParams.errorCallbackReceiver = this; + callbackParams.errorCallbackMethod = "handleDeleteError"; + AccountManager::getInstance().authenticatedRequest(PLACES_DELETE.arg(_id), + QNetworkAccessManager::DeleteOperation, + callbackParams); + } } void UserLocation::handleDeleteResponse(const QJsonObject& responseData) { From bfde24fe121621ea22c3c0df51aa1aea96e68345 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 30 Jun 2014 22:37:32 -0700 Subject: [PATCH 07/15] Update MyLocations sort order --- interface/src/ui/UserLocationsWindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/src/ui/UserLocationsWindow.cpp b/interface/src/ui/UserLocationsWindow.cpp index 7e4cc57248..523d32f930 100644 --- a/interface/src/ui/UserLocationsWindow.cpp +++ b/interface/src/ui/UserLocationsWindow.cpp @@ -29,6 +29,7 @@ UserLocationsWindow::UserLocationsWindow(QWidget* parent) : _ui.locationsTreeView->setModel(&_proxyModel); _ui.locationsTreeView->setSortingEnabled(true); + _ui.locationsTreeView->sortByColumn(UserLocationsModel::NameColumn, Qt::AscendingOrder); connect(_ui.locationsTreeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &UserLocationsWindow::updateEnabled); From 50b13c99a7e3486a200ee245692f25a09fafba45 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 30 Jun 2014 22:44:04 -0700 Subject: [PATCH 08/15] Update UserLocationsWindow derive from QDialog --- interface/src/ui/UserLocationsWindow.cpp | 2 +- interface/src/ui/UserLocationsWindow.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/ui/UserLocationsWindow.cpp b/interface/src/ui/UserLocationsWindow.cpp index 523d32f930..f7e684fc64 100644 --- a/interface/src/ui/UserLocationsWindow.cpp +++ b/interface/src/ui/UserLocationsWindow.cpp @@ -17,7 +17,7 @@ #include "UserLocationsWindow.h" UserLocationsWindow::UserLocationsWindow(QWidget* parent) : - QWidget(parent, Qt::Window), + QDialog(parent), _ui(), _proxyModel(this), _userLocationsModel(this) { diff --git a/interface/src/ui/UserLocationsWindow.h b/interface/src/ui/UserLocationsWindow.h index 6188f396a2..215c1957f3 100644 --- a/interface/src/ui/UserLocationsWindow.h +++ b/interface/src/ui/UserLocationsWindow.h @@ -15,7 +15,7 @@ #include "ui_userLocationsWindow.h" #include "UserLocationsModel.h" -class UserLocationsWindow : public QWidget { +class UserLocationsWindow : public QDialog { Q_OBJECT public: UserLocationsWindow(QWidget* parent = NULL); From 9953fd6d2bdcbd31f9722a14ced4296717b221d7 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 1 Jul 2014 15:29:13 -0700 Subject: [PATCH 09/15] Update MyLocations to not send rename request if unchanged --- interface/src/UserLocationsModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/UserLocationsModel.cpp b/interface/src/UserLocationsModel.cpp index 539f9197a4..000ab34703 100644 --- a/interface/src/UserLocationsModel.cpp +++ b/interface/src/UserLocationsModel.cpp @@ -31,7 +31,7 @@ UserLocation::UserLocation(QString id, QString name, QString location) : } void UserLocation::requestRename(const QString& newName) { - if (!_updating) { + if (!_updating && newName.toLower() != _name) { _updating = true; JSONCallbackParameters callbackParams; From e7e7bef5064ae18442b2b29c0d469a391c03a891 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 1 Jul 2014 15:37:10 -0700 Subject: [PATCH 10/15] Add error string on rename failure --- interface/src/UserLocationsModel.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/interface/src/UserLocationsModel.cpp b/interface/src/UserLocationsModel.cpp index 000ab34703..824c1269bd 100644 --- a/interface/src/UserLocationsModel.cpp +++ b/interface/src/UserLocationsModel.cpp @@ -63,7 +63,16 @@ void UserLocation::handleRenameResponse(const QJsonObject& responseData) { _name = updatedName; } else { _name = _previousName; + QString msg = "There was an error renaming location '" + _name + "'"; + + QJsonValue data = responseData["data"]; + if (!data.isUndefined()) { + QJsonValue nameError = data.toObject()["name"]; + if (!nameError.isUndefined()) { + msg += ": " + nameError.toString(); + } + } qDebug() << msg; QMessageBox::warning(Application::getInstance()->getWindow(), "Error", msg); } From a9e352981a94de1a0949d1ecc1fa87bc1273b3f9 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 1 Jul 2014 17:59:49 -0700 Subject: [PATCH 11/15] Fix cleanup of resources for UserLocations* --- interface/src/Menu.cpp | 2 +- interface/src/UserLocationsModel.cpp | 6 ++++++ interface/src/UserLocationsModel.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index ae3cc1b77c..c3417144ee 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -1187,7 +1187,7 @@ void Menu::namedLocationCreated(LocationManager::NamedLocationCreateResponse res void Menu::toggleLocationList() { if (!_userLocationsWindow) { - _userLocationsWindow = new UserLocationsWindow(); + _userLocationsWindow = new UserLocationsWindow(Application::getInstance()->getWindow()); } if (_userLocationsWindow->isVisible()) { _userLocationsWindow->hide(); diff --git a/interface/src/UserLocationsModel.cpp b/interface/src/UserLocationsModel.cpp index 824c1269bd..90d6927e1e 100644 --- a/interface/src/UserLocationsModel.cpp +++ b/interface/src/UserLocationsModel.cpp @@ -133,6 +133,11 @@ UserLocationsModel::UserLocationsModel(QObject* parent) : refresh(); } +UserLocationsModel::~UserLocationsModel() { + qDeleteAll(_locations); + _locations.clear(); +} + void UserLocationsModel::update() { beginResetModel(); endResetModel(); @@ -151,6 +156,7 @@ void UserLocationsModel::renameLocation(const QModelIndex& index, const QString& void UserLocationsModel::refresh() { if (!_updating) { beginResetModel(); + qDeleteAll(_locations); _locations.clear(); _updating = true; endResetModel(); diff --git a/interface/src/UserLocationsModel.h b/interface/src/UserLocationsModel.h index 7cf984a8ac..d3f86faa5a 100644 --- a/interface/src/UserLocationsModel.h +++ b/interface/src/UserLocationsModel.h @@ -52,6 +52,7 @@ class UserLocationsModel : public QAbstractListModel { Q_OBJECT public: UserLocationsModel(QObject* parent = NULL); + ~UserLocationsModel(); virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; From aa08577c73c9fc1097f723bd2947e1a0ae814e0a Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 1 Jul 2014 17:59:59 -0700 Subject: [PATCH 12/15] Fix long line --- interface/src/UserLocationsModel.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/interface/src/UserLocationsModel.cpp b/interface/src/UserLocationsModel.cpp index 90d6927e1e..b69d8db748 100644 --- a/interface/src/UserLocationsModel.cpp +++ b/interface/src/UserLocationsModel.cpp @@ -181,7 +181,9 @@ void UserLocationsModel::handleLocationsResponse(const QJsonObject& responseData QJsonObject location = (*it).toObject(); QJsonObject address = location["address"].toObject(); UserLocation* userLocation = new UserLocation(location["id"].toString(), location["name"].toString(), - "hifi://" + address["domain"].toString() + "/" + address["position"].toString() + "/" + address["orientation"].toString()); + "hifi://" + address["domain"].toString() + + "/" + address["position"].toString() + + "/" + address["orientation"].toString()); _locations.append(userLocation); connect(userLocation, &UserLocation::deleted, this, &UserLocationsModel::removeLocation); connect(userLocation, &UserLocation::updated, this, &UserLocationsModel::update); From 83349e0e53e97f7e9e4eca43b23d4abcf2e043ee Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 1 Jul 2014 20:03:05 -0700 Subject: [PATCH 13/15] Rename UserLocationsWindow to UserLocationsDialog --- interface/src/Menu.cpp | 12 +++++----- interface/src/Menu.h | 4 ++-- ...ionsWindow.cpp => UserLocationsDialog.cpp} | 24 +++++++++---------- ...ocationsWindow.h => UserLocationsDialog.h} | 16 ++++++------- ...ationsWindow.ui => userLocationsDialog.ui} | 4 ++-- 5 files changed, 30 insertions(+), 30 deletions(-) rename interface/src/ui/{UserLocationsWindow.cpp => UserLocationsDialog.cpp} (82%) rename interface/src/ui/{UserLocationsWindow.h => UserLocationsDialog.h} (65%) rename interface/ui/{userLocationsWindow.ui => userLocationsDialog.ui} (97%) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index c3417144ee..a1c7ee3c08 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -91,7 +91,7 @@ Menu::Menu() : _jsConsole(NULL), _octreeStatsDialog(NULL), _lodToolsDialog(NULL), - _userLocationsWindow(NULL), + _userLocationsDialog(NULL), _maxVoxels(DEFAULT_MAX_VOXELS_PER_SYSTEM), _voxelSizeScale(DEFAULT_OCTREE_SIZE_SCALE), _oculusUIAngularSize(DEFAULT_OCULUS_UI_ANGULAR_SIZE), @@ -1186,13 +1186,13 @@ void Menu::namedLocationCreated(LocationManager::NamedLocationCreateResponse res } void Menu::toggleLocationList() { - if (!_userLocationsWindow) { - _userLocationsWindow = new UserLocationsWindow(Application::getInstance()->getWindow()); + if (!_userLocationsDialog) { + _userLocationsDialog = new UserLocationsDialog(Application::getInstance()->getWindow()); } - if (_userLocationsWindow->isVisible()) { - _userLocationsWindow->hide(); + if (_userLocationsDialog->isVisible()) { + _userLocationsDialog->hide(); } else { - _userLocationsWindow->show(); + _userLocationsDialog->show(); } } diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 9a5e2f9d43..3112607753 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -29,7 +29,7 @@ #include "ui/JSConsole.h" #include "ui/LoginDialog.h" #include "ui/ScriptEditorWindow.h" -#include "ui/UserLocationsWindow.h" +#include "ui/UserLocationsDialog.h" const float ADJUST_LOD_DOWN_FPS = 40.0; const float ADJUST_LOD_UP_FPS = 55.0; @@ -261,7 +261,7 @@ private: QDialog* _jsConsole; OctreeStatsDialog* _octreeStatsDialog; LodToolsDialog* _lodToolsDialog; - UserLocationsWindow* _userLocationsWindow; + UserLocationsDialog* _userLocationsDialog; int _maxVoxels; float _voxelSizeScale; float _oculusUIAngularSize; diff --git a/interface/src/ui/UserLocationsWindow.cpp b/interface/src/ui/UserLocationsDialog.cpp similarity index 82% rename from interface/src/ui/UserLocationsWindow.cpp rename to interface/src/ui/UserLocationsDialog.cpp index f7e684fc64..f72e66ce77 100644 --- a/interface/src/ui/UserLocationsWindow.cpp +++ b/interface/src/ui/UserLocationsDialog.cpp @@ -1,5 +1,5 @@ // -// UserLocationsWindow.cpp +// UserLocationsDialog.cpp // interface/src/ui // // Created by Ryan Huffman on 06/24/14. @@ -14,9 +14,9 @@ #include #include "Menu.h" -#include "UserLocationsWindow.h" +#include "UserLocationsDialog.h" -UserLocationsWindow::UserLocationsWindow(QWidget* parent) : +UserLocationsDialog::UserLocationsDialog(QWidget* parent) : QDialog(parent), _ui(), _proxyModel(this), @@ -32,30 +32,30 @@ UserLocationsWindow::UserLocationsWindow(QWidget* parent) : _ui.locationsTreeView->sortByColumn(UserLocationsModel::NameColumn, Qt::AscendingOrder); connect(_ui.locationsTreeView->selectionModel(), &QItemSelectionModel::selectionChanged, - this, &UserLocationsWindow::updateEnabled); - connect(&_userLocationsModel, &UserLocationsModel::modelReset, this, &UserLocationsWindow::updateEnabled); + this, &UserLocationsDialog::updateEnabled); + connect(&_userLocationsModel, &UserLocationsModel::modelReset, this, &UserLocationsDialog::updateEnabled); connect(&_userLocationsModel, &UserLocationsModel::modelReset, &_proxyModel, &QSortFilterProxyModel::invalidate); - connect(_ui.locationsTreeView, &QTreeView::doubleClicked, this, &UserLocationsWindow::goToModelIndex); + connect(_ui.locationsTreeView, &QTreeView::doubleClicked, this, &UserLocationsDialog::goToModelIndex); - connect(_ui.deleteButton, &QPushButton::clicked, this, &UserLocationsWindow::deleteSelection); - connect(_ui.renameButton, &QPushButton::clicked, this, &UserLocationsWindow::renameSelection); + connect(_ui.deleteButton, &QPushButton::clicked, this, &UserLocationsDialog::deleteSelection); + connect(_ui.renameButton, &QPushButton::clicked, this, &UserLocationsDialog::renameSelection); connect(_ui.refreshButton, &QPushButton::clicked, &_userLocationsModel, &UserLocationsModel::refresh); this->setWindowTitle("My Locations"); } -void UserLocationsWindow::updateEnabled() { +void UserLocationsDialog::updateEnabled() { bool enabled = _ui.locationsTreeView->selectionModel()->hasSelection(); _ui.renameButton->setEnabled(enabled); _ui.deleteButton->setEnabled(enabled); } -void UserLocationsWindow::goToModelIndex(const QModelIndex& index) { +void UserLocationsDialog::goToModelIndex(const QModelIndex& index) { QVariant location = _proxyModel.data(index.sibling(index.row(), UserLocationsModel::LocationColumn)); Menu::getInstance()->goToURL(location.toString()); } -void UserLocationsWindow::deleteSelection() { +void UserLocationsDialog::deleteSelection() { QModelIndex selection = _ui.locationsTreeView->selectionModel()->currentIndex(); selection = _proxyModel.mapToSource(selection); if (selection.isValid()) { @@ -63,7 +63,7 @@ void UserLocationsWindow::deleteSelection() { } } -void UserLocationsWindow::renameSelection() { +void UserLocationsDialog::renameSelection() { QModelIndex selection = _ui.locationsTreeView->selectionModel()->currentIndex(); selection = _proxyModel.mapToSource(selection); if (selection.isValid()) { diff --git a/interface/src/ui/UserLocationsWindow.h b/interface/src/ui/UserLocationsDialog.h similarity index 65% rename from interface/src/ui/UserLocationsWindow.h rename to interface/src/ui/UserLocationsDialog.h index 215c1957f3..0e596ece87 100644 --- a/interface/src/ui/UserLocationsWindow.h +++ b/interface/src/ui/UserLocationsDialog.h @@ -1,5 +1,5 @@ // -// UserLocationsWindow.h +// UserLocationsDialog.h // interface/src/ui // // Created by Ryan Huffman on 06/24/14. @@ -9,16 +9,16 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef hifi_UserLocationsWindow_h -#define hifi_UserLocationsWindow_h +#ifndef hifi_UserLocationsDialog_h +#define hifi_UserLocationsDialog_h -#include "ui_userLocationsWindow.h" +#include "ui_userLocationsDialog.h" #include "UserLocationsModel.h" -class UserLocationsWindow : public QDialog { +class UserLocationsDialog : public QDialog { Q_OBJECT public: - UserLocationsWindow(QWidget* parent = NULL); + UserLocationsDialog(QWidget* parent = NULL); protected slots: void updateEnabled(); @@ -27,9 +27,9 @@ protected slots: void renameSelection(); private: - Ui::UserLocationsWindow _ui; + Ui::UserLocationsDialog _ui; QSortFilterProxyModel _proxyModel; UserLocationsModel _userLocationsModel; }; -#endif // hifi_UserLocationsWindow_h +#endif // hifi_UserLocationsDialog_h diff --git a/interface/ui/userLocationsWindow.ui b/interface/ui/userLocationsDialog.ui similarity index 97% rename from interface/ui/userLocationsWindow.ui rename to interface/ui/userLocationsDialog.ui index 61bb0149f8..609ce1c8ab 100644 --- a/interface/ui/userLocationsWindow.ui +++ b/interface/ui/userLocationsDialog.ui @@ -1,7 +1,7 @@ - UserLocationsWindow - + UserLocationsDialog + 0 From f0c013960df8fe1267be7bc7940239b4820f0d3e Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 1 Jul 2014 20:05:30 -0700 Subject: [PATCH 14/15] Remove unnecessary qDebug --- interface/src/UserLocationsModel.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/src/UserLocationsModel.cpp b/interface/src/UserLocationsModel.cpp index b69d8db748..87c81bbcd9 100644 --- a/interface/src/UserLocationsModel.cpp +++ b/interface/src/UserLocationsModel.cpp @@ -56,7 +56,6 @@ void UserLocation::requestRename(const QString& newName) { void UserLocation::handleRenameResponse(const QJsonObject& responseData) { _updating = false; - qDebug() << responseData; QJsonValue status = responseData["status"]; if (!status.isUndefined() && status.toString() == "success") { QString updatedName = responseData["data"].toObject()["name"].toString(); From 70121357be57dc557eb7682cfd0e4f31479483a5 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 2 Jul 2014 11:12:06 -0700 Subject: [PATCH 15/15] Update JSONCallbackParameters to take params in constructor --- interface/src/UserLocationsModel.cpp | 16 +++------------- libraries/networking/src/AccountManager.cpp | 16 +++++++++------- libraries/networking/src/AccountManager.h | 4 +++- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/interface/src/UserLocationsModel.cpp b/interface/src/UserLocationsModel.cpp index 87c81bbcd9..e84cae8f95 100644 --- a/interface/src/UserLocationsModel.cpp +++ b/interface/src/UserLocationsModel.cpp @@ -34,11 +34,7 @@ void UserLocation::requestRename(const QString& newName) { if (!_updating && newName.toLower() != _name) { _updating = true; - JSONCallbackParameters callbackParams; - callbackParams.jsonCallbackReceiver = this; - callbackParams.jsonCallbackMethod = "handleRenameResponse"; - callbackParams.errorCallbackReceiver = this; - callbackParams.errorCallbackMethod = "handleRenameError"; + JSONCallbackParameters callbackParams(this, "handleRenameResponse", this, "handleRenameError"); QJsonObject jsonNameObject; jsonNameObject.insert("name", QJsonValue(newName)); QJsonDocument jsonDocument(jsonNameObject); @@ -93,11 +89,7 @@ void UserLocation::requestDelete() { if (!_updating) { _updating = true; - JSONCallbackParameters callbackParams; - callbackParams.jsonCallbackReceiver = this; - callbackParams.jsonCallbackMethod = "handleDeleteResponse"; - callbackParams.errorCallbackReceiver = this; - callbackParams.errorCallbackMethod = "handleDeleteError"; + JSONCallbackParameters callbackParams(this, "handleDeleteResponse", this, "handleDeleteError"); AccountManager::getInstance().authenticatedRequest(PLACES_DELETE.arg(_id), QNetworkAccessManager::DeleteOperation, callbackParams); @@ -160,9 +152,7 @@ void UserLocationsModel::refresh() { _updating = true; endResetModel(); - JSONCallbackParameters callbackParams; - callbackParams.jsonCallbackReceiver = this; - callbackParams.jsonCallbackMethod = "handleLocationsResponse"; + JSONCallbackParameters callbackParams(this, "handleLocationsResponse"); AccountManager::getInstance().authenticatedRequest(PLACES_GET, QNetworkAccessManager::GetOperation, callbackParams); diff --git a/libraries/networking/src/AccountManager.cpp b/libraries/networking/src/AccountManager.cpp index 8800686178..ce138e144e 100644 --- a/libraries/networking/src/AccountManager.cpp +++ b/libraries/networking/src/AccountManager.cpp @@ -37,13 +37,15 @@ Q_DECLARE_METATYPE(JSONCallbackParameters) const QString ACCOUNTS_GROUP = "accounts"; -JSONCallbackParameters::JSONCallbackParameters() : - jsonCallbackReceiver(NULL), - jsonCallbackMethod(), - errorCallbackReceiver(NULL), - errorCallbackMethod(), - updateReciever(NULL), - updateSlot() +JSONCallbackParameters::JSONCallbackParameters(QObject* jsonCallbackReceiver, const QString& jsonCallbackMethod, + QObject* errorCallbackReceiver, const QString& errorCallbackMethod, + QObject* updateReceiver, const QString& updateSlot) : + jsonCallbackReceiver(jsonCallbackReceiver), + jsonCallbackMethod(jsonCallbackMethod), + errorCallbackReceiver(errorCallbackReceiver), + errorCallbackMethod(errorCallbackMethod), + updateReciever(updateReceiver), + updateSlot(updateSlot) { } diff --git a/libraries/networking/src/AccountManager.h b/libraries/networking/src/AccountManager.h index c18836ca54..389f84e01f 100644 --- a/libraries/networking/src/AccountManager.h +++ b/libraries/networking/src/AccountManager.h @@ -22,7 +22,9 @@ class JSONCallbackParameters { public: - JSONCallbackParameters(); + JSONCallbackParameters(QObject* jsonCallbackReceiver = NULL, const QString& jsonCallbackMethod = QString(), + QObject* errorCallbackReceiver = NULL, const QString& errorCallbackMethod = QString(), + QObject* updateReceiver = NULL, const QString& updateSlot = QString()); bool isEmpty() const { return !jsonCallbackReceiver && !errorCallbackReceiver; }