fix build on Linux

This commit is contained in:
Skarn
2021-12-28 12:20:54 +03:00
parent cdf814e87d
commit 882483c816
3 changed files with 49 additions and 38 deletions

View File

@@ -7,6 +7,7 @@
#include <noggit/ui/uid_fix_window.hpp>
#include <noggit/ui/tools/MapCreationWizard/Ui/MapCreationWizard.hpp>
#include <noggit/application/Configuration/NoggitApplicationConfiguration.hpp>
#include <noggit/ui/windows/noggitWindow/components/BuildMapListComponent.hpp>
#include <noggit/project/ApplicationProject.h>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QStackedWidget>
@@ -17,11 +18,6 @@
class StackedWidget;
namespace Noggit::Ui::Component
{
class BuildMapListComponent;
}
namespace Noggit::Ui
{
class minimap_widget;
@@ -34,9 +30,9 @@ namespace Noggit::Ui::Windows
{
class NoggitWindow : public QMainWindow
{
Q_OBJECT
Q_OBJECT
friend class Noggit::Ui::Component::BuildMapListComponent;
friend Component::BuildMapListComponent;
public:
NoggitWindow(std::shared_ptr<Noggit::Application::NoggitApplicationConfiguration> application,
std::shared_ptr<Noggit::Project::NoggitProject> project);

View File

@@ -0,0 +1,38 @@
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
#include <noggit/ui/windows/noggitWindow/components/BuildMapListComponent.hpp>
#include <noggit/ui/windows/noggitWindow/widgets/MapListItem.hpp>
#include <noggit/ui/windows/noggitWindow/NoggitWindow.hpp>
using namespace Noggit::Ui::Component;
void BuildMapListComponent::BuildMapList(Noggit::Ui::Windows::NoggitWindow* parent)
{
parent->_continents_table->clear();
const auto& table = std::string("Map");
auto mapTable = parent->_project->ClientDatabase->LoadTable(table);
auto iterator = mapTable.Records();
while (iterator.HasRecords())
{
auto record = iterator.Next();
auto mapListData = Widget::MapListData();
mapListData.MapName = QString::fromUtf8(record.Columns["MapName_lang"].Value.c_str());
mapListData.MapId = record.RecordId;
mapListData.MapTypeId = std::stoi(record.Columns["InstanceType"].Value);
mapListData.ExpansionId = std::stoi(record.Columns["ExpansionID"].Value);
if (mapListData.MapTypeId < 0 || mapListData.MapTypeId > 5 || !World::IsEditableWorld(record))
continue;
auto mapListItem = new Widget::MapListItem(mapListData, parent->_continents_table);
auto item = new QListWidgetItem(parent->_continents_table);
item->setSizeHint(mapListItem->minimumSizeHint());
item->setData(Qt::UserRole, QVariant(mapListData.MapId));
parent->_continents_table->setItemWidget(item, mapListItem);
}
parent->_project->ClientDatabase->UnloadTable(table);
}

View File

@@ -1,44 +1,21 @@
#ifndef NOGGIT_COMPONENT_BUILD_MAP_LIST_HPP
#define NOGGIT_COMPONENT_BUILD_MAP_LIST_HPP
#include <noggit/ui/windows/noggitWindow/NoggitWindow.hpp>
namespace Noggit::Ui::Windows
{
class NoggitWindow;
}
namespace Noggit::Ui::Component
{
class BuildMapListComponent
{
friend Noggit::Ui::Windows::NoggitWindow;
friend class Noggit::Ui::Windows::NoggitWindow;
public:
void BuildMapList(Noggit::Ui::Windows::NoggitWindow* parent)
{
parent->_continents_table->clear();
const auto& table = std::string("Map");
auto mapTable = parent->_project->ClientDatabase->LoadTable(table);
auto iterator = mapTable.Records();
while (iterator.HasRecords())
{
auto record = iterator.Next();
auto mapListData = Widget::MapListData();
mapListData.MapName = QString::fromUtf8(record.Columns["MapName_lang"].Value.c_str());
mapListData.MapId = record.RecordId;
mapListData.MapTypeId = std::stoi(record.Columns["InstanceType"].Value);
mapListData.ExpansionId = std::stoi(record.Columns["ExpansionID"].Value);
if (mapListData.MapTypeId < 0 || mapListData.MapTypeId > 5 || !World::IsEditableWorld(record))
continue;
auto mapListItem = new Widget::MapListItem(mapListData, parent->_continents_table);
auto item = new QListWidgetItem(parent->_continents_table);
item->setSizeHint(mapListItem->minimumSizeHint());
item->setData(Qt::UserRole, QVariant(mapListData.MapId));
parent->_continents_table->setItemWidget(item, mapListItem);
}
parent->_project->ClientDatabase->UnloadTable(table);
}
void BuildMapList(Noggit::Ui::Windows::NoggitWindow* parent);
};
}
#endif //NOGGIT_COMPONENT_BUILD_MAP_LIST_HPP