mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
fix tab order and TOC level in edit mode
1. Fix tab order of left and right corner widgets; 2. Insert [EMPTY] header when header level is not continuous in edit mode.
This commit is contained in:
parent
b0d3e42647
commit
584472f902
@ -423,7 +423,7 @@ void VEditTab::parseTocLi(QXmlStreamReader &xml, QVector<VHeader> &headers, int
|
||||
}
|
||||
} else if (xml.name() == "ul") {
|
||||
// Such as header 3 under header 1 directly
|
||||
VHeader header(level, "[Empty]", "#", -1);
|
||||
VHeader header(level, "[EMPTY]", "#", -1);
|
||||
headers.append(header);
|
||||
parseTocUl(xml, headers, level + 1);
|
||||
} else {
|
||||
|
@ -61,6 +61,19 @@ void VEditWindow::initTabActions()
|
||||
|
||||
void VEditWindow::setupCornerWidget()
|
||||
{
|
||||
// Left corner button
|
||||
tabListAct = new QActionGroup(this);
|
||||
connect(tabListAct, &QActionGroup::triggered,
|
||||
this, &VEditWindow::tabListJump);
|
||||
leftBtn = new QPushButton(QIcon(":/resources/icons/corner_tablist.svg"),
|
||||
"", this);
|
||||
leftBtn->setProperty("CornerBtn", true);
|
||||
QMenu *leftMenu = new QMenu(this);
|
||||
leftBtn->setMenu(leftMenu);
|
||||
setCornerWidget(leftBtn, Qt::TopLeftCorner);
|
||||
connect(leftMenu, &QMenu::aboutToShow,
|
||||
this, &VEditWindow::updateTabListMenu);
|
||||
|
||||
// Right corner button
|
||||
// Actions
|
||||
splitAct = new QAction(QIcon(":/resources/icons/split_window.svg"),
|
||||
@ -85,19 +98,6 @@ void VEditWindow::setupCornerWidget()
|
||||
setCornerWidget(rightBtn, Qt::TopRightCorner);
|
||||
connect(rightMenu, &QMenu::aboutToShow,
|
||||
this, &VEditWindow::updateSplitMenu);
|
||||
|
||||
// Left corner button
|
||||
tabListAct = new QActionGroup(this);
|
||||
connect(tabListAct, &QActionGroup::triggered,
|
||||
this, &VEditWindow::tabListJump);
|
||||
leftBtn = new QPushButton(QIcon(":/resources/icons/corner_tablist.svg"),
|
||||
"", this);
|
||||
leftBtn->setProperty("CornerBtn", true);
|
||||
QMenu *leftMenu = new QMenu(this);
|
||||
leftBtn->setMenu(leftMenu);
|
||||
setCornerWidget(leftBtn, Qt::TopLeftCorner);
|
||||
connect(leftMenu, &QMenu::aboutToShow,
|
||||
this, &VEditWindow::updateTabListMenu);
|
||||
}
|
||||
|
||||
void VEditWindow::splitWindow()
|
||||
|
@ -243,13 +243,21 @@ void VMdEdit::generateEditOutline()
|
||||
// Assume that each block contains only one line
|
||||
// Only support # syntax for now
|
||||
QRegExp headerReg("(#{1,6})\\s*(\\S.*)"); // Need to trim the spaces
|
||||
int lastLevel = 0;
|
||||
for (QTextBlock block = doc->begin(); block != doc->end(); block = block.next()) {
|
||||
Q_ASSERT(block.lineCount() == 1);
|
||||
if ((block.userState() == HighlightBlockState::Normal) &&
|
||||
headerReg.exactMatch(block.text())) {
|
||||
VHeader header(headerReg.cap(1).length(),
|
||||
headerReg.cap(2).trimmed(), "", block.firstLineNumber());
|
||||
int level = headerReg.cap(1).length();
|
||||
VHeader header(level, headerReg.cap(2).trimmed(),
|
||||
"", block.firstLineNumber());
|
||||
while (level > lastLevel + 1) {
|
||||
// Insert empty level.
|
||||
m_headers.append(VHeader(++lastLevel, "[EMPTY]",
|
||||
"", block.firstLineNumber()));
|
||||
}
|
||||
m_headers.append(header);
|
||||
lastLevel = level;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user