2022-05-26 23:18:54 +02:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
/*
|
|
|
|
* PolyMC - Minecraft Launcher
|
|
|
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
2017-05-22 23:42:47 +02:00
|
|
|
*
|
2022-05-26 23:18:54 +02:00
|
|
|
* 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, version 3.
|
2017-05-22 23:42:47 +02:00
|
|
|
*
|
2022-05-26 23:18:54 +02:00
|
|
|
* 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.
|
2017-05-22 23:42:47 +02:00
|
|
|
*
|
2022-05-26 23:18:54 +02:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2017-05-22 23:42:47 +02:00
|
|
|
*/
|
2014-01-31 22:51:45 +01:00
|
|
|
#pragma once
|
2013-12-24 11:47:30 +01:00
|
|
|
|
2022-09-30 23:37:00 +02:00
|
|
|
#include <QStackedWidget>
|
|
|
|
#include <QAbstractItemView>
|
|
|
|
#include <QTableView>
|
2013-12-24 11:47:30 +01:00
|
|
|
|
2022-09-30 23:37:00 +02:00
|
|
|
#include "BaseInstance.h"
|
2013-12-30 23:39:10 +01:00
|
|
|
|
2022-09-30 23:37:00 +02:00
|
|
|
class InstanceProxyModel;
|
|
|
|
class InstanceList;
|
2013-12-24 11:47:30 +01:00
|
|
|
|
2022-09-30 23:37:00 +02:00
|
|
|
class InstanceView : public QStackedWidget {
|
|
|
|
Q_OBJECT
|
2013-12-24 11:47:30 +01:00
|
|
|
|
2022-09-30 23:37:00 +02:00
|
|
|
public:
|
|
|
|
explicit InstanceView(QWidget *parent = nullptr, InstanceList* instances = nullptr);
|
2014-03-07 15:46:56 +01:00
|
|
|
|
2022-09-30 23:37:00 +02:00
|
|
|
QAbstractItemView* currentView() {
|
|
|
|
return m_table;
|
2019-08-20 02:58:27 +02:00
|
|
|
}
|
|
|
|
|
2022-09-30 23:37:00 +02:00
|
|
|
InstancePtr currentInstance();
|
2013-12-24 11:47:30 +01:00
|
|
|
|
2017-04-22 06:11:26 +02:00
|
|
|
signals:
|
2022-09-30 23:37:00 +02:00
|
|
|
void instanceActivated(InstancePtr inst);
|
|
|
|
void currentInstanceChanged(InstancePtr current, InstancePtr previous);
|
2013-12-24 11:47:30 +01:00
|
|
|
|
2022-09-30 23:37:00 +02:00
|
|
|
private slots:
|
|
|
|
void currentRowChanged(const QModelIndex& current, const QModelIndex& previous);
|
|
|
|
void selectNameColumn(const QModelIndex& current, const QModelIndex& previous);
|
|
|
|
// emits currentRowChanged if a data update affected the current instance
|
|
|
|
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
|
2018-01-28 02:04:47 +01:00
|
|
|
|
2013-12-24 11:47:30 +01:00
|
|
|
private:
|
2022-09-30 23:37:00 +02:00
|
|
|
void createTable();
|
|
|
|
void prepareModel();
|
2013-12-26 21:16:03 +01:00
|
|
|
|
2022-09-30 23:37:00 +02:00
|
|
|
int m_rowHeight = 48;
|
2013-12-30 18:46:12 +01:00
|
|
|
|
2022-09-30 23:37:00 +02:00
|
|
|
QTableView* m_table;
|
|
|
|
InstanceProxyModel* m_proxy;
|
|
|
|
InstanceList* m_instances;
|
2013-12-24 11:47:30 +01:00
|
|
|
};
|