Add feature to duplicate selected streams to create user defined number of copies
Fixes issue 23
This commit is contained in:
parent
e3e61b7320
commit
ecbb257912
BIN
client/icons/stream_duplicate.png
Normal file
BIN
client/icons/stream_duplicate.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 859 B |
@ -33,6 +33,7 @@
|
||||
<file>icons/sound_none.png</file>
|
||||
<file>icons/stream_add.png</file>
|
||||
<file>icons/stream_delete.png</file>
|
||||
<file>icons/stream_duplicate.png</file>
|
||||
<file>icons/stream_edit.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -422,6 +422,31 @@ void Port::updateStats(OstProto::PortStats *portStats)
|
||||
}
|
||||
}
|
||||
|
||||
void Port::duplicateStreams(const QList<int> &list, int count)
|
||||
{
|
||||
QList<OstProto::Stream> sources;
|
||||
foreach(int index, list) {
|
||||
OstProto::Stream stream;
|
||||
Q_ASSERT(index < mStreams.size());
|
||||
mStreams.at(index)->protoDataCopyInto(stream);
|
||||
sources.append(stream);
|
||||
}
|
||||
|
||||
int insertAt = mStreams.size();
|
||||
for (int i=0; i < count; i++) {
|
||||
for (int j=0; j < sources.size(); j++) {
|
||||
newStreamAt(insertAt, &sources.at(j));
|
||||
// Rename stream by appending the copy count
|
||||
mStreams.at(insertAt)->setName(QString("%1 (%2)")
|
||||
.arg(mStreams.at(insertAt)->name())
|
||||
.arg(i+1));
|
||||
insertAt++;
|
||||
}
|
||||
}
|
||||
|
||||
emit streamListChanged(mPortGroupId, mPortId);
|
||||
}
|
||||
|
||||
bool Port::openStreams(QString fileName, bool append, QString &error)
|
||||
{
|
||||
bool ret = false;
|
||||
|
@ -138,6 +138,8 @@ public:
|
||||
void recalculateAverageRates();
|
||||
void updateStats(OstProto::PortStats *portStats);
|
||||
|
||||
void duplicateStreams(const QList<int> &list, int count);
|
||||
|
||||
bool openStreams(QString fileName, bool append, QString &error);
|
||||
bool saveStreams(QString fileName, QString fileType, QString &error);
|
||||
|
||||
|
@ -60,6 +60,7 @@ PortsWindow::PortsWindow(PortGroupList *pgl, QWidget *parent)
|
||||
// Populate StramList Context Menu Actions
|
||||
tvStreamList->addAction(actionNew_Stream);
|
||||
tvStreamList->addAction(actionEdit_Stream);
|
||||
tvStreamList->addAction(actionDuplicate_Stream);
|
||||
tvStreamList->addAction(actionDelete_Stream);
|
||||
|
||||
sep = new QAction(this);
|
||||
@ -280,7 +281,8 @@ void PortsWindow::updateStreamViewActions()
|
||||
actionEdit_Stream->setEnabled(true);
|
||||
}
|
||||
|
||||
// Delete is always enabled as long as we have a selection
|
||||
// Duplicate/Delete are always enabled as long as we have a selection
|
||||
actionDuplicate_Stream->setEnabled(true);
|
||||
actionDelete_Stream->setEnabled(true);
|
||||
}
|
||||
else
|
||||
@ -291,6 +293,7 @@ void PortsWindow::updateStreamViewActions()
|
||||
else
|
||||
actionNew_Stream->setDisabled(true);
|
||||
actionEdit_Stream->setDisabled(true);
|
||||
actionDuplicate_Stream->setDisabled(true);
|
||||
actionDelete_Stream->setDisabled(true);
|
||||
}
|
||||
actionOpen_Streams->setEnabled(plm->isPort(
|
||||
@ -525,6 +528,30 @@ void PortsWindow::on_actionEdit_Stream_triggered()
|
||||
}
|
||||
}
|
||||
|
||||
void PortsWindow::on_actionDuplicate_Stream_triggered()
|
||||
{
|
||||
QItemSelectionModel* model = tvStreamList->selectionModel();
|
||||
QModelIndex current = tvPortList->selectionModel()->currentIndex();
|
||||
qDebug("Duplicate Stream Action");
|
||||
|
||||
if (model->hasSelection())
|
||||
{
|
||||
bool isOk;
|
||||
int count = QInputDialog::getInteger(this, "Duplicate Streams",
|
||||
"Count", 1, 1, 9999, 1, &isOk);
|
||||
|
||||
if (!isOk)
|
||||
return;
|
||||
|
||||
QList<int> list;
|
||||
foreach(QModelIndex index, model->selectedRows())
|
||||
list.append(index.row());
|
||||
plm->port(current).duplicateStreams(list, count);
|
||||
}
|
||||
else
|
||||
qDebug("No selection");
|
||||
}
|
||||
|
||||
void PortsWindow::on_actionDelete_Stream_triggered()
|
||||
{
|
||||
qDebug("Delete Stream Action");
|
||||
|
@ -74,6 +74,7 @@ private slots:
|
||||
|
||||
void on_actionNew_Stream_triggered();
|
||||
void on_actionEdit_Stream_triggered();
|
||||
void on_actionDuplicate_Stream_triggered();
|
||||
void on_actionDelete_Stream_triggered();
|
||||
|
||||
void on_actionOpen_Streams_triggered();
|
||||
|
@ -258,6 +258,14 @@
|
||||
<string>Port Configuration ...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDuplicate_Stream" >
|
||||
<property name="icon" >
|
||||
<iconset resource="ostinato.qrc" >:/icons/stream_duplicate.png</iconset>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Duplicate Stream</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="ostinato.qrc" />
|
||||
|
Loading…
Reference in New Issue
Block a user