Skip to content

Commit

Permalink
Fix sorting menu actions
Browse files Browse the repository at this point in the history
Fixes #2267
  • Loading branch information
hluk committed Feb 20, 2023
1 parent 02f5189 commit bcd05c9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/item/clipboardmodel.cpp
Expand Up @@ -202,6 +202,7 @@ void ClipboardModel::sortItems(const QModelIndexList &indexList, CompareItems *c
{
QList<QPersistentModelIndex> list = validIndeces(indexList);
std::sort( list.begin(), list.end(), compare );
sortItems(list);
}

void ClipboardModel::sortItems(const QList<QPersistentModelIndex> &sorted)
Expand Down
27 changes: 27 additions & 0 deletions src/tests/tests.cpp
Expand Up @@ -2621,6 +2621,33 @@ void Tests::selectAndCopyOrder()
WAIT_ON_OUTPUT("clipboard", "D\nC\nB\nA");
}

void Tests::sortAndReverse()
{
const auto tab = testTab(1);
const Args args = Args("tab") << tab << "separator" << " ";
RUN(args << "add" << "D" << "A" << "C" << "B", "");
RUN("setCurrentTab" << tab, "");

RUN("keys" << "CTRL+A", "");
RUN(args << "testSelected", tab + " 0 0 1 2 3\n");

RUN("keys" << "CTRL+SHIFT+S", "");
RUN(args << "read" << "0" << "1" << "2" << "3" << "4", "A B C D ");
RUN(args << "testSelected", tab + " 1 0 1 2 3\n");
RUN("keys" << keyNameFor(QKeySequence::Copy), "");
WAIT_ON_OUTPUT("clipboard", "A\nB\nC\nD");

RUN("keys" << "CTRL+SHIFT+R", "");
RUN(args << "read" << "0" << "1" << "2" << "3" << "4", "D C B A ");
RUN(args << "testSelected", tab + " 2 0 1 2 3\n");
RUN("keys" << keyNameFor(QKeySequence::Copy), "");
WAIT_ON_OUTPUT("clipboard", "D\nC\nB\nA");

RUN("keys" << "CTRL+SHIFT+R", "");
RUN(args << "read" << "0" << "1" << "2" << "3" << "4", "A B C D ");
RUN(args << "testSelected", tab + " 1 0 1 2 3\n");
}

void Tests::createTabDialog()
{
const auto tab1 = testTab(1);
Expand Down
2 changes: 2 additions & 0 deletions src/tests/tests.h
Expand Up @@ -162,6 +162,8 @@ private slots:
void copyItems();
void selectAndCopyOrder();

void sortAndReverse();

void createTabDialog();

void copyPasteCommands();
Expand Down

0 comments on commit bcd05c9

Please sign in to comment.