From ecbb2579123d197d73d50c07137acbc14d4b4720 Mon Sep 17 00:00:00 2001 From: "Srivats P." Date: Sun, 1 Mar 2015 21:58:40 +0530 Subject: [PATCH] Add feature to duplicate selected streams to create user defined number of copies Fixes issue 23 --- client/icons/stream_duplicate.png | Bin 0 -> 859 bytes client/ostinato.qrc | 1 + client/port.cpp | 25 +++++++++++++++++++++++++ client/port.h | 2 ++ client/portswindow.cpp | 29 ++++++++++++++++++++++++++++- client/portswindow.h | 1 + client/portswindow.ui | 8 ++++++++ 7 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 client/icons/stream_duplicate.png diff --git a/client/icons/stream_duplicate.png b/client/icons/stream_duplicate.png new file mode 100644 index 0000000000000000000000000000000000000000..3262767cda95a217ac8d3fabf6c4bfe3514fd770 GIT binary patch literal 859 zcmV-h1El-)HU~Z@BQ7|ITsWqFPt%czwZJk^u%JZL0Ogu z7-JwwQn0tTclx3}?kvID+L{XidsxQ^&e&|W7P?hu`JbU6)Keq zD2hUaNxZkB72a$%4^2)^`UtC|A7te-nGAX1Xrjep5qO>_@7ffX%SGn`-ED7gLpU5( zk(@u5K{Og2Z)$29rKuELp-_NyIt_Job>MI~K&R7bgynLX>`sh~jA#lt3}_YQwqglZ ztJPR4mEiF3kO&v?|I7ONdO%xaZnyg`4MVH2u&{85WF^F8xkx0!oK7d7&*!07ENT-s zHZ~xYO7;1CzImGB_xm6GXq~MiVV0C|gzZGQ)-QC?rN*&h*fy7fxUu2>pgCsM)-Q?tMb$Vds z*E@*sEW?$R-d!Zlo`yI#H#gqa);3B?D6pBWXVBO67?`R6Qy3_qLZ+|_MxhlJx8`9r z{Xs@mdTouNQ0N7+J#TJqhNGh+O#w+J@OC~45~`3D2_z=L-&zrFU%dy%Qdzg0ic~cM z%s{~na19L&^isj*=4PpCtqL-e!E)J#V5X7%DWt(#}Pq3W$oGSy^Pc4j%jrk7_ z4xV5*S(C}slXQfB*Dx$m5ut)=uA6Vdoof#vmX1Pr{o_H2ueAT3P;2Ktrs3gX7h2gv zE62G1jK||?p|odbXLH|f%y4eoeRKHd`|tRw^&nXM?`u5!c)i}iTrM|2E9N*Z__gcJ lE2dmBR}@y4olxbIzJJd{=EC=vF*^VN002ovPDHLkV1lGDi4On( literal 0 HcmV?d00001 diff --git a/client/ostinato.qrc b/client/ostinato.qrc index 6162ac0..d2e81f2 100644 --- a/client/ostinato.qrc +++ b/client/ostinato.qrc @@ -33,6 +33,7 @@ icons/sound_none.png icons/stream_add.png icons/stream_delete.png + icons/stream_duplicate.png icons/stream_edit.png diff --git a/client/port.cpp b/client/port.cpp index e9e5915..e23f0ac 100644 --- a/client/port.cpp +++ b/client/port.cpp @@ -422,6 +422,31 @@ void Port::updateStats(OstProto::PortStats *portStats) } } +void Port::duplicateStreams(const QList &list, int count) +{ + QList 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; diff --git a/client/port.h b/client/port.h index 6df7a98..a0a249d 100644 --- a/client/port.h +++ b/client/port.h @@ -138,6 +138,8 @@ public: void recalculateAverageRates(); void updateStats(OstProto::PortStats *portStats); + void duplicateStreams(const QList &list, int count); + bool openStreams(QString fileName, bool append, QString &error); bool saveStreams(QString fileName, QString fileType, QString &error); diff --git a/client/portswindow.cpp b/client/portswindow.cpp index 41004c9..9fbbe67 100644 --- a/client/portswindow.cpp +++ b/client/portswindow.cpp @@ -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 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"); diff --git a/client/portswindow.h b/client/portswindow.h index 5c071f0..98338e9 100644 --- a/client/portswindow.h +++ b/client/portswindow.h @@ -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(); diff --git a/client/portswindow.ui b/client/portswindow.ui index a5d9261..d3a2c55 100644 --- a/client/portswindow.ui +++ b/client/portswindow.ui @@ -258,6 +258,14 @@ Port Configuration ... + + + :/icons/stream_duplicate.png + + + Duplicate Stream + +