- change: Remove "limit for copy" and "limit for undo" options.

This commit is contained in:
Roy Qu 2024-04-07 21:33:08 +08:00
parent c5bdecca17
commit 04c7f3b5d5
14 changed files with 1 additions and 436 deletions

View File

@ -127,6 +127,7 @@ Red Panda C++ Version 2.27
- fix: Theme manager not correctly inited in options dialog / environment / appearance. - fix: Theme manager not correctly inited in options dialog / environment / appearance.
- enhancement: Size of icons in the completion popup changes with the editor font size. - enhancement: Size of icons in the completion popup changes with the editor font size.
- change: Completion popup size settings are based on editor's char width/line height. - change: Completion popup size settings are based on editor's char width/line height.
- change: Remove "limit for copy" and "limit for undo" options.
Red Panda C++ Version 2.26 Red Panda C++ Version 2.26
- enhancement: Code suggestion for embedded std::vectors. - enhancement: Code suggestion for embedded std::vectors.

View File

@ -1645,21 +1645,6 @@ void Editor::resizeEvent(QResizeEvent *event)
void Editor::copyToClipboard() void Editor::copyToClipboard()
{ {
if (pSettings->editor().copySizeLimit()) {
int startLine = blockBegin().line;
int endLine = blockEnd().line;
if ((endLine-startLine+1) > pSettings->editor().copyLineLimits()) {
QMessageBox::critical(pMainWindow,tr("Error"),
tr("The text to be copied exceeds count limit!"));
return;
}
if ((selText().length()) > pSettings->editor().copyCharLimits() * 1000) {
QMessageBox::critical(pMainWindow,tr("Error"),
tr("The text to be copied exceeds character limit!"));
return;
}
}
switch(pSettings->editor().copyWithFormatAs()) { switch(pSettings->editor().copyWithFormatAs()) {
case 1: //HTML case 1: //HTML
copyAsHTML(); copyAsHTML();
@ -1671,20 +1656,6 @@ void Editor::copyToClipboard()
void Editor::cutToClipboard() void Editor::cutToClipboard()
{ {
if (pSettings->editor().copySizeLimit()) {
int startLine = blockBegin().line;
int endLine = blockEnd().line;
if ((endLine-startLine+1) > pSettings->editor().copyLineLimits()) {
QMessageBox::critical(pMainWindow,tr("Error"),
tr("The text to be cut exceeds count limit!"));
return;
}
if ((selText().length()) > pSettings->editor().copyCharLimits() * 1000) {
QMessageBox::critical(pMainWindow,tr("Error"),
tr("The text to be cut exceeds character limit!"));
return;
}
}
QSynedit::QSynEdit::cutToClipboard(); QSynedit::QSynEdit::cutToClipboard();
} }
@ -5434,9 +5405,6 @@ void Editor::applySettings()
((QSynedit::CppSyntaxer*)(syntaxer().get()))->setCustomTypeKeywords(set); ((QSynedit::CppSyntaxer*)(syntaxer().get()))->setCustomTypeKeywords(set);
} }
this->setUndoLimit(pSettings->editor().undoLimit());
this->setUndoMemoryUsage(pSettings->editor().undoMemoryUsage());
initAutoBackup(); initAutoBackup();
setMouseWheelScrollSpeed(pSettings->editor().mouseWheelScrollSpeed()); setMouseWheelScrollSpeed(pSettings->editor().mouseWheelScrollSpeed());

View File

@ -705,26 +705,6 @@ void Settings::Editor::setAutoDetectFileEncoding(bool newAutoDetectFileEncoding)
mAutoDetectFileEncoding = newAutoDetectFileEncoding; mAutoDetectFileEncoding = newAutoDetectFileEncoding;
} }
int Settings::Editor::undoLimit() const
{
return mUndoLimit;
}
void Settings::Editor::setUndoLimit(int newUndoLimit)
{
mUndoLimit = newUndoLimit;
}
int Settings::Editor::undoMemoryUsage() const
{
return mUndoMemoryUsage;
}
void Settings::Editor::setUndoMemoryUsage(int newUndoMemoryUsage)
{
mUndoMemoryUsage = newUndoMemoryUsage;
}
bool Settings::Editor::autoFormatWhenSaved() const bool Settings::Editor::autoFormatWhenSaved() const
{ {
return mAutoFormatWhenSaved; return mAutoFormatWhenSaved;
@ -1125,36 +1105,6 @@ void Settings::Editor::setCopyRTFUseBackground(bool copyRTFUseBackground)
mCopyRTFUseBackground = copyRTFUseBackground; mCopyRTFUseBackground = copyRTFUseBackground;
} }
int Settings::Editor::copyLineLimits() const
{
return mCopyLineLimits;
}
void Settings::Editor::setCopyLineLimits(int copyLineLimits)
{
mCopyLineLimits = copyLineLimits;
}
int Settings::Editor::copyCharLimits() const
{
return mCopyCharLimits;
}
void Settings::Editor::setCopyCharLimits(int copyCharLimits)
{
mCopyCharLimits = copyCharLimits;
}
bool Settings::Editor::copySizeLimit() const
{
return mCopySizeLimit;
}
void Settings::Editor::setCopySizeLimit(bool copyLimit)
{
mCopySizeLimit = copyLimit;
}
int Settings::Editor::gutterLeftOffset() const int Settings::Editor::gutterLeftOffset() const
{ {
return mGutterLeftOffset; return mGutterLeftOffset;
@ -1365,9 +1315,6 @@ void Settings::Editor::doSave()
saveValue("gutter_font_only_monospaced",mGutterFontOnlyMonospaced); saveValue("gutter_font_only_monospaced",mGutterFontOnlyMonospaced);
//copy //copy
saveValue("copy_limit",mCopySizeLimit);
saveValue("copy_char_limits",mCopyCharLimits);
saveValue("copy_line_limits",mCopyLineLimits);
saveValue("copy_with_format_as",mCopyWithFormatAs); saveValue("copy_with_format_as",mCopyWithFormatAs);
saveValue("copy_rtf_use_background",mCopyRTFUseBackground); saveValue("copy_rtf_use_background",mCopyRTFUseBackground);
saveValue("copy_rtf_use_editor_color_scheme",mCopyRTFUseEditorColor); saveValue("copy_rtf_use_editor_color_scheme",mCopyRTFUseEditorColor);
@ -1413,8 +1360,6 @@ void Settings::Editor::doSave()
saveValue("auto_load_last_files",mAutoLoadLastFiles); saveValue("auto_load_last_files",mAutoLoadLastFiles);
saveValue("default_file_cpp",mDefaultFileCpp); saveValue("default_file_cpp",mDefaultFileCpp);
saveValue("auto_detect_file_encoding",mAutoDetectFileEncoding); saveValue("auto_detect_file_encoding",mAutoDetectFileEncoding);
saveValue("undo_limit",mUndoLimit);
saveValue("undo_memory_usage", mUndoMemoryUsage);
saveValue("auto_format_when_saved", mAutoFormatWhenSaved); saveValue("auto_format_when_saved", mAutoFormatWhenSaved);
saveValue("remove_trailing_spaces_when_saved",mRemoveTrailingSpacesWhenSaved); saveValue("remove_trailing_spaces_when_saved",mRemoveTrailingSpacesWhenSaved);
saveValue("parse_todos",mParseTodos); saveValue("parse_todos",mParseTodos);
@ -1518,9 +1463,6 @@ void Settings::Editor::doLoad()
mGutterFontOnlyMonospaced = boolValue("gutter_font_only_monospaced",true); mGutterFontOnlyMonospaced = boolValue("gutter_font_only_monospaced",true);
//copy //copy
mCopySizeLimit = boolValue("copy_limit",false);
mCopyCharLimits = intValue("copy_char_limits",100);
mCopyLineLimits = intValue("copy_line_limits",100000);
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
mCopyWithFormatAs = intValue("copy_with_format_as",1); //html mCopyWithFormatAs = intValue("copy_with_format_as",1); //html
#else #else
@ -1576,8 +1518,6 @@ void Settings::Editor::doLoad()
else else
mDefaultEncoding = value("default_encoding", ENCODING_UTF8).toByteArray(); mDefaultEncoding = value("default_encoding", ENCODING_UTF8).toByteArray();
mAutoDetectFileEncoding = boolValue("auto_detect_file_encoding",true); mAutoDetectFileEncoding = boolValue("auto_detect_file_encoding",true);
mUndoLimit = intValue("undo_limit",0);
mUndoMemoryUsage = intValue("undo_memory_usage", 0);
mAutoFormatWhenSaved = boolValue("auto_format_when_saved", false); mAutoFormatWhenSaved = boolValue("auto_format_when_saved", false);
mRemoveTrailingSpacesWhenSaved = boolValue("remove_trailing_spaces_when_saved",false); mRemoveTrailingSpacesWhenSaved = boolValue("remove_trailing_spaces_when_saved",false);
mParseTodos = boolValue("parse_todos",true); mParseTodos = boolValue("parse_todos",true);

View File

@ -212,15 +212,6 @@ public:
int gutterRightOffset() const; int gutterRightOffset() const;
void setGutterRightOffset(int gutterRightOffset); void setGutterRightOffset(int gutterRightOffset);
bool copySizeLimit() const;
void setCopySizeLimit(bool copyLimit);
int copyCharLimits() const;
void setCopyCharLimits(int copyCharLimits);
int copyLineLimits() const;
void setCopyLineLimits(int copyLineLimits);
bool copyRTFUseBackground() const; bool copyRTFUseBackground() const;
void setCopyRTFUseBackground(bool copyRTFUseBackground); void setCopyRTFUseBackground(bool copyRTFUseBackground);
@ -362,12 +353,6 @@ public:
bool autoDetectFileEncoding() const; bool autoDetectFileEncoding() const;
void setAutoDetectFileEncoding(bool newAutoDetectFileEncoding); void setAutoDetectFileEncoding(bool newAutoDetectFileEncoding);
int undoLimit() const;
void setUndoLimit(int newUndoLimit);
int undoMemoryUsage() const;
void setUndoMemoryUsage(int newUndoMemoryUsage);
bool autoFormatWhenSaved() const; bool autoFormatWhenSaved() const;
void setAutoFormatWhenSaved(bool newAutoFormatWhenSaved); void setAutoFormatWhenSaved(bool newAutoFormatWhenSaved);
@ -471,9 +456,6 @@ public:
bool mGutterFontOnlyMonospaced; bool mGutterFontOnlyMonospaced;
//copy //copy
bool mCopySizeLimit;
int mCopyCharLimits;
int mCopyLineLimits;
int mCopyWithFormatAs; int mCopyWithFormatAs;
bool mCopyRTFUseBackground; bool mCopyRTFUseBackground;
bool mCopyRTFUseEditorColor; bool mCopyRTFUseEditorColor;
@ -519,8 +501,6 @@ public:
bool mReadOnlySytemHeader; bool mReadOnlySytemHeader;
bool mAutoLoadLastFiles; bool mAutoLoadLastFiles;
bool mDefaultFileCpp; bool mDefaultFileCpp;
int mUndoLimit;
int mUndoMemoryUsage;
bool mAutoFormatWhenSaved; bool mAutoFormatWhenSaved;
bool mRemoveTrailingSpacesWhenSaved; bool mRemoveTrailingSpacesWhenSaved;
bool mParseTodos; bool mParseTodos;

View File

@ -60,10 +60,6 @@ void EditorClipboardWidget::doLoad()
//pSettings->editor().load(); //pSettings->editor().load();
//copy //copy
QString mCopyHTMLColorScheme; QString mCopyHTMLColorScheme;
ui->grpCopySizeLimit->setChecked(pSettings->editor().copySizeLimit());
ui->spinCopyCharLimits->setValue(pSettings->editor().copyCharLimits());
ui->spinCopyLineLimits->setValue(pSettings->editor().copyLineLimits());
ui->cbCopyWithFormatAs->setCurrentIndex(std::max(0,std::min(ui->cbCopyWithFormatAs->count(), ui->cbCopyWithFormatAs->setCurrentIndex(std::max(0,std::min(ui->cbCopyWithFormatAs->count(),
pSettings->editor().copyWithFormatAs())) ); pSettings->editor().copyWithFormatAs())) );
ui->chkCopyRTFUseBackground->setChecked(pSettings->editor().copyRTFUseBackground()); ui->chkCopyRTFUseBackground->setChecked(pSettings->editor().copyRTFUseBackground());
@ -78,9 +74,6 @@ void EditorClipboardWidget::doLoad()
void EditorClipboardWidget::doSave() void EditorClipboardWidget::doSave()
{ {
//copy //copy
pSettings->editor().setCopySizeLimit(ui->grpCopySizeLimit->isChecked());
pSettings->editor().setCopyCharLimits(ui->spinCopyCharLimits->value());
pSettings->editor().setCopyLineLimits(ui->spinCopyLineLimits->value());
pSettings->editor().setCopyWithFormatAs(ui->cbCopyWithFormatAs->currentIndex()); pSettings->editor().setCopyWithFormatAs(ui->cbCopyWithFormatAs->currentIndex());
pSettings->editor().setCopyRTFUseBackground(ui->chkCopyRTFUseBackground->isChecked()); pSettings->editor().setCopyRTFUseBackground(ui->chkCopyRTFUseBackground->isChecked());

View File

@ -14,90 +14,6 @@
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="grpCopySizeLimit">
<property name="title">
<string>Copy Size Limit</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Don't copy text larger than</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Lines</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Size(kilo characters):</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="spinCopyLineLimits">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>99999999</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="spinCopyCharLimits">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999999</number>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QWidget" name="widget_4" native="true"> <widget class="QWidget" name="widget_4" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
@ -277,9 +193,6 @@
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>grpCopySizeLimit</tabstop>
<tabstop>spinCopyCharLimits</tabstop>
<tabstop>spinCopyLineLimits</tabstop>
<tabstop>cbCopyWithFormatAs</tabstop> <tabstop>cbCopyWithFormatAs</tabstop>
<tabstop>chkCopyHTMLUseBackground</tabstop> <tabstop>chkCopyHTMLUseBackground</tabstop>
<tabstop>chkCopyHTMLUseEditorColor</tabstop> <tabstop>chkCopyHTMLUseEditorColor</tabstop>

View File

@ -64,8 +64,6 @@ void EditorMiscWidget::doLoad()
} }
ui->cbEncodingDetail->setCurrentText(defaultEncoding); ui->cbEncodingDetail->setCurrentText(defaultEncoding);
} }
ui->spinMaxUndo->setValue(pSettings->editor().undoLimit());
ui->spinMaxUndoMemory->setValue(pSettings->editor().undoMemoryUsage());
if (pSettings->editor().removeTrailingSpacesWhenSaved()) if (pSettings->editor().removeTrailingSpacesWhenSaved())
ui->rbRemoveTrailingSpaces->setChecked(true); ui->rbRemoveTrailingSpaces->setChecked(true);
else if (pSettings->editor().autoFormatWhenSaved()) else if (pSettings->editor().autoFormatWhenSaved())
@ -88,8 +86,6 @@ void EditorMiscWidget::doSave()
} else { } else {
pSettings->editor().setDefaultEncoding(ui->cbEncoding->currentData().toByteArray()); pSettings->editor().setDefaultEncoding(ui->cbEncoding->currentData().toByteArray());
} }
pSettings->editor().setUndoLimit(ui->spinMaxUndo->value());
pSettings->editor().setUndoMemoryUsage(ui->spinMaxUndoMemory->value());
pSettings->editor().setAutoFormatWhenSaved(ui->rbAutoReformat->isChecked()); pSettings->editor().setAutoFormatWhenSaved(ui->rbAutoReformat->isChecked());
pSettings->editor().setRemoveTrailingSpacesWhenSaved(ui->rbRemoveTrailingSpaces->isChecked()); pSettings->editor().setRemoveTrailingSpacesWhenSaved(ui->rbRemoveTrailingSpaces->isChecked());
pSettings->editor().setParseTodos(ui->chkParseTodos->isChecked()); pSettings->editor().setParseTodos(ui->chkParseTodos->isChecked());

View File

@ -35,58 +35,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Limits for Undo</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Memory Usage</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="spinMaxUndo">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>1000000000</number>
</property>
<property name="singleStep">
<number>50</number>
</property>
<property name="value">
<number>10000</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Steps</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QSpinBox" name="spinMaxUndoMemory">
<property name="suffix">
<string>MB</string>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>50</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QWidget" name="widget" native="true"> <widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
@ -256,8 +204,6 @@
<tabstop>chkReadonlySystemHeaders</tabstop> <tabstop>chkReadonlySystemHeaders</tabstop>
<tabstop>chkLoadLastFiles</tabstop> <tabstop>chkLoadLastFiles</tabstop>
<tabstop>chkParseTodos</tabstop> <tabstop>chkParseTodos</tabstop>
<tabstop>spinMaxUndo</tabstop>
<tabstop>spinMaxUndoMemory</tabstop>
<tabstop>rbNone</tabstop> <tabstop>rbNone</tabstop>
<tabstop>rbAutoReformat</tabstop> <tabstop>rbAutoReformat</tabstop>
<tabstop>rbRemoveTrailingSpaces</tabstop> <tabstop>rbRemoveTrailingSpaces</tabstop>

View File

@ -54,7 +54,6 @@ void EnvironmentPerformanceWidget::doLoad()
// } // }
//#endif //#endif
ui->chkEditorsShareParser->setChecked(pSettings->codeCompletion().shareParser()); ui->chkEditorsShareParser->setChecked(pSettings->codeCompletion().shareParser());
ui->spinMaxUndoMemory->setValue(pSettings->editor().undoMemoryUsage());
} }
void EnvironmentPerformanceWidget::doSave() void EnvironmentPerformanceWidget::doSave()
@ -63,6 +62,5 @@ void EnvironmentPerformanceWidget::doSave()
pSettings->codeCompletion().setShareParser(ui->chkEditorsShareParser->isChecked()); pSettings->codeCompletion().setShareParser(ui->chkEditorsShareParser->isChecked());
pSettings->codeCompletion().save(); pSettings->codeCompletion().save();
pSettings->editor().setUndoMemoryUsage(ui->spinMaxUndoMemory->value());
pSettings->editor().save(); pSettings->editor().save();
} }

View File

@ -34,57 +34,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Max undo memory for each editor:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinMaxUndoMemory">
<property name="suffix">
<string>MB</string>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -1373,16 +1373,12 @@ int DocumentLine::glyphStartChar(int i) const
UndoList::UndoList():QObject() UndoList::UndoList():QObject()
{ {
mMaxUndoActions = 1024;
mMaxMemoryUsage = 50 * 1024 * 1024;
mNextChangeNumber = 1; mNextChangeNumber = 1;
mInsideRedo = false; mInsideRedo = false;
mBlockChangeNumber=0; mBlockChangeNumber=0;
mBlockLock=0; mBlockLock=0;
mFullUndoImposible=false; mFullUndoImposible=false;
mBlockCount=0;
mMemoryUsage=0;
mLastPoppedItemChangeNumber=0; mLastPoppedItemChangeNumber=0;
mInitialChangeNumber = 0; mInitialChangeNumber = 0;
mLastRestoredItemChangeNumber=0; mLastRestoredItemChangeNumber=0;
@ -1402,14 +1398,9 @@ void UndoList::addChange(ChangeReason reason, const BufferCoord &startPos,
reason, reason,
selMode,startPos,endPos,changeText, selMode,startPos,endPos,changeText,
changeNumber); changeNumber);
// qDebug()<<"add change"<<changeNumber<<(int)reason;
mItems.append(newItem); mItems.append(newItem);
addMemoryUsage(newItem);
ensureMaxEntries();
if (reason!=ChangeReason::GroupBreak && !inBlock()) { if (reason!=ChangeReason::GroupBreak && !inBlock()) {
mBlockCount++;
// qDebug()<<"add"<<mBlockCount;
emit addedUndo(); emit addedUndo();
} }
} }
@ -1426,13 +1417,9 @@ void UndoList::restoreChange(PUndoItem item)
{ {
size_t changeNumber = item->changeNumber(); size_t changeNumber = item->changeNumber();
mItems.append(item); mItems.append(item);
addMemoryUsage(item);
ensureMaxEntries();
if (changeNumber>mNextChangeNumber) if (changeNumber>mNextChangeNumber)
mNextChangeNumber=changeNumber; mNextChangeNumber=changeNumber;
if (changeNumber!=mLastRestoredItemChangeNumber) { if (changeNumber!=mLastRestoredItemChangeNumber) {
// qDebug()<<"restore"<<mBlockCount;
mBlockCount++;
emit addedUndo(); emit addedUndo();
} }
mLastRestoredItemChangeNumber=changeNumber; mLastRestoredItemChangeNumber=changeNumber;
@ -1464,9 +1451,7 @@ void UndoList::clear()
mInitialChangeNumber=0; mInitialChangeNumber=0;
mLastPoppedItemChangeNumber=0; mLastPoppedItemChangeNumber=0;
mLastRestoredItemChangeNumber=0; mLastRestoredItemChangeNumber=0;
mBlockCount=0;
mBlockLock=0; mBlockLock=0;
mMemoryUsage=0;
} }
void UndoList::endBlock() void UndoList::endBlock()
@ -1478,8 +1463,6 @@ void UndoList::endBlock()
size_t iBlockID = mBlockChangeNumber; size_t iBlockID = mBlockChangeNumber;
mBlockChangeNumber = 0; mBlockChangeNumber = 0;
if (mItems.count() > 0 && peekItem()->changeNumber() == iBlockID) { if (mItems.count() > 0 && peekItem()->changeNumber() == iBlockID) {
mBlockCount++;
// qDebug()<<"end block"<<mBlockCount;
emit addedUndo(); emit addedUndo();
} }
} }
@ -1496,30 +1479,6 @@ unsigned int UndoList::getNextChangeNumber()
return mNextChangeNumber++; return mNextChangeNumber++;
} }
void UndoList::addMemoryUsage(PUndoItem item)
{
if (!item)
return;
mMemoryUsage += item->memoryUsage();
}
void UndoList::reduceMemoryUsage(PUndoItem item)
{
if (!item)
return;
mMemoryUsage -= item->memoryUsage();
}
int UndoList::maxMemoryUsage() const
{
return mMaxMemoryUsage;
}
void UndoList::setMaxMemoryUsage(int newMaxMemoryUsage)
{
mMaxMemoryUsage = newMaxMemoryUsage;
}
ChangeReason UndoList::lastChangeReason() ChangeReason UndoList::lastChangeReason()
{ {
if (mItems.count() == 0) if (mItems.count() == 0)
@ -1548,16 +1507,7 @@ PUndoItem UndoList::popItem()
else { else {
PUndoItem item = mItems.last(); PUndoItem item = mItems.last();
// qDebug()<<"popped"<<item->changeNumber()<<item->changeText()<<(int)item->changeReason()<<mLastPoppedItemChangeNumber; // qDebug()<<"popped"<<item->changeNumber()<<item->changeText()<<(int)item->changeReason()<<mLastPoppedItemChangeNumber;
if (mLastPoppedItemChangeNumber!=item->changeNumber() && item->changeReason()!=ChangeReason::GroupBreak) {
mBlockCount--;
Q_ASSERT(mBlockCount>=0);
// qDebug()<<"pop"<<mBlockCount;
if (mBlockCount<0) {
mBlockCount=0;
}
}
mLastPoppedItemChangeNumber = item->changeNumber(); mLastPoppedItemChangeNumber = item->changeNumber();
reduceMemoryUsage(item);
mItems.removeLast(); mItems.removeLast();
return item; return item;
} }
@ -1573,19 +1523,6 @@ int UndoList::itemCount()
return mItems.count(); return mItems.count();
} }
int UndoList::maxUndoActions() const
{
return mMaxUndoActions;
}
void UndoList::setMaxUndoActions(int maxUndoActions)
{
if (maxUndoActions!=mMaxUndoActions) {
mMaxUndoActions = maxUndoActions;
ensureMaxEntries();
}
}
bool UndoList::initialState() bool UndoList::initialState()
{ {
if (itemCount() == 0) { if (itemCount() == 0) {
@ -1618,38 +1555,6 @@ bool UndoList::fullUndoImposible() const
return mFullUndoImposible; return mFullUndoImposible;
} }
void UndoList::ensureMaxEntries()
{
if (mItems.isEmpty())
return;
// qDebug()<<QString("-- List Memory: %1 %2").arg(mMemoryUsage).arg(mMaxMemoryUsage);
if ((mMaxUndoActions >0 && mBlockCount > mMaxUndoActions)
|| (mMaxMemoryUsage>0 && mMemoryUsage>mMaxMemoryUsage)){
PUndoItem lastItem = mItems.back();
mFullUndoImposible = true;
while (((mMaxUndoActions >0 && mBlockCount > mMaxUndoActions)
|| (mMaxMemoryUsage>0 && mMemoryUsage>mMaxMemoryUsage))
&& !mItems.isEmpty()) {
//remove all undo item in block
PUndoItem item = mItems.front();
size_t changeNumber = item->changeNumber();
//we shouldn't drop the newest changes;
if (changeNumber == lastItem->changeNumber())
break;
while (mItems.count()>0) {
item = mItems.front();
if (item->changeNumber()!=changeNumber)
break;
reduceMemoryUsage(item);
mItems.removeFirst();
}
if (item->changeReason()!=ChangeReason::GroupBreak)
mBlockCount--;
}
}
// qDebug()<<QString("++ List Memory: %1").arg(mMemoryUsage);
}
SelectionMode UndoItem::changeSelMode() const SelectionMode UndoItem::changeSelMode() const
{ {
return mChangeSelMode; return mChangeSelMode;

View File

@ -712,28 +712,18 @@ public:
bool fullUndoImposible() const; bool fullUndoImposible() const;
int maxMemoryUsage() const;
void setMaxMemoryUsage(int newMaxMemoryUsage);
signals: signals:
void addedUndo(); void addedUndo();
protected: protected:
void ensureMaxEntries();
bool inBlock(); bool inBlock();
unsigned int getNextChangeNumber(); unsigned int getNextChangeNumber();
void addMemoryUsage(PUndoItem item);
void reduceMemoryUsage(PUndoItem item);
protected: protected:
size_t mBlockChangeNumber; size_t mBlockChangeNumber;
int mBlockLock; int mBlockLock;
int mBlockCount; // count of action blocks;
int mMemoryUsage;
size_t mLastPoppedItemChangeNumber; size_t mLastPoppedItemChangeNumber;
size_t mLastRestoredItemChangeNumber; size_t mLastRestoredItemChangeNumber;
bool mFullUndoImposible; bool mFullUndoImposible;
QVector<PUndoItem> mItems; QVector<PUndoItem> mItems;
int mMaxUndoActions;
int mMaxMemoryUsage;
unsigned int mNextChangeNumber; unsigned int mNextChangeNumber;
unsigned int mInitialChangeNumber; unsigned int mInitialChangeNumber;
bool mInsideRedo; bool mInsideRedo;

View File

@ -6493,17 +6493,6 @@ void QSynEdit::setGutterWidth(int Value)
} }
} }
void QSynEdit::setUndoLimit(int size)
{
mUndoList->setMaxUndoActions(size);
}
void QSynEdit::setUndoMemoryUsage(int size)
{
mUndoList->setMaxMemoryUsage(size*1024*1024);
// mUndoList->setMaxMemoryUsage(size*1024);
}
void QSynEdit::onBookMarkOptionsChanged() void QSynEdit::onBookMarkOptionsChanged()
{ {
invalidateGutter(); invalidateGutter();

View File

@ -355,9 +355,6 @@ public:
return clientWidth() - mGutterWidth - 2; return clientWidth() - mGutterWidth - 2;
} }
void setUndoLimit(int size);
void setUndoMemoryUsage(int size);
int gutterWidth() const; int gutterWidth() const;
void setGutterWidth(int value); void setGutterWidth(int value);