Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lisää templaattien hakutoiminnalisuus #20

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions arho_feature_template/core/feature_template_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,26 @@ def __init__(self) -> None:
self.template_dock.library_selection.currentIndexChanged.connect(
lambda: self.set_active_library(self.template_dock.library_selection.currentText())
)
# Update template list when search text changes
self.template_dock.search_box.valueChanged.connect(self.on_template_search_text_changed)

# Activate map tool when template selection changes
self.template_model.itemChanged.connect(self.on_item_changed)

self.digitize_map_tool = TemplateGeometryDigitizeMapTool(iface.mapCanvas(), iface.cadDockWidget())
self.digitize_map_tool.digitizingCompleted.connect(self.ask_for_feature_attributes)

def on_template_search_text_changed(self, search_text: str):
for row in range(self.template_model.rowCount()):
item = self.template_model.item(row)

# If the search text is in the item's text, show the row
if search_text in item.text().lower():
self.template_dock.template_list.setRowHidden(row, False)
else:
# Otherwise, hide the row
self.template_dock.template_list.setRowHidden(row, True)

def on_item_changed(self, item: TemplateItem) -> None:
if item.checkState() == Qt.Checked:
self._uncheck_others(item)
Expand Down
Loading