Fix build on macOS and Linux.

This commit is contained in:
John Preston 2019-04-09 15:17:29 +04:00
parent b5be6df5e2
commit fe3181649b
7 changed files with 14 additions and 12 deletions

View file

@ -903,7 +903,7 @@ void InnerWidget::keyPressEvent(QKeyEvent *e) {
copySelectedText();
#ifdef Q_OS_MAC
} else if (e->key() == Qt::Key_E && e->modifiers().testFlag(Qt::ControlModifier)) {
SetClipboardWithEntities(getSelectedText(), QClipboard::FindBuffer);
SetClipboardText(getSelectedText(), QClipboard::FindBuffer);
#endif // Q_OS_MAC
} else {
e->ignore();
@ -1394,7 +1394,7 @@ void InnerWidget::mouseActionFinish(const QPoint &screenPos, Qt::MouseButton but
#if defined Q_OS_LINUX32 || defined Q_OS_LINUX64
if (_selectedItem && _selectedText.from != _selectedText.to) {
SetClipboardWithEntities(
SetClipboardText(
_selectedItem->selectedText(_selectedText),
QClipboard::Selection);
}

View file

@ -1380,7 +1380,7 @@ void HistoryInner::mouseActionFinish(
if (!_selected.empty() && _selected.cbegin()->second != FullSelection) {
const auto [item, selection] = *_selected.cbegin();
if (const auto view = item->mainView()) {
SetClipboardWithEntities(
SetClipboardText(
view->selectedText(selection),
QClipboard::Selection);
}
@ -1959,7 +1959,7 @@ void HistoryInner::keyPressEvent(QKeyEvent *e) {
#ifdef Q_OS_MAC
} else if (e->key() == Qt::Key_E
&& e->modifiers().testFlag(Qt::ControlModifier)) {
SetClipboardWithEntities(getSelectedText(), QClipboard::FindBuffer);
SetClipboardText(getSelectedText(), QClipboard::FindBuffer);
#endif // Q_OS_MAC
} else if (e == QKeySequence::Delete) {
auto selectedState = getSelectionState();

View file

@ -2035,7 +2035,7 @@ void ListWidget::mouseActionFinish(
if (_selectedTextItem
&& _selectedTextRange.from != _selectedTextRange.to) {
if (const auto view = viewForItem(_selectedTextItem)) {
SetClipboardWithEntities(
SetClipboardText(
view->selectedText(_selectedTextRange),
QClipboard::Selection);
}

View file

@ -2031,7 +2031,7 @@ void ListWidget::mouseActionFinish(
#if defined Q_OS_LINUX32 || defined Q_OS_LINUX64
//if (hasSelectedText()) { // #TODO linux clipboard
// SetClipboardWithEntities(_selected.cbegin()->first->selectedText(_selected.cbegin()->second), QClipboard::Selection);
// SetClipboardText(_selected.cbegin()->first->selectedText(_selected.cbegin()->second), QClipboard::Selection);
//}
#endif // Q_OS_LINUX32 || Q_OS_LINUX64
}

View file

@ -2007,8 +2007,9 @@ EntityInText::EntityInText(
int EntityInText::FirstMonospaceOffset(
const EntitiesInText &entities,
int textLength) {
auto &&monospace = ranges::view::all(
entities
auto &&monospace = ranges::make_iterator_range(
entities.begin(),
entities.end()
) | ranges::view::filter([](const EntityInText & entity) {
return (entity.type() == EntityType::Pre)
|| (entity.type() == EntityType::Code);

View file

@ -762,8 +762,9 @@ struct FormattingAction {
QString ExpandCustomLinks(const TextWithTags &text) {
const auto entities = ConvertTextTagsToEntities(text.tags);
auto &&urls = ranges::view::all(
entities
auto &&urls = ranges::make_iterator_range(
entities.begin(),
entities.end()
) | ranges::view::filter([](const EntityInText &entity) {
return entity.type() == EntityType::CustomUrl;
});

View file

@ -363,7 +363,7 @@ Text::StateResult FlatLabel::dragActionFinish(const QPoint &p, Qt::MouseButton b
#if defined Q_OS_LINUX32 || defined Q_OS_LINUX64
if (!_selection.empty()) {
QApplication::clipboard()->setText(_text.originalText(_selection, ExpandLinksAll), QClipboard::Selection);
SetClipboardText(_text.toTextForMimeData(_selection), QClipboard::Selection);
}
#endif // Q_OS_LINUX32 || Q_OS_LINUX64
@ -434,7 +434,7 @@ void FlatLabel::keyPressEvent(QKeyEvent *e) {
} else if (e->key() == Qt::Key_E && e->modifiers().testFlag(Qt::ControlModifier)) {
auto selection = _selection.empty() ? (_contextMenu ? _savedSelection : _selection) : _selection;
if (!selection.empty()) {
QApplication::clipboard()->setText(_text.originalText(selection, ExpandLinksAll), QClipboard::FindBuffer);
SetClipboardText(_text.toTextForMimeData(selection), QClipboard::FindBuffer);
}
#endif // Q_OS_MAC
}