Gui: clean-up Selection API

Replace the int of the 'resolve' argument of several functions with a proper enum class.
* This avoids the inconsistencies in client code where often true/false is passed when an int is expected
* This avoids the use of magic numbers like 0, 1, 2 or the undocumented 3
This commit is contained in:
wmayer
2022-04-09 17:03:43 +02:00
parent 2d266a75cd
commit 0b2c73cf32
24 changed files with 365 additions and 274 deletions

View File

@@ -54,7 +54,7 @@ using namespace Gui::DockWnd;
SelectionView::SelectionView(Gui::Document* pcDocument, QWidget *parent)
: DockWindow(pcDocument,parent)
, SelectionObserver(true,0)
, SelectionObserver(true, ResolveMode::NoResolve)
, x(0.0f), y(0.0f), z(0.0f)
, openedAutomatically(false)
{
@@ -201,7 +201,7 @@ void SelectionView::onSelectionChanged(const SelectionChanges &Reason)
else if (Reason.Type == SelectionChanges::SetSelection) {
// remove all items
selectionView->clear();
std::vector<SelectionSingleton::SelObj> objs = Gui::Selection().getSelection(Reason.pDocName,0);
std::vector<SelectionSingleton::SelObj> objs = Gui::Selection().getSelection(Reason.pDocName, ResolveMode::NoResolve);
for (std::vector<SelectionSingleton::SelObj>::iterator it = objs.begin(); it != objs.end(); ++it) {
// save as user data
QStringList list;
@@ -360,12 +360,12 @@ void SelectionView::deselect(void)
void SelectionView::toggleSelect(QListWidgetItem* item)
{
if (!item)
if (!item)
return;
std::string name = item->text().toLatin1().constData();
char *docname = &name.at(0);
char *objname = std::strchr(docname,'#');
if(!objname)
if(!objname)
return;
*objname++ = 0;
char *subname = std::strchr(objname,'.');
@@ -400,12 +400,12 @@ void SelectionView::toggleSelect(QListWidgetItem* item)
void SelectionView::preselect(QListWidgetItem* item)
{
if (!item)
if (!item)
return;
std::string name = item->text().toLatin1().constData();
char *docname = &name.at(0);
char *objname = std::strchr(docname,'#');
if(!objname)
if(!objname)
return;
*objname++ = 0;
char *subname = std::strchr(objname,'.');