Skip to content

Commit

Permalink
chore: Fix duplication between lastItem() and layoutItem()
Browse files Browse the repository at this point in the history
Both meant the same thing. Removed the latter.
  • Loading branch information
iamsergio committed Jul 10, 2024
1 parent 7a39a59 commit fd09338
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
7 changes: 6 additions & 1 deletion src/core/Position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void Position::addPlaceholderItem(Core::Item *placeholder)
// meaningful names in separated variables
}

Core::Item *Position::layoutItem() const
Core::Item *Position::lastItem() const
{
// Return the layout item that is in a MainWindow, that's where we restore the dock widget to.
// In the future we might want to restore it to FloatingWindows.
Expand Down Expand Up @@ -215,6 +215,11 @@ LayoutSaver::Position Position::serialize() const
return l;
}

bool Position::isValid() const
{
return lastItem() != nullptr;
}

Position::ItemRef::ItemRef(KDBindings::ConnectionHandle conn, Core::Item *it)
: item(it)
, connection(std::move(conn))
Expand Down
21 changes: 2 additions & 19 deletions src/core/Position_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,7 @@ class DOCKS_EXPORT_FOR_UNIT_TESTS Position
* @brief Returns whether the Position is valid. If invalid then the DockWidget was never
* in a MainWindow.
*/
bool isValid() const
{
return layoutItem() != nullptr;
}

/**
* @brief returns if the dock widget was in a tab
* @return if the position is tabbed, false otherwise
*/
bool isTabbed() const
{
return m_tabIndex != -1;
}
bool isValid() const;

///@brief The tab index in case the dock widget was in a TabWidget, -1 otherwise.
int m_tabIndex = -1;
Expand All @@ -85,8 +73,6 @@ class DOCKS_EXPORT_FOR_UNIT_TESTS Position
///@brief Adds the last layout item where the dock widget was (or is)
void addPlaceholderItem(Core::Item *placeholder);

Core::Item *layoutItem() const;

bool containsPlaceholder(Core::Item *) const;
void removePlaceholders();

Expand Down Expand Up @@ -120,10 +106,7 @@ class DOCKS_EXPORT_FOR_UNIT_TESTS Position
return m_lastFloatingGeometry;
}

Core::Item *lastItem() const
{
return layoutItem();
}
Core::Item *lastItem() const;

int lastTabIndex() const
{
Expand Down

0 comments on commit fd09338

Please sign in to comment.