2016-12-16 18:14:19 +01:00
|
|
|
#ifndef _LC_PARTSELECTIONWIDGET_H_
|
|
|
|
#define _LC_PARTSELECTIONWIDGET_H_
|
|
|
|
|
|
|
|
class lcPartSelectionListModel;
|
2017-01-11 02:48:05 +01:00
|
|
|
class lcPartSelectionListView;
|
2016-12-16 18:14:19 +01:00
|
|
|
|
|
|
|
class lcPartSelectionFilterModel : public QSortFilterProxyModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
lcPartSelectionFilterModel(QObject* Parent);
|
|
|
|
|
|
|
|
void SetFilter(const QString& Filter);
|
2017-02-04 22:14:41 +01:00
|
|
|
void SetShowDecoratedParts(bool Show);
|
2017-01-28 03:20:44 +01:00
|
|
|
|
2017-02-04 22:14:41 +01:00
|
|
|
bool GetShowDecoratedParts() const
|
2017-01-28 03:20:44 +01:00
|
|
|
{
|
2017-02-04 22:14:41 +01:00
|
|
|
return mShowDecoratedParts;
|
2017-01-28 03:20:44 +01:00
|
|
|
}
|
2016-12-16 18:14:19 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool filterAcceptsRow(int SourceRow, const QModelIndex& SourceParent) const;
|
|
|
|
|
|
|
|
QByteArray mFilter;
|
2017-02-04 22:14:41 +01:00
|
|
|
bool mShowDecoratedParts;
|
2016-12-16 18:14:19 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class lcPartSelectionItemDelegate : public QStyledItemDelegate
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
lcPartSelectionItemDelegate(QObject* Parent, lcPartSelectionListModel* ListModel, lcPartSelectionFilterModel* FilterModel)
|
|
|
|
: QStyledItemDelegate(Parent), mListModel(ListModel), mFilterModel(FilterModel)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void paint(QPainter* Painter, const QStyleOptionViewItem& Option, const QModelIndex& Index) const;
|
|
|
|
virtual QSize sizeHint(const QStyleOptionViewItem& Option, const QModelIndex& Index) const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
lcPartSelectionListModel* mListModel;
|
|
|
|
lcPartSelectionFilterModel* mFilterModel;
|
|
|
|
};
|
|
|
|
|
|
|
|
class lcPartSelectionListModel : public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
lcPartSelectionListModel(QObject* Parent);
|
2017-01-23 04:28:05 +01:00
|
|
|
virtual ~lcPartSelectionListModel();
|
2016-12-16 18:14:19 +01:00
|
|
|
|
|
|
|
virtual int rowCount(const QModelIndex& Parent = QModelIndex()) const;
|
|
|
|
virtual QVariant data(const QModelIndex& Index, int Role = Qt::DisplayRole) const;
|
|
|
|
virtual QVariant headerData(int Section, Qt::Orientation Orientation, int Role = Qt::DisplayRole) const;
|
|
|
|
virtual Qt::ItemFlags flags(const QModelIndex& Index) const;
|
|
|
|
|
|
|
|
PieceInfo* GetPieceInfo(QModelIndex Index) const
|
|
|
|
{
|
|
|
|
return Index.isValid() ? mParts[Index.row()].first : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
PieceInfo* GetPieceInfo(int Row) const
|
|
|
|
{
|
|
|
|
return mParts[Row].first;
|
|
|
|
}
|
|
|
|
|
2017-01-28 03:20:44 +01:00
|
|
|
int GetIconSize() const
|
|
|
|
{
|
|
|
|
return mIconSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetShowPartNames() const
|
|
|
|
{
|
|
|
|
return mShowPartNames;
|
|
|
|
}
|
|
|
|
|
2017-02-04 22:14:41 +01:00
|
|
|
bool IsColorLocked() const
|
|
|
|
{
|
|
|
|
return mColorLocked;
|
|
|
|
}
|
|
|
|
|
2016-12-29 16:28:53 +01:00
|
|
|
void Redraw();
|
2017-02-04 22:14:41 +01:00
|
|
|
void SetColorIndex(int ColorIndex);
|
|
|
|
void ToggleColorLocked();
|
2016-12-16 18:14:19 +01:00
|
|
|
void SetCategory(int CategoryIndex);
|
2016-12-19 03:53:25 +01:00
|
|
|
void SetModelsCategory();
|
2017-01-27 04:02:42 +01:00
|
|
|
void SetCurrentModelCategory();
|
2017-01-04 15:45:01 +01:00
|
|
|
void RequestPreview(int InfoIndex);
|
2016-12-20 23:46:12 +01:00
|
|
|
void SetIconSize(int Size);
|
2017-01-28 03:20:44 +01:00
|
|
|
void SetShowPartNames(bool Show);
|
2016-12-16 18:14:19 +01:00
|
|
|
|
2017-01-11 02:48:05 +01:00
|
|
|
protected slots:
|
2017-01-23 04:28:05 +01:00
|
|
|
void PartLoaded(PieceInfo* Info);
|
2017-01-04 15:45:01 +01:00
|
|
|
|
2017-01-11 02:48:05 +01:00
|
|
|
protected:
|
2017-01-23 04:28:05 +01:00
|
|
|
void ClearRequests();
|
|
|
|
void DrawPreview(int InfoIndex);
|
|
|
|
|
2017-01-11 02:48:05 +01:00
|
|
|
lcPartSelectionListView* mListView;
|
2016-12-16 18:14:19 +01:00
|
|
|
QVector<QPair<PieceInfo*, QPixmap>> mParts;
|
2017-01-04 15:45:01 +01:00
|
|
|
QList<int> mRequestedPreviews;
|
2016-12-20 23:46:12 +01:00
|
|
|
int mIconSize;
|
2017-02-04 22:14:41 +01:00
|
|
|
bool mColorLocked;
|
|
|
|
int mColorIndex;
|
2017-01-28 03:20:44 +01:00
|
|
|
bool mShowPartNames;
|
2016-12-16 18:14:19 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class lcPartSelectionListView : public QListView
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
lcPartSelectionListView(QWidget* Parent);
|
|
|
|
|
|
|
|
virtual void startDrag(Qt::DropActions SupportedActions);
|
|
|
|
|
|
|
|
PieceInfo* GetCurrentPart() const
|
|
|
|
{
|
|
|
|
return mListModel->GetPieceInfo(mFilterModel->mapToSource(currentIndex()));
|
|
|
|
}
|
|
|
|
|
|
|
|
lcPartSelectionListModel* GetListModel() const
|
|
|
|
{
|
|
|
|
return mListModel;
|
|
|
|
}
|
|
|
|
|
|
|
|
lcPartSelectionFilterModel* GetFilterModel() const
|
|
|
|
{
|
|
|
|
return mFilterModel;
|
|
|
|
}
|
|
|
|
|
2016-12-20 23:46:12 +01:00
|
|
|
protected slots:
|
|
|
|
void CustomContextMenuRequested(QPoint Pos);
|
2017-01-28 03:20:44 +01:00
|
|
|
void SetNoIcons();
|
2016-12-20 23:46:12 +01:00
|
|
|
void SetSmallIcons();
|
|
|
|
void SetMediumIcons();
|
|
|
|
void SetLargeIcons();
|
2017-01-28 03:20:44 +01:00
|
|
|
void TogglePartNames();
|
2017-02-04 22:14:41 +01:00
|
|
|
void ToggleDecoratedParts();
|
|
|
|
void ToggleFixedColor();
|
2016-12-20 23:46:12 +01:00
|
|
|
|
2016-12-16 18:14:19 +01:00
|
|
|
protected:
|
2016-12-20 23:46:12 +01:00
|
|
|
void SetIconSize(int Size);
|
|
|
|
|
2016-12-16 18:14:19 +01:00
|
|
|
lcPartSelectionListModel* mListModel;
|
|
|
|
lcPartSelectionFilterModel* mFilterModel;
|
|
|
|
|
|
|
|
// QSize sizeHint() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
class lcPartSelectionWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
lcPartSelectionWidget(QWidget* Parent);
|
|
|
|
|
2016-12-28 22:30:31 +01:00
|
|
|
void Redraw();
|
|
|
|
void SetDefaultPart();
|
2016-12-19 03:53:25 +01:00
|
|
|
void UpdateModels();
|
2016-12-20 23:11:19 +01:00
|
|
|
void UpdateCategories();
|
2017-02-06 18:06:52 +01:00
|
|
|
void LoadState(QSettings& Settings);
|
|
|
|
void SaveState(QSettings& Settings);
|
2016-12-19 03:53:25 +01:00
|
|
|
|
2017-02-04 22:14:41 +01:00
|
|
|
void SetColorIndex(int ColorIndex)
|
|
|
|
{
|
|
|
|
mPartsWidget->GetListModel()->SetColorIndex(ColorIndex);
|
|
|
|
}
|
|
|
|
|
2016-12-16 18:14:19 +01:00
|
|
|
protected slots:
|
2017-02-06 18:06:52 +01:00
|
|
|
void DockLocationChanged(Qt::DockWidgetArea Area);
|
2016-12-16 18:14:19 +01:00
|
|
|
void FilterChanged(const QString& Text);
|
2017-02-01 06:12:30 +01:00
|
|
|
void FilterTriggered();
|
2016-12-16 18:14:19 +01:00
|
|
|
void CategoryChanged(QTreeWidgetItem* Current, QTreeWidgetItem* Previous);
|
|
|
|
void PartChanged(const QModelIndex& Current, const QModelIndex& Previous);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void resizeEvent(QResizeEvent* Event);
|
|
|
|
|
|
|
|
QTreeWidget* mCategoriesWidget;
|
2017-02-01 06:12:30 +01:00
|
|
|
QTreeWidgetItem* mAllPartsCategoryItem;
|
2017-01-27 04:02:42 +01:00
|
|
|
QTreeWidgetItem* mCurrentModelCategoryItem;
|
2016-12-19 03:53:25 +01:00
|
|
|
QTreeWidgetItem* mModelsCategoryItem;
|
2016-12-16 18:14:19 +01:00
|
|
|
QLineEdit* mFilterWidget;
|
2017-02-01 06:12:30 +01:00
|
|
|
QAction* mFilterAction;
|
2016-12-16 18:14:19 +01:00
|
|
|
lcPartSelectionListView* mPartsWidget;
|
|
|
|
QSplitter* mSplitter;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _LC_PARTSELECTIONWIDGET_H_
|