* Find a suitable insertion point in a list of actions. * * @param actions a list of actions ordered by title of their associated document case-insensitively. * @param actionDocumentTitle the title of the document associated with the action to be inserted. */
| 72 | * @param actionDocumentTitle the title of the document associated with the action to be inserted. |
| 73 | */ |
| 74 | ActionInsertionPoint findActionInsertionPoint(const QList<QAction*>& actions, const QString& actionDocumentTitle) |
| 75 | { |
| 76 | const auto it = std::lower_bound( |
| 77 | actions.cbegin(), actions.cend(), actionDocumentTitle, [](const QAction* lhs, const QString& rhs) { |
| 78 | return lhs->data().value<Sublime::View*>()->document()->title().compare(rhs, Qt::CaseInsensitive) < 0; |
| 79 | }); |
| 80 | ActionInsertionPoint ret; |
| 81 | ret.next = it == actions.cend() ? nullptr : *it; |
| 82 | ret.previous = it == actions.cbegin() ? nullptr : *(it - 1); |
| 83 | return ret; |
| 84 | } |
| 85 | |
| 86 | } // namespace |
| 87 |
no test coverage detected