WIP: more on properties dialog

This commit is contained in:
Matthias Koefferlein 2022-10-08 18:53:27 +02:00
parent 83d37d4187
commit 1006bf6d57
5 changed files with 47 additions and 3 deletions

View File

@ -382,7 +382,35 @@ PropertiesPage::select_entries (const std::vector<size_t> &entries)
std::string
PropertiesPage::description (size_t entry) const
{
return "Ruler"; // @@@
const ant::Object *obj = dynamic_cast <const ant::Object *> (m_selection [entry]->ptr ());
if (! obj) {
return std::string ("nil");
}
std::string d = tl::to_string (tr ("Ruler"));
if (! obj->category ().empty ()) {
std::string cat = obj->category ();
// category is "_ruler" for example. Turn in into "Ruler".
if (cat.size () >= 2 && cat [0] == '_') {
cat = tl::to_upper_case (std::string (cat.begin () + 1, cat.begin () + 2)) + std::string (cat.begin () + 2, cat.end ());
}
d += "[" + cat + "]";
}
if (obj->points ().size () > 3) {
d += tl::sprintf (tl::to_string (tr ("(%d points)")), obj->points ().size ());
} else {
d += "(";
for (auto p = obj->points ().begin (); p != obj->points ().end (); ++p) {
if (p != obj->points ().begin ()) {
d += ";";
}
d += p->to_string ();
}
d += ")";
}
return d;
}
std::string

View File

@ -171,7 +171,17 @@ PropertiesPage::select_entries (const std::vector<size_t> &entries)
std::string
PropertiesPage::description (size_t entry) const
{
return "image"; // @@@
const img::Object *obj = dynamic_cast <const img::Object *> (m_selection [entry]->ptr ());
if (! obj) {
return std::string ("nil");
}
std::string d = tl::to_string (tr ("Image"));
if (! obj->filename ().empty ()) {
d += "[" + tl::filename (obj->filename ()) + "]";
}
d += tl::sprintf ("(%dx%d)", obj->width (), obj->height ());
return d;
}
std::string

View File

@ -322,6 +322,9 @@ MacroEditorDialog::MacroEditorDialog (lay::Dispatcher *pr, lym::MacroCollection
macro_tree->addAction (actionSaveAs);
macro_tree->header ()->hide ();
// TODO: that is supposed to enable the horizontal scroll bar, but it doesn't:
macro_tree->header ()->setStretchLastSection (false);
macro_tree->header ()->setSectionResizeMode (QHeaderView::ResizeToContents);
macro_tree->setItemDelegate (new EditRoleDelegate (macro_tree));

View File

@ -38,6 +38,9 @@
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<attribute name="headerStretchLastSection">
<bool>false</bool>
</attribute>
</widget>
<widget class="QFrame" name="content_frame">
<property name="sizePolicy">

View File

@ -213,7 +213,7 @@ PropertiesDialog::PropertiesDialog (QWidget * /*parent*/, db::Manager *manager,
// if at end disable the "Next" button and return (this may only happen at the first call)
mp_tree_model = new PropertiesTreeModel (this, mp_ui->tree->iconSize ().width (), mp_ui->tree->iconSize ().height ());
mp_ui->tree->setModel (mp_tree_model);
mp_ui->tree->header ()->setSectionResizeMode (QHeaderView::ResizeToContents);
mp_ui->tree->header()->setSectionResizeMode (QHeaderView::ResizeToContents);
mp_ui->tree->expandAll ();
m_signals_enabled = false;