diff --git a/common/lc_partselectionwidget.cpp b/common/lc_partselectionwidget.cpp index 3b975fe0..120ccdfb 100644 --- a/common/lc_partselectionwidget.cpp +++ b/common/lc_partselectionwidget.cpp @@ -99,6 +99,7 @@ lcPartSelectionListModel::lcPartSelectionListModel(QObject* Parent) mListView = (lcPartSelectionListView*)Parent; mIconSize = 0; mShowPartNames = lcGetProfileInt(LC_PROFILE_PARTS_LIST_NAMES); + mListMode = lcGetProfileInt(LC_PROFILE_PARTS_LIST_LISTMODE); int ColorCode = lcGetProfileInt(LC_PROFILE_PARTS_LIST_COLOR); if (ColorCode == -1) @@ -162,6 +163,14 @@ void lcPartSelectionListModel::ToggleColorLocked() lcSetProfileInt(LC_PROFILE_PARTS_LIST_COLOR, mColorLocked ? lcGetColorCode(mColorIndex) : -1); } +void lcPartSelectionListModel::ToggleListMode() +{ + mListMode = !mListMode; + + mListView->UpdateViewMode(); + lcSetProfileInt(LC_PROFILE_PARTS_LIST_LISTMODE, mListMode); +} + void lcPartSelectionListModel::SetCategory(int CategoryIndex) { ClearRequests(); @@ -243,7 +252,7 @@ QVariant lcPartSelectionListModel::data(const QModelIndex& Index, int Role) cons switch (Role) { case Qt::DisplayRole: - if (!mIconSize || mShowPartNames) + if (!mIconSize || mShowPartNames || mListMode) return QVariant(QString::fromLatin1(Info->m_strDescription)); break; @@ -444,7 +453,7 @@ void lcPartSelectionListView::CustomContextMenuRequested(QPoint Pos) Menu->addSeparator(); - if (mListModel->GetIconSize() != 0) + if (mListModel->GetIconSize() != 0 && !mListModel->IsListMode()) { QAction* PartNames = Menu->addAction(tr("Show Part Names"), this, SLOT(TogglePartNames())); PartNames->setCheckable(true); @@ -455,6 +464,10 @@ void lcPartSelectionListView::CustomContextMenuRequested(QPoint Pos) DecoratedParts->setCheckable(true); DecoratedParts->setChecked(mFilterModel->GetShowDecoratedParts()); + QAction* ListMode = Menu->addAction(tr("List Mode"), this, SLOT(ToggleListMode())); + ListMode->setCheckable(true); + ListMode->setChecked(mListModel->IsListMode()); + QAction* FixedColor = Menu->addAction(tr("Lock Preview Color"), this, SLOT(ToggleFixedColor())); FixedColor->setCheckable(true); FixedColor->setChecked(mListModel->IsColorLocked()); @@ -501,17 +514,28 @@ void lcPartSelectionListView::ToggleDecoratedParts() lcSetProfileInt(LC_PROFILE_PARTS_LIST_DECORATED, Show); } +void lcPartSelectionListView::ToggleListMode() +{ + mListModel->ToggleListMode(); +} + void lcPartSelectionListView::ToggleFixedColor() { mListModel->ToggleColorLocked(); } +void lcPartSelectionListView::UpdateViewMode() +{ + setViewMode(mListModel->GetIconSize() && !mListModel->IsListMode() ? QListView::IconMode : QListView::ListMode); + setWordWrap(mListModel->IsListMode()); +} + void lcPartSelectionListView::SetIconSize(int Size) { - setViewMode(Size ? QListView::IconMode : QListView::ListMode); setIconSize(QSize(Size, Size)); lcSetProfileInt(LC_PROFILE_PARTS_LIST_ICONS, Size); mListModel->SetIconSize(Size); + UpdateViewMode(); } void lcPartSelectionListView::startDrag(Qt::DropActions SupportedActions) diff --git a/common/lc_partselectionwidget.h b/common/lc_partselectionwidget.h index d37d7cc1..a1053415 100644 --- a/common/lc_partselectionwidget.h +++ b/common/lc_partselectionwidget.h @@ -82,9 +82,15 @@ public: return mColorLocked; } + bool IsListMode() const + { + return mListMode; + } + void Redraw(); void SetColorIndex(int ColorIndex); void ToggleColorLocked(); + void ToggleListMode(); void SetCategory(int CategoryIndex); void SetModelsCategory(); void SetCurrentModelCategory(); @@ -106,6 +112,7 @@ protected: bool mColorLocked; int mColorIndex; bool mShowPartNames; + bool mListMode; }; class lcPartSelectionListView : public QListView @@ -132,6 +139,8 @@ public: return mFilterModel; } + void UpdateViewMode(); + protected slots: void CustomContextMenuRequested(QPoint Pos); void SetNoIcons(); @@ -141,6 +150,7 @@ protected slots: void SetExtraLargeIcons(); void TogglePartNames(); void ToggleDecoratedParts(); + void ToggleListMode(); void ToggleFixedColor(); protected: @@ -148,8 +158,6 @@ protected: lcPartSelectionListModel* mListModel; lcPartSelectionFilterModel* mFilterModel; - -// QSize sizeHint() const; }; class lcPartSelectionWidget : public QWidget diff --git a/common/lc_profile.cpp b/common/lc_profile.cpp index 5f19cab9..e5cf9f11 100644 --- a/common/lc_profile.cpp +++ b/common/lc_profile.cpp @@ -88,6 +88,7 @@ lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS] = lcProfileEntry("Settings", "PartsListNames", 0), // LC_PROFILE_PARTS_LIST_NAMES lcProfileEntry("Settings", "PartsListFixedColor", -1), // LC_PROFILE_PARTS_LIST_FIXED_COLOR lcProfileEntry("Settings", "PartsListDecorated", 1), // LC_PROFILE_PARTS_LIST_DECORATED + lcProfileEntry("Settings", "PartsListListMode", 0), // LC_PROFILE_PARTS_LIST_LISTMODE lcProfileEntry("Defaults", "Author", ""), // LC_PROFILE_DEFAULT_AUTHOR_NAME lcProfileEntry("Defaults", "FloorColor", LC_RGB(0, 191, 0)), // LC_PROFILE_DEFAULT_FLOOR_COLOR diff --git a/common/lc_profile.h b/common/lc_profile.h index f4e0fe02..78aa9953 100644 --- a/common/lc_profile.h +++ b/common/lc_profile.h @@ -37,6 +37,7 @@ enum LC_PROFILE_KEY LC_PROFILE_PARTS_LIST_NAMES, LC_PROFILE_PARTS_LIST_COLOR, LC_PROFILE_PARTS_LIST_DECORATED, + LC_PROFILE_PARTS_LIST_LISTMODE, // Defaults for new projects. LC_PROFILE_DEFAULT_AUTHOR_NAME,