mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
add sequence to edit tab
This commit is contained in:
parent
9bc8f36733
commit
e1c09a83ec
@ -319,16 +319,34 @@ void VEditWindow::noticeTabStatus(int p_index)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateTabInfo(p_index);
|
||||||
|
updateAllTabsSequence();
|
||||||
|
|
||||||
|
VEditTab *editor = getTab(p_index);
|
||||||
|
const VFile *file = editor->getFile();
|
||||||
|
bool editMode = editor->getIsEditMode();
|
||||||
|
emit tabStatusChanged(file, editor, editMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VEditWindow::updateTabInfo(int p_index)
|
||||||
|
{
|
||||||
VEditTab *editor = getTab(p_index);
|
VEditTab *editor = getTab(p_index);
|
||||||
const VFile *file = editor->getFile();
|
const VFile *file = editor->getFile();
|
||||||
bool editMode = editor->getIsEditMode();
|
bool editMode = editor->getIsEditMode();
|
||||||
|
|
||||||
// Update tab text
|
setTabText(p_index, generateTabText(p_index, file->getName(), file->isModified()));
|
||||||
setTabText(p_index, generateTabText(file->getName(), file->isModified()));
|
|
||||||
setTabToolTip(p_index, generateTooltip(file));
|
setTabToolTip(p_index, generateTooltip(file));
|
||||||
setTabIcon(p_index, editMode ? QIcon(":/resources/icons/editing.svg") :
|
setTabIcon(p_index, editMode ? QIcon(":/resources/icons/editing.svg") :
|
||||||
QIcon(":/resources/icons/reading.svg"));
|
QIcon(":/resources/icons/reading.svg"));
|
||||||
emit tabStatusChanged(file, editor, editMode);
|
}
|
||||||
|
|
||||||
|
void VEditWindow::updateAllTabsSequence()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < count(); ++i) {
|
||||||
|
VEditTab *editor = getTab(i);
|
||||||
|
const VFile *file = editor->getFile();
|
||||||
|
setTabText(i, generateTabText(i, file->getName(), file->isModified()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Be requested to report current status
|
// Be requested to report current status
|
||||||
|
@ -92,9 +92,13 @@ private:
|
|||||||
void noticeTabStatus(int p_index);
|
void noticeTabStatus(int p_index);
|
||||||
void noticeStatus(int index);
|
void noticeStatus(int index);
|
||||||
inline QString generateTooltip(const VFile *p_file) const;
|
inline QString generateTooltip(const VFile *p_file) const;
|
||||||
inline QString generateTabText(const QString &p_name, bool p_modified) const;
|
inline QString generateTabText(int p_index, const QString &p_name,
|
||||||
|
bool p_modified) const;
|
||||||
bool canRemoveSplit();
|
bool canRemoveSplit();
|
||||||
void moveTabOneSplit(int p_tabIdx, bool p_right);
|
void moveTabOneSplit(int p_tabIdx, bool p_right);
|
||||||
|
void updateTabInfo(int p_idx);
|
||||||
|
// Update the sequence number of all the tabs.
|
||||||
|
void updateAllTabsSequence();
|
||||||
|
|
||||||
VNote *vnote;
|
VNote *vnote;
|
||||||
VEditArea *m_editArea;
|
VEditArea *m_editArea;
|
||||||
@ -127,9 +131,13 @@ inline QString VEditWindow::generateTooltip(const VFile *p_file) const
|
|||||||
return QString("[%1] %2").arg(p_file->getNotebookName()).arg(p_file->retrivePath());
|
return QString("[%1] %2").arg(p_file->getNotebookName()).arg(p_file->retrivePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QString VEditWindow::generateTabText(const QString &p_name, bool p_modified) const
|
inline QString VEditWindow::generateTabText(int p_index, const QString &p_name,
|
||||||
|
bool p_modified) const
|
||||||
{
|
{
|
||||||
return p_modified ? (p_name + "*") : p_name;
|
// Based on 1.
|
||||||
|
const int base = 1;
|
||||||
|
QString seq = QString::number(p_index + base, 10);
|
||||||
|
return seq + ". " + (p_modified ? (p_name + "*") : p_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VEDITWINDOW_H
|
#endif // VEDITWINDOW_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user