Skip to content
Snippets Groups Projects
Commit f802c84a authored by Raphael's avatar Raphael
Browse files

change the RobotUnitPluginWidgetController to sort the list of projects

parent e9277778
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,7 @@
#include <boost/filesystem.hpp>
#include <QDir>
#include <QSortFilterProxyModel>
#include <ArmarXCore/core/system/cmake/CMakePackageFinder.h>
#include <ArmarXCore/core/exceptions/local/ExpressionException.h>
......@@ -106,7 +107,7 @@ RobotUnitPluginWidgetController::RobotUnitPluginWidgetController()
path p = path {homeDir} / ".cmake" / "packages";
if (is_directory(p))
{
for (const path & entry : boost::make_iterator_range(directory_iterator(p), {}))
for (const path& entry : boost::make_iterator_range(directory_iterator(p), {}))
{
const std::string pkg = entry.filename().string();
if (CMakePackageFinder {pkg, "", true} .packageFound())
......@@ -114,6 +115,14 @@ RobotUnitPluginWidgetController::RobotUnitPluginWidgetController()
widget.comboBoxPackage->addItem(QString::fromStdString(pkg));
}
}
// for sorting you need the following 4 lines
QSortFilterProxyModel* proxy = new QSortFilterProxyModel(widget.comboBoxPackage);
proxy->setSourceModel(widget.comboBoxPackage->model());
// combo's current model must be reparented,
// otherwise QComboBox::setModel() will delete it
widget.comboBoxPackage->model()->setParent(proxy);
widget.comboBoxPackage->setModel(proxy);
widget.comboBoxPackage->model()->sort(0);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment