chore: fix formatting
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
@@ -872,7 +872,9 @@ SET(LAUNCHER_SOURCES
|
|||||||
# GUI - instance group view
|
# GUI - instance group view
|
||||||
ui/instanceview/InstanceProxyModel.cpp
|
ui/instanceview/InstanceProxyModel.cpp
|
||||||
ui/instanceview/InstanceProxyModel.h
|
ui/instanceview/InstanceProxyModel.h
|
||||||
ui/instanceview/InstanceView.cpp ui/instanceview/InstanceView.h)
|
ui/instanceview/InstanceView.h
|
||||||
|
ui/instanceview/InstanceView.cpp
|
||||||
|
)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(LAUNCHER_SOURCES
|
set(LAUNCHER_SOURCES
|
||||||
|
|||||||
@@ -15,11 +15,12 @@
|
|||||||
|
|
||||||
#include "InstanceProxyModel.h"
|
#include "InstanceProxyModel.h"
|
||||||
|
|
||||||
#include "InstanceList.h"
|
|
||||||
#include "Application.h"
|
|
||||||
#include <icons/IconList.h>
|
#include <icons/IconList.h>
|
||||||
|
#include "Application.h"
|
||||||
|
#include "InstanceList.h"
|
||||||
|
|
||||||
InstanceProxyModel::InstanceProxyModel(QObject *parent) : QSortFilterProxyModel(parent) {
|
InstanceProxyModel::InstanceProxyModel(QObject* parent) : QSortFilterProxyModel(parent)
|
||||||
|
{
|
||||||
m_naturalSort.setNumericMode(true);
|
m_naturalSort.setNumericMode(true);
|
||||||
m_naturalSort.setCaseSensitivity(Qt::CaseSensitivity::CaseInsensitive);
|
m_naturalSort.setCaseSensitivity(Qt::CaseSensitivity::CaseInsensitive);
|
||||||
// FIXME: use loaded translation as source of locale instead, hook this up to translation changes
|
// FIXME: use loaded translation as source of locale instead, hook this up to translation changes
|
||||||
@@ -29,8 +30,7 @@ InstanceProxyModel::InstanceProxyModel(QObject *parent) : QSortFilterProxyModel(
|
|||||||
QVariant InstanceProxyModel::data(const QModelIndex& index, int role) const
|
QVariant InstanceProxyModel::data(const QModelIndex& index, int role) const
|
||||||
{
|
{
|
||||||
QVariant data = QSortFilterProxyModel::data(index, role);
|
QVariant data = QSortFilterProxyModel::data(index, role);
|
||||||
if(role == Qt::DecorationRole)
|
if (role == Qt::DecorationRole) {
|
||||||
{
|
|
||||||
if (!data.toString().isEmpty())
|
if (!data.toString().isEmpty())
|
||||||
return APPLICATION->icons()->getIcon(data.toString()); // FIXME: Needs QStyledItemDelegate
|
return APPLICATION->icons()->getIcon(data.toString()); // FIXME: Needs QStyledItemDelegate
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,11 +15,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QSortFilterProxyModel>
|
|
||||||
#include <QCollator>
|
#include <QCollator>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
class InstanceProxyModel : public QSortFilterProxyModel
|
class InstanceProxyModel : public QSortFilterProxyModel {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -22,8 +22,8 @@
|
|||||||
* or later.
|
* or later.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Application.h"
|
|
||||||
#include "InstanceView.h"
|
#include "InstanceView.h"
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
#include "InstanceList.h"
|
#include "InstanceList.h"
|
||||||
#include "ui/instanceview/InstanceProxyModel.h"
|
#include "ui/instanceview/InstanceProxyModel.h"
|
||||||
@@ -31,7 +31,8 @@
|
|||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
|
|
||||||
InstanceView::InstanceView(QWidget *parent, InstanceList *instances) : QStackedWidget(parent), m_instances(instances) {
|
InstanceView::InstanceView(QWidget* parent, InstanceList* instances) : QStackedWidget(parent), m_instances(instances)
|
||||||
|
{
|
||||||
prepareModel();
|
prepareModel();
|
||||||
createTable();
|
createTable();
|
||||||
|
|
||||||
@@ -39,19 +40,21 @@ InstanceView::InstanceView(QWidget *parent, InstanceList *instances) : QStackedW
|
|||||||
setCurrentWidget(m_table);
|
setCurrentWidget(m_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceView::storeState() {
|
void InstanceView::storeState()
|
||||||
|
{
|
||||||
APPLICATION->settings()->set("InstanceViewTableHeaderState", m_table->horizontalHeader()->saveState().toBase64());
|
APPLICATION->settings()->set("InstanceViewTableHeaderState", m_table->horizontalHeader()->saveState().toBase64());
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceView::prepareModel() {
|
void InstanceView::prepareModel()
|
||||||
|
{
|
||||||
m_proxy = new InstanceProxyModel(this);
|
m_proxy = new InstanceProxyModel(this);
|
||||||
m_proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
|
m_proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||||
m_proxy->setSourceModel(m_instances);
|
m_proxy->setSourceModel(m_instances);
|
||||||
connect(m_proxy, &InstanceProxyModel::dataChanged, this, &InstanceView::dataChanged);
|
connect(m_proxy, &InstanceProxyModel::dataChanged, this, &InstanceView::dataChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceView::createTable() {
|
void InstanceView::createTable()
|
||||||
|
{
|
||||||
m_table = new QTableView(this);
|
m_table = new QTableView(this);
|
||||||
m_table->setModel(m_proxy);
|
m_table->setModel(m_proxy);
|
||||||
|
|
||||||
@@ -92,7 +95,8 @@ void InstanceView::createTable() {
|
|||||||
connect(m_table, &QWidget::customContextMenuRequested, this, &InstanceView::contextMenuRequested);
|
connect(m_table, &QWidget::customContextMenuRequested, this, &InstanceView::contextMenuRequested);
|
||||||
}
|
}
|
||||||
|
|
||||||
InstancePtr InstanceView::currentInstance() {
|
InstancePtr InstanceView::currentInstance()
|
||||||
|
{
|
||||||
auto current = m_table->selectionModel()->currentIndex();
|
auto current = m_table->selectionModel()->currentIndex();
|
||||||
if (current.isValid()) {
|
if (current.isValid()) {
|
||||||
int row = mappedIndex(current).row();
|
int row = mappedIndex(current).row();
|
||||||
@@ -101,14 +105,16 @@ InstancePtr InstanceView::currentInstance() {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceView::activateInstance(const QModelIndex &index) {
|
void InstanceView::activateInstance(const QModelIndex& index)
|
||||||
|
{
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
int row = mappedIndex(index).row();
|
int row = mappedIndex(index).row();
|
||||||
emit instanceActivated(m_instances->at(row));
|
emit instanceActivated(m_instances->at(row));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceView::currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous) {
|
void InstanceView::currentRowChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||||
|
{
|
||||||
InstancePtr inst1, inst2;
|
InstancePtr inst1, inst2;
|
||||||
if (current.isValid()) {
|
if (current.isValid()) {
|
||||||
int row = mappedIndex(current).row();
|
int row = mappedIndex(current).row();
|
||||||
@@ -121,12 +127,14 @@ void InstanceView::currentRowChanged(const QModelIndex ¤t, const QModelInd
|
|||||||
emit currentInstanceChanged(inst1, inst2);
|
emit currentInstanceChanged(inst1, inst2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceView::selectNameColumn(const QModelIndex ¤t, const QModelIndex &previous) {
|
void InstanceView::selectNameColumn(const QModelIndex& current, const QModelIndex& previous)
|
||||||
|
{
|
||||||
// Make sure Name column is always selected
|
// Make sure Name column is always selected
|
||||||
m_table->setCurrentIndex(current.siblingAtColumn(InstanceList::Name));
|
m_table->setCurrentIndex(current.siblingAtColumn(InstanceList::Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) {
|
void InstanceView::dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
|
||||||
|
{
|
||||||
// Notify others if data of the current instance changed
|
// Notify others if data of the current instance changed
|
||||||
auto current = m_table->selectionModel()->currentIndex();
|
auto current = m_table->selectionModel()->currentIndex();
|
||||||
|
|
||||||
@@ -138,7 +146,8 @@ void InstanceView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceView::contextMenuRequested(const QPoint pos) {
|
void InstanceView::contextMenuRequested(const QPoint pos)
|
||||||
|
{
|
||||||
QModelIndex index = m_table->indexAt(pos);
|
QModelIndex index = m_table->indexAt(pos);
|
||||||
|
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
@@ -148,6 +157,7 @@ void InstanceView::contextMenuRequested(const QPoint pos) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex InstanceView::mappedIndex(const QModelIndex& index) const {
|
QModelIndex InstanceView::mappedIndex(const QModelIndex& index) const
|
||||||
|
{
|
||||||
return m_proxy->mapToSource(index);
|
return m_proxy->mapToSource(index);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QStackedWidget>
|
|
||||||
#include <QAbstractItemView>
|
#include <QAbstractItemView>
|
||||||
|
#include <QStackedWidget>
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
|
|
||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
@@ -32,9 +32,7 @@ class InstanceView : public QStackedWidget {
|
|||||||
public:
|
public:
|
||||||
explicit InstanceView(QWidget* parent = nullptr, InstanceList* instances = nullptr);
|
explicit InstanceView(QWidget* parent = nullptr, InstanceList* instances = nullptr);
|
||||||
|
|
||||||
QAbstractItemView* currentView() {
|
QAbstractItemView* currentView() { return m_table; }
|
||||||
return m_table;
|
|
||||||
}
|
|
||||||
|
|
||||||
InstancePtr currentInstance();
|
InstancePtr currentInstance();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user