Crossfire Server, Trunk
EditMonstersDialog.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2022 the Crossfire Development Team
5  *
6  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7  * welcome to redistribute it under certain conditions. For details, please
8  * see COPYING and LICENSE.
9  *
10  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
11  */
12 
13 #include <QtWidgets>
14 #include <QSortFilterProxyModel>
15 
16 #include "EditMonstersDialog.h"
17 #include "ArchetypesModel.h"
18 #include "ResourcesManager.h"
19 
20 
22  setWindowTitle(tr("Edit monsters"));
23 
24  QGridLayout* layout = new QGridLayout(this);
25 
26  QTableView *view = new QTableView();
27  layout->addWidget(view, 0, 0, 1, 2);
28 
29  QPushButton* save = new QPushButton(tr("Save"), this);
30  connect(save, SIGNAL(clicked()), resources, SLOT(saveArchetypes()));
31  layout->addWidget(save, 1, 0, 1, 1);
32 
33  QPushButton *close = new QPushButton(tr("Close"), this);
34  connect(close, SIGNAL(clicked()), this, SLOT(reject()));
35  layout->addWidget(close, 1, 1, 1, 1);
36 
37  setLayout(layout);
38 
39  auto model = new ArchetypesModel(resources);
40  QSortFilterProxyModel* proxyModel = new QSortFilterProxyModel();
41  proxyModel->setSourceModel(model);
42  view->setModel(proxyModel);
43  view->setEditTriggers(QAbstractItemView::DoubleClicked);
44  view->setSortingEnabled(true);
45  connect(model, SIGNAL(archetypeModified(archetype *)), resources, SLOT(archetypeModified(archetype *)));
46 }
layout
Definition: main.cpp:84
ResourcesManager
Definition: ResourcesManager.h:80
EditMonstersDialog::EditMonstersDialog
EditMonstersDialog(ResourcesManager *resources)
Definition: EditMonstersDialog.cpp:21
ArchetypesModel
Definition: ArchetypesModel.h:25
EditMonstersDialog.h
ArchetypesModel.h
archetype
Definition: object.h:483
ResourcesManager.h
connect
Definition: connect.py:1