Skip to content

Commit

Permalink
Fix editing multiple items
Browse files Browse the repository at this point in the history
Fixes #2810
  • Loading branch information
hluk committed Aug 22, 2024
1 parent e54d698 commit 1ddd986
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/gui/clipboardbrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,7 @@ void ClipboardBrowser::setCurrent(int row, bool keepSelection, bool setCurrentOn
void ClipboardBrowser::editSelected()
{
if ( selectedIndexes().size() > 1 ) {
editNew( selectedText() );
editNew( mimeText, selectedText().toUtf8() );
} else {
QModelIndex ind = currentIndex();
if ( ind.isValid() ) {
Expand Down
2 changes: 1 addition & 1 deletion src/gui/clipboardbrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class ClipboardBrowser final : public QListView
* Create and edit new item.
*/
void editNew(
const QString &format, const QByteArray &content = {}, bool changeClipboard = false);
const QString &format, const QByteArray &content, bool changeClipboard = false);

/** Edit item in given @a row. */
void editRow(int row, const QString &format);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3790,7 +3790,7 @@ void MainWindow::editNewItem()
showWindow();
if ( !c->isInternalEditorOpen() ) {
c->setFocus();
c->editNew(mimeText);
c->editNew(mimeText, {});
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/tests/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2796,6 +2796,14 @@ void Tests::editItems()
<< editorId << "HOME" << ":Line 3" << "ENTER" << "F2", "");
RUN("read" << "1", "Line 3\nLine 4");
RUN("read" << "0", "Line 1\nLine 2");

// Edit multiple items
RUN("keys"
<< clipboardBrowserId << "SHIFT+UP" << "F2"
<< editorId << "END" << "ENTER" << ":Line 5" << "F2", "");
RUN("read" << "0", "Line 3\nLine 4\nLine 1\nLine 2\nLine 5");
RUN("read" << "1", "Line 1\nLine 2");
RUN("read" << "2", "Line 3\nLine 4");
}

void Tests::createNewItem()
Expand Down

0 comments on commit 1ddd986

Please sign in to comment.