cleanup: resolve map list scrolling

This commit is contained in:
garak 2024-04-18 13:25:06 -04:00
parent 89fb4019a5
commit 5bb0983c33
2 changed files with 6 additions and 15 deletions

View file

@ -379,7 +379,6 @@ private:
bool loadDataStructures(); bool loadDataStructures();
bool loadProjectCombos(); bool loadProjectCombos();
bool populateMapList(); bool populateMapList();
void sortMapList();
void openSubWindow(QWidget * window); void openSubWindow(QWidget * window);
void scrollTreeView(QString itemName); void scrollTreeView(QString itemName);
QString getExistingDirectory(QString); QString getExistingDirectory(QString);

View file

@ -250,7 +250,6 @@ void MainWindow::initCustomUI() {
} }
void MainWindow::initExtraSignals() { void MainWindow::initExtraSignals() {
/// !TODO
// Right-clicking on items in the map list tree view brings up a context menu. // Right-clicking on items in the map list tree view brings up a context menu.
ui->mapList->setContextMenuPolicy(Qt::CustomContextMenu); ui->mapList->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->mapList, &QTreeView::customContextMenuRequested, connect(ui->mapList, &QTreeView::customContextMenuRequested,
@ -402,17 +401,12 @@ void MainWindow::initMiscHeapObjects() {
ui->tabWidget_EventType->clear(); ui->tabWidget_EventType->clear();
} }
// !TODO: scroll view on first showing
void MainWindow::initMapSortOrder() { void MainWindow::initMapSortOrder() {
mapSortOrder = porymapConfig.getMapSortOrder(); mapSortOrder = porymapConfig.getMapSortOrder();
// if (mapSortOrder == MapSortOrder::SortByLayout)
// mapSortOrder = MapSortOrder::SortByGroup;
this->ui->mapListContainer->setCurrentIndex(static_cast<int>(this->mapSortOrder)); this->ui->mapListContainer->setCurrentIndex(static_cast<int>(this->mapSortOrder));
} }
void MainWindow::showWindowTitle() { void MainWindow::showWindowTitle() {
// !TODO, check editor editmode
if (editor->map) { if (editor->map) {
setWindowTitle(QString("%1%2 - %3") setWindowTitle(QString("%1%2 - %3")
.arg(editor->map->hasUnsavedChanges() ? "* " : "") .arg(editor->map->hasUnsavedChanges() ? "* " : "")
@ -490,18 +484,22 @@ void MainWindow::on_lineEdit_filterBox_Layouts_textChanged(const QString &text)
void MainWindow::applyMapListFilter(QString filterText) { void MainWindow::applyMapListFilter(QString filterText) {
FilterChildrenProxyModel *proxy; FilterChildrenProxyModel *proxy;
QTreeView *list; QTreeView *list;
QModelIndex sourceIndex;
switch (this->mapSortOrder) { switch (this->mapSortOrder) {
case MapSortOrder::SortByGroup: case MapSortOrder::SortByGroup:
proxy = this->groupListProxyModel; proxy = this->groupListProxyModel;
list = this->ui->mapList; list = this->ui->mapList;
sourceIndex = mapGroupModel->indexOfMap(editor->map->name);
break; break;
case MapSortOrder::SortByArea: case MapSortOrder::SortByArea:
proxy = this->areaListProxyModel; proxy = this->areaListProxyModel;
list = this->ui->areaList; list = this->ui->areaList;
sourceIndex = mapAreaModel->indexOfMap(editor->map->name);
break; break;
case MapSortOrder::SortByLayout: case MapSortOrder::SortByLayout:
proxy = this->layoutListProxyModel; proxy = this->layoutListProxyModel;
list = this->ui->layoutList; list = this->ui->layoutList;
sourceIndex = layoutTreeModel->indexOfLayout(editor->layout->id);
break; break;
} }
@ -512,10 +510,8 @@ void MainWindow::applyMapListFilter(QString filterText) {
list->expandToDepth(0); list->expandToDepth(0);
} }
/// !TODO list->setExpanded(proxy->mapFromSource(sourceIndex), true);
// ui->mapList->setExpanded(groupListProxyModel->mapFromSource(mapGroupModel->indexOfMap(map_name)), false); list->scrollTo(proxy->mapFromSource(sourceIndex), QAbstractItemView::PositionAtCenter);
// ui->mapList->setExpanded(mapListProxyModel->mapFromSource(mapListIndexes.value(editor->map->name)), true);
// ui->mapList->scrollTo(mapListProxyModel->mapFromSource(mapListIndexes.value(editor->map->name)), QAbstractItemView::PositionAtCenter);
} }
void MainWindow::loadUserSettings() { void MainWindow::loadUserSettings() {
@ -1285,10 +1281,6 @@ void MainWindow::scrollTreeView(QString itemName) {
} }
} }
// !TODO: remove this?
void MainWindow::sortMapList() {
}
void MainWindow::onOpenMapListContextMenu(const QPoint &point) { void MainWindow::onOpenMapListContextMenu(const QPoint &point) {
QStandardItemModel *model; QStandardItemModel *model;
int dataRole; int dataRole;