mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
Editor: fix smart table cell crossing lines
This commit is contained in:
parent
dd12a6cdf3
commit
37c415f732
@ -125,7 +125,7 @@ You could help VNote's development in many ways.
|
|||||||
|
|
||||||
<img src="screenshots/wechat_pay.png" width="256px" height="256px" />
|
<img src="screenshots/wechat_pay.png" width="256px" height="256px" />
|
||||||
|
|
||||||
Thanks very much to [them](https://github.com/tamlok/vnote/wiki/Donate-List) who donated to VNote!
|
Thank [users who donated to VNote](https://github.com/tamlok/vnote/wiki/Donate-List)!
|
||||||
|
|
||||||
# Why VNote
|
# Why VNote
|
||||||
## Markdown Editor & Notes Management
|
## Markdown Editor & Notes Management
|
||||||
|
@ -126,7 +126,7 @@ VNote不是一个简单的Markdown编辑器。通过提供笔记管理功能,V
|
|||||||
|
|
||||||
<img src="screenshots/wechat_pay.png" width="256px" height="256px" />
|
<img src="screenshots/wechat_pay.png" width="256px" height="256px" />
|
||||||
|
|
||||||
非常感谢这些VNote的 [捐赠者](https://github.com/tamlok/vnote/wiki/Donate-List) !
|
非常感谢[这些用户](https://github.com/tamlok/vnote/wiki/Donate-List)对VNote的捐赠!
|
||||||
|
|
||||||
# 开发VNote的动机
|
# 开发VNote的动机
|
||||||
## Markdown编辑器与笔记管理
|
## Markdown编辑器与笔记管理
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
[VNote](https://tamlok.github.io/vnote) provides fancy Markdown experience as well as powerful notes management.
|
[VNote](https://tamlok.github.io/vnote) provides fancy Markdown experience as well as powerful notes management.
|
||||||
|
|
||||||
VNote is **open source** and currently mainly developed and maintained by one single person in spare time. Hence, please don't hesitate to give VNote a hand if she does improve your productivity.
|
VNote is **open source** and currently mainly developed and maintained by one single person in spare time. Hence, please don't hesitate to give VNote a hand if she does improve your productivity. Thank [users who donated to VNote](https://github.com/tamlok/vnote/wiki/Donate-List)!
|
||||||
|
|
||||||
## Troubleshooting Guide
|
## Troubleshooting Guide
|
||||||
VNote could be used in two ways:
|
VNote could be used in two ways:
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
[VNote](https://tamlok.github.io/vnote) 提供了美妙的Markdown体验以及强大的笔记管理。
|
[VNote](https://tamlok.github.io/vnote) 提供了美妙的Markdown体验以及强大的笔记管理。
|
||||||
|
|
||||||
VNote是**开源**的,当前主要由个人在业余时间进行开发和维护。因此,如果VNote给您的效率带来了提升,请考虑帮助VNote成长。
|
VNote是**开源**的,当前主要由个人在业余时间进行开发和维护。因此,如果VNote给您的效率带来了提升,请考虑帮助VNote成长。非常感谢[这些用户](https://github.com/tamlok/vnote/wiki/Donate-List)对VNote的捐赠!
|
||||||
|
|
||||||
## 问题解决指南
|
## 问题解决指南
|
||||||
VNote有两种使用方式:
|
VNote有两种使用方式:
|
||||||
|
@ -3405,7 +3405,9 @@ void VMainWindow::kickOffStartUpTimer(const QStringList &p_files)
|
|||||||
QCoreApplication::sendPostedEvents();
|
QCoreApplication::sendPostedEvents();
|
||||||
openStartupPages();
|
openStartupPages();
|
||||||
openFiles(p_files, false, g_config->getNoteOpenMode(), false, true);
|
openFiles(p_files, false, g_config->getNoteOpenMode(), false, true);
|
||||||
if (g_config->versionChanged()) {
|
|
||||||
|
if (g_config->versionChanged()
|
||||||
|
|| (QDate::currentDate().dayOfYear() % 64 == 1)) {
|
||||||
QString docFile = VUtils::getDocFile("welcome.md");
|
QString docFile = VUtils::getDocFile("welcome.md");
|
||||||
VFile *file = vnote->getFile(docFile, true);
|
VFile *file = vnote->getFile(docFile, true);
|
||||||
m_editArea->openFile(file, OpenFileMode::Read);
|
m_editArea->openFile(file, OpenFileMode::Read);
|
||||||
|
@ -325,6 +325,12 @@ void VTable::formatOneColumn(int p_idx, int p_cursorRowIdx, int p_cursorPib)
|
|||||||
QString core = cell.m_text.mid(info.m_coreOffset, info.m_coreLength);
|
QString core = cell.m_text.mid(info.m_coreOffset, info.m_coreLength);
|
||||||
int nr = (targetWidth - info.m_coreWidth + m_spaceWidth / 2) / m_spaceWidth;
|
int nr = (targetWidth - info.m_coreWidth + m_spaceWidth / 2) / m_spaceWidth;
|
||||||
cell.m_formattedText = generateFormattedText(core, nr, fakeAlign);
|
cell.m_formattedText = generateFormattedText(core, nr, fakeAlign);
|
||||||
|
|
||||||
|
// For cells crossing lines and having spaces at the end of one line,
|
||||||
|
// Qt will collapse those spaces, which make it not well formatted.
|
||||||
|
if (cell.m_text == cell.m_formattedText) {
|
||||||
|
cell.m_formattedText.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -407,12 +413,28 @@ void VTable::calculateBasicWidths(const QTextBlock &p_block, int p_borderPos)
|
|||||||
|
|
||||||
int VTable::calculateTextWidth(const QTextBlock &p_block, int p_pib, int p_length) const
|
int VTable::calculateTextWidth(const QTextBlock &p_block, int p_pib, int p_length) const
|
||||||
{
|
{
|
||||||
QTextLine line = p_block.layout()->lineForTextPosition(p_pib);
|
// The block may cross multiple lines.
|
||||||
if (line.isValid()) {
|
int width = 0;
|
||||||
return line.cursorToX(p_pib + p_length) - line.cursorToX(p_pib);
|
QTextLayout *layout = p_block.layout();
|
||||||
|
QTextLine line = layout->lineForTextPosition(p_pib);
|
||||||
|
while (line.isValid()) {
|
||||||
|
int lineEnd = line.textStart() + line.textLength();
|
||||||
|
if (lineEnd >= p_pib + p_length) {
|
||||||
|
// The last line.
|
||||||
|
width += line.cursorToX(p_pib + p_length) - line.cursorToX(p_pib);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
// Cross lines.
|
||||||
|
width += line.cursorToX(lineEnd) - line.cursorToX(p_pib);
|
||||||
|
|
||||||
|
// Move to next line.
|
||||||
|
p_length = p_length - (lineEnd - p_pib);
|
||||||
|
p_pib = lineEnd;
|
||||||
|
line = layout->lineForTextPosition(p_pib + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return width > 0 ? width : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VTable::isHeaderRow(int p_idx) const
|
bool VTable::isHeaderRow(int p_idx) const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user