add toggleable button to hide empty map folders
This commit is contained in:
parent
c0f32c6a17
commit
cd5b1f98d2
8 changed files with 113 additions and 1 deletions
|
@ -79,6 +79,31 @@
|
|||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_HideShow_Groups">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Toggle hide all empty map folders</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources/images.qrc">
|
||||
<normaloff>:/icons/folder_eye_closed.ico</normaloff>
|
||||
<normalon>:/icons/folder_eye_open.ico</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::InstantPopup</enum>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_ExpandAll_Groups">
|
||||
<property name="toolTip">
|
||||
|
@ -214,6 +239,31 @@
|
|||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_HideShow_Areas">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Toggle hide all empty mapsection folders</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources/images.qrc">
|
||||
<normaloff>:/icons/folder_eye_closed.ico</normaloff>
|
||||
<normalon>:/icons/folder_eye_open.ico</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::InstantPopup</enum>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_ExpandAll_Areas">
|
||||
<property name="toolTip">
|
||||
|
@ -349,6 +399,31 @@
|
|||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_HideShow_Layouts">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Toggle hide all unused layouts</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources/images.qrc">
|
||||
<normaloff>:/icons/folder_eye_closed.ico</normaloff>
|
||||
<normalon>:/icons/folder_eye_open.ico</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::InstantPopup</enum>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_ExpandAll_Layouts">
|
||||
<property name="toolTip">
|
||||
|
|
|
@ -279,10 +279,13 @@ private slots:
|
|||
|
||||
void on_horizontalSlider_CollisionTransparency_valueChanged(int value);
|
||||
|
||||
void on_toolButton_HideShow_Groups_clicked();
|
||||
void on_toolButton_ExpandAll_Groups_clicked();
|
||||
void on_toolButton_CollapseAll_Groups_clicked();
|
||||
void on_toolButton_HideShow_Areas_clicked();
|
||||
void on_toolButton_ExpandAll_Areas_clicked();
|
||||
void on_toolButton_CollapseAll_Areas_clicked();
|
||||
void on_toolButton_HideShow_Layouts_clicked();
|
||||
void on_toolButton_ExpandAll_Layouts_clicked();
|
||||
void on_toolButton_CollapseAll_Layouts_clicked();
|
||||
|
||||
|
|
|
@ -9,9 +9,11 @@ class FilterChildrenProxyModel : public QSortFilterProxyModel
|
|||
|
||||
public:
|
||||
explicit FilterChildrenProxyModel(QObject *parent = nullptr);
|
||||
void toggleHideEmpty() { this->hideEmpty = !this->hideEmpty; }
|
||||
protected:
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const;
|
||||
|
||||
private:
|
||||
bool hideEmpty = false;
|
||||
};
|
||||
|
||||
#endif // FILTERCHILDRENPROXYMODEL_H
|
||||
|
|
BIN
resources/icons/folder_eye_closed.ico
Normal file
BIN
resources/icons/folder_eye_closed.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
BIN
resources/icons/folder_eye_open.ico
Normal file
BIN
resources/icons/folder_eye_open.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
|
@ -12,6 +12,8 @@
|
|||
<file>icons/fill_color.ico</file>
|
||||
<file>icons/folder_closed_map.ico</file>
|
||||
<file>icons/folder_closed.ico</file>
|
||||
<file>icons/folder_eye_closed.ico</file>
|
||||
<file>icons/folder_eye_open.ico</file>
|
||||
<file>icons/folder_map_edited.ico</file>
|
||||
<file>icons/folder_map_opened.ico</file>
|
||||
<file>icons/folder_map.ico</file>
|
||||
|
|
|
@ -2821,6 +2821,13 @@ void MainWindow::initTilesetEditor() {
|
|||
connect(this->tilesetEditor, &TilesetEditor::tilesetsSaved, this, &MainWindow::onTilesetsSaved);
|
||||
}
|
||||
|
||||
void MainWindow::on_toolButton_HideShow_Groups_clicked() {
|
||||
if (ui->mapList) {
|
||||
this->groupListProxyModel->toggleHideEmpty();
|
||||
this->groupListProxyModel->setFilterRegularExpression(this->ui->lineEdit_filterBox->text());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_toolButton_ExpandAll_Groups_clicked() {
|
||||
if (ui->mapList) {
|
||||
ui->mapList->expandToDepth(0);
|
||||
|
@ -2833,6 +2840,13 @@ void MainWindow::on_toolButton_CollapseAll_Groups_clicked() {
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_toolButton_HideShow_Areas_clicked() {
|
||||
if (ui->areaList) {
|
||||
this->areaListProxyModel->toggleHideEmpty();
|
||||
this->areaListProxyModel->setFilterRegularExpression(this->ui->lineEdit_filterBox->text());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_toolButton_ExpandAll_Areas_clicked() {
|
||||
if (ui->areaList) {
|
||||
ui->areaList->expandToDepth(0);
|
||||
|
@ -2845,6 +2859,13 @@ void MainWindow::on_toolButton_CollapseAll_Areas_clicked() {
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_toolButton_HideShow_Layouts_clicked() {
|
||||
if (ui->layoutList) {
|
||||
this->layoutListProxyModel->toggleHideEmpty();
|
||||
this->layoutListProxyModel->setFilterRegularExpression(this->ui->lineEdit_filterBox->text());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_toolButton_ExpandAll_Layouts_clicked() {
|
||||
if (ui->layoutList) {
|
||||
ui->layoutList->expandToDepth(0);
|
||||
|
|
|
@ -8,6 +8,15 @@ FilterChildrenProxyModel::FilterChildrenProxyModel(QObject *parent) :
|
|||
|
||||
bool FilterChildrenProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||
{
|
||||
if (this->hideEmpty && source_parent.row() < 0) // want to hide children
|
||||
{
|
||||
QModelIndex source_index = sourceModel()->index(source_row, this->filterKeyColumn(), source_parent) ;
|
||||
if(source_index.isValid())
|
||||
{
|
||||
if (!sourceModel()->hasChildren(source_index))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// custom behaviour :
|
||||
if(filterRegularExpression().pattern().isEmpty() == false)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue