OGS
Applications/DataExplorer/Base/Utils.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#include "Base/Utils.h"
5
6namespace Utils
7{
8std::vector<std::string> getSelectedObjects(QStringList const& list)
9{
10 std::vector<std::string> indexList;
11 std::transform(list.begin(), list.end(), std::back_inserter(indexList),
12 [](auto const& index) { return index.toStdString(); });
13 return indexList;
14}
15
16void moveSelectedItems(QListView* sourceView,
17 QStringListModel& sourceModel,
18 QStringListModel& targetModel)
19{
20 QModelIndexList selected = sourceView->selectionModel()->selectedIndexes();
21 QStringList targetList = targetModel.stringList();
22
23 for (const auto& index : selected)
24 {
25 targetList.append(index.data().toString());
26 sourceModel.removeRow(index.row());
27 }
28
29 targetModel.setStringList(targetList);
30}
31} // namespace Utils
std::vector< std::string > getSelectedObjects(QStringList const &list)
void moveSelectedItems(QListView *sourceView, QStringListModel &sourceModel, QStringListModel &targetModel)