Skip to content

Commit

Permalink
migration from QTextEdit to QPlainTextEdit
Browse files Browse the repository at this point in the history
  • Loading branch information
pbek committed Sep 6, 2017
1 parent 2b5f028 commit cb4d412
Show file tree
Hide file tree
Showing 20 changed files with 125 additions and 122 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,9 @@
# QOwnNotes Changelog

## 17.09.1
- the `QMarkdownTextedit` that is used in all markdown text-edits is now based
on`QPlainTextEdit` instead of `QTextEdit`, which should result in improved
rendering speed in large notes
- the automatic closing of brackets now also works for `'`
(for [Issue #708](https://github.com/pbek/QOwnNotes/issues/708))

Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/notedialog.cpp
Expand Up @@ -12,7 +12,7 @@ NoteDialog::NoteDialog(QWidget *parent) :

void NoteDialog::setNote(Note note) {
setWindowTitle(note.getName());
ui->textEdit->setText(note.getNoteText());
ui->textEdit->setPlainText(note.getNoteText());
}

NoteDialog::~NoteDialog() {
Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/notedialog.ui
Expand Up @@ -29,7 +29,7 @@
<customwidgets>
<customwidget>
<class>QOwnNotesMarkdownTextEdit</class>
<extends>QTextEdit</extends>
<extends>QPlainTextEdit</extends>
<header location="global">widgets/qownnotesmarkdowntextedit.h</header>
</customwidget>
</customwidgets>
Expand Down
9 changes: 1 addition & 8 deletions src/dialogs/settingsdialog.ui
Expand Up @@ -3446,13 +3446,6 @@ Just test yourself if you get sync conflicts and set a higher value if so.</stri
<property name="readOnly">
<bool>true</bool>
</property>
<property name="html">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Noto Sans'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="plainText">
<string/>
</property>
Expand Down Expand Up @@ -4488,7 +4481,7 @@ git config --global user.name &quot;Your name&quot;</string>
<customwidgets>
<customwidget>
<class>QOwnNotesMarkdownTextEdit</class>
<extends>QTextEdit</extends>
<extends>QPlainTextEdit</extends>
<header location="global">widgets/qownnotesmarkdowntextedit.h</header>
</customwidget>
<customwidget>
Expand Down
4 changes: 2 additions & 2 deletions src/dialogs/tododialog.cpp
Expand Up @@ -340,7 +340,7 @@ void TodoDialog::clearTodoList() {

void TodoDialog::resetEditFrameControls() {
ui->summaryEdit->setText("");
ui->descriptionEdit->setText("");
ui->descriptionEdit->setPlainText("");
ui->prioritySlider->setValue(0);
ui->reminderCheckBox->setChecked(false);
ui->reminderDateTimeEdit->hide();
Expand Down Expand Up @@ -437,7 +437,7 @@ void TodoDialog::on_todoList_currentItemChanged(
if (currentCalendarItem.isFetched()) {
ui->summaryEdit->setText(currentCalendarItem.getSummary());
ui->summaryEdit->setCursorPosition(0);
ui->descriptionEdit->setText(currentCalendarItem.getDescription());
ui->descriptionEdit->setPlainText(currentCalendarItem.getDescription());

QDateTime alarmDate = currentCalendarItem.getAlarmDate();
ui->reminderCheckBox->setChecked(alarmDate.isValid());
Expand Down
12 changes: 1 addition & 11 deletions src/dialogs/tododialog.ui
Expand Up @@ -58,16 +58,6 @@
<property name="readOnly">
<bool>false</bool>
</property>
<property name="html">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Noto Sans'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
Expand Down Expand Up @@ -343,7 +333,7 @@ p, li { white-space: pre-wrap; }
<customwidgets>
<customwidget>
<class>QOwnNotesMarkdownTextEdit</class>
<extends>QTextEdit</extends>
<extends>QPlainTextEdit</extends>
<header location="global">widgets/qownnotesmarkdowntextedit.h</header>
</customwidget>
</customwidgets>
Expand Down
4 changes: 2 additions & 2 deletions src/dialogs/trashdialog.cpp
Expand Up @@ -106,7 +106,7 @@ TrashDialog::TrashDialog(QJSValue notes, MainWindow *mainWindow,

ui->trashListWidget->setCurrentRow(0);
if (dataList->count() > 0) {
ui->noteBrowser->setText(dataList->at(0));
ui->noteBrowser->setPlainText(dataList->at(0));
}
}

Expand Down Expand Up @@ -136,7 +136,7 @@ TrashDialog::~TrashDialog() {
}

void TrashDialog::on_trashListWidget_currentRowChanged(int currentRow) {
ui->noteBrowser->setText(dataList->value(currentRow));
ui->noteBrowser->setPlainText(dataList->value(currentRow));
}

void TrashDialog::dialogButtonClicked(QAbstractButton *button) {
Expand Down
9 changes: 1 addition & 8 deletions src/dialogs/trashdialog.ui
Expand Up @@ -74,13 +74,6 @@
<property name="readOnly">
<bool>true</bool>
</property>
<property name="html">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Oxygen-Sans'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="0">
Expand Down Expand Up @@ -119,7 +112,7 @@ p, li { white-space: pre-wrap; }
<customwidgets>
<customwidget>
<class>QOwnNotesMarkdownTextEdit</class>
<extends>QTextEdit</extends>
<extends>QPlainTextEdit</extends>
<header location="global">widgets/qownnotesmarkdowntextedit.h</header>
</customwidget>
</customwidgets>
Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/versiondialog.cpp
Expand Up @@ -120,7 +120,7 @@ VersionDialog::~VersionDialog() {

void VersionDialog::on_versionListWidget_currentRowChanged(int currentRow) {
ui->diffBrowser->setHtml(diffList->value(currentRow));
ui->noteTextEdit->setText(dataList->value(currentRow));
ui->noteTextEdit->setPlainText(dataList->value(currentRow));
}

void VersionDialog::dialogButtonClicked(QAbstractButton *button) {
Expand Down
9 changes: 1 addition & 8 deletions src/dialogs/versiondialog.ui
Expand Up @@ -118,13 +118,6 @@ p, li { white-space: pre-wrap; }
<property name="readOnly">
<bool>true</bool>
</property>
<property name="html">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Noto Sans'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="0">
Expand Down Expand Up @@ -159,7 +152,7 @@ p, li { white-space: pre-wrap; }
<customwidgets>
<customwidget>
<class>QOwnNotesMarkdownTextEdit</class>
<extends>QTextEdit</extends>
<extends>QPlainTextEdit</extends>
<header location="global">widgets/qownnotesmarkdowntextedit.h</header>
</customwidget>
</customwidgets>
Expand Down
10 changes: 5 additions & 5 deletions src/entities/notehistory.cpp
Expand Up @@ -6,7 +6,7 @@
* NoteHistoryItem implementation
*/

NoteHistoryItem::NoteHistoryItem(Note *note, QTextEdit *textEdit) {
NoteHistoryItem::NoteHistoryItem(Note *note, QPlainTextEdit *textEdit) {
_noteName = "";
_noteSubFolderPathData = "";
_cursorPosition = 0;
Expand Down Expand Up @@ -38,7 +38,7 @@ NoteHistoryItem::NoteHistoryItem(QString noteName,
* Returns the relative note text edit scrollbar position (0..1)
*/
float NoteHistoryItem::getTextEditScrollBarRelativePosition(
QTextEdit *textEdit) {
QPlainTextEdit *textEdit) {
QScrollBar *scrollBar = textEdit->verticalScrollBar();
int max = scrollBar->maximum();

Expand Down Expand Up @@ -73,7 +73,7 @@ float NoteHistoryItem::getRelativeScrollBarPosition() const {
*
* @param textEdit
*/
void NoteHistoryItem::restoreTextEditPosition(QTextEdit *textEdit) {
void NoteHistoryItem::restoreTextEditPosition(QPlainTextEdit *textEdit) {
// set the cursor position
QTextCursor c = textEdit->textCursor();
c.setPosition(_cursorPosition);
Expand Down Expand Up @@ -148,7 +148,7 @@ NoteHistory::NoteHistory() {
currentIndex = 0;
}

void NoteHistory::add(Note note, QTextEdit *textEdit) {
void NoteHistory::add(Note note, QPlainTextEdit *textEdit) {
if (!note.exists()) {
return;
}
Expand Down Expand Up @@ -178,7 +178,7 @@ void NoteHistory::add(Note note, QTextEdit *textEdit) {
qDebug() << " added to history: " << item;
}

void NoteHistory::updateCursorPositionOfNote(Note note, QTextEdit *textEdit) {
void NoteHistory::updateCursorPositionOfNote(Note note, QPlainTextEdit *textEdit) {
if (isEmpty()) {
return;
}
Expand Down
12 changes: 6 additions & 6 deletions src/entities/notehistory.h
@@ -1,15 +1,15 @@
#ifndef NOTEHISTORY_H
#define NOTEHISTORY_H

#include <QTextEdit>
#include <QPlainTextEdit>
#include <QDataStream>
#include "note.h"


class NoteHistoryItem
{
public:
explicit NoteHistoryItem(Note *note = NULL, QTextEdit *textEdit = NULL);
explicit NoteHistoryItem(Note *note = NULL, QPlainTextEdit *textEdit = NULL);
explicit NoteHistoryItem(QString noteName, QString noteSubFolderPathData,
int cursorPosition,
float relativeScrollBarPosition);
Expand All @@ -21,14 +21,14 @@ class NoteHistoryItem
Note getNote();
bool isNoteValid();
bool operator ==(const NoteHistoryItem &item) const;
void restoreTextEditPosition(QTextEdit *textEdit);
void restoreTextEditPosition(QPlainTextEdit *textEdit);

private:
QString _noteName;
QString _noteSubFolderPathData;
int _cursorPosition;
float _relativeScrollBarPosition;
static float getTextEditScrollBarRelativePosition(QTextEdit *textEdit);
static float getTextEditScrollBarRelativePosition(QPlainTextEdit *textEdit);
};

// we want to store the class to the settings
Expand All @@ -46,13 +46,13 @@ class NoteHistory

public:
explicit NoteHistory();
void add(Note note, QTextEdit *textEdit);
void add(Note note, QPlainTextEdit *textEdit);
friend QDebug operator<<(QDebug dbg, const NoteHistory &history);
bool back();
bool forward();
bool isEmpty();
NoteHistoryItem getCurrentHistoryItem();
void updateCursorPositionOfNote(Note note, QTextEdit *textEdit);
void updateCursorPositionOfNote(Note note, QPlainTextEdit *textEdit);
void clear();

NoteHistoryItem getLastItemOfNote(Note note);
Expand Down

0 comments on commit cb4d412

Please sign in to comment.