示例#1
0
int BookViewPreview::GetSelectionOffset(const QMap<int, QString> &node_offsets,
                                        Searchable::Direction search_direction)
{
    QList<ViewEditor::ElementIndex> cl = GetCaretLocation();
    // remove final #text node if it exists
    if (cl.at(cl.count()-1).name == "#text") {
        cl.removeLast();
    }
    QString caret_node = ConvertHierarchyToQWebPath(cl);
    bool searching_down = search_direction == Searchable::Direction_Down ? true : false;
    int local_offset    = GetLocalSelectionOffset(!searching_down);
    int search_start    = node_offsets.key(caret_node) + local_offset;
    return search_start;
}
示例#2
0
int BookViewPreview::GetSelectionOffset(const QMap<int, QString> &node_offsets,
                                        Searchable::Direction search_direction)
{
    QList<ViewEditor::ElementIndex> cl = GetCaretLocation();
    // remove final #text node if it exists
    // Some BookView tabs with only SVG images report a cl.count of 0
    // meaning there is no cursor, so test for that case
    if ((cl.count() > 0) && (cl.at(cl.count()-1).name == "#text")) {
        cl.removeLast();
    }
    QString caret_node = ConvertHierarchyToQWebPath(cl);
    bool searching_down = search_direction == Searchable::Direction_Down ? true : false;
    int local_offset    = GetLocalSelectionOffset(!searching_down);
    int search_start    = node_offsets.key(caret_node) + local_offset;
    return search_start;
}