mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-10-03 08:41:42 +00:00
NOISSUE First step towards 10000 instances
This commit is contained in:
@@ -17,8 +17,7 @@ QVariant InstanceProxyModel::data(const QModelIndex & index, int role) const
|
||||
return data;
|
||||
}
|
||||
|
||||
bool InstanceProxyModel::subSortLessThan(const QModelIndex &left,
|
||||
const QModelIndex &right) const
|
||||
bool InstanceProxyModel::subSortLessThan(const QModelIndex &left, const QModelIndex &right) const
|
||||
{
|
||||
BaseInstance *pdataLeft = static_cast<BaseInstance *>(left.internalPointer());
|
||||
BaseInstance *pdataRight = static_cast<BaseInstance *>(right.internalPointer());
|
||||
|
@@ -679,6 +679,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow
|
||||
|
||||
proxymodel = new InstanceProxyModel(this);
|
||||
proxymodel->setSourceModel(MMC->instances().get());
|
||||
auto sortMode = MMC->settings()->getSetting("InstSortMode");
|
||||
connect(sortMode.get(), &Setting::SettingChanged, [](const Setting &setting, QVariant value){
|
||||
auto StrValue = value.toString();
|
||||
|
||||
});
|
||||
proxymodel->sort(0);
|
||||
connect(proxymodel, &InstanceProxyModel::dataChanged, this, &MainWindow::instanceDataChanged);
|
||||
|
||||
@@ -1370,15 +1375,17 @@ void MainWindow::finalizeInstance(InstancePtr inst)
|
||||
{
|
||||
view->updateGeometries();
|
||||
setSelectedInstanceById(inst->id());
|
||||
if (MMC->accounts()->anyAccountIsValid())
|
||||
{
|
||||
if (MMC->accounts()->anyAccountIsValid()) {
|
||||
ProgressDialog loadDialog(this);
|
||||
auto update = inst->createUpdateTask(Net::Mode::Online);
|
||||
connect(update.get(), &Task::failed, [this](QString reason)
|
||||
{
|
||||
QString error = QString("Instance load failed: %1").arg(reason);
|
||||
CustomMessageBox::selectable(this, tr("Error"), error, QMessageBox::Warning)->show();
|
||||
});
|
||||
connect(
|
||||
update.get(),
|
||||
&Task::failed,
|
||||
[this](QString reason) {
|
||||
QString error = QString("Instance load failed: %1").arg(reason);
|
||||
CustomMessageBox::selectable(this, tr("Error"), error, QMessageBox::Warning)->show();
|
||||
}
|
||||
);
|
||||
if(update)
|
||||
{
|
||||
loadDialog.setSkipButton(true, tr("Abort"));
|
||||
@@ -1387,10 +1394,12 @@ void MainWindow::finalizeInstance(InstancePtr inst)
|
||||
}
|
||||
else
|
||||
{
|
||||
CustomMessageBox::selectable(this, tr("Error"), tr("MultiMC cannot download Minecraft or update instances unless you have at least "
|
||||
"one account added.\nPlease add your Mojang or Minecraft account."),
|
||||
QMessageBox::Warning)
|
||||
->show();
|
||||
CustomMessageBox::selectable(
|
||||
this,
|
||||
tr("Error"),
|
||||
tr("MultiMC cannot download Minecraft or update instances unless you have at least one account added.\nPlease add your Mojang or Minecraft account."),
|
||||
QMessageBox::Warning
|
||||
)->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -36,6 +36,7 @@ void VisualGroup::update()
|
||||
{
|
||||
auto temp_items = items();
|
||||
auto itemsPerRow = view->itemsPerRow();
|
||||
m_itemLookup.clear();
|
||||
|
||||
int numRows = qMax(1, qCeil((qreal)temp_items.size() / (qreal)itemsPerRow));
|
||||
rows = QVector<VisualRow>(numRows);
|
||||
@@ -61,6 +62,7 @@ void VisualGroup::update()
|
||||
maxRowHeight = itemHeight;
|
||||
}
|
||||
rows[currentRow].items.append(item);
|
||||
m_itemLookup[item] = QPair<int, int>(positionInRow, currentRow);
|
||||
positionInRow++;
|
||||
}
|
||||
rows[currentRow].height = maxRowHeight;
|
||||
@@ -69,20 +71,12 @@ void VisualGroup::update()
|
||||
|
||||
QPair<int, int> VisualGroup::positionOf(const QModelIndex &index) const
|
||||
{
|
||||
int y = 0;
|
||||
for (auto & row: rows)
|
||||
{
|
||||
for(auto x = 0; x < row.items.size(); x++)
|
||||
{
|
||||
if(row.items[x] == index)
|
||||
{
|
||||
return qMakePair(x,y);
|
||||
}
|
||||
}
|
||||
y++;
|
||||
auto iter = m_itemLookup.find(index);
|
||||
if(iter == m_itemLookup.end()) {
|
||||
qWarning() << "Item" << index.row() << index.data(Qt::DisplayRole).toString() << "not found in visual group" << text;
|
||||
return qMakePair(0, 0);
|
||||
}
|
||||
qWarning() << "Item" << index.row() << index.data(Qt::DisplayRole).toString() << "not found in visual group" << text;
|
||||
return qMakePair(0, 0);
|
||||
return *iter;
|
||||
}
|
||||
|
||||
int VisualGroup::rowTopOf(const QModelIndex &index) const
|
||||
|
@@ -50,6 +50,7 @@ struct VisualGroup
|
||||
QString text;
|
||||
bool collapsed = false;
|
||||
QVector<VisualRow> rows;
|
||||
QMap<QModelIndex, QPair<int, int>> m_itemLookup;
|
||||
int firstItemIndex = 0;
|
||||
int m_verticalPosition = 0;
|
||||
|
||||
|
Reference in New Issue
Block a user