OGS
Utils Namespace Reference

Functions

std::vector< std::string > getSelectedObjects (QStringList const &list)
 
void moveSelectedItems (QListView *sourceView, QStringListModel &sourceModel, QStringListModel &targetModel)
 

Function Documentation

◆ getSelectedObjects()

std::vector< std::string > Utils::getSelectedObjects ( QStringList const & list)

Definition at line 15 of file Utils.cpp.

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}

Referenced by AddFaultsToVoxelGridDialog::accept(), GMSHPrefsDialog::accept(), Layers2GridDialog::accept(), TranslateDataDialog::accept(), and Layers2GridDialog::updateExpectedVoxel().

◆ moveSelectedItems()

void Utils::moveSelectedItems ( QListView * sourceView,
QStringListModel & sourceModel,
QStringListModel & targetModel )

Definition at line 23 of file Utils.cpp.

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}

Referenced by AddFaultsToVoxelGridDialog::on_deselectDataButton_pressed(), TranslateDataDialog::on_deselectDataButton_pressed(), AddFaultsToVoxelGridDialog::on_selectDataButton_pressed(), and TranslateDataDialog::on_selectDataButton_pressed().