Loading files
c43996719This file is pinned to the selected release. Download the original to open it in your design tool.
/*
* LibrePCB - Professional EDA for everyone!
* Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
* https://librepcb.org/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBREPCB_EDITOR_APIENDPOINTLISTMODELLEGACY_H
#define LIBREPCB_EDITOR_APIENDPOINTLISTMODELLEGACY_H
/*******************************************************************************
* Includes
******************************************************************************/
#include <librepcb/core/network/apiendpoint.h>
#include <librepcb/core/workspace/workspacesettings.h>
#include <QtCore>
/*******************************************************************************
* Namespace / Forward Declarations
******************************************************************************/
namespace librepcb {
class WorkspaceSettings;
namespace editor {
/*******************************************************************************
* Class ApiEndpointListModelLegacy
******************************************************************************/
/**
* @brief The ApiEndpointListModelLegacy class
*/
class ApiEndpointListModelLegacy final : public QAbstractTableModel {
Q_OBJECT
public:
enum Column {
COLUMN_URL,
COLUMN_LIBRARIES,
COLUMN_PARTS,
COLUMN_ORDER,
COLUMN_USER,
COLUMN_ACTIONS,
_COLUMN_COUNT
};
// Constructors / Destructor
// ApiEndpointListModelLegacy() = delete;
ApiEndpointListModelLegacy(const ApiEndpointListModelLegacy& other) = delete;
explicit ApiEndpointListModelLegacy(const WorkspaceSettings& settings,
QObject* parent = nullptr) noexcept;
~ApiEndpointListModelLegacy() noexcept override;
// General Methods
void setValues(const QList<WorkspaceSettings::ApiEndpoint>& values) noexcept;
const QList<WorkspaceSettings::ApiEndpoint>& getValues() const noexcept {
return mValues;
}
// Slots
void add(const QPersistentModelIndex& itemIndex) noexcept;
void remove(const QPersistentModelIndex& itemIndex) noexcept;
void moveUp(const QPersistentModelIndex& itemIndex) noexcept;
void moveDown(const QPersistentModelIndex& itemIndex) noexcept;
void logInOut(const QPersistentModelIndex& itemIndex) noexcept;
// Inherited from QAbstractItemModel
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex& index,
int role = Qt::DisplayRole) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
bool setData(const QModelIndex& itemIndex, const QVariant& value,
int role = Qt::EditRole) override;
// Operator Overloadings
ApiEndpointListModelLegacy& operator=(
const ApiEndpointListModelLegacy& rhs) noexcept;
private: // Methods
void pollOAuthToken(const std::shared_ptr<ApiEndpoint>& ep,
const QString& deviceCode, int intervalMs,
qint64 timeoutAtMs) noexcept;
void handleOAuthTokenResult(const std::shared_ptr<ApiEndpoint>& ep,
const ApiEndpoint::OAuthTokenResult& result,
const QString& deviceCode, int intervalMs,
qint64 timeoutAtMs) noexcept;
void requestMissingUserData() noexcept;
private: // Data
const WorkspaceSettings& mSettings;
QList<WorkspaceSettings::ApiEndpoint> mValues;
QUrl mNewUrl;
};
/*******************************************************************************
* End of File
******************************************************************************/
} // namespace editor
} // namespace librepcb
#endif