mirror of
https://github.com/leozide/leocad
synced 2025-01-30 20:34:56 +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();
|
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());
|
mParts.reserve(Favorites.size());
|
||||||
|
|
||||||
for (PieceInfo* Favorite : Favorites)
|
for (PieceInfo* Favorite : Favorites)
|
||||||
|
@ -495,29 +502,22 @@ void lcPartSelectionListView::CustomContextMenuRequested(QPoint Pos)
|
||||||
{
|
{
|
||||||
QMenu* Menu = new QMenu(this);
|
QMenu* Menu = new QMenu(this);
|
||||||
|
|
||||||
|
mContextInfo = nullptr;
|
||||||
QModelIndex Index = indexAt(Pos);
|
QModelIndex Index = indexAt(Pos);
|
||||||
|
|
||||||
if (Index.isValid())
|
if (Index.isValid())
|
||||||
{
|
{
|
||||||
PieceInfo* Info = mListModel->GetPieceInfo(Index.row());
|
mContextInfo = mListModel->GetPieceInfo(Index.row());
|
||||||
lcPiecesLibrary* Library = lcGetPiecesLibrary();
|
|
||||||
|
|
||||||
if (!Library->IsFavorite(Info))
|
if (mContextInfo)
|
||||||
{
|
{
|
||||||
Menu->addAction(tr("Add to Favorites"), [Library, Info]()
|
if (!lcGetPiecesLibrary()->IsFavorite(mContextInfo))
|
||||||
{
|
Menu->addAction(tr("Add to Favorites"), this, SLOT(AddToFavorites()));
|
||||||
Library->AddToFavorites(Info);
|
else
|
||||||
});
|
Menu->addAction(tr("Remove from Favorites"), this, SLOT(RemoveFromFavorites()));
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Menu->addAction(tr("Remove from Favorites"), [this, Library, Info]()
|
|
||||||
{
|
|
||||||
Library->RemoveFromFavorites(Info);
|
|
||||||
emit FavoriteRemoved();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Menu->addSeparator();
|
Menu->addSeparator();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gSupportsFramebufferObjectARB || gSupportsFramebufferObjectEXT)
|
if (gSupportsFramebufferObjectARB || gSupportsFramebufferObjectEXT)
|
||||||
|
@ -638,6 +638,21 @@ void lcPartSelectionListView::ToggleFixedColor()
|
||||||
mListModel->ToggleColorLocked();
|
mListModel->ToggleColorLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcPartSelectionListView::AddToFavorites()
|
||||||
|
{
|
||||||
|
if (mContextInfo)
|
||||||
|
lcGetPiecesLibrary()->AddToFavorites(mContextInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcPartSelectionListView::RemoveFromFavorites()
|
||||||
|
{
|
||||||
|
if (mContextInfo)
|
||||||
|
{
|
||||||
|
lcGetPiecesLibrary()->RemoveFromFavorites(mContextInfo);
|
||||||
|
emit FavoriteRemoved();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void lcPartSelectionListView::UpdateViewMode()
|
void lcPartSelectionListView::UpdateViewMode()
|
||||||
{
|
{
|
||||||
setViewMode(mListModel->GetIconSize() && !mListModel->IsListMode() ? QListView::IconMode : QListView::ListMode);
|
setViewMode(mListModel->GetIconSize() && !mListModel->IsListMode() ? QListView::IconMode : QListView::ListMode);
|
||||||
|
|
|
@ -147,11 +147,14 @@ public slots:
|
||||||
void TogglePartAliases();
|
void TogglePartAliases();
|
||||||
void ToggleListMode();
|
void ToggleListMode();
|
||||||
void ToggleFixedColor();
|
void ToggleFixedColor();
|
||||||
|
void AddToFavorites();
|
||||||
|
void RemoveFromFavorites();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void SetIconSize(int Size);
|
void SetIconSize(int Size);
|
||||||
|
|
||||||
lcPartSelectionListModel* mListModel;
|
lcPartSelectionListModel* mListModel;
|
||||||
|
PieceInfo* mContextInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
class lcPartSelectionWidget : public QWidget
|
class lcPartSelectionWidget : public QWidget
|
||||||
|
|
Loading…
Add table
Reference in a new issue