mirror of
https://github.com/leozide/leocad
synced 2025-01-17 18:11:42 +01:00
Fixed Qt4 errors.
This commit is contained in:
parent
17a230c52a
commit
7b21d4af0b
2 changed files with 35 additions and 17 deletions
|
@ -195,6 +195,13 @@ void lcPartSelectionListModel::SetFavoritesCategory()
|
|||
|
||||
std::vector<PieceInfo*> Favorites = lcGetPiecesLibrary()->GetFavorites();
|
||||
|
||||
auto lcPartSortFunc = [](const PieceInfo* a, const PieceInfo* b)
|
||||
{
|
||||
return strcmp(a->m_strDescription, b->m_strDescription) < 0;
|
||||
};
|
||||
|
||||
std::sort(Favorites.begin(), Favorites.end(), lcPartSortFunc);
|
||||
|
||||
mParts.reserve(Favorites.size());
|
||||
|
||||
for (PieceInfo* Favorite : Favorites)
|
||||
|
@ -495,29 +502,22 @@ void lcPartSelectionListView::CustomContextMenuRequested(QPoint Pos)
|
|||
{
|
||||
QMenu* Menu = new QMenu(this);
|
||||
|
||||
mContextInfo = nullptr;
|
||||
QModelIndex Index = indexAt(Pos);
|
||||
|
||||
if (Index.isValid())
|
||||
{
|
||||
PieceInfo* Info = mListModel->GetPieceInfo(Index.row());
|
||||
lcPiecesLibrary* Library = lcGetPiecesLibrary();
|
||||
mContextInfo = mListModel->GetPieceInfo(Index.row());
|
||||
|
||||
if (!Library->IsFavorite(Info))
|
||||
if (mContextInfo)
|
||||
{
|
||||
Menu->addAction(tr("Add to Favorites"), [Library, Info]()
|
||||
{
|
||||
Library->AddToFavorites(Info);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Menu->addAction(tr("Remove from Favorites"), [this, Library, Info]()
|
||||
{
|
||||
Library->RemoveFromFavorites(Info);
|
||||
emit FavoriteRemoved();
|
||||
});
|
||||
}
|
||||
if (!lcGetPiecesLibrary()->IsFavorite(mContextInfo))
|
||||
Menu->addAction(tr("Add to Favorites"), this, SLOT(AddToFavorites()));
|
||||
else
|
||||
Menu->addAction(tr("Remove from Favorites"), this, SLOT(RemoveFromFavorites()));
|
||||
|
||||
Menu->addSeparator();
|
||||
Menu->addSeparator();
|
||||
}
|
||||
}
|
||||
|
||||
if (gSupportsFramebufferObjectARB || gSupportsFramebufferObjectEXT)
|
||||
|
@ -638,6 +638,21 @@ void lcPartSelectionListView::ToggleFixedColor()
|
|||
mListModel->ToggleColorLocked();
|
||||
}
|
||||
|
||||
void lcPartSelectionListView::AddToFavorites()
|
||||
{
|
||||
if (mContextInfo)
|
||||
lcGetPiecesLibrary()->AddToFavorites(mContextInfo);
|
||||
}
|
||||
|
||||
void lcPartSelectionListView::RemoveFromFavorites()
|
||||
{
|
||||
if (mContextInfo)
|
||||
{
|
||||
lcGetPiecesLibrary()->RemoveFromFavorites(mContextInfo);
|
||||
emit FavoriteRemoved();
|
||||
}
|
||||
}
|
||||
|
||||
void lcPartSelectionListView::UpdateViewMode()
|
||||
{
|
||||
setViewMode(mListModel->GetIconSize() && !mListModel->IsListMode() ? QListView::IconMode : QListView::ListMode);
|
||||
|
|
|
@ -147,11 +147,14 @@ public slots:
|
|||
void TogglePartAliases();
|
||||
void ToggleListMode();
|
||||
void ToggleFixedColor();
|
||||
void AddToFavorites();
|
||||
void RemoveFromFavorites();
|
||||
|
||||
protected:
|
||||
void SetIconSize(int Size);
|
||||
|
||||
lcPartSelectionListModel* mListModel;
|
||||
PieceInfo* mContextInfo;
|
||||
};
|
||||
|
||||
class lcPartSelectionWidget : public QWidget
|
||||
|
|
Loading…
Reference in a new issue