Added category with parts in the current model.
This commit is contained in:
@@ -145,6 +145,24 @@ void lcPartSelectionListModel::SetModelsCategory()
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void lcPartSelectionListModel::SetCurrentModelCategory()
|
||||
{
|
||||
ClearRequests();
|
||||
|
||||
beginResetModel();
|
||||
|
||||
mParts.clear();
|
||||
|
||||
lcModel* CurrentModel = lcGetActiveModel();
|
||||
lcPartsList PartsList;
|
||||
CurrentModel->GetPartsList(gDefaultColor, PartsList);
|
||||
|
||||
for (lcPartsList::const_iterator PartIt = PartsList.constBegin(); PartIt != PartsList.constEnd(); PartIt++)
|
||||
mParts.append(QPair<PieceInfo*, QPixmap>((PieceInfo*)PartIt.key(), QPixmap()));
|
||||
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
int lcPartSelectionListModel::rowCount(const QModelIndex& Parent) const
|
||||
{
|
||||
Q_UNUSED(Parent);
|
||||
@@ -468,11 +486,14 @@ void lcPartSelectionWidget::FilterChanged(const QString& Text)
|
||||
void lcPartSelectionWidget::CategoryChanged(QTreeWidgetItem* Current, QTreeWidgetItem* Previous)
|
||||
{
|
||||
Q_UNUSED(Previous);
|
||||
lcPartSelectionListModel* ListModel = mPartsWidget->GetListModel();
|
||||
|
||||
if (Current != mModelsCategoryItem)
|
||||
mPartsWidget->GetListModel()->SetCategory(mCategoriesWidget->indexOfTopLevelItem(Current));
|
||||
if (Current == mModelsCategoryItem)
|
||||
ListModel->SetModelsCategory();
|
||||
else if (Current == mCurrentModelCategoryItem)
|
||||
ListModel->SetCurrentModelCategory();
|
||||
else
|
||||
mPartsWidget->GetListModel()->SetModelsCategory();
|
||||
ListModel->SetCategory(mCategoriesWidget->indexOfTopLevelItem(Current));
|
||||
|
||||
mPartsWidget->setCurrentIndex(mPartsWidget->GetFilterModel()->index(0, 0));
|
||||
}
|
||||
@@ -506,12 +527,18 @@ void lcPartSelectionWidget::SetDefaultPart()
|
||||
|
||||
void lcPartSelectionWidget::UpdateCategories()
|
||||
{
|
||||
int CurrentIndex = mCategoriesWidget->indexOfTopLevelItem(mCategoriesWidget->currentItem());
|
||||
|
||||
mCategoriesWidget->clear();
|
||||
|
||||
for (int CategoryIdx = 0; CategoryIdx < gCategories.GetSize(); CategoryIdx++)
|
||||
new QTreeWidgetItem(mCategoriesWidget, QStringList((const char*)gCategories[CategoryIdx].Name));
|
||||
|
||||
mCurrentModelCategoryItem = new QTreeWidgetItem(mCategoriesWidget, QStringList(tr("Current Model")));
|
||||
mModelsCategoryItem = new QTreeWidgetItem(mCategoriesWidget, QStringList(tr("Models")));
|
||||
|
||||
if (CurrentIndex != -1)
|
||||
mCategoriesWidget->setCurrentItem(mCategoriesWidget->topLevelItem(CurrentIndex));
|
||||
}
|
||||
|
||||
void lcPartSelectionWidget::UpdateModels()
|
||||
|
||||
@@ -63,6 +63,7 @@ public:
|
||||
void Redraw();
|
||||
void SetCategory(int CategoryIndex);
|
||||
void SetModelsCategory();
|
||||
void SetCurrentModelCategory();
|
||||
void RequestPreview(int InfoIndex);
|
||||
void SetIconSize(int Size);
|
||||
|
||||
@@ -140,6 +141,7 @@ protected:
|
||||
virtual void resizeEvent(QResizeEvent* Event);
|
||||
|
||||
QTreeWidget* mCategoriesWidget;
|
||||
QTreeWidgetItem* mCurrentModelCategoryItem;
|
||||
QTreeWidgetItem* mModelsCategoryItem;
|
||||
QLineEdit* mFilterWidget;
|
||||
lcPartSelectionListView* mPartsWidget;
|
||||
|
||||
+5
-5
@@ -944,7 +944,7 @@ void Project::ExportBrickLink()
|
||||
|
||||
BrickLinkFile.WriteLine("<INVENTORY>\n");
|
||||
|
||||
for (QMap<const PieceInfo*, QMap<int, int>>::const_iterator PartIt = PartsList.constBegin(); PartIt != PartsList.constEnd(); PartIt++)
|
||||
for (lcPartsList::const_iterator PartIt = PartsList.constBegin(); PartIt != PartsList.constEnd(); PartIt++)
|
||||
{
|
||||
const PieceInfo* Info = PartIt.key();
|
||||
|
||||
@@ -1006,7 +1006,7 @@ void Project::ExportCSV()
|
||||
|
||||
CSVFile.WriteLine("Part Name,Color,Quantity,Part ID,Color Code\n");
|
||||
|
||||
for (QMap<const PieceInfo*, QMap<int, int>>::const_iterator PartIt = PartsList.constBegin(); PartIt != PartsList.constEnd(); PartIt++)
|
||||
for (lcPartsList::const_iterator PartIt = PartsList.constBegin(); PartIt != PartsList.constEnd(); PartIt++)
|
||||
{
|
||||
const PieceInfo* Info = PartIt.key();
|
||||
|
||||
@@ -1031,7 +1031,7 @@ void Project::CreateHTMLPieceList(QTextStream& Stream, lcModel* Model, lcStep St
|
||||
else
|
||||
Model->GetPartsListForStep(Step, gDefaultColor, PartsList);
|
||||
|
||||
for (QMap<const PieceInfo*, QMap<int, int>>::const_iterator PartIt = PartsList.constBegin(); PartIt != PartsList.constEnd(); PartIt++)
|
||||
for (lcPartsList::const_iterator PartIt = PartsList.constBegin(); PartIt != PartsList.constEnd(); PartIt++)
|
||||
for (QMap<int, int>::const_iterator ColorIt = PartIt.value().constBegin(); ColorIt != PartIt.value().constEnd(); ColorIt++)
|
||||
ColorsUsed[ColorIt.key()]++;
|
||||
|
||||
@@ -1048,7 +1048,7 @@ void Project::CreateHTMLPieceList(QTextStream& Stream, lcModel* Model, lcStep St
|
||||
NumColors++;
|
||||
Stream << QLatin1String("</tr>\n");
|
||||
|
||||
for (QMap<const PieceInfo*, QMap<int, int>>::const_iterator PartIt = PartsList.constBegin(); PartIt != PartsList.constEnd(); PartIt++)
|
||||
for (lcPartsList::const_iterator PartIt = PartsList.constBegin(); PartIt != PartsList.constEnd(); PartIt++)
|
||||
{
|
||||
const PieceInfo* Info = PartIt.key();
|
||||
|
||||
@@ -1316,7 +1316,7 @@ void Project::ExportHTML()
|
||||
Context->SetProjectionMatrix(ProjectionMatrix);
|
||||
Context->SetProgram(LC_PROGRAM_SIMPLE);
|
||||
|
||||
for (QMap<const PieceInfo*, QMap<int, int>>::const_iterator PartIt = PartsList.constBegin(); PartIt != PartsList.constEnd(); PartIt++)
|
||||
for (lcPartsList::const_iterator PartIt = PartsList.constBegin(); PartIt != PartsList.constEnd(); PartIt++)
|
||||
{
|
||||
const PieceInfo* Info = PartIt.key();
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ lcQPropertiesDialog::lcQPropertiesDialog(QWidget *parent, void *data) :
|
||||
|
||||
QVector<bool> ColorsUsed(gNumUserColors);
|
||||
|
||||
for (QMap<const PieceInfo*, QMap<int, int>>::const_iterator PartIt = PartsList.constBegin(); PartIt != PartsList.constEnd(); PartIt++)
|
||||
for (lcPartsList::const_iterator PartIt = PartsList.constBegin(); PartIt != PartsList.constEnd(); PartIt++)
|
||||
for (QMap<int, int>::const_iterator ColorIt = PartIt.value().constBegin(); ColorIt != PartIt.value().constEnd(); ColorIt++)
|
||||
ColorsUsed[ColorIt.key()] = true;
|
||||
|
||||
@@ -94,7 +94,7 @@ lcQPropertiesDialog::lcQPropertiesDialog(QWidget *parent, void *data) :
|
||||
QVector<int> ColorTotals(NumColors);
|
||||
int Row = 0, Total = 0;
|
||||
|
||||
for (QMap<const PieceInfo*, QMap<int, int>>::const_iterator PartIt = PartsList.constBegin(); PartIt != PartsList.constEnd(); PartIt++, Row++)
|
||||
for (lcPartsList::const_iterator PartIt = PartsList.constBegin(); PartIt != PartsList.constEnd(); PartIt++, Row++)
|
||||
{
|
||||
table->setItem(Row, 0, new QTableWidgetItem(PartIt.key()->m_strDescription));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user