File indexing completed on 2024-12-15 04:51:47
0001 /* 0002 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #include "noteeditorutils.h" 0007 0008 #include <QLocale> 0009 0010 #include <QChar> 0011 #include <QDateTime> 0012 #include <QTextCursor> 0013 #include <QTextEdit> 0014 0015 using namespace NoteShared; 0016 NoteEditorUtils::NoteEditorUtils() = default; 0017 0018 void NoteEditorUtils::addCheckmark(QTextCursor &cursor) 0019 { 0020 static const QChar unicode[] = {QChar(0x2713)}; 0021 const int size = sizeof(unicode) / sizeof(QChar); 0022 const int position = cursor.position(); 0023 cursor.movePosition(QTextCursor::StartOfLine); 0024 const QString checkMark = QString::fromRawData(unicode, size); 0025 cursor.insertText(checkMark); 0026 cursor.setPosition(position + checkMark.size()); 0027 } 0028 0029 void NoteEditorUtils::insertDate(QTextEdit *editor) 0030 { 0031 editor->insertPlainText(QLocale().toString(QDateTime::currentDateTime(), QLocale::ShortFormat) + QLatin1Char(' ')); 0032 }