From e19f9a02df7379c45782b81e2f401c9a4f6869a5 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sat, 5 Aug 2023 13:26:43 +0900 Subject: [PATCH] Finish off the indenter code and update to TQ_OBJECT Signed-off-by: Michele Calgaro --- src/AboutDialog.h | 2 +- src/IndentHandler.cpp | 103 ++++++--------------------- src/IndentHandler.h | 12 +--- src/MainWindow.cpp | 10 ++- src/UiGuiErrorMessage.h | 2 +- src/UiGuiSettings.h | 2 +- src/__TODO/AboutDialogGraphicsView.h | 2 +- src/__TODO/UiGuiHighlighter.h | 2 +- src/__TODO/UiGuiIndentServer.h | 2 +- src/__TODO/UiGuiSettingsDialog.h | 2 +- src/debugging/TSLogger.h | 2 +- 11 files changed, 37 insertions(+), 104 deletions(-) diff --git a/src/AboutDialog.h b/src/AboutDialog.h index 2447b08..9cfb375 100644 --- a/src/AboutDialog.h +++ b/src/AboutDialog.h @@ -25,7 +25,7 @@ class AboutDialog : public AboutDialogBase { - Q_OBJECT + TQ_OBJECT public: AboutDialog(TQWidget *parent = NULL, WFlags flags = 0); diff --git a/src/IndentHandler.cpp b/src/IndentHandler.cpp index 40ebe3f..588d6e4 100644 --- a/src/IndentHandler.cpp +++ b/src/IndentHandler.cpp @@ -51,9 +51,6 @@ #include #include #include -//--- #include -//--- #include -//--- #include // \defgroup grp_Indenter All concerning handling of the indenter. @@ -311,39 +308,7 @@ TQString IndentHandler::generateShellScript(const TQString &configFilename) */ TQString IndentHandler::callIndenter(const TQString &sourceCode, const TQString &inputFileExtension) { - if (m_indenterExecutableSuffix == ".js") - { - return callJavaScriptIndenter(sourceCode); - } - else - { - return callExecutableIndenter(sourceCode, inputFileExtension); - } -} - -/* - \brief Format \a sourceCode by calling the interpreted JavaScript code of the indenter. - - The \a inputFileExtension has to be given as parameter so the called indenter - can identify the programming language if needed. - */ -TQString IndentHandler::callJavaScriptIndenter(const TQString &sourceCode) -{ -//--- TQScriptEngine engine; -//--- -//--- engine.globalObject().setProperty("unformattedCode", sourceCode); -//--- -//--- TQFile jsDecoderFile(m_indenterExecutableCallString); -//--- TQString jsDecoderCode; -//--- if (jsDecoderFile.open(TQFile::ReadOnly)) -//--- { -//--- jsDecoderCode = jsDecoderFile.readAll(); -//--- } -//--- jsDecoderFile.close(); -//--- -//--- TQScriptValue value = engine.evaluate(jsDecoderCode); -//--- return value.toString(); -return ""; + return callExecutableIndenter(sourceCode, inputFileExtension); } /* @@ -1279,13 +1244,13 @@ void IndentHandler::setIndenter(int indenterID) TQApplication::restoreOverrideCursor(); } -//--- /* -//--- \brief Returns a string containing by the indenter supported file types/extensions divided by a space. -//--- */ -//--- TQString IndentHandler::getPossibleIndenterFileExtensions() -//--- { -//--- return m_fileTypes; -//--- } +/* + \brief Returns a string containing by the indenter supported file types/extensions divided by a space. + */ +TQString IndentHandler::getPossibleIndenterFileExtensions() +{ + return m_fileTypes; +} /* \brief Returns the path and filename of the current indenter config file. @@ -1523,20 +1488,20 @@ bool IndentHandler::createIndenterCallString() return false; } -//--- /* -//--- \brief Returns a string that points to where the indenters manual can be found. -//--- */ -//--- TQString IndentHandler::getManual() -//--- { -//--- if (m_indenterSettings != nullptr) -//--- { -//--- return m_indenterSettings->value("header/manual").toString(); -//--- } -//--- else -//--- { -//--- return ""; -//--- } -//--- } +/* + \brief Returns a string that points to where the indenters manual can be found. + */ +TQString IndentHandler::getManual() +{ + if (m_indenterSettings != nullptr) + { + return m_indenterSettings->value("header/manual").toString(); + } + else + { + return ""; + } +} /* \brief This slot gets the reference to the indenters manual and opens it. @@ -1676,30 +1641,6 @@ void IndentHandler::resetIndenterParameter() } } -//--- /* -//--- \brief Catch some events and let some other be handled by the super class. -//--- -//--- Is needed for use as Notepad++ plugin. -//--- */ -//--- bool IndentHandler::event(TQEvent *event) -//--- { -//--- if (event->type() == TQEvent::WindowActivate) -//--- { -//--- event->accept(); -//--- return true; -//--- } -//--- else if (event->type() == TQEvent::WindowDeactivate) -//--- { -//--- event->accept(); -//--- return true; -//--- } -//--- else -//--- { -//--- event->ignore(); -//--- return TQWidget::event(event); -//--- } -//--- } - /* \brief Emits the \a indenterSettingsChanged signal */ diff --git a/src/IndentHandler.h b/src/IndentHandler.h index d719fce..0d61544 100644 --- a/src/IndentHandler.h +++ b/src/IndentHandler.h @@ -40,7 +40,7 @@ class TQVBoxLayout; class IndentHandler : public TQWidget { - Q_OBJECT + TQ_OBJECT public: IndentHandler(int indenterID, MainWindow *mainWindow = nullptr, TQWidget *parent = nullptr); @@ -51,20 +51,15 @@ class IndentHandler : public TQWidget bool loadConfigFile(const TQString &filePathName); void resetToDefaultValues(); TQStringList getAvailableIndenters(); -///-- TQString getPossibleIndenterFileExtensions(); + TQString getPossibleIndenterFileExtensions(); TQString getParameterString(); TQString getIndenterCfgFile(); -///-- TQString getManual(); + TQString getManual(); TQString getCurrentIndenterName(); void contextMenuEvent(TQContextMenuEvent *event); signals: void indenterSettingsChanged(); -///-- void selectedIndenterIndexChanged(int index); - -///-- protected: -///-- bool event(TQEvent *event); -///-- void wheelEvent(TQWheelEvent *event); private slots: void setIndenter(int indenterID); @@ -78,7 +73,6 @@ class IndentHandler : public TQWidget private: TQString callExecutableIndenter(const TQString &sourceCode, const TQString &inputFileExt); - TQString callJavaScriptIndenter(const TQString &sourceCode); void saveConfigFile(const TQString &filePathName, const TQString ¶meterString); void readIndentIniFile(const TQString &iniFilePath); bool createIndenterCallString(); diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 48f65d4..c945da4 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -522,9 +522,8 @@ void MainWindow::openSourceFileDialog(const TQString &fileName) return; } TQString openedSourceFileContent = ""; - TQString fileExtensions = "*.h *.c *.cpp *.*"; // Remove this line when the indenter is available -///-- TQString fileExtensions = tr("Supported by indenter") + " (" + -///-- m_indentHandler->getPossibleIndenterFileExtensions() + ");;" + tr("All files") + " (*.*)"; + TQString fileExtensions = tr("Supported by indenter") + " (" + + m_indentHandler->getPossibleIndenterFileExtensions() + ");;" + tr("All files") + " (*.*)"; TQString fileToOpen = fileName; if (fileToOpen.isEmpty()) @@ -565,9 +564,8 @@ void MainWindow::openSourceFileDialog(const TQString &fileName) */ bool MainWindow::saveasSourceFileDialog(TQAction *chosenEncodingAction) { - TQString fileExtensions = "*.h *.c *.cpp *.*"; // Remove this line when the indenter is available -//--- TQString fileExtensions = tr("Supported by indenter") + " (" + -//--- m_indentHandler->getPossibleIndenterFileExtensions() + ");;" + tr("All files") + " (*.*)"; + TQString fileExtensions = tr("Supported by indenter") + " (" + + m_indentHandler->getPossibleIndenterFileExtensions() + ");;" + tr("All files") + " (*.*)"; TQString fileName = TQFileDialog::getSaveFileName(m_currentSourceFile, fileExtensions, this, nullptr, tr("Save source code file")); diff --git a/src/UiGuiErrorMessage.h b/src/UiGuiErrorMessage.h index 480ec86..62ab16b 100644 --- a/src/UiGuiErrorMessage.h +++ b/src/UiGuiErrorMessage.h @@ -28,7 +28,7 @@ class TQCheckBox; class UiGuiErrorMessage : public TQErrorMessage { - Q_OBJECT + TQ_OBJECT public: UiGuiErrorMessage(TQWidget *parent = nullptr); diff --git a/src/UiGuiSettings.h b/src/UiGuiSettings.h index adfaf52..df9d04f 100644 --- a/src/UiGuiSettings.h +++ b/src/UiGuiSettings.h @@ -30,7 +30,7 @@ class TQSettings; class UiGuiSettings : public TQObject { - Q_OBJECT + TQ_OBJECT private: UiGuiSettings(); diff --git a/src/__TODO/AboutDialogGraphicsView.h b/src/__TODO/AboutDialogGraphicsView.h index 4554e36..1cc5d37 100644 --- a/src/__TODO/AboutDialogGraphicsView.h +++ b/src/__TODO/AboutDialogGraphicsView.h @@ -29,7 +29,7 @@ class TQSplashScreen; class AboutDialogGraphicsView : public TQGraphicsView { - Q_OBJECT + TQ_OBJECT public: AboutDialogGraphicsView(AboutDialog *aboutDialog, TQWidget *parentWindow = NULL); diff --git a/src/__TODO/UiGuiHighlighter.h b/src/__TODO/UiGuiHighlighter.h index 602017e..d160f9b 100644 --- a/src/__TODO/UiGuiHighlighter.h +++ b/src/__TODO/UiGuiHighlighter.h @@ -34,7 +34,7 @@ class QsciLexer; class UiGuiHighlighter : public TQObject { - Q_OBJECT + TQ_OBJECT public: UiGuiHighlighter(TQextScintilla *parent); diff --git a/src/__TODO/UiGuiIndentServer.h b/src/__TODO/UiGuiIndentServer.h index 3f8c996..9bf72d2 100644 --- a/src/__TODO/UiGuiIndentServer.h +++ b/src/__TODO/UiGuiIndentServer.h @@ -28,7 +28,7 @@ class TQTcpSocket; class UiGuiIndentServer : public TQObject { - Q_OBJECT + TQ_OBJECT public: UiGuiIndentServer(void); diff --git a/src/__TODO/UiGuiSettingsDialog.h b/src/__TODO/UiGuiSettingsDialog.h index 8dc9543..eef08d6 100644 --- a/src/__TODO/UiGuiSettingsDialog.h +++ b/src/__TODO/UiGuiSettingsDialog.h @@ -32,7 +32,7 @@ namespace Ui class UiGuiSettingsDialog : public TQDialog { - Q_OBJECT + TQ_OBJECT public: UiGuiSettingsDialog(TQWidget *parent, TQSharedPointer settings); diff --git a/src/debugging/TSLogger.h b/src/debugging/TSLogger.h index 261398c..8510ecb 100644 --- a/src/debugging/TSLogger.h +++ b/src/debugging/TSLogger.h @@ -36,7 +36,7 @@ namespace tschweitzer class TSLogger : public TQDialog { - Q_OBJECT + TQ_OBJECT public: static TSLogger* getInstance(int verboseLevel);