本文整理汇总了C++中QDocumentCursor::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ QDocumentCursor::isValid方法的具体用法?C++ QDocumentCursor::isValid怎么用?C++ QDocumentCursor::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDocumentCursor
的用法示例。
在下文中一共展示了QDocumentCursor::isValid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: back
QDocumentCursor CursorHistory::back(const QDocumentCursor ¤tCursor) {
if (currentEntry == history.begin()) {
updateNavActions();
return QDocumentCursor();
}
// insert currentCursor to be able to go back
if (currentCursor.isValid() && insertPos(currentCursor, false)) {
currentEntry--;
}
CursorPosition pos(currentCursor);
if (pos.isValid() && !pos.equals(*currentEntry)) {
updateNavActions();
return currentPos();
}
currentEntry = prevValidEntry(currentEntry);
updateNavActions();
return currentPos();
}
示例2: insertPos
/*!
Inserts the cursor behind the current entry
*/
bool CursorHistory::insertPos(QDocumentCursor cur, bool deleteBehindCurrent) {
if (!m_insertionEnabled) return false;
if (!cur.isValid()) return false;
CursorPosition pos(cur);
connectUnique(pos.doc(), SIGNAL(destroyed(QObject*)), this, SLOT(documentClosed(QObject*)));
// TODO destroyed() may be duplicate to aboutToDeleteDocument() - needs more testing. anyway it does not harm
connectUnique(pos.doc(), SIGNAL(lineDeleted(QDocumentLineHandle*)), this, SLOT(lineDeleted(QDocumentLineHandle*)));
connectUnique(pos.doc(), SIGNAL(lineRemoved(QDocumentLineHandle*)), this, SLOT(lineDeleted(QDocumentLineHandle*)));
if (deleteBehindCurrent && currentEntry != history.end()) {
currentEntry++;
currentEntry = history.erase(currentEntry, history.end());
}
if (currentEntry == history.end() && currentEntry != history.begin()) currentEntry--;
// do not insert neighboring duplicates
if (currentEntryValid() && (*currentEntry).equals(pos)) {
updateNavActions();
return false;
}
CursorPosList::iterator it = prevValidEntry(currentEntry);
if (it != history.end() && (*it).isValid() && (*it).equals(pos)) {
updateNavActions();
return false;
}
if (history.count() >= m_maxLength) {
if (currentEntry == history.begin()) {
history.removeLast();
} else {
history.removeFirst();
}
}
currentEntry++;
history.insert(currentEntry, pos);
updateNavActions();
return true;
}