OGS
Utils.cpp
Go to the documentation of this file.
1
11#include "Base/Utils.h"
12
13namespace Utils
14{
15std::vector<std::string> getSelectedObjects(QStringList const& list)
16{
17 std::vector<std::string> indexList;
18 std::transform(list.begin(), list.end(), std::back_inserter(indexList),
19 [](auto const& index) { return index.toStdString(); });
20 return indexList;
21}
22
23void moveSelectedItems(QListView* sourceView,
24 QStringListModel& sourceModel,
25 QStringListModel& targetModel)
26{
27 QModelIndexList selected = sourceView->selectionModel()->selectedIndexes();
28 QStringList targetList = targetModel.stringList();
29
30 for (const auto& index : selected)
31 {
32 targetList.append(index.data().toString());
33 sourceModel.removeRow(index.row());
34 }
35
36 targetModel.setStringList(targetList);
37}
38} // namespace Utils
std::vector< std::string > getSelectedObjects(QStringList const &list)
Definition Utils.cpp:15
void moveSelectedItems(QListView *sourceView, QStringListModel &sourceModel, QStringListModel &targetModel)
Definition Utils.cpp:23