Engauge Digitizer  2
Public Member Functions | Protected Member Functions | List of all members
DlgSettingsGridRemoval Class Reference

Dialog for editing grid removal settings. More...

#include <DlgSettingsGridRemoval.h>

Inheritance diagram for DlgSettingsGridRemoval:
Inheritance graph
Collaboration diagram for DlgSettingsGridRemoval:
Collaboration graph

Public Member Functions

 DlgSettingsGridRemoval (MainWindow &mainWindow)
 Single constructor. More...
 
virtual ~DlgSettingsGridRemoval ()
 
virtual void createOptionalSaveDefault (QHBoxLayout *layout)
 Let subclass define an optional Save As Default button. More...
 
virtual QWidget * createSubPanel ()
 Create dialog-specific panel to which base class will add Ok and Cancel buttons. More...
 
virtual void load (CmdMediator &cmdMediator)
 Load settings from Document. More...
 
virtual void setSmallDialogs (bool smallDialogs)
 If false then dialogs have a minimum size so all controls are visible. More...
 
- Public Member Functions inherited from DlgSettingsAbstractBase
 DlgSettingsAbstractBase (const QString &title, const QString &dialogName, MainWindow &mainWindow)
 Single constructor. More...
 
virtual ~DlgSettingsAbstractBase ()
 

Protected Member Functions

virtual void handleOk ()
 Process slotOk. More...
 
- Protected Member Functions inherited from DlgSettingsAbstractBase
CmdMediatorcmdMediator ()
 Provide access to Document information wrapped inside CmdMediator. More...
 
void enableOk (bool enable)
 Let leaf subclass control the Ok button. More...
 
void finishPanel (QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH, int minimumHeightOrZero=0)
 Add Ok and Cancel buttons to subpanel to get the whole dialog. More...
 
MainWindowmainWindow ()
 Get method for MainWindow. More...
 
const MainWindowmainWindow () const
 Const get method for MainWindow. More...
 
void populateColorComboWithoutTransparent (QComboBox &combo)
 Add colors in color palette to combobox, without transparent entry at end. More...
 
void populateColorComboWithTransparent (QComboBox &combo)
 Add colors in color palette to combobox, with transparent entry at end. More...
 
void setCmdMediator (CmdMediator &cmdMediator)
 Store CmdMediator for easy access by the leaf class. More...
 
void setDisableOkAtStartup (bool disableOkAtStartup)
 Override the default Ok button behavior applied in showEvent. More...
 

Additional Inherited Members

- Static Protected Attributes inherited from DlgSettingsAbstractBase
static int MINIMUM_DIALOG_WIDTH = 380
 Dialog layout constant that guarantees every widget has sufficient room. Can be increased by finishPanel. More...
 
static int MINIMUM_PREVIEW_HEIGHT = 100
 Dialog layout constant that guarantees preview has sufficent room. More...
 

Detailed Description

Dialog for editing grid removal settings.

Definition at line 23 of file DlgSettingsGridRemoval.h.

Constructor & Destructor Documentation

◆ DlgSettingsGridRemoval()

DlgSettingsGridRemoval::DlgSettingsGridRemoval ( MainWindow mainWindow)

Single constructor.

Definition at line 35 of file DlgSettingsGridRemoval.cpp.

35  :
36  DlgSettingsAbstractBase (tr ("Grid Removal"),
37  "DlgSettingsGridRemoval",
38  mainWindow),
39  m_validatorCloseDistance (nullptr),
40  m_validatorCountX (nullptr),
41  m_validatorStartX (nullptr),
42  m_validatorStepX (nullptr),
43  m_validatorStopX (nullptr),
44  m_validatorCountY (nullptr),
45  m_validatorStartY (nullptr),
46  m_validatorStepY (nullptr),
47  m_validatorStopY (nullptr),
48  m_scenePreview (nullptr),
49  m_viewPreview (nullptr),
50  m_modelGridRemovalBefore (nullptr),
51  m_modelGridRemovalAfter (nullptr)
52 {
53  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::DlgSettingsGridRemoval";
54 
55  QWidget *subPanel = createSubPanel ();
56  finishPanel (subPanel);
57 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
void finishPanel(QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH, int minimumHeightOrZero=0)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
Abstract base class for all Settings dialogs.
virtual QWidget * createSubPanel()
Create dialog-specific panel to which base class will add Ok and Cancel buttons.
MainWindow & mainWindow()
Get method for MainWindow.

◆ ~DlgSettingsGridRemoval()

DlgSettingsGridRemoval::~DlgSettingsGridRemoval ( )
virtual

Definition at line 59 of file DlgSettingsGridRemoval.cpp.

60 {
61  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::~DlgSettingsGridRemoval";
62 
63  delete m_validatorCloseDistance;
64  delete m_validatorCountX;
65  delete m_validatorStartX;
66  delete m_validatorStepX;
67  delete m_validatorStopX;
68  delete m_validatorCountY;
69  delete m_validatorStartY;
70  delete m_validatorStepY;
71  delete m_validatorStopY;
72 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14

Member Function Documentation

◆ createOptionalSaveDefault()

void DlgSettingsGridRemoval::createOptionalSaveDefault ( QHBoxLayout *  layout)
virtual

Let subclass define an optional Save As Default button.

Implements DlgSettingsAbstractBase.

Definition at line 74 of file DlgSettingsGridRemoval.cpp.

75 {
76 }

◆ createSubPanel()

QWidget * DlgSettingsGridRemoval::createSubPanel ( )
virtual

Create dialog-specific panel to which base class will add Ok and Cancel buttons.

Implements DlgSettingsAbstractBase.

Definition at line 279 of file DlgSettingsGridRemoval.cpp.

280 {
281  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::createSubPanel";
282 
283  QWidget *subPanel = new QWidget ();
284  QGridLayout *layout = new QGridLayout (subPanel);
285  subPanel->setLayout (layout);
286 
287  layout->setColumnStretch(0, 1); // Empty first column
288  layout->setColumnStretch(1, 0); // Checkbox part of "section" checkboxes. In other rows this has empty space as indentation
289  layout->setColumnStretch(2, 0); // X
290  layout->setColumnStretch(3, 0); // Y
291  layout->setColumnStretch(4, 1); // Empty last column
292 
293  int row = 0;
294  createRemoveGridLines (layout, row);
295  createPreview (layout, row);
296 
297  return subPanel;
298 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14

◆ handleOk()

void DlgSettingsGridRemoval::handleOk ( )
protectedvirtual

Process slotOk.

Implements DlgSettingsAbstractBase.

Definition at line 300 of file DlgSettingsGridRemoval.cpp.

301 {
302  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::handleOk";
303 
304  // Set the stable flag
305  m_modelGridRemovalAfter->setStable ();
306 
308  cmdMediator ().document(),
309  *m_modelGridRemovalBefore,
310  *m_modelGridRemovalAfter);
311  cmdMediator ().push (cmd);
312 
313  hide ();
314 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
Command for DlgSettingsGridRemoval.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
void setStable()
Set the stable flag to true. This public version has no argument since it cannot be undone...
MainWindow & mainWindow()
Get method for MainWindow.
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.

◆ load()

void DlgSettingsGridRemoval::load ( CmdMediator cmdMediator)
virtual

Load settings from Document.

Implements DlgSettingsAbstractBase.

Definition at line 316 of file DlgSettingsGridRemoval.cpp.

317 {
318  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsGridRemoval::load";
319 
321 
322  // Flush old data
323  delete m_modelGridRemovalBefore;
324  delete m_modelGridRemovalAfter;
325 
326  // Save new data
327  m_modelGridRemovalBefore = new DocumentModelGridRemoval (cmdMediator.document());
328  m_modelGridRemovalAfter = new DocumentModelGridRemoval (cmdMediator.document());
329 
330  // Sanity checks. Incoming defaults must be acceptable to the local limits
331  ENGAUGE_ASSERT (CLOSE_DISTANCE_MIN <= m_modelGridRemovalAfter->closeDistance());
332  ENGAUGE_ASSERT (CLOSE_DISTANCE_MAX >= m_modelGridRemovalAfter->closeDistance());
333 
334  // Populate controls
335  m_chkRemoveGridLines->setChecked (m_modelGridRemovalAfter->removeDefinedGridLines());
336 
337  m_editCloseDistance->setText (QString::number (m_modelGridRemovalAfter->closeDistance()));
338 
339  int indexDisableX = m_cmbDisableX->findData (QVariant (m_modelGridRemovalAfter->gridCoordDisableX()));
340  m_cmbDisableX->setCurrentIndex (indexDisableX);
341 
342  m_editCountX->setText(QString::number(m_modelGridRemovalAfter->countX()));
343  m_editStartX->setText(QString::number(m_modelGridRemovalAfter->startX()));
344  m_editStepX->setText(QString::number(m_modelGridRemovalAfter->stepX()));
345  m_editStopX->setText(QString::number(m_modelGridRemovalAfter->stopX()));
346 
347  int indexDisableY = m_cmbDisableY->findData (QVariant (m_modelGridRemovalAfter->gridCoordDisableY()));
348  m_cmbDisableY->setCurrentIndex (indexDisableY);
349 
350  m_editCountY->setText(QString::number(m_modelGridRemovalAfter->countY()));
351  m_editStartY->setText(QString::number(m_modelGridRemovalAfter->startY()));
352  m_editStepY->setText(QString::number(m_modelGridRemovalAfter->stepY()));
353  m_editStopY->setText(QString::number(m_modelGridRemovalAfter->stopY()));
354 
355  updateControls ();
356  enableOk (false); // Disable Ok button since there not yet any changes
357  updatePreview();
358 }
double closeDistance() const
Get method for close distance.
GridCoordDisable gridCoordDisableX() const
Get method for x coord parameter to disable.
double stopY() const
Get method for y stop.
double stopX() const
Get method for x stop.
int countY() const
Get method for y count.
double startY() const
Get method for y start.
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
Definition: CmdMediator.cpp:72
double stepX() const
Get method for x step.
bool removeDefinedGridLines() const
Get method for removing defined grid lines.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
int countX() const
Get method for x count.
void enableOk(bool enable)
Let leaf subclass control the Ok button.
const double CLOSE_DISTANCE_MAX
double startX() const
Get method for x start.
Model for DlgSettingsGridRemoval and CmdSettingsGridRemoval. The settings are unstable until the user...
GridCoordDisable gridCoordDisableY() const
Get method for y coord parameter to disable.
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
Definition: EngaugeAssert.h:20
double stepY() const
Get method for y step.

◆ setSmallDialogs()

void DlgSettingsGridRemoval::setSmallDialogs ( bool  smallDialogs)
virtual

If false then dialogs have a minimum size so all controls are visible.

Implements DlgSettingsAbstractBase.

Definition at line 360 of file DlgSettingsGridRemoval.cpp.

361 {
362  if (!smallDialogs) {
363  setMinimumHeight (MINIMUM_HEIGHT);
364  }
365 }
const int MINIMUM_HEIGHT

The documentation for this class was generated from the following files: