MCPcopy Create free account
hub / github.com/MultiMC/Launcher / ProfileSelectDialog

Method ProfileSelectDialog

launcher/ui/dialogs/ProfileSelectDialog.cpp:27–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25#include "ui/dialogs/ProgressDialog.h"
26
27ProfileSelectDialog::ProfileSelectDialog(const QString &message, int flags, QWidget *parent)
28 : QDialog(parent), ui(new Ui::ProfileSelectDialog)
29{
30 ui->setupUi(this);
31
32 m_accounts = APPLICATION->accounts();
33 auto view = ui->listView;
34 //view->setModel(m_accounts.get());
35 //view->hideColumn(AccountList::ActiveColumn);
36 view->setColumnCount(1);
37 view->setRootIsDecorated(false);
38 // FIXME: use a real model, not this
39 if(QTreeWidgetItem* header = view->headerItem())
40 {
41 header->setText(0, tr("Name"));
42 }
43 else
44 {
45 view->setHeaderLabel(tr("Name"));
46 }
47 QList <QTreeWidgetItem *> items;
48 for (int i = 0; i < m_accounts->count(); i++)
49 {
50 MinecraftAccountPtr account = m_accounts->at(i);
51 QString profileLabel;
52 if(account->isInUse()) {
53 profileLabel = tr("%1 (in use)").arg(account->profileName());
54 }
55 else {
56 profileLabel = account->profileName();
57 }
58 auto item = new QTreeWidgetItem(view);
59 item->setText(0, profileLabel);
60 item->setIcon(0, account->getFace());
61 item->setData(0, AccountList::PointerRole, QVariant::fromValue(account));
62 items.append(item);
63 }
64 view->addTopLevelItems(items);
65
66 // Set the message label.
67 ui->msgLabel->setVisible(!message.isEmpty());
68 ui->msgLabel->setText(message);
69
70 // Flags...
71 ui->globalDefaultCheck->setVisible(flags & GlobalDefaultCheckbox);
72 ui->instDefaultCheck->setVisible(flags & InstanceDefaultCheckbox);
73 qDebug() << flags;
74
75 // Select the first entry in the list.
76 ui->listView->setCurrentIndex(ui->listView->model()->index(0, 0));
77
78 connect(ui->listView, SIGNAL(doubleClicked(QModelIndex)), SLOT(on_buttonBox_accepted()));
79}
80
81ProfileSelectDialog::~ProfileSelectDialog()
82{

Callers

nothing calls this directly

Calls 15

accountsMethod · 0.80
isInUseMethod · 0.80
getFaceMethod · 0.80
appendMethod · 0.80
setVisibleMethod · 0.80
isEmptyMethod · 0.80
modelMethod · 0.80
setupUiMethod · 0.45
setTextMethod · 0.45
countMethod · 0.45
atMethod · 0.45
profileNameMethod · 0.45

Tested by

no test coverage detected