... and a patch to git-master for convenience.

Jürgen


Am 06.02.2019 um 16:25 schrieb Jürgen Womser-Schütz:
> Hi,
>
> in the surrounding field of bug #11484 I tried to improve the "user
> experiance" by checking the existence of the user-specified listing file.
> I changed two files:
>     src/frontends/qt4/GuiInclude.cpp
>     src/frontends/qt4/GuiInclude.h
> The diff-output is attached.
>
> Jürgen

From 559a25f02c3f1d35e31b7cd1adcbf5609175c296 Mon Sep 17 00:00:00 2001
From: JWS <jws1...@web.de>
Date: Wed, 6 Feb 2019 17:39:35 +0100
Subject: [PATCH] Improve the "user experience" by checking the existence
---
 src/frontends/qt4/GuiInclude.cpp | 17 ++++++++++++++++-
 src/frontends/qt4/GuiInclude.h   |  2 ++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/frontends/qt4/GuiInclude.cpp b/src/frontends/qt4/GuiInclude.cpp
index c55d71fa7f..4d96ac8415 100644
--- a/src/frontends/qt4/GuiInclude.cpp
+++ b/src/frontends/qt4/GuiInclude.cpp
@@ -303,7 +303,22 @@ void GuiInclude::edit()
 
 bool GuiInclude::isValid()
 {
-       return !filenameED->text().isEmpty() && 
validate_listings_params().empty();
+       return listingFileExist() && validate_listings_params().empty();
+}
+
+
+bool GuiInclude::listingFileExist()
+{
+       // check whether the file of the listing exists
+       QString const listingFileName = filenameED->text();
+       QString docpath = toqstr(support::onlyPath(buffer().absFileName()));
+       docpath += listingFileName;
+
+       bool listingFileExist = false;
+       if (!listingFileName.isEmpty())
+               listingFileExist = FileName(docpath.toStdString()).exists();
+
+       return listingFileExist;
 }
 
 
diff --git a/src/frontends/qt4/GuiInclude.h b/src/frontends/qt4/GuiInclude.h
index 1106c3e02e..862cdab968 100644
--- a/src/frontends/qt4/GuiInclude.h
+++ b/src/frontends/qt4/GuiInclude.h
@@ -72,6 +72,8 @@ private:
        void updateLists();
        /// validate listings parameters and return an error message, if any
        docstring validate_listings_params();
+       /// exists the file?
+       bool listingFileExist();
        ///
        bool isValid();
        /// Apply changes
-- 
2.20.1

Reply via email to