Implementation proposal

The solution tries to be a bit more generic:

- four buttons are there to synchronize coordinates
- three buttons to snap p1, p2 and auto-measure from p1.
This commit is contained in:
Matthias Koefferlein 2019-09-01 19:58:57 +02:00
parent 1106d3faac
commit 9fa5277e41
19 changed files with 938 additions and 533 deletions

File diff suppressed because it is too large Load Diff

View File

@ -31,14 +31,32 @@ namespace ant
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// PropertiesPage implementation // PropertiesPage implementation
PropertiesPage::PropertiesPage (ant::Service *rulers, QWidget *parent) PropertiesPage::PropertiesPage (ant::Service *rulers, db::Manager *manager, QWidget *parent)
: lay::PropertiesPage (parent, rulers), mp_rulers (rulers), m_enable_cb_callback (true) : lay::PropertiesPage (parent, manager, rulers), mp_rulers (rulers), m_enable_cb_callback (true)
{ {
mp_rulers->get_selection (m_selection); mp_rulers->get_selection (m_selection);
m_pos = m_selection.begin (); m_pos = m_selection.begin ();
setupUi (this); setupUi (this);
connect (p1x_to_p2x, SIGNAL (clicked ()), this, SLOT (xfer_coord_clicked ()));
connect (p2x_to_p1x, SIGNAL (clicked ()), this, SLOT (xfer_coord_clicked ()));
connect (p1y_to_p2y, SIGNAL (clicked ()), this, SLOT (xfer_coord_clicked ()));
connect (p2y_to_p1y, SIGNAL (clicked ()), this, SLOT (xfer_coord_clicked ()));
connect (p1_to_layout, SIGNAL (clicked ()), this, SLOT (snap_to_layout_clicked ()));
connect (p2_to_layout, SIGNAL (clicked ()), this, SLOT (snap_to_layout_clicked ()));
connect (both_to_layout, SIGNAL (clicked ()), this, SLOT (snap_to_layout_clicked ()));
p1x_to_p2x->setEnabled (! readonly());
p2x_to_p1x->setEnabled (! readonly());
p1y_to_p2y->setEnabled (! readonly());
p2y_to_p1y->setEnabled (! readonly());
p1_to_layout->setEnabled (! readonly());
p2_to_layout->setEnabled (! readonly());
both_to_layout->setEnabled (! readonly());
lay::activate_help_links (help_label); lay::activate_help_links (help_label);
mp_rulers->clear_highlights (); mp_rulers->clear_highlights ();
@ -61,6 +79,115 @@ PropertiesPage::front ()
m_pos = m_selection.begin (); m_pos = m_selection.begin ();
} }
void
PropertiesPage::xfer_coord_clicked ()
{
if (readonly ()) {
return;
}
if (sender () == p1x_to_p2x) {
x2->setText (x1->text ());
} else if (sender () == p2x_to_p1x) {
x1->setText (x2->text ());
} else if (sender () == p1y_to_p2y) {
y2->setText (y1->text ());
} else if (sender () == p2y_to_p1y) {
y1->setText (y2->text ());
}
db::Transaction t (manager (), tl::to_string (QObject::tr ("Copy ruler coordinates")));
apply ();
}
void
PropertiesPage::snap_to_layout_clicked ()
{
if (readonly ()) {
return;
}
ant::Service *service = dynamic_cast<ant::Service *> (editable ());
tl_assert (service != 0);
double dx1 = 0.0, dy1 = 0.0, dx2 = 0.0, dy2 = 0.0;
tl::from_string (tl::to_string (x1->text ()), dx1);
tl::from_string (tl::to_string (x2->text ()), dx2);
tl::from_string (tl::to_string (y1->text ()), dy1);
tl::from_string (tl::to_string (y2->text ()), dy2);
db::DPoint p1 (dx1, dy1), p2 (dx2, dy2);
ant::Object r = current ();
// for auto-metric we need some cutline constraint - any or global won't do.
lay::angle_constraint_type ac = r.angle_constraint ();
if (ac == lay::AC_Global) {
ac = service->snap_mode ();
}
if (ac == lay::AC_Global) {
ac = lay::AC_Diagonal;
}
db::DVector g;
if (service->grid_snap ()) {
g = db::DVector (service->grid (), service->grid ());
}
if (sender () == p1_to_layout || sender () == p2_to_layout) {
double snap_range = service->widget ()->mouse_event_trans ().inverted ().ctrans (service->snap_range ());
double max_range = 1000 * snap_range;
while (snap_range < max_range) {
std::pair<bool, db::DPoint> pp = lay::obj_snap (service->view (), p1, p1, g, ac, snap_range);
if (pp.first) {
QString xs = tl::to_qstring (tl::micron_to_string (pp.second.x ()));
QString ys = tl::to_qstring (tl::micron_to_string (pp.second.y ()));
if (sender () == p1_to_layout) {
x1->setText (xs);
y1->setText (ys);
} else {
x2->setText (xs);
y2->setText (ys);
}
db::Transaction t (manager (), tl::to_string (sender () == p1_to_layout ? QObject::tr ("Snap first ruler point") : QObject::tr ("Snap second ruler point")));
apply ();
break;
}
// no point found -> one more iteration with increased range
snap_range *= 2.0;
}
} else {
double snap_range = service->widget ()->mouse_event_trans ().inverted ().ctrans (service->snap_range ());
snap_range *= 0.5;
std::pair<bool, db::DEdge> ee = lay::obj_snap2 (service->view (), p1, g, ac, snap_range, snap_range * 1000.0);
if (ee.first) {
x1->setText (tl::to_qstring (tl::micron_to_string (ee.second.p1 ().x ())));
y1->setText (tl::to_qstring (tl::micron_to_string (ee.second.p1 ().y ())));
x2->setText (tl::to_qstring (tl::micron_to_string (ee.second.p2 ().x ())));
y2->setText (tl::to_qstring (tl::micron_to_string (ee.second.p2 ().y ())));
db::Transaction t (manager (), tl::to_string (QObject::tr ("Snap both ruler points")));
apply ();
}
}
}
const ant::Object & const ant::Object &
PropertiesPage::current () const PropertiesPage::current () const
{ {

View File

@ -39,7 +39,7 @@ class PropertiesPage
Q_OBJECT Q_OBJECT
public: public:
PropertiesPage (ant::Service *rulers, QWidget *parent); PropertiesPage (ant::Service *rulers, db::Manager *manager, QWidget *parent);
~PropertiesPage (); ~PropertiesPage ();
virtual void back (); virtual void back ();
@ -53,6 +53,10 @@ public:
virtual bool readonly (); virtual bool readonly ();
virtual void apply (); virtual void apply ();
private slots:
void xfer_coord_clicked ();
void snap_to_layout_clicked ();
private: private:
std::vector <ant::Service::obj_iterator> m_selection; std::vector <ant::Service::obj_iterator> m_selection;
std::vector <ant::Service::obj_iterator>::iterator m_pos; std::vector <ant::Service::obj_iterator>::iterator m_pos;

View File

@ -2067,9 +2067,9 @@ Service::display_status (bool transient)
} }
lay::PropertiesPage * lay::PropertiesPage *
Service::properties_page (QWidget *parent) Service::properties_page (db::Manager *manager, QWidget *parent)
{ {
return new PropertiesPage (this, parent); return new PropertiesPage (this, manager, parent);
} }
void void

View File

@ -333,7 +333,7 @@ public:
/** /**
* @brief Create the properties page * @brief Create the properties page
*/ */
virtual lay::PropertiesPage *properties_page (QWidget * /*parent*/); virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent);
/** /**
* @brief Get the selection for the properties page * @brief Get the selection for the properties page
@ -416,6 +416,38 @@ public:
return mp_view; return mp_view;
} }
/**
* @brief Gets the snap range
*/
int snap_range () const
{
return m_snap_range;
}
/**
* @brief Gets the global snap mode
*/
lay::angle_constraint_type snap_mode () const
{
return m_snap_mode;
}
/**
* @brief Gets the grid
*/
double grid () const
{
return m_grid;
}
/**
* @brief Gets a value indicating whether to snap to grid
*/
bool grid_snap () const
{
return m_grid_snap;
}
/** /**
* @brief Implement the menu response function * @brief Implement the menu response function
*/ */

View File

@ -44,8 +44,8 @@ namespace edt
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// InstPropertiesPage implementation // InstPropertiesPage implementation
InstPropertiesPage::InstPropertiesPage (edt::Service *service, QWidget *parent) InstPropertiesPage::InstPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent)
: lay::PropertiesPage (parent, service), mp_service (service), m_enable_cb_callback (true), mp_pcell_parameters (0) : lay::PropertiesPage (parent, manager, service), mp_service (service), m_enable_cb_callback (true), mp_pcell_parameters (0)
{ {
m_selection_ptrs.reserve (service->selection ().size ()); m_selection_ptrs.reserve (service->selection ().size ());
for (edt::Service::obj_iterator s = service->selection ().begin (); s != service->selection ().end (); ++s) { for (edt::Service::obj_iterator s = service->selection ().begin (); s != service->selection ().end (); ++s) {

View File

@ -43,7 +43,7 @@ class InstPropertiesPage
Q_OBJECT Q_OBJECT
public: public:
InstPropertiesPage (edt::Service *service, QWidget *parent); InstPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent);
~InstPropertiesPage (); ~InstPropertiesPage ();
virtual void back (); virtual void back ();

View File

@ -40,8 +40,8 @@ namespace edt
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// ShapePropertiesPage implementation // ShapePropertiesPage implementation
ShapePropertiesPage::ShapePropertiesPage (edt::Service *service, QWidget *parent) ShapePropertiesPage::ShapePropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent)
: lay::PropertiesPage (parent, service), : lay::PropertiesPage (parent, manager, service),
mp_service (service), m_enable_cb_callback (true) mp_service (service), m_enable_cb_callback (true)
{ {
m_selection_ptrs.reserve (service->selection ().size ()); m_selection_ptrs.reserve (service->selection ().size ());
@ -403,8 +403,8 @@ ShapePropertiesPage::readonly ()
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// PolygonPropertiesPage implementation // PolygonPropertiesPage implementation
PolygonPropertiesPage::PolygonPropertiesPage (edt::Service *service, QWidget *parent) PolygonPropertiesPage::PolygonPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent)
: ShapePropertiesPage (service, parent) : ShapePropertiesPage (service, manager, parent)
{ {
setupUi (this); setupUi (this);
setup (); setup ();
@ -517,8 +517,8 @@ PolygonPropertiesPage::create_applicator (db::Shapes & /*shapes*/, const db::Sha
static bool s_coordinateMode = true; static bool s_coordinateMode = true;
BoxPropertiesPage::BoxPropertiesPage (edt::Service *service, QWidget *parent) BoxPropertiesPage::BoxPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent)
: ShapePropertiesPage (service, parent), : ShapePropertiesPage (service, manager, parent),
m_recursion_sentinel (false), m_tab_index (0), m_dbu (1.0), m_lr_swapped (false), m_tb_swapped (false) m_recursion_sentinel (false), m_tab_index (0), m_dbu (1.0), m_lr_swapped (false), m_tb_swapped (false)
{ {
setupUi (this); setupUi (this);
@ -669,8 +669,8 @@ BoxPropertiesPage::changed ()
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// TextPropertiesPage implementation // TextPropertiesPage implementation
TextPropertiesPage::TextPropertiesPage (edt::Service *service, QWidget *parent) TextPropertiesPage::TextPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent)
: ShapePropertiesPage (service, parent) : ShapePropertiesPage (service, manager, parent)
{ {
setupUi (this); setupUi (this);
setup (); setup ();
@ -755,8 +755,8 @@ TextPropertiesPage::create_applicator (db::Shapes & /*shapes*/, const db::Shape
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// PathPropertiesPage implementation // PathPropertiesPage implementation
PathPropertiesPage::PathPropertiesPage (edt::Service *service, QWidget *parent) PathPropertiesPage::PathPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent)
: ShapePropertiesPage (service, parent) : ShapePropertiesPage (service, manager, parent)
{ {
setupUi (this); setupUi (this);
setup (); setup ();
@ -857,8 +857,8 @@ PathPropertiesPage::create_applicator (db::Shapes & /*shapes*/, const db::Shape
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// EditablePathPropertiesPage implementation // EditablePathPropertiesPage implementation
EditablePathPropertiesPage::EditablePathPropertiesPage (edt::Service *service, QWidget *parent) EditablePathPropertiesPage::EditablePathPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent)
: ShapePropertiesPage (service, parent) : ShapePropertiesPage (service, manager, parent)
{ {
setupUi (this); setupUi (this);
setup (); setup ();

View File

@ -45,7 +45,7 @@ class ShapePropertiesPage
Q_OBJECT Q_OBJECT
public: public:
ShapePropertiesPage (edt::Service *service, QWidget *parent); ShapePropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent);
~ShapePropertiesPage (); ~ShapePropertiesPage ();
virtual void back (); virtual void back ();
@ -96,7 +96,7 @@ class PolygonPropertiesPage
Q_OBJECT Q_OBJECT
public: public:
PolygonPropertiesPage (edt::Service *service, QWidget *parent); PolygonPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent);
virtual void do_update (const db::Shape &shape, double dbu, const std::string &lname); virtual void do_update (const db::Shape &shape, double dbu, const std::string &lname);
virtual ChangeApplicator *create_applicator (db::Shapes &shapes, const db::Shape &shape, double dbu); virtual ChangeApplicator *create_applicator (db::Shapes &shapes, const db::Shape &shape, double dbu);
@ -113,7 +113,7 @@ class BoxPropertiesPage
Q_OBJECT Q_OBJECT
public: public:
BoxPropertiesPage (edt::Service *service, QWidget *parent); BoxPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent);
virtual void do_update (const db::Shape &shape, double dbu, const std::string &lname); virtual void do_update (const db::Shape &shape, double dbu, const std::string &lname);
virtual ChangeApplicator *create_applicator (db::Shapes &shapes, const db::Shape &shape, double dbu); virtual ChangeApplicator *create_applicator (db::Shapes &shapes, const db::Shape &shape, double dbu);
@ -142,7 +142,7 @@ class TextPropertiesPage
Q_OBJECT Q_OBJECT
public: public:
TextPropertiesPage (edt::Service *service, QWidget *parent); TextPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent);
virtual void do_update (const db::Shape &shape, double dbu, const std::string &lname); virtual void do_update (const db::Shape &shape, double dbu, const std::string &lname);
virtual ChangeApplicator *create_applicator (db::Shapes &shapes, const db::Shape &shape, double dbu); virtual ChangeApplicator *create_applicator (db::Shapes &shapes, const db::Shape &shape, double dbu);
@ -159,7 +159,7 @@ class PathPropertiesPage
Q_OBJECT Q_OBJECT
public: public:
PathPropertiesPage (edt::Service *service, QWidget *parent); PathPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent);
virtual void do_update (const db::Shape &shape, double dbu, const std::string &lname); virtual void do_update (const db::Shape &shape, double dbu, const std::string &lname);
virtual ChangeApplicator *create_applicator (db::Shapes &shapes, const db::Shape &shape, double dbu); virtual ChangeApplicator *create_applicator (db::Shapes &shapes, const db::Shape &shape, double dbu);
@ -176,7 +176,7 @@ class EditablePathPropertiesPage
Q_OBJECT Q_OBJECT
public: public:
EditablePathPropertiesPage (edt::Service *service, QWidget *parent); EditablePathPropertiesPage (edt::Service *service, db::Manager *manager, QWidget *parent);
virtual void do_update (const db::Shape &shape, double dbu, const std::string &lname); virtual void do_update (const db::Shape &shape, double dbu, const std::string &lname);
virtual ChangeApplicator *create_applicator (db::Shapes &shapes, const db::Shape &shape, double dbu); virtual ChangeApplicator *create_applicator (db::Shapes &shapes, const db::Shape &shape, double dbu);

View File

@ -296,9 +296,9 @@ PolygonService::PolygonService (db::Manager *manager, lay::LayoutView *view)
} }
lay::PropertiesPage * lay::PropertiesPage *
PolygonService::properties_page (QWidget *parent) PolygonService::properties_page (db::Manager *manager, QWidget *parent)
{ {
return new edt::PolygonPropertiesPage (this, parent); return new edt::PolygonPropertiesPage (this, manager, parent);
} }
void void
@ -624,9 +624,9 @@ BoxService::BoxService (db::Manager *manager, lay::LayoutView *view)
} }
lay::PropertiesPage * lay::PropertiesPage *
BoxService::properties_page (QWidget *parent) BoxService::properties_page (db::Manager *manager, QWidget *parent)
{ {
return new edt::BoxPropertiesPage (this, parent); return new edt::BoxPropertiesPage (this, manager, parent);
} }
void void
@ -712,9 +712,9 @@ TextService::~TextService ()
} }
lay::PropertiesPage * lay::PropertiesPage *
TextService::properties_page (QWidget *parent) TextService::properties_page (db::Manager *manager, QWidget *parent)
{ {
return new edt::TextPropertiesPage (this, parent); return new edt::TextPropertiesPage (this, manager, parent);
} }
void void
@ -895,12 +895,12 @@ PathService::~PathService ()
} }
lay::PropertiesPage * lay::PropertiesPage *
PathService::properties_page (QWidget *parent) PathService::properties_page (db::Manager *manager, QWidget *parent)
{ {
if (view ()->is_editable ()) { if (view ()->is_editable ()) {
return new edt::EditablePathPropertiesPage (this, parent); return new edt::EditablePathPropertiesPage (this, manager, parent);
} else { } else {
return new edt::PathPropertiesPage (this, parent); return new edt::PathPropertiesPage (this, manager, parent);
} }
} }
@ -1120,9 +1120,9 @@ InstService::InstService (db::Manager *manager, lay::LayoutView *view)
} }
lay::PropertiesPage * lay::PropertiesPage *
InstService::properties_page (QWidget *parent) InstService::properties_page (db::Manager *manager, QWidget *parent)
{ {
return new edt::InstPropertiesPage (this, parent); return new edt::InstPropertiesPage (this, manager, parent);
} }
bool bool

View File

@ -85,7 +85,7 @@ class PolygonService
public: public:
PolygonService (db::Manager *manager, lay::LayoutView *view); PolygonService (db::Manager *manager, lay::LayoutView *view);
virtual lay::PropertiesPage *properties_page (QWidget *parent); virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent);
virtual void do_begin_edit (const db::DPoint &p); virtual void do_begin_edit (const db::DPoint &p);
virtual void do_mouse_move (const db::DPoint &p); virtual void do_mouse_move (const db::DPoint &p);
virtual bool do_mouse_click (const db::DPoint &p); virtual bool do_mouse_click (const db::DPoint &p);
@ -114,7 +114,7 @@ class BoxService
public: public:
BoxService (db::Manager *manager, lay::LayoutView *view); BoxService (db::Manager *manager, lay::LayoutView *view);
virtual lay::PropertiesPage *properties_page (QWidget *parent); virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent);
virtual void do_begin_edit (const db::DPoint &p); virtual void do_begin_edit (const db::DPoint &p);
virtual void do_mouse_move (const db::DPoint &p); virtual void do_mouse_move (const db::DPoint &p);
virtual bool do_mouse_click (const db::DPoint &p); virtual bool do_mouse_click (const db::DPoint &p);
@ -139,7 +139,7 @@ public:
TextService (db::Manager *manager, lay::LayoutView *view); TextService (db::Manager *manager, lay::LayoutView *view);
~TextService (); ~TextService ();
virtual lay::PropertiesPage *properties_page (QWidget *parent); virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent);
virtual void do_begin_edit (const db::DPoint &p); virtual void do_begin_edit (const db::DPoint &p);
virtual void do_mouse_transform (const db::DPoint &p, db::DFTrans trans); virtual void do_mouse_transform (const db::DPoint &p, db::DFTrans trans);
virtual void do_mouse_move (const db::DPoint &p); virtual void do_mouse_move (const db::DPoint &p);
@ -170,7 +170,7 @@ public:
PathService (db::Manager *manager, lay::LayoutView *view); PathService (db::Manager *manager, lay::LayoutView *view);
~PathService (); ~PathService ();
virtual lay::PropertiesPage *properties_page (QWidget *parent); virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent);
virtual void do_begin_edit (const db::DPoint &p); virtual void do_begin_edit (const db::DPoint &p);
virtual void do_mouse_move (const db::DPoint &p); virtual void do_mouse_move (const db::DPoint &p);
virtual bool do_mouse_click (const db::DPoint &p); virtual bool do_mouse_click (const db::DPoint &p);
@ -204,7 +204,7 @@ class InstService
public: public:
InstService (db::Manager *manager, lay::LayoutView *view); InstService (db::Manager *manager, lay::LayoutView *view);
virtual lay::PropertiesPage *properties_page (QWidget *parent); virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent);
virtual void do_begin_edit (const db::DPoint &p); virtual void do_begin_edit (const db::DPoint &p);
virtual void do_mouse_move (const db::DPoint &p); virtual void do_mouse_move (const db::DPoint &p);
virtual bool do_mouse_click (const db::DPoint &p); virtual bool do_mouse_click (const db::DPoint &p);

View File

@ -36,8 +36,8 @@ const double max_gamma = 3.0;
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// PropertiesPage implementation // PropertiesPage implementation
PropertiesPage::PropertiesPage (img::Service *service, QWidget *parent) PropertiesPage::PropertiesPage (img::Service *service, db::Manager *manager, QWidget *parent)
: lay::PropertiesPage (parent, service), mp_service (service), mp_direct_image (0) : lay::PropertiesPage (parent, manager, service), mp_service (service), mp_direct_image (0)
{ {
mp_service->get_selection (m_selection); mp_service->get_selection (m_selection);
m_pos = m_selection.begin (); m_pos = m_selection.begin ();
@ -48,7 +48,7 @@ PropertiesPage::PropertiesPage (img::Service *service, QWidget *parent)
} }
PropertiesPage::PropertiesPage (QWidget *parent) PropertiesPage::PropertiesPage (QWidget *parent)
: lay::PropertiesPage (parent, 0), mp_service (0), mp_direct_image (0) : lay::PropertiesPage (parent, 0, 0), mp_service (0), mp_direct_image (0)
{ {
init (); init ();
} }

View File

@ -45,7 +45,7 @@ class PropertiesPage
Q_OBJECT Q_OBJECT
public: public:
PropertiesPage (img::Service *service, QWidget *parent); PropertiesPage (img::Service *service, db::Manager *manager, QWidget *parent);
PropertiesPage (QWidget *parent); PropertiesPage (QWidget *parent);
~PropertiesPage (); ~PropertiesPage ();

View File

@ -1312,9 +1312,9 @@ Service::display_status (bool transient)
} }
lay::PropertiesPage * lay::PropertiesPage *
Service::properties_page (QWidget *parent) Service::properties_page (db::Manager *manager, QWidget *parent)
{ {
return new img::PropertiesPage (this, parent); return new img::PropertiesPage (this, manager, parent);
} }
void void

View File

@ -352,7 +352,7 @@ public:
/** /**
* @brief Create the properties page * @brief Create the properties page
*/ */
virtual lay::PropertiesPage *properties_page (QWidget * /*parent*/); virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent);
/** /**
* @brief Get the selection for the properties page * @brief Get the selection for the properties page

View File

@ -331,7 +331,7 @@ public:
* by the caller. The return value is 0 if the Editable object does * by the caller. The return value is 0 if the Editable object does
* not support a properties page. * not support a properties page.
*/ */
virtual lay::PropertiesPage *properties_page (QWidget * /*parent*/) virtual lay::PropertiesPage *properties_page (db::Manager * /*manager*/, QWidget * /*parent*/)
{ {
return 0; return 0;
} }

View File

@ -27,8 +27,8 @@
namespace lay namespace lay
{ {
PropertiesPage::PropertiesPage (QWidget *parent, lay::Editable *editable) PropertiesPage::PropertiesPage (QWidget *parent, db::Manager *manager, lay::Editable *editable)
: QFrame (parent), mp_editable (editable) : QFrame (parent), mp_manager (manager), mp_editable (editable)
{ {
// .. nothing else .. // .. nothing else ..
} }

View File

@ -57,7 +57,7 @@ public:
* empty, at_start () is supposed to return true then. * empty, at_start () is supposed to return true then.
* The dialog will call update () to update the display accordingly. * The dialog will call update () to update the display accordingly.
*/ */
PropertiesPage (QWidget *parent, lay::Editable *editable); PropertiesPage (QWidget *parent, db::Manager *manager, lay::Editable *editable);
/** /**
* @brief The destructor * @brief The destructor
@ -210,7 +210,17 @@ public:
return mp_editable; return mp_editable;
} }
/**
* @brief Gets the transaction manager object
* Use this object to implement undable operations on the properties page.
*/
db::Manager *manager ()
{
return mp_manager;
}
private: private:
db::Manager *mp_manager;
lay::Editable *mp_editable; lay::Editable *mp_editable;
}; };

View File

@ -46,7 +46,7 @@ PropertiesDialog::PropertiesDialog (QWidget * /*parent*/, db::Manager *manager,
mp_stack = new QStackedLayout; mp_stack = new QStackedLayout;
for (lay::Editables::iterator e = mp_editables->begin (); e != mp_editables->end (); ++e) { for (lay::Editables::iterator e = mp_editables->begin (); e != mp_editables->end (); ++e) {
mp_properties_pages.push_back (e->properties_page (content_frame)); mp_properties_pages.push_back (e->properties_page (mp_manager, content_frame));
if (mp_properties_pages.back ()) { if (mp_properties_pages.back ()) {
mp_stack->addWidget (mp_properties_pages.back ()); mp_stack->addWidget (mp_properties_pages.back ());
} }