[rkward/work/kateintegration] rkward/windows: Confine scope of enum

Thomas Friedrichsmeier null at kde.org
Sat Jan 11 23:03:55 GMT 2020


Git commit e3ddb52ec24b8d49ab032826aae7088b83aaea1c by Thomas Friedrichsmeier.
Committed on 11/01/2020 at 23:03.
Pushed by tfry into branch 'work/kateintegration'.

Confine scope of enum

M  +7    -7    rkward/windows/rkcommandeditorwindow.cpp
M  +10   -8    rkward/windows/rkworkplace.h

https://commits.kde.org/rkward/e3ddb52ec24b8d49ab032826aae7088b83aaea1c

diff --git a/rkward/windows/rkcommandeditorwindow.cpp b/rkward/windows/rkcommandeditorwindow.cpp
index d225569d..7beca4a9 100644
--- a/rkward/windows/rkcommandeditorwindow.cpp
+++ b/rkward/windows/rkcommandeditorwindow.cpp
@@ -112,8 +112,8 @@ RKCommandEditorWindow::RKCommandEditorWindow (QWidget *parent, const QUrl _url,
 	QUrl url = _url;
 	m_doc = 0;
 	preview_dir = 0;
-	visible_to_kateplugins = flags & VisibleToKTextEditorPlugins;
-	bool use_r_highlighting = (flags & ForceRHighlighting) || (url.isEmpty() && (flags & DefaultToRHighlighting)) || RKSettingsModuleCommandEditor::matchesScriptFileFilter (url.fileName ());
+	visible_to_kateplugins = flags & RKCommandEditorFlags::VisibleToKTextEditorPlugins;
+	bool use_r_highlighting = (flags & RKCommandEditorFlags::ForceRHighlighting) || (url.isEmpty() && (flags & RKCommandEditorFlags::DefaultToRHighlighting)) || RKSettingsModuleCommandEditor::matchesScriptFileFilter (url.fileName ());
 
 	// Lookup of existing text editor documents: First, if no url is given at all, create a new document, and register an id, in case this window will get split, later
 	if (url.isEmpty ()) {
@@ -158,7 +158,7 @@ RKCommandEditorWindow::RKCommandEditorWindow (QWidget *parent, const QUrl _url,
 		if (!url.isEmpty ()) {
 			if (m_doc->openUrl (url)) {
 				// KF5 TODO: Check which parts of this are still needed in KF5, and which no longer work
-				if (!(flags & DeleteOnClose)) {	// don't litter config with temporary files
+				if (!(flags & RKCommandEditorFlags::DeleteOnClose)) {	// don't litter config with temporary files
 					QString p_url = RKWorkplace::mainWorkplace ()->portableUrl (m_doc->url ());
 					KConfigGroup conf (RKWorkplace::mainWorkplace ()->workspaceConfig (), QString ("SkriptDocumentSettings %1").arg (p_url));
 					// HACK: Hmm. KTextEditor::Document's readSessionConfig() simply restores too much. Yes, I want to load bookmarks and stuff.
@@ -177,10 +177,10 @@ RKCommandEditorWindow::RKCommandEditorWindow (QWidget *parent, const QUrl _url,
 		}
 	}
 
-	setReadOnly (flags & ReadOnly);
+	setReadOnly (flags & RKCommandEditorFlags::ReadOnly);
 
-	if (flags & DeleteOnClose) {
-		if (flags & ReadOnly) {
+	if (flags & RKCommandEditorFlags::DeleteOnClose) {
+		if (flags & RKCommandEditorFlags::ReadOnly) {
 			RKCommandEditorWindow::delete_on_close = url;
 		} else {
 			RK_ASSERT (false);
@@ -242,7 +242,7 @@ RKCommandEditorWindow::RKCommandEditorWindow (QWidget *parent, const QUrl _url,
 	hinter = 0;
 	if (use_r_highlighting) {
 		RKCommandHighlighter::setHighlighting (m_doc, RKCommandHighlighter::RScript);
-		if (flags & UseCodeHinting) {
+		if (flags & RKCommandEditorFlags::UseCodeHinting) {
 			new RKCompletionManager (m_view);
 			//hinter = new RKFunctionArgHinter (this, m_view);
 		}
diff --git a/rkward/windows/rkworkplace.h b/rkward/windows/rkworkplace.h
index c77700f8..25e5e7c6 100644
--- a/rkward/windows/rkworkplace.h
+++ b/rkward/windows/rkworkplace.h
@@ -68,16 +68,18 @@ private:
 	RKMDIWindowHistoryWidget *getSwitcher (QAction *prev_action, QAction *next_action);
 };
 
+struct RKCommandEditorFlags {
 /** Or'able enum of flags to pass the RKCommandEditorWindow c'tor. Logically, these would belong to the RKCommandEditor-class,
     but are defined, here for technical reasons (trouble including texteditor includes from some places). */
-enum RKCommandEditorFlags {
-	DefaultToRHighlighting = 1, ///< Apply R highlighting, also if the url is empty
-	ForceRHighlighting = 1 << 1,///< Apply R highlighting, even if the url does not match R script extension
-	UseCodeHinting = 1 << 2,    ///< The file is (probably) an editable R script file, and should show code hints
-	ReadOnly = 1 << 3,          ///< Open the file in read-only mode
-	DeleteOnClose = 1 << 4,     ///< The file to show should be deleted when closing the window. Only respected with read_only=true
-	VisibleToKTextEditorPlugins = 1 << 5,
-	DefaultFlags = DefaultToRHighlighting | UseCodeHinting | VisibleToKTextEditorPlugins
+	enum Flags {
+		DefaultToRHighlighting = 1, ///< Apply R highlighting, also if the url is empty
+		ForceRHighlighting = 1 << 1,///< Apply R highlighting, even if the url does not match R script extension
+		UseCodeHinting = 1 << 2,    ///< The file is (probably) an editable R script file, and should show code hints
+		ReadOnly = 1 << 3,          ///< Open the file in read-only mode
+		DeleteOnClose = 1 << 4,     ///< The file to show should be deleted when closing the window. Only respected with read_only=true
+		VisibleToKTextEditorPlugins = 1 << 5,
+		DefaultFlags = DefaultToRHighlighting | UseCodeHinting | VisibleToKTextEditorPlugins
+	};
 };
 
 /** This class (only one instance will probably be around) keeps track of which windows are opened in the workplace, which are detached, etc. Also it is responsible for creating and manipulating those windows.



More information about the rkward-tracker mailing list