Skip to content

Commit

Permalink
Github Issue #29: Routine for checkbox press is now implemented with …
Browse files Browse the repository at this point in the history
…the new way to save and extract data from raw document
  • Loading branch information
AngryFender committed Apr 6, 2024
1 parent 272b0ec commit 6d4f00a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
13 changes: 6 additions & 7 deletions mkedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,14 +378,11 @@ void MkEdit::fileSaveNow()
applyMkEffects();
}

void MkEdit::fileSaveWithScroll(const bool scroll)
void MkEdit::fileSaveWithScroll()
{
fileSaveTimer.stop();
//removeAllMkDataFunc(this->textCursor().blockNumber());
postUndoSetup();
//emit fileSave();
emit fileSaveRaw();
//applyMkEffects(scroll);
}

bool MkEdit::isMouseOnCheckBox(QMouseEvent *e)
Expand Down Expand Up @@ -417,11 +414,13 @@ bool MkEdit::isMouseOnCheckBox(QMouseEvent *e)
rect.setWidth(width);
if(rect.contains(pointer)){
int pos = (*it);
//removeAllMkDataFunc(this->textCursor().blockNumber());

disconnectSignals();
preUndoSetup();
//applyMkEffects(false);
emit pushCheckBox(pos);
fileSaveWithScroll(false);
fileSaveWithScroll();
connectSignals();

return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion mkedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class MkEdit : public QTextEdit
void removeAllMkDataFunc(int blockNumber);
void applyMkEffects(const bool scroll = true);
void fileSaveNow();
void fileSaveWithScroll(const bool scroll = true);
void fileSaveWithScroll();

bool isMouseOnCheckBox(QMouseEvent *e);
void showSelectionAfterUndo();
Expand Down
22 changes: 13 additions & 9 deletions mktextdocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,7 @@ void MkTextDocument::cursorPosChangedHandle( bool hasSelection, int blockNumber,

void MkTextDocument::removeAllMkDataHandle(int blockNo)
{
// showMKSymbolsFromSavedBlocks(nullptr, blockNo);
// stripUserData();

// this->setPlainText(this->rawDocument.toPlainText());
QTextDocument::setPlainText(this->rawDocument.toPlainText());
//identifyUserData(false);
}

void MkTextDocument::applyAllMkDataHandle(bool hasSelection, int blockNumber, bool showAll,QRect rect)
Expand Down Expand Up @@ -690,10 +685,7 @@ void MkTextDocument::extractSymbolsInBlock(QTextBlock &block, QString &result)
}
FormatData* formatData = dynamic_cast<FormatData*>(data);
if(formatData){
if(formatData->isHidden()){
formatData->setHidden(false);
showFormatSymbolsInTextBlock(block, formatData, result);
}
showFormatSymbolsInTextBlock(block, formatData, result);
}
}
}
Expand Down Expand Up @@ -1113,6 +1105,7 @@ void MkTextDocument::pushCheckBoxHandle(const int position)
cursor.movePosition(QTextCursor::NextCharacter,QTextCursor::KeepAnchor);

QTextBlock block = findBlock(position);
int blockNo = block.blockNumber();
QTextBlockUserData* data =block.userData();
FormatData* formatData = dynamic_cast<FormatData*>(data);

Expand Down Expand Up @@ -1158,6 +1151,17 @@ void MkTextDocument::pushCheckBoxHandle(const int position)
index2++;
}
}

//update the pushing checking actions on the raw document as well
QTextBlock rawBlock(block);
QString rawString;
extractSymbolsInBlock(rawBlock, rawString);

QTextCursor cursorRaw(&rawDocument);
cursorRaw.setPosition(rawDocument.findBlockByLineNumber(blockNo).position());
cursorRaw.movePosition(QTextCursor::StartOfBlock);
cursorRaw.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
cursorRaw.insertText(rawString);
}

void MkTextDocument::pushLinkHandle(const int position)
Expand Down

0 comments on commit 6d4f00a

Please sign in to comment.