Skip to content

Commit

Permalink
DRY
Browse files Browse the repository at this point in the history
  • Loading branch information
gvnnz committed May 15, 2024
1 parent 2bd7c2f commit 2fea159
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/gui/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,23 +229,25 @@ void Model::moveChannel(ID channelId, std::size_t newColumnIndex, int newPositio

void Model::addChannelToColumn(ID channelId, std::size_t columnIndex, int position)
{
Column& column = getColumnByIndex(columnIndex);
Column& column = getColumnByIndex(columnIndex);
Channel channel = {channelId, /*groupId=*/0, columnIndex};
if (position == -1)
column.add({channelId, /*groupId=*/0, columnIndex});
column.add(std::move(channel));
else
column.insert({channelId, /*groupId=*/0, columnIndex}, position);
column.insert(std::move(channel), position);
}

/* -------------------------------------------------------------------------- */

void Model::addChannelToGroup(ID channelId, ID groupId, int position)
{
Column& column = getColumnByChannelId(groupId);
Channel& group = column.getById(groupId);
Column& column = getColumnByChannelId(groupId);
Channel& group = column.getById(groupId);
Channel channel = {channelId, groupId, column.index};
if (position == -1)
group.add({channelId, groupId, column.index});
group.add(std::move(channel));
else
group.insert({channelId, groupId, column.index}, position);
group.insert(std::move(channel), position);
}

/* -------------------------------------------------------------------------- */
Expand Down

0 comments on commit 2fea159

Please sign in to comment.