Option for searching through the map list
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
#include <QtWidgets/QVBoxLayout>
|
#include <QtWidgets/QVBoxLayout>
|
||||||
#include <QtWidgets/QWidget>
|
#include <QtWidgets/QWidget>
|
||||||
#include <QtWidgets/QStackedWidget>
|
#include <QtWidgets/QStackedWidget>
|
||||||
|
#include <QtWidgets/QComboBox>
|
||||||
#include <noggit/ui/windows/noggitWindow/widgets/MapListItem.hpp>
|
#include <noggit/ui/windows/noggitWindow/widgets/MapListItem.hpp>
|
||||||
#include <noggit/ui/windows/noggitWindow/widgets/MapBookmarkListItem.hpp>
|
#include <noggit/ui/windows/noggitWindow/widgets/MapBookmarkListItem.hpp>
|
||||||
#include <QtNetwork/QTcpSocket>
|
#include <QtNetwork/QTcpSocket>
|
||||||
@@ -179,6 +180,37 @@ namespace Noggit::Ui::Windows
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NoggitWindow::applyFilterSearch(const QString &name, int type, int expansion)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _continents_table->count(); ++i)
|
||||||
|
{
|
||||||
|
auto item_widget = _continents_table->item(i);
|
||||||
|
auto widget = qobject_cast<Noggit::Ui::Widget::MapListItem*>(_continents_table->itemWidget(item_widget));
|
||||||
|
|
||||||
|
if (!widget)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
item_widget->setHidden(false);
|
||||||
|
|
||||||
|
if (!widget->name().contains(name, Qt::CaseInsensitive))
|
||||||
|
{
|
||||||
|
item_widget->setHidden(true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(widget->type() == (type - 2)) && type != 0)
|
||||||
|
{
|
||||||
|
item_widget->setHidden(true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(widget->expansion() == (expansion - 1)) && expansion != 0)
|
||||||
|
{
|
||||||
|
item_widget->setHidden(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NoggitWindow::loadMap(int map_id)
|
void NoggitWindow::loadMap(int map_id)
|
||||||
{
|
{
|
||||||
_minimap->world(nullptr);
|
_minimap->world(nullptr);
|
||||||
@@ -219,9 +251,73 @@ namespace Noggit::Ui::Windows
|
|||||||
|
|
||||||
|
|
||||||
QTabWidget* entry_points_tabs(new QTabWidget(widget));
|
QTabWidget* entry_points_tabs(new QTabWidget(widget));
|
||||||
entry_points_tabs->addTab(_continents_table, "Maps");
|
//entry_points_tabs->addTab(_continents_table, "Maps");
|
||||||
|
|
||||||
|
/* set-up widget for seaching etc... through _continents_table */
|
||||||
|
{
|
||||||
|
QWidget* _first_tab = new QWidget(this);
|
||||||
|
QVBoxLayout* _first_tab_layout = new QVBoxLayout();
|
||||||
|
_first_tab->setLayout(_first_tab_layout);
|
||||||
|
|
||||||
|
QGroupBox* _group_search = new QGroupBox(tr("Search"), this);
|
||||||
|
|
||||||
|
QLineEdit* _line_edit_search = new QLineEdit(this);
|
||||||
|
QComboBox* _combo_search = new QComboBox(this);
|
||||||
|
_combo_search->addItems(QStringList() <<
|
||||||
|
tr("All") <<
|
||||||
|
tr("Unknown") <<
|
||||||
|
tr("Continent") <<
|
||||||
|
tr("Dungeon") <<
|
||||||
|
tr("Raid") <<
|
||||||
|
tr("Battleground") <<
|
||||||
|
tr("Arena") <<
|
||||||
|
tr("Scenario"));
|
||||||
|
_combo_search->setCurrentIndex(0);
|
||||||
|
|
||||||
|
QComboBox* _combo_exp_search = new QComboBox(this);
|
||||||
|
_combo_exp_search->addItem(tr("All"));
|
||||||
|
_combo_exp_search->addItem(QIcon(":/icon-classic"), tr("Classic"));
|
||||||
|
_combo_exp_search->addItem(QIcon(":/icon-burning"), tr("Burning Cursade"));
|
||||||
|
_combo_exp_search->addItem(QIcon(":/icon-wrath"), tr("Wrath of the Lich King"));
|
||||||
|
_combo_exp_search->addItem(QIcon(":/icon-cata"), tr("Cataclism"));
|
||||||
|
_combo_exp_search->addItem(QIcon(":/icon-panda"), tr("Mist of Pandaria"));
|
||||||
|
_combo_exp_search->addItem(QIcon(":/icon-warlords"), tr("Warlords of Draenor"));
|
||||||
|
_combo_exp_search->addItem(QIcon(":/icon-legion"), tr("Legion"));
|
||||||
|
_combo_exp_search->addItem(QIcon(":/icon-battle"), tr("Battle for Azeroth"));
|
||||||
|
_combo_exp_search->addItem(QIcon(":/icon-shadow"), tr("Shadowlands"));
|
||||||
|
_combo_exp_search->setCurrentIndex(0);
|
||||||
|
|
||||||
|
QObject::connect(_line_edit_search, QOverload<const QString&>::of(&QLineEdit::textChanged), [this, _combo_search, _combo_exp_search](const QString &name)
|
||||||
|
{
|
||||||
|
applyFilterSearch(name, _combo_search->currentIndex(), _combo_exp_search->currentIndex());
|
||||||
|
});
|
||||||
|
|
||||||
|
QObject::connect(_combo_search, QOverload<int>::of(&QComboBox::currentIndexChanged), [this, _line_edit_search, _combo_exp_search](int index)
|
||||||
|
{
|
||||||
|
applyFilterSearch(_line_edit_search->text(), index, _combo_exp_search->currentIndex());
|
||||||
|
});
|
||||||
|
|
||||||
|
QObject::connect(_combo_exp_search, QOverload<int>::of(&QComboBox::currentIndexChanged), [this, _line_edit_search, _combo_search](int index)
|
||||||
|
{
|
||||||
|
applyFilterSearch(_line_edit_search->text(), _combo_search->currentIndex(), index);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
QFormLayout* _group_layout = new QFormLayout();
|
||||||
|
_group_layout->addRow(tr("Name : "), _line_edit_search);
|
||||||
|
_group_layout->addRow(tr("Type : "), _combo_search);
|
||||||
|
_group_layout->addRow(tr("Expansion : "), _combo_exp_search);
|
||||||
|
_group_search->setLayout(_group_layout);
|
||||||
|
|
||||||
|
_first_tab_layout->addWidget(_group_search);
|
||||||
|
_first_tab_layout->addSpacing(12);
|
||||||
|
_first_tab_layout->addWidget(_continents_table);
|
||||||
|
|
||||||
|
entry_points_tabs->addTab(_first_tab, tr("Maps"));
|
||||||
|
}
|
||||||
|
|
||||||
entry_points_tabs->addTab(bookmarks_table, "Bookmarks");
|
entry_points_tabs->addTab(bookmarks_table, "Bookmarks");
|
||||||
entry_points_tabs->setFixedWidth(300);
|
entry_points_tabs->setFixedWidth(310);
|
||||||
layout->addWidget(entry_points_tabs);
|
layout->addWidget(entry_points_tabs);
|
||||||
|
|
||||||
_buildMapListComponent->buildMapList(this);
|
_buildMapListComponent->buildMapList(this);
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ namespace Noggit::Ui::Windows
|
|||||||
class NoggitWindow : public QMainWindow
|
class NoggitWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
friend class Noggit::Ui::Component::BuildMapListComponent;
|
|
||||||
|
friend class Noggit::Ui::Component::BuildMapListComponent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NoggitWindow(std::shared_ptr<Noggit::Application::NoggitApplicationConfiguration> application,
|
NoggitWindow(std::shared_ptr<Noggit::Application::NoggitApplicationConfiguration> application,
|
||||||
@@ -84,6 +85,9 @@ namespace Noggit::Ui::Windows
|
|||||||
QMetaObject::Connection _map_wizard_connection;
|
QMetaObject::Connection _map_wizard_connection;
|
||||||
|
|
||||||
QListWidget* _continents_table;
|
QListWidget* _continents_table;
|
||||||
|
QString _filter_name;
|
||||||
|
|
||||||
|
void applyFilterSearch(const QString& name, int type, int expansion);
|
||||||
|
|
||||||
std::unique_ptr<World> _world;
|
std::unique_ptr<World> _world;
|
||||||
|
|
||||||
@@ -92,4 +96,4 @@ namespace Noggit::Ui::Windows
|
|||||||
virtual void closeEvent (QCloseEvent*) override;
|
virtual void closeEvent (QCloseEvent*) override;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // NOGGIT_WINDOW_NOGGIT_HPP
|
#endif // NOGGIT_WINDOW_NOGGIT_HPP
|
||||||
|
|||||||
@@ -4,28 +4,30 @@
|
|||||||
|
|
||||||
namespace Noggit::Ui::Widget
|
namespace Noggit::Ui::Widget
|
||||||
{
|
{
|
||||||
MapListItem::MapListItem(const MapListData& data, QWidget* parent = nullptr) : QWidget(parent)
|
MapListItem::MapListItem(const MapListData& data, QWidget* parent = nullptr)
|
||||||
|
: QWidget(parent)
|
||||||
|
, _map_data(data)
|
||||||
{
|
{
|
||||||
auto layout = QGridLayout();
|
auto layout = QGridLayout();
|
||||||
|
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
if (data.expansion_id == 0)
|
if (_map_data.expansion_id == 0)
|
||||||
icon = QIcon(":/icon-classic");
|
icon = QIcon(":/icon-classic");
|
||||||
if (data.expansion_id == 1)
|
if (_map_data.expansion_id == 1)
|
||||||
icon = QIcon(":/icon-burning");
|
icon = QIcon(":/icon-burning");
|
||||||
if (data.expansion_id == 2)
|
if (_map_data.expansion_id == 2)
|
||||||
icon = QIcon(":/icon-wrath");
|
icon = QIcon(":/icon-wrath");
|
||||||
if (data.expansion_id == 3)
|
if (_map_data.expansion_id == 3)
|
||||||
icon = QIcon(":/icon-cata");
|
icon = QIcon(":/icon-cata");
|
||||||
if (data.expansion_id == 4)
|
if (_map_data.expansion_id == 4)
|
||||||
icon = QIcon(":/icon-panda");
|
icon = QIcon(":/icon-panda");
|
||||||
if (data.expansion_id == 5)
|
if (_map_data.expansion_id == 5)
|
||||||
icon = QIcon(":/icon-warlords");
|
icon = QIcon(":/icon-warlords");
|
||||||
if (data.expansion_id == 6)
|
if (_map_data.expansion_id == 6)
|
||||||
icon = QIcon(":/icon-legion");
|
icon = QIcon(":/icon-legion");
|
||||||
if (data.expansion_id == 7)
|
if (_map_data.expansion_id == 7)
|
||||||
icon = QIcon(":/icon-battle");
|
icon = QIcon(":/icon-battle");
|
||||||
if (data.expansion_id == 8)
|
if (_map_data.expansion_id == 8)
|
||||||
icon = QIcon(":/icon-shadow");
|
icon = QIcon(":/icon-shadow");
|
||||||
|
|
||||||
_map_icon = new QLabel("", parent);
|
_map_icon = new QLabel("", parent);
|
||||||
@@ -34,13 +36,13 @@ namespace Noggit::Ui::Widget
|
|||||||
_map_icon->setObjectName("project-icon-label");
|
_map_icon->setObjectName("project-icon-label");
|
||||||
_map_icon->setStyleSheet("QLabel#project-icon-label { font-size: 12px; padding: 0px;}");
|
_map_icon->setStyleSheet("QLabel#project-icon-label { font-size: 12px; padding: 0px;}");
|
||||||
|
|
||||||
auto project_name = toCamelCase(QString(data.map_name));
|
auto project_name = toCamelCase(QString(_map_data.map_name));
|
||||||
_map_name = new QLabel(project_name, parent);
|
_map_name = new QLabel(project_name, parent);
|
||||||
_map_name->setGeometry(32, 0, 300, 20);
|
_map_name->setGeometry(32, 0, 300, 20);
|
||||||
_map_name->setObjectName("project-title-label");
|
_map_name->setObjectName("project-title-label");
|
||||||
_map_name->setStyleSheet("QLabel#project-title-label { font-size: 12px; }");
|
_map_name->setStyleSheet("QLabel#project-title-label { font-size: 12px; }");
|
||||||
|
|
||||||
_map_id = new QLabel(QString::number(data.map_id), parent);
|
_map_id = new QLabel(QString::number(_map_data.map_id), parent);
|
||||||
_map_id->setGeometry(32, 15, 300, 20);
|
_map_id->setGeometry(32, 15, 300, 20);
|
||||||
_map_id->setObjectName("project-information");
|
_map_id->setObjectName("project-information");
|
||||||
_map_id->setStyleSheet("QLabel#project-information { font-size: 10px; }");
|
_map_id->setStyleSheet("QLabel#project-information { font-size: 10px; }");
|
||||||
@@ -52,17 +54,17 @@ namespace Noggit::Ui::Widget
|
|||||||
_map_id->setAutoFillBackground(true);
|
_map_id->setAutoFillBackground(true);
|
||||||
|
|
||||||
auto instance_type = QString("Unknown");
|
auto instance_type = QString("Unknown");
|
||||||
if (data.map_type_id == 0)
|
if (_map_data.map_type_id == 0)
|
||||||
instance_type = QString("Continent");
|
instance_type = QString("Continent");
|
||||||
if (data.map_type_id == 1)
|
if (_map_data.map_type_id == 1)
|
||||||
instance_type = QString("Dungeon");
|
instance_type = QString("Dungeon");
|
||||||
if (data.map_type_id == 2)
|
if (_map_data.map_type_id == 2)
|
||||||
instance_type = QString("Raid");
|
instance_type = QString("Raid");
|
||||||
if (data.map_type_id == 3)
|
if (_map_data.map_type_id == 3)
|
||||||
instance_type = QString("Battleground");
|
instance_type = QString("Battleground");
|
||||||
if (data.map_type_id == 4)
|
if (_map_data.map_type_id == 4)
|
||||||
instance_type = QString("Arena");
|
instance_type = QString("Arena");
|
||||||
if (data.map_type_id == 5)
|
if (_map_data.map_type_id == 5)
|
||||||
instance_type = QString("Scenario");
|
instance_type = QString("Scenario");
|
||||||
|
|
||||||
_map_instance_type = new QLabel(instance_type, this);
|
_map_instance_type = new QLabel(instance_type, this);
|
||||||
@@ -77,7 +79,7 @@ namespace Noggit::Ui::Widget
|
|||||||
_map_instance_type->setGraphicsEffect(last_edited_effect);
|
_map_instance_type->setGraphicsEffect(last_edited_effect);
|
||||||
_map_instance_type->setAutoFillBackground(true);
|
_map_instance_type->setAutoFillBackground(true);
|
||||||
|
|
||||||
if (data.pinned)
|
if (_map_data.pinned)
|
||||||
{
|
{
|
||||||
_map_pinned_label = new QLabel("", this);
|
_map_pinned_label = new QLabel("", this);
|
||||||
_map_pinned_label->setPixmap(FontAwesomeIcon(FontAwesome::star).pixmap(QSize(16, 16)));
|
_map_pinned_label->setPixmap(FontAwesomeIcon(FontAwesome::star).pixmap(QSize(16, 16)));
|
||||||
|
|||||||
@@ -30,12 +30,20 @@ namespace Noggit::Ui::Widget
|
|||||||
QLabel* _map_instance_type;
|
QLabel* _map_instance_type;
|
||||||
QLabel* _map_pinned_label;
|
QLabel* _map_pinned_label;
|
||||||
int _max_width;
|
int _max_width;
|
||||||
|
MapListData _map_data;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MapListItem(const MapListData& data, QWidget* parent);
|
MapListItem(const MapListData& data, QWidget* parent);
|
||||||
QSize minimumSizeHint() const override;
|
QSize minimumSizeHint() const override;
|
||||||
|
|
||||||
|
const QString name() { return _map_data.map_name; };
|
||||||
|
int id() { return _map_data.map_id; };
|
||||||
|
int type() { return _map_data.map_type_id; };
|
||||||
|
int expansion() { return _map_data.expansion_id; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString toCamelCase(const QString& s);
|
QString toCamelCase(const QString& s);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //NOGGIT_WIGDET_MAP_LIST_ITEM_HPP
|
#endif //NOGGIT_WIGDET_MAP_LIST_ITEM_HPP
|
||||||
|
|||||||
Reference in New Issue
Block a user