[PATCH] Patches to review

Yuriy Skalko yuriy.skalko at gmail.com
Thu Jan 21 07:38:08 UTC 2021


Please review my recent patches for LyX.

Yuriy
-------------- next part --------------
From 9c9fd209149b05d6ec879d1792b9628734ce3ed5 Mon Sep 17 00:00:00 2001
From: Yuriy Skalko <yuriy.skalko at gmail.com>
Date: Sun, 10 Jan 2021 13:27:40 +0200
Subject: [PATCH 1/5] Update Development.lyx

---
 lib/doc/Development.lyx | 99 +++++++++++++++++++++++++++--------------
 1 file changed, 65 insertions(+), 34 deletions(-)

diff --git a/lib/doc/Development.lyx b/lib/doc/Development.lyx
index 5a4c3864d7..46f253ff11 100644
--- a/lib/doc/Development.lyx
+++ b/lib/doc/Development.lyx
@@ -1,5 +1,5 @@
 #LyX 2.4 created this file. For more info see https://www.lyx.org/
-\lyxformat 600
+\lyxformat 601
 \begin_document
 \begin_header
 \save_transient_properties true
@@ -3616,7 +3616,7 @@ Wontfix
 \end_layout
 
 \begin_layout Paragraph
-suspended tests
+Suspended tests
 \end_layout
 
 \begin_layout Standard
@@ -5178,7 +5178,7 @@ PDF (pdflatex)
 
 \begin_layout Enumerate
 All fixes (typos, compilation fixes, updates info etc.) go at first into
- the current GIT branch because the user should benefit from all fixes with
+ the current Git branch because the user should benefit from all fixes with
  every minor release.
  Feel free to commit directly to branch as long as you follow rule
 \begin_inset space ~
@@ -5213,12 +5213,10 @@ The main documentation consists of these files:
 \end_layout
 
 \begin_layout Description
-Welcome.lyx it is the first file you see after an installation.
+Welcome.lyx It is the first file you see after an installation.
  We assume that a new user sees this.
  It is therefore designed to be as simple as possible.
  Therefore please don't add any new formatting, only fix typos etc.
- Welcome.lyx is up to date for \SpecialChar LyX
- 2.1.x, currently maintained by Uwe Stöhr.
 \end_layout
 
 \begin_layout Description
@@ -5229,60 +5227,47 @@ Intro.lyx This is the manual new users will read to learn \SpecialChar LyX
  Since new users will first learn about the formatting possibilities of
  \SpecialChar LyX
  please keep this file that simple.
- Intro.lyx is up to date for \SpecialChar LyX
- 2.1.x, currently maintained by Uwe Stöhr.
 \end_layout
 
 \begin_layout Description
-Tutorial.lyx our tutorial.
+Tutorial.lyx Our tutorial.
  It must be always up to date.
  Normally there is nothing to add since we don't want to overwhelm new users
  with too much details.
- The will learn these details while using \SpecialChar LyX
+ They will learn these details while using \SpecialChar LyX
  and we have special manuals.
- Tutorial.lyx is up to date for \SpecialChar LyX
- 2.1.x, currently maintained by Uwe Stöhr.
 \end_layout
 
 \begin_layout Description
-UserGuide.lyx our main user guide.
+UserGuide.lyx Our main user guide.
  It covers a mixture of basic and detailed information.
  Some information is also in the Math and EmbeddedObjects manual so that
  the UserGuide refers to these files.
- UserGuide.lyx is up to date for \SpecialChar LyX
- 2.1.x, currently maintained by Uwe Stöhr.
 \end_layout
 
 \begin_layout Description
-EmbeddedObjects.lyx a special manual to explain things like tables floats
+EmbeddedObjects.lyx A special manual to explain things like tables floats
  boxes etc.
  in all detail.
- EmbeddedObjects.lyx is up to date for \SpecialChar LyX
- 2.1.x, currently maintained by Uwe
- Stöhr.
 \end_layout
 
 \begin_layout Description
-Math.lyx a special manual to explain everything regarding math in all detail.
- Math.lyx is up to date for \SpecialChar LyX
- 2.1.x, currently maintained by Uwe Stöhr.
+Math.lyx A special manual to explain everything regarding math in all detail.
 \end_layout
 
 \begin_layout Description
-Additional.lyx this manual covers information that would be too much detail
+Additional.lyx This manual covers information that would be too much detail
  for the UserGuide or would make the UserGuide uncompilable or only compilable
  when installing a lot of special \SpecialChar LaTeX
--packages.
+ packages.
  What should be in the UserGuide or better in Additional is a matter of
  taste.
- it is up to you to decide that.
- Additional.lyx is not completely up to date for \SpecialChar LyX
- 2.1.x.
- Only chapter
+ It is up to you to decide that.
+ Additional.lyx is not completely up to date (only chapter
 \begin_inset space ~
 \end_inset
 
-8 is up to date and currently maintained by Uwe Stöhr.
+8 is up to date).
  It certainly needs a rewrite and update.
  For example many info in chapter
 \begin_inset space ~
@@ -5293,7 +5278,7 @@ Additional.lyx this manual covers information that would be too much detail
 \end_layout
 
 \begin_layout Description
-Customization.lyx this manual covers information how to customize \SpecialChar LyX
+Customization.lyx This manual covers information how to customize \SpecialChar LyX
  for certain
  output formats, operating systems, languages etc.
  It is currently completely out of date and needs a major rewrite and update.
@@ -5861,7 +5846,12 @@ switch (f) {
 
 \begin_layout Plain Layout
 
-case FOO_BAR1: ...; 
+case FOO_BAR1:
+\end_layout
+
+\begin_layout Plain Layout
+
+	...;
 \end_layout
 
 \begin_layout Plain Layout
@@ -5871,7 +5861,12 @@ case FOO_BAR1: ...;
 
 \begin_layout Plain Layout
 
-case FOO_BAR2: ...; 
+case FOO_BAR2:
+\end_layout
+
+\begin_layout Plain Layout
+
+	...;
 \end_layout
 
 \begin_layout Plain Layout
@@ -5881,12 +5876,12 @@ case FOO_BAR2: ...;
 
 \begin_layout Plain Layout
 
-default: ...; 
+default: // not needed and would shadow a wrong use of Foo
 \end_layout
 
 \begin_layout Plain Layout
 
-	// not needed and would shadow a wrong use of Foo
+	...;
 \end_layout
 
 \begin_layout Plain Layout
@@ -6393,6 +6388,42 @@ enum Foo {
 \end_layout
 
 \begin_layout Standard
+or (C++11)
+\end_layout
+
+\begin_layout Standard
+\begin_inset listings
+lstparams "basicstyle={\ttfamily},showstringspaces=false,tabsize=4"
+inline false
+status open
+
+\begin_layout Plain Layout
+
+enum class Foo {
+\end_layout
+
+\begin_layout Plain Layout
+
+	One = 1,
+\end_layout
+
+\begin_layout Plain Layout
+
+	Two = 2,
+\end_layout
+
+\begin_layout Plain Layout
+
+	Three = 3
+\end_layout
+
+\begin_layout Plain Layout
+
+};
+\end_layout
+
+\end_inset
+
 and not
 \end_layout
 
-- 
2.28.0.windows.1

-------------- next part --------------
From 5ed0e1f17dfaa62f0b12ed52ee20dca6a6b89a56 Mon Sep 17 00:00:00 2001
From: Yuriy Skalko <yuriy.skalko at gmail.com>
Date: Sun, 10 Jan 2021 23:16:28 +0200
Subject: [PATCH 2/5] QList -> std::vector

---
 src/frontends/qt/InsetParamsWidget.cpp | 6 +++---
 src/frontends/qt/InsetParamsWidget.h   | 5 ++---
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/frontends/qt/InsetParamsWidget.cpp b/src/frontends/qt/InsetParamsWidget.cpp
index 9f6d4eeb57..2393733eae 100644
--- a/src/frontends/qt/InsetParamsWidget.cpp
+++ b/src/frontends/qt/InsetParamsWidget.cpp
@@ -51,15 +51,15 @@ QString InsetParamsWidget::dialogTitle() const
 
 void InsetParamsWidget::addCheckedWidget(QLineEdit * input, QWidget * label)
 {
-	checked_widgets_.append(CheckedWidget(input, label));
+	checked_widgets_.push_back(CheckedWidget(input, label));
 }
 
 
 bool InsetParamsWidget::checkWidgets(bool) const
 {
 	bool valid = true;
-	Q_FOREACH(CheckedWidget const & le, checked_widgets_)
-			valid &= le.check();
+	for (CheckedWidget const & le : checked_widgets_)
+		valid &= le.check();
 	return valid;
 }
 
diff --git a/src/frontends/qt/InsetParamsWidget.h b/src/frontends/qt/InsetParamsWidget.h
index 0811ca5e49..ab8acb6035 100644
--- a/src/frontends/qt/InsetParamsWidget.h
+++ b/src/frontends/qt/InsetParamsWidget.h
@@ -19,6 +19,7 @@
 #include "support/strfwd.h"
 
 #include <QWidget>
+#include <vector>
 
 class QLineEdit;
 
@@ -45,8 +46,6 @@ private:
 };
 
 
-typedef QList<CheckedWidget> CheckedWidgets;
-
 class InsetParamsWidget : public QWidget
 {
 	Q_OBJECT
@@ -80,7 +79,7 @@ protected:
 	void addCheckedWidget(QLineEdit * input, QWidget * label = 0);
 private:
 	///
-	CheckedWidgets checked_widgets_;
+	std::vector<CheckedWidget> checked_widgets_;
 };
 
 } // namespace frontend
-- 
2.28.0.windows.1

-------------- next part --------------
From ebab58cefde7b25c7dfb7c7ffb826f812d3307f5 Mon Sep 17 00:00:00 2001
From: Yuriy Skalko <yuriy.skalko at gmail.com>
Date: Sun, 10 Jan 2021 23:44:39 +0200
Subject: [PATCH 3/5] Remove unused includes

---
 src/frontends/qt/qt_helpers.cpp | 2 --
 src/support/FileName.cpp        | 1 -
 2 files changed, 3 deletions(-)

diff --git a/src/frontends/qt/qt_helpers.cpp b/src/frontends/qt/qt_helpers.cpp
index 211d286dda..0f8bcd17c2 100644
--- a/src/frontends/qt/qt_helpers.cpp
+++ b/src/frontends/qt/qt_helpers.cpp
@@ -28,7 +28,6 @@
 #include "support/Systemcall.h"
 
 #include <QApplication>
-#include <QCheckBox>
 #include <QComboBox>
 #include <QDesktopServices>
 #include <QDir>
@@ -36,7 +35,6 @@
 #include <QLocale>
 #include <QPalette>
 #include <QSet>
-#include <QTextLayout>
 #include <QTextDocument>
 #include <QToolTip>
 #include <QUrl>
diff --git a/src/support/FileName.cpp b/src/support/FileName.cpp
index 5295741e1a..fdae12ca78 100644
--- a/src/support/FileName.cpp
+++ b/src/support/FileName.cpp
@@ -27,7 +27,6 @@
 #include <QDir>
 #include <QFile>
 #include <QFileInfo>
-#include <QList>
 #include <QTemporaryFile>
 #include <QElapsedTimer>
 
-- 
2.28.0.windows.1

-------------- next part --------------
From 1a87c6edd4d848d63df6705b8c9c6a82ee0aef16 Mon Sep 17 00:00:00 2001
From: Yuriy Skalko <yuriy.skalko at gmail.com>
Date: Mon, 18 Jan 2021 15:50:34 +0200
Subject: [PATCH 4/5] Fix compiler warnings on recent Qt version

---
 src/frontends/qt/DockView.h        | 2 +-
 src/frontends/qt/FindAndReplace.h  | 2 +-
 src/frontends/qt/GuiProgressView.h | 2 +-
 src/frontends/qt/GuiSetBorder.h    | 2 +-
 src/frontends/qt/GuiSpellchecker.h | 2 +-
 src/frontends/qt/GuiViewSource.h   | 2 +-
 src/frontends/qt/GuiWorkArea.cpp   | 8 ++++----
 7 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/frontends/qt/DockView.h b/src/frontends/qt/DockView.h
index 9c3a9e7460..1e7bd5f2db 100644
--- a/src/frontends/qt/DockView.h
+++ b/src/frontends/qt/DockView.h
@@ -36,7 +36,7 @@ public:
 	         Qt::DockWidgetArea area = Qt::LeftDockWidgetArea, ///< Position of
 															   ///the dock (and
 															   ///also drawer)
-	         Qt::WindowFlags flags = 0);
+	         Qt::WindowFlags flags = {});
 
 	virtual ~DockView() {}
 
diff --git a/src/frontends/qt/FindAndReplace.h b/src/frontends/qt/FindAndReplace.h
index 169530a516..565db5afa6 100644
--- a/src/frontends/qt/FindAndReplace.h
+++ b/src/frontends/qt/FindAndReplace.h
@@ -79,7 +79,7 @@ public:
 	FindAndReplace(
 		GuiView & parent, ///< the main window where to dock.
 		Qt::DockWidgetArea area = Qt::RightDockWidgetArea, ///< Position of the dock (and also drawer)
-		Qt::WindowFlags flags = 0);
+		Qt::WindowFlags flags = {});
 
 	~FindAndReplace();
 
diff --git a/src/frontends/qt/GuiProgressView.h b/src/frontends/qt/GuiProgressView.h
index 1a722b31b2..f49112b707 100644
--- a/src/frontends/qt/GuiProgressView.h
+++ b/src/frontends/qt/GuiProgressView.h
@@ -47,7 +47,7 @@ public:
 	GuiProgressView(
 		GuiView & parent, ///< the main window where to dock.
 		Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, ///< Position of the dock (and also drawer)
-		Qt::WindowFlags flags = 0);
+		Qt::WindowFlags flags = {});
 
 	~GuiProgressView();
 	/// Controller inherited method.
diff --git a/src/frontends/qt/GuiSetBorder.h b/src/frontends/qt/GuiSetBorder.h
index 5e444743c7..509c6000e5 100644
--- a/src/frontends/qt/GuiSetBorder.h
+++ b/src/frontends/qt/GuiSetBorder.h
@@ -27,7 +27,7 @@ class GuiSetBorder : public QWidget
 {
 	Q_OBJECT
 public:
-	GuiSetBorder(QWidget * parent = nullptr, Qt::WindowFlags fl = nullptr);
+	GuiSetBorder(QWidget * parent = nullptr, Qt::WindowFlags fl = {});
 
 	// We need tristate for multi-cell selection
 	enum BorderState {
diff --git a/src/frontends/qt/GuiSpellchecker.h b/src/frontends/qt/GuiSpellchecker.h
index 1297157249..0ee7df164c 100644
--- a/src/frontends/qt/GuiSpellchecker.h
+++ b/src/frontends/qt/GuiSpellchecker.h
@@ -63,7 +63,7 @@ public:
 	GuiSpellchecker(
 		GuiView & parent, ///< the main window where to dock.
 		Qt::DockWidgetArea area = Qt::RightDockWidgetArea, ///< Position of the dock (and also drawer)
-		Qt::WindowFlags flags = 0);
+		Qt::WindowFlags flags = {});
 	~GuiSpellchecker();
 
 private:
diff --git a/src/frontends/qt/GuiViewSource.h b/src/frontends/qt/GuiViewSource.h
index 8b2a005ba2..f75978d34e 100644
--- a/src/frontends/qt/GuiViewSource.h
+++ b/src/frontends/qt/GuiViewSource.h
@@ -100,7 +100,7 @@ public:
 	GuiViewSource(
 		GuiView & parent, ///< the main window where to dock.
 		Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, ///< Position of the dock (and also drawer)
-		Qt::WindowFlags flags = 0);
+		Qt::WindowFlags flags = {});
 
 	/// Controller inherited method.
 	///@{
diff --git a/src/frontends/qt/GuiWorkArea.cpp b/src/frontends/qt/GuiWorkArea.cpp
index 3a2a362f09..02e03aaaeb 100644
--- a/src/frontends/qt/GuiWorkArea.cpp
+++ b/src/frontends/qt/GuiWorkArea.cpp
@@ -93,7 +93,7 @@ static mouse_button::state q_button_state(Qt::MouseButton button)
 		case Qt::LeftButton:
 			b = mouse_button::button1;
 			break;
-		case Qt::MidButton:
+		case Qt::MiddleButton:
 			b = mouse_button::button2;
 			break;
 		case Qt::RightButton:
@@ -112,7 +112,7 @@ mouse_button::state q_motion_state(Qt::MouseButtons state)
 	mouse_button::state b = mouse_button::none;
 	if (state & Qt::LeftButton)
 		b |= mouse_button::button1;
-	if (state & Qt::MidButton)
+	if (state & Qt::MiddleButton)
 		b |= mouse_button::button2;
 	if (state & Qt::RightButton)
 		b |= mouse_button::button3;
@@ -1549,7 +1549,7 @@ TabWorkArea::TabWorkArea(QWidget * parent)
 
 void TabWorkArea::mousePressEvent(QMouseEvent *me)
 {
-	if (me->button() == Qt::MidButton)
+	if (me->button() == Qt::MiddleButton)
 		midpressed_tab_ = tabBar()->tabAt(me->pos());
 	else
 		QTabWidget::mousePressEvent(me);
@@ -1558,7 +1558,7 @@ void TabWorkArea::mousePressEvent(QMouseEvent *me)
 
 void TabWorkArea::mouseReleaseEvent(QMouseEvent *me)
 {
-	if (me->button() == Qt::MidButton) {
+	if (me->button() == Qt::MiddleButton) {
 		int const midreleased_tab = tabBar()->tabAt(me->pos());
 		if (midpressed_tab_ == midreleased_tab && posIsTab(me->pos()))
 			closeTab(midreleased_tab);
-- 
2.28.0.windows.1

-------------- next part --------------
From 3ef009cd9e2d8da02e99f6ef1d64451ec94414f9 Mon Sep 17 00:00:00 2001
From: Yuriy Skalko <yuriy.skalko at gmail.com>
Date: Thu, 21 Jan 2021 09:32:21 +0200
Subject: [PATCH 5/5] Change lastfiles container to std::list

---
 src/Session.cpp | 2 +-
 src/Session.h   | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/Session.cpp b/src/Session.cpp
index 16b6df7c61..99ae78d93b 100644
--- a/src/Session.cpp
+++ b/src/Session.cpp
@@ -86,7 +86,7 @@ void LastFilesSection::add(FileName const & file)
 	LastFiles::iterator it = find(lastfiles.begin(), lastfiles.end(), file);
 	if (it != lastfiles.end())
 		lastfiles.erase(it);
-	lastfiles.insert(lastfiles.begin(), file);
+	lastfiles.push_front(file);
 	if (lastfiles.size() > num_lastfiles)
 		lastfiles.pop_back();
 }
diff --git a/src/Session.h b/src/Session.h
index 857e056100..dc73bdf46c 100644
--- a/src/Session.h
+++ b/src/Session.h
@@ -57,7 +57,7 @@ class LastFilesSection : SessionSection
 {
 public:
 	///
-	typedef std::vector<support::FileName> LastFiles;
+	typedef std::list<support::FileName> LastFiles;
 
 public:
 	///
@@ -69,10 +69,10 @@ public:
 	///
 	void write(std::ostream & os) const override;
 
-	/// Return lastfiles container (vector)
+	/// Return lastfiles container
 	LastFiles const lastFiles() const { return lastfiles; }
 
-	/** Insert #file# into the lastfile vector.
+	/** Insert #file# into the lastfile.
 	    This funtion inserts #file# into the last files list. If the file
 	    already exists it is moved to the top of the list, else exist it
 	    is placed on the top of the list. If the list is full the last
-- 
2.28.0.windows.1



More information about the lyx-devel mailing list