Skip to content

Commit

Permalink
Improve tool tips (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
soininen authored Mar 15, 2024
2 parents f1c61c6 + 4228d6e commit a8baabd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
6 changes: 3 additions & 3 deletions spine_items/exporter/mvcmodels/mapping_editor_table_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
DefaultValueIndexNameMapping,
ParameterDefaultValueTypeMapping,
)
from spinetoolbox.helpers import color_from_index
from spinetoolbox.helpers import color_from_index, plain_to_rich
from ..commands import SetMappingNullable, SetMappingPositions, SetMappingProperty


Expand Down Expand Up @@ -152,9 +152,9 @@ def data(self, index, role=Qt.ItemDataRole.DisplayRole):
return self._mapping_colors.get(m.position, QColor(Qt.GlobalColor.gray).lighter())
elif role == Qt.ItemDataRole.ToolTipRole:
if column == EditorColumn.FILTER:
return "Regular expression to filter database items."
return plain_to_rich("Regular expression to filter database items.")
elif column == EditorColumn.NULLABLE:
return "When checked, ignore this row if it yields nothing to export."
return plain_to_rich("When checked, ignore this row if it yields nothing to export.")
if role == self.MAPPING_ITEM_ROLE:
return self._mappings[index.row()]
return None
Expand Down
12 changes: 5 additions & 7 deletions spine_items/importer/mvcmodels/mappings_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import re
from PySide6.QtCore import QAbstractItemModel, QModelIndex, Qt, Signal
from PySide6.QtGui import QColor, QFont
from spinetoolbox.helpers import unique_name
from spinetoolbox.helpers import plain_to_rich, list_to_rich_text, unique_name
from spinedb_api.parameter_value import join_value_and_type, split_value_and_type
from spinedb_api import from_database, ParameterValueFormatError
from spinedb_api.import_mapping.import_mapping import ScenarioBeforeAlternativeMapping
Expand Down Expand Up @@ -214,9 +214,9 @@ def _table_list_data(self, index, role):
list_item = self._mappings[row]
if not list_item.empty:
if not list_item.in_source:
return "Table isn't in source data."
return plain_to_rich("Table isn't in source data.")
if not list_item.in_specification:
return "Table's mappings haven't been saved with the specification yet."
return plain_to_rich("Table's mappings haven't been saved with the specification yet.")
return None
if role == Qt.ItemDataRole.FontRole:
return self._add_table_row_font if self._mappings[index.row()].empty else None
Expand Down Expand Up @@ -288,11 +288,9 @@ def _mapping_data(flattened_mappings, index, role):
if role == Qt.ItemDataRole.ToolTipRole:
if column == FlattenedColumn.POSITION:
issues = flattened_mappings.display_row_issues(index.row())
if issues:
return issues
return None
return list_to_rich_text(issues) if issues else None
if column == FlattenedColumn.REGEXP:
return "Enter regular expression to filter importer data."
return plain_to_rich("Enter regular expression to filter importer data.")
return None

def headerData(self, section, orientation, role=Qt.ItemDataRole.DisplayRole):
Expand Down
3 changes: 2 additions & 1 deletion tests/importer/mvcmodels/test_mappings_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ def test_turn_empty_row_into_non_real_table(self):
self.assertEqual(index.data(Qt.ItemDataRole.CheckStateRole), Qt.CheckState.Checked)
self.assertIsNone(index.data(Qt.ItemDataRole.FontRole))
self.assertEqual(
index.data(Qt.ItemDataRole.ToolTipRole), "Table's mappings haven't been saved with the specification yet."
index.data(Qt.ItemDataRole.ToolTipRole),
"<qt>Table's mappings haven't been saved with the specification yet.</qt>",
)
flags = self._model.flags(index)
self.assertEqual(
Expand Down

0 comments on commit a8baabd

Please sign in to comment.