--- a/src/mainWindow.cc Tue Jun 03 20:28:10 2014 +0300 +++ b/src/mainWindow.cc Wed Jun 04 01:43:21 2014 +0300 @@ -48,6 +48,7 @@ #include "messageLog.h" #include "configuration.h" #include "ui_ldforge.h" +#include "primitives.h" static bool g_isSelectionLocked = false; @@ -84,6 +85,11 @@ connect (ui->objectList, SIGNAL (itemDoubleClicked (QListWidgetItem*)), this, SLOT (slot_editObject (QListWidgetItem*))); connect (m_tabs, SIGNAL (currentChanged(int)), this, SLOT (changeCurrentFile())); + if (getActivePrimitiveScanner() != null) + connect (getActivePrimitiveScanner(), SIGNAL (workDone()), this, SLOT (updatePrimitives())); + else + updatePrimitives(); + m_msglog = new MessageManager; m_msglog->setRenderer (R()); m_renderer->setMessageLog (m_msglog); @@ -991,6 +997,13 @@ // ============================================================================= // +void MainWindow::updatePrimitives() +{ + populatePrimitives (ui->primitives); +} + +// ============================================================================= +// QImage imageFromScreencap (uchar* data, int w, int h) { // GL and Qt formats have R and B swapped. Also, GL flips Y - correct it as well. @@ -1016,3 +1029,29 @@ { return color() == null; } + +void populatePrimitives (QTreeWidget* tw, QString const& selectByDefault) +{ + tw->clear(); + + for (PrimitiveCategory* cat : g_PrimitiveCategories) + { + SubfileListItem* parentItem = new SubfileListItem (tw, null); + parentItem->setText (0, cat->name()); + QList<QTreeWidgetItem*> subfileItems; + + for (Primitive& prim : cat->prims) + { + SubfileListItem* item = new SubfileListItem (parentItem, &prim); + item->setText (0, format ("%1 - %2", prim.name, prim.title)); + subfileItems << item; + + // If this primitive is the one the current object points to, + // select it by default + if (selectByDefault == prim.name) + tw->setCurrentItem (item); + } + + tw->addTopLevelItem (parentItem); + } +}