diff --git a/MdiChild.cpp b/MdiChild.cpp index 9285c16..6a63192 100644 --- a/MdiChild.cpp +++ b/MdiChild.cpp @@ -4,6 +4,12 @@ #include "ui_ExtensibleObjectModelUI.h" +/*! + * \brief MdiChild::MdiChild + * + * Implementation Status: ? + * + */ MdiChild::MdiChild() { setAttribute(Qt::WA_DeleteOnClose); @@ -11,11 +17,23 @@ connect(document(), SIGNAL(contentsChanged()), this, SIGNAL(documentContentsChanged())); } +/*! + * \brief MdiChild::~MdiChild + * + * Implementation Status: ? + * + */ MdiChild::~MdiChild() { closing(); } +/*! + * \brief MdiChild::newFile + * + * Implementation Status: ? + * + */ void MdiChild::newFile() { static int sequenceNumber = 1; @@ -25,6 +43,14 @@ connect(document(), SIGNAL(contentsChanged()), this, SLOT(documentWasModified())); } +/*! + * \brief MdiChild::loadFile + * \param fileName + * \return + * + * Implementation Status: ? + * + */ bool MdiChild::loadFile(const QString &fileName) { QFile file(fileName); @@ -43,11 +69,25 @@ return true; } +/*! + * \brief MdiChild::save + * \return + * + * Implementation Status: ? + * + */ bool MdiChild::save() { return (isUntitled) ? saveAs() : saveFile(curFile); } +/*! + * \brief MdiChild::saveAs prompts for the file name to save the file as + * \return + * + * Implementation Status: ? + * + */ bool MdiChild::saveAs() { QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), curFile); @@ -56,6 +96,14 @@ return saveFile(fileName); } +/*! + * \brief MdiChild::saveFile + * \param fileName + * \return + * + * Implementation Status: ? + * + */ bool MdiChild::saveFile(const QString &fileName) { QFile file(fileName); @@ -73,11 +121,25 @@ return true; } +/*! + * \brief MdiChild::userFriendlyCurrentFile + * \return + * + * Implementation Status: ? + * + */ QString MdiChild::userFriendlyCurrentFile() { return strippedName(curFile); } +/*! + * \brief MdiChild::closeEvent + * \param event + * + * Implementation Status: ? + * + */ void MdiChild::closeEvent(QCloseEvent *event) { if (maybeSave()) { @@ -87,11 +149,24 @@ } } +/*! + * \brief MdiChild::documentWasModified + * + * Implementation Status: ? + * + */ void MdiChild::documentWasModified() { setWindowModified(document()->isModified()); } +/*! + * \brief MdiChild::maybeSave + * \return + * + * Implementation Status: ? + * + */ bool MdiChild::maybeSave() { if (document()->isModified()) { @@ -110,6 +185,13 @@ return true; } +/*! + * \brief MdiChild::setCurrentFile + * \param fileName + * + * Implementation Status: ? + * + */ void MdiChild::setCurrentFile(const QString &fileName) { curFile = QFileInfo(fileName).canonicalFilePath(); @@ -119,13 +201,27 @@ setWindowTitle(userFriendlyCurrentFile() + "[*]"); } +/*! + * \brief MdiChild::strippedName + * \param fullFileName + * \return + * + * Implementation Status: ? + * + */ QString MdiChild::strippedName(const QString &fullFileName) { return QFileInfo(fullFileName).fileName(); } - - +/*! + * \brief MdiChild::markdownSelection + * \param preText + * \param postText + * + * Implementation Status: ? + * + */ void MdiChild::markdownSelection(const char* preText, const char* postText) { QTextCursor cur = textCursor(); @@ -136,106 +232,269 @@ cur.endEditBlock(); } +/*! + * \brief MdiChild::insertText + * \param text + * + * Implementation Status: ? + * TODO: Appears to replace current selection. Is that expected? Perhaps should only add text. + * + */ +void MdiChild::insertText(const char* text) +{ + QTextCursor cur = textCursor(); + cur.beginEditBlock(); + cur.insertText(text); + cur.endEditBlock(); +} - +/*! + * \brief MdiChild::bold + * + * Implementation Status: 50% + * TODO: modal bold? If no selection, click it, type, then click it again to turn off bold mode + * + */ void MdiChild::bold() { markdownSelection("**", "**"); } +/*! + * \brief MdiChild::italic + * + * Implementation Status: ? + * + */ void MdiChild::italic() { markdownSelection("*", "*"); } +/*! + * \brief MdiChild::quote + * + * Implementation Status: ? + * + */ void MdiChild::quote() { markdownSelection("`", "`"); } +/*! + * \brief MdiChild::code + * + * Implementation Status: ? + * + */ void MdiChild::code() { //markdownSelection("*", "*"); // Need to add indentation of text with 4 spaces each line } +/*! + * \brief MdiChild::heading1 + * + * Implementation Status: ? + * + */ void MdiChild::heading1() { markdownSelection("# ", " #"); } +/*! + * \brief MdiChild::heading2 + * + * Implementation Status: ? + * + */ void MdiChild::heading2() { markdownSelection("## ", " ##"); } +/*! + * \brief MdiChild::heading3 + * + * Implementation Status: ? + * + */ void MdiChild::heading3() { markdownSelection("### ", " ###"); } +/*! + * \brief MdiChild::heading4 + * + * Implementation Status: ? + * + */ void MdiChild::heading4() { markdownSelection("#### ", " ####"); } +/*! + * \brief MdiChild::hyperlink + * + * Implementation Status: ? + * + */ void MdiChild::hyperlink() { } +/*! + * \brief MdiChild::image + * + * Implementation Status: ? + * + */ void MdiChild::image() { } +/*! + * \brief MdiChild::unorderedList + * + * Implementation Status: ? + * + */ void MdiChild::unorderedList() { } +/*! + * \brief MdiChild::orderedList + * + * Implementation Status: ? + * + */ void MdiChild::orderedList() { } +/*! + * \brief MdiChild::horizontalRule + * + * Implementation Status: 0% + * + */ void MdiChild::horizontalRule() { + insertText("----------"); } +/*! + * \brief MdiChild::timestamp + * + * Implementation Status: 0% + * TODO: Appears to replace current selection. Is that expected? + * + */ void MdiChild::timestamp() { + insertText("[TIMESTAMP]"); } +/*! + * \brief MdiChild::pageNumber + * + * Implementation Status: 0% + * + */ void MdiChild::pageNumber() { + insertText("[PAGENUM]"); } +/*! + * \brief MdiChild::pageCount + * + * Implementation Status: 0% + * + */ void MdiChild::pageCount() { + insertText("[PAGECOUNT]"); } +/*! + * \brief MdiChild::del + * + * Implementation Status: 100% + * + */ void MdiChild::del() { - //QTextEdit::cursor().pos() + QTextCursor cur = textCursor(); + cur.beginEditBlock(); + cur.removeSelectedText(); + cur.endEditBlock(); } +/*! + * \brief MdiChild::undo + * + * Implementation Status: 100% + * + */ void MdiChild::undo() { + QTextEdit::undo(); } +/*! + * \brief MdiChild::redo + * + * Implementation Status: 100% + * + */ void MdiChild::redo() { + QTextEdit::redo(); } +/*! + * \brief MdiChild::find + * + * Implementation Status: 0% + * + */ void MdiChild::find() { } +/*! + * \brief MdiChild::findNext + * + * Implementation Status: 0% + * + */ void MdiChild::findNext() { } +/*! + * \brief MdiChild::findPrevious + * + * Implementation Status: 0% + * + */ void MdiChild::findPrevious() { } +/*! + * \brief MdiChild::goToLine + * + * Implementation Status: 0% + * + */ void MdiChild::goToLine() { } diff --git a/MdiChild.cpp b/MdiChild.cpp index 9285c16..6a63192 100644 --- a/MdiChild.cpp +++ b/MdiChild.cpp @@ -4,6 +4,12 @@ #include "ui_ExtensibleObjectModelUI.h" +/*! + * \brief MdiChild::MdiChild + * + * Implementation Status: ? + * + */ MdiChild::MdiChild() { setAttribute(Qt::WA_DeleteOnClose); @@ -11,11 +17,23 @@ connect(document(), SIGNAL(contentsChanged()), this, SIGNAL(documentContentsChanged())); } +/*! + * \brief MdiChild::~MdiChild + * + * Implementation Status: ? + * + */ MdiChild::~MdiChild() { closing(); } +/*! + * \brief MdiChild::newFile + * + * Implementation Status: ? + * + */ void MdiChild::newFile() { static int sequenceNumber = 1; @@ -25,6 +43,14 @@ connect(document(), SIGNAL(contentsChanged()), this, SLOT(documentWasModified())); } +/*! + * \brief MdiChild::loadFile + * \param fileName + * \return + * + * Implementation Status: ? + * + */ bool MdiChild::loadFile(const QString &fileName) { QFile file(fileName); @@ -43,11 +69,25 @@ return true; } +/*! + * \brief MdiChild::save + * \return + * + * Implementation Status: ? + * + */ bool MdiChild::save() { return (isUntitled) ? saveAs() : saveFile(curFile); } +/*! + * \brief MdiChild::saveAs prompts for the file name to save the file as + * \return + * + * Implementation Status: ? + * + */ bool MdiChild::saveAs() { QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), curFile); @@ -56,6 +96,14 @@ return saveFile(fileName); } +/*! + * \brief MdiChild::saveFile + * \param fileName + * \return + * + * Implementation Status: ? + * + */ bool MdiChild::saveFile(const QString &fileName) { QFile file(fileName); @@ -73,11 +121,25 @@ return true; } +/*! + * \brief MdiChild::userFriendlyCurrentFile + * \return + * + * Implementation Status: ? + * + */ QString MdiChild::userFriendlyCurrentFile() { return strippedName(curFile); } +/*! + * \brief MdiChild::closeEvent + * \param event + * + * Implementation Status: ? + * + */ void MdiChild::closeEvent(QCloseEvent *event) { if (maybeSave()) { @@ -87,11 +149,24 @@ } } +/*! + * \brief MdiChild::documentWasModified + * + * Implementation Status: ? + * + */ void MdiChild::documentWasModified() { setWindowModified(document()->isModified()); } +/*! + * \brief MdiChild::maybeSave + * \return + * + * Implementation Status: ? + * + */ bool MdiChild::maybeSave() { if (document()->isModified()) { @@ -110,6 +185,13 @@ return true; } +/*! + * \brief MdiChild::setCurrentFile + * \param fileName + * + * Implementation Status: ? + * + */ void MdiChild::setCurrentFile(const QString &fileName) { curFile = QFileInfo(fileName).canonicalFilePath(); @@ -119,13 +201,27 @@ setWindowTitle(userFriendlyCurrentFile() + "[*]"); } +/*! + * \brief MdiChild::strippedName + * \param fullFileName + * \return + * + * Implementation Status: ? + * + */ QString MdiChild::strippedName(const QString &fullFileName) { return QFileInfo(fullFileName).fileName(); } - - +/*! + * \brief MdiChild::markdownSelection + * \param preText + * \param postText + * + * Implementation Status: ? + * + */ void MdiChild::markdownSelection(const char* preText, const char* postText) { QTextCursor cur = textCursor(); @@ -136,106 +232,269 @@ cur.endEditBlock(); } +/*! + * \brief MdiChild::insertText + * \param text + * + * Implementation Status: ? + * TODO: Appears to replace current selection. Is that expected? Perhaps should only add text. + * + */ +void MdiChild::insertText(const char* text) +{ + QTextCursor cur = textCursor(); + cur.beginEditBlock(); + cur.insertText(text); + cur.endEditBlock(); +} - +/*! + * \brief MdiChild::bold + * + * Implementation Status: 50% + * TODO: modal bold? If no selection, click it, type, then click it again to turn off bold mode + * + */ void MdiChild::bold() { markdownSelection("**", "**"); } +/*! + * \brief MdiChild::italic + * + * Implementation Status: ? + * + */ void MdiChild::italic() { markdownSelection("*", "*"); } +/*! + * \brief MdiChild::quote + * + * Implementation Status: ? + * + */ void MdiChild::quote() { markdownSelection("`", "`"); } +/*! + * \brief MdiChild::code + * + * Implementation Status: ? + * + */ void MdiChild::code() { //markdownSelection("*", "*"); // Need to add indentation of text with 4 spaces each line } +/*! + * \brief MdiChild::heading1 + * + * Implementation Status: ? + * + */ void MdiChild::heading1() { markdownSelection("# ", " #"); } +/*! + * \brief MdiChild::heading2 + * + * Implementation Status: ? + * + */ void MdiChild::heading2() { markdownSelection("## ", " ##"); } +/*! + * \brief MdiChild::heading3 + * + * Implementation Status: ? + * + */ void MdiChild::heading3() { markdownSelection("### ", " ###"); } +/*! + * \brief MdiChild::heading4 + * + * Implementation Status: ? + * + */ void MdiChild::heading4() { markdownSelection("#### ", " ####"); } +/*! + * \brief MdiChild::hyperlink + * + * Implementation Status: ? + * + */ void MdiChild::hyperlink() { } +/*! + * \brief MdiChild::image + * + * Implementation Status: ? + * + */ void MdiChild::image() { } +/*! + * \brief MdiChild::unorderedList + * + * Implementation Status: ? + * + */ void MdiChild::unorderedList() { } +/*! + * \brief MdiChild::orderedList + * + * Implementation Status: ? + * + */ void MdiChild::orderedList() { } +/*! + * \brief MdiChild::horizontalRule + * + * Implementation Status: 0% + * + */ void MdiChild::horizontalRule() { + insertText("----------"); } +/*! + * \brief MdiChild::timestamp + * + * Implementation Status: 0% + * TODO: Appears to replace current selection. Is that expected? + * + */ void MdiChild::timestamp() { + insertText("[TIMESTAMP]"); } +/*! + * \brief MdiChild::pageNumber + * + * Implementation Status: 0% + * + */ void MdiChild::pageNumber() { + insertText("[PAGENUM]"); } +/*! + * \brief MdiChild::pageCount + * + * Implementation Status: 0% + * + */ void MdiChild::pageCount() { + insertText("[PAGECOUNT]"); } +/*! + * \brief MdiChild::del + * + * Implementation Status: 100% + * + */ void MdiChild::del() { - //QTextEdit::cursor().pos() + QTextCursor cur = textCursor(); + cur.beginEditBlock(); + cur.removeSelectedText(); + cur.endEditBlock(); } +/*! + * \brief MdiChild::undo + * + * Implementation Status: 100% + * + */ void MdiChild::undo() { + QTextEdit::undo(); } +/*! + * \brief MdiChild::redo + * + * Implementation Status: 100% + * + */ void MdiChild::redo() { + QTextEdit::redo(); } +/*! + * \brief MdiChild::find + * + * Implementation Status: 0% + * + */ void MdiChild::find() { } +/*! + * \brief MdiChild::findNext + * + * Implementation Status: 0% + * + */ void MdiChild::findNext() { } +/*! + * \brief MdiChild::findPrevious + * + * Implementation Status: 0% + * + */ void MdiChild::findPrevious() { } +/*! + * \brief MdiChild::goToLine + * + * Implementation Status: 0% + * + */ void MdiChild::goToLine() { } diff --git a/MdiChild.h b/MdiChild.h index 0f7e3e8..87d11b1 100644 --- a/MdiChild.h +++ b/MdiChild.h @@ -21,6 +21,7 @@ QString currentFile() { return curFile; } void markdownSelection(const char* preText, const char* postText); + void insertText(const char* text); void bold(); void italic();