]> git.lyx.org Git - features.git/commitdiff
Give FileFilterList its own .[Ch] files.
authorAngus Leeming <leeming@lyx.org>
Thu, 25 Nov 2004 11:08:32 +0000 (11:08 +0000)
committerAngus Leeming <leeming@lyx.org>
Thu, 25 Nov 2004 11:08:32 +0000 (11:08 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9305 a592a061-630c-0410-9148-cb99ea01b6c8

25 files changed:
src/BufferView_pimpl.C
src/ChangeLog
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlBibtex.C
src/frontends/controllers/ControlExternal.C
src/frontends/controllers/ControlGraphics.C
src/frontends/controllers/ControlInclude.C
src/frontends/controllers/ControlPrefs.C
src/frontends/controllers/ControlPrint.C
src/frontends/controllers/helper_funcs.C
src/frontends/qt2/ChangeLog
src/frontends/qt2/FileDialog.C
src/frontends/qt2/FileDialog_private.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/FileDialog.C
src/frontends/xforms/FormBibtex.C
src/frontends/xforms/FormFiledialog.C
src/lyx_cb.C
src/lyxfunc.C
src/support/ChangeLog
src/support/Makefile.am
src/support/filefilterlist.C [new file with mode: 0644]
src/support/filefilterlist.h [new file with mode: 0644]
src/support/globbing.C
src/support/globbing.h

index 62c17dbb500b0778d062713acdf99a9b2b192880..d1ef1b60a129256b2a109ba3f6a33d058183c7c3 100644 (file)
@@ -63,9 +63,9 @@
 
 #include "graphics/Previews.h"
 
+#include "support/filefilterlist.h"
 #include "support/filetools.h"
 #include "support/forkedcontr.h"
-#include "support/globbing.h"
 #include "support/path_defines.h"
 #include "support/tostr.h"
 #include "support/types.h"
index 6e03fbe666e5eb957bad0a2ff53f631ace9f964c..861fdf51a586a051a5054f4296e6ac189e7a2eab 100644 (file)
@@ -1,3 +1,9 @@
+2004-11-25  Angus Leeming  <leeming@lyx.org>
+
+       * BufferView_pimpl.C:
+       * lyx_cb.C:
+       * lyxfunc.C: s/globbing.h/filefilterlist.h/ in #includes.
+
 2004-11-24  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
 
        * lyxfunc.C (getStatus, dispatch): use FuncStatus::message; only
index 93a04392727dd26ca4e4db8968a8ec7f3c8a2dfa..572535bab0cfd79c6c34d25ffa8bfa2e45e1a93a 100644 (file)
@@ -1,3 +1,14 @@
+2004-11-25  Angus Leeming  <leeming@lyx.org>
+
+       * ControlBibtex.C:
+       * ControlExternal.C:
+       * ControlGraphics.C:
+       * ControlInclude.C:
+       * ControlPrefs.C:
+       * ControlPrint.C: s/globbing.h/filefilterlist.h/ in #includes.
+
+       * helper_funcs.C: remove #include "globbing.h".
+
 2004-11-22  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
 
        * ControlSpellchecker.C (check): update the view when setting the
index 9d7fb6c069bbffd168d81c666669c397c65caf48..6d4c4328f0521c97857b1da88e1e9e4be4cfc0e0 100644 (file)
@@ -22,8 +22,8 @@
 #include "tex_helpers.h"
 #include "gettext.h"
 
+#include "support/filefilterlist.h"
 #include "support/filetools.h"
-#include "support/globbing.h"
 
 using std::pair;
 using std::string;
index f4c75bd1870e0869a2505adbbb19773a4919b71d..9c6a251b14f9d1079bbdf38ad59ab1b9e32d2a40 100644 (file)
@@ -27,8 +27,8 @@
 #include "insets/ExternalSupport.h"
 #include "insets/ExternalTemplate.h"
 
+#include "support/filefilterlist.h"
 #include "support/filetools.h"
-#include "support/globbing.h"
 #include "support/tostr.h"
 
 using std::advance;
index d7ca70aacfb960394d76ad0766e1b0c691c8a611..a7a46506b61a3e3182561a6d07ab627c14141bcc 100644 (file)
@@ -26,8 +26,8 @@
 #include "insets/insetgraphics.h"
 
 #include "support/FileInfo.h"
+#include "support/filefilterlist.h"
 #include "support/filetools.h"
-#include "support/globbing.h"
 #include "support/path_defines.h"
 #include "support/tostr.h"
 #include "support/types.h"
index 841543e175eced896312e16933f3cce5b4b4c1b8..7fa1a1756b6989372c30575944a646310c9afc3c 100644 (file)
@@ -24,8 +24,8 @@
 
 #include "insets/insetinclude.h"
 
+#include "support/filefilterlist.h"
 #include "support/filetools.h"
-#include "support/globbing.h"
 
 #include <utility>
 
index 67f0dc910e83ea29180a64e3b655afbb6feca98d..93f2698267045f4f3978eda5e4714b3885bce6e8 100644 (file)
@@ -20,7 +20,7 @@
 #include "funcrequest.h"
 #include "LColor.h"
 
-#include "support/globbing.h"
+#include "support/filefilterlist.h"
 
 #include <sstream>
 
index 38844fb6d23c694b321e6a66561c52dfa2ce6db8..bd2344d8af29b09545c17918185c8df58457cf48 100644 (file)
@@ -22,8 +22,8 @@
 #include "PrinterParams.h"
 
 #include "support/tostr.h"
+#include "support/filefilterlist.h"
 #include "support/filetools.h"
-#include "support/globbing.h"
 
 using std::string;
 
index 739e3578cbfc8a990a5c7157f156d9650dc353f1..7d9fdb1614a1f85dfdd159852d1e2b4845bde52c 100644 (file)
@@ -21,7 +21,6 @@
 
 #include "support/filetools.h"
 #include "support/path_defines.h"
-#include "support/globbing.h"
 
 using std::pair;
 using std::vector;
index 918c219ff03970b46520023bd4a98428768a2934..f37cdd4904e3f277b50ce977144c3b9b1b14910b 100644 (file)
@@ -1,3 +1,8 @@
+2004-11-25  Angus Leeming  <leeming@lyx.org>
+
+       * FileDialog.C:
+       * FileDialog_private.C: s/globbing.h/filefilterlist.h/ in #includes.
+
 2004-11-22  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
        * lengthvalidator.[Ch]: add GlueLength validator
index 7af88fd20838b4a51df5f876f85a6117f08433ae..90e92d8c87c3837813c7082a27178610cd66446c 100644 (file)
@@ -19,7 +19,7 @@
 #include "debug.h"
 #include "gettext.h"
 
-#include "support/globbing.h"
+#include "support/filefilterlist.h"
 
 /** when this is defined, the code will use
  * QFileDialog::getOpenFileName and friends to create filedialogs.
index be328bbe14e7852710c6fc5c290f42bd5ebd1670..bad9d561c05eec915eeaa423a7e325220cae3dd4 100644 (file)
@@ -13,7 +13,7 @@
 #include "FileDialog_private.h"
 #include "qt_helpers.h"
 
-#include "support/globbing.h"
+#include "support/filefilterlist.h"
 #include "support/lstrings.h"
 
 #include <qapplication.h>
index 5a19d8a3e4e91466aa0fe2887009e6d55c438093..4a187c0dee3ba94c66ae038b25c1c83bbe93cd82 100644 (file)
@@ -1,3 +1,9 @@
+2004-11-25  Angus Leeming  <leeming@lyx.org>
+
+       * FileDialog.C: s/globbing.h/filefilterlist.h/ in #includes.
+       * FormFileDialog.C: add #include "filefilterlist.h"
+       * FormBibtex.C: remove #include "globbing.h".
+
 2004-11-16  Lars Gullik Bjonnes  <larsbj@gullik.net>
 
        * Layoutengine.[Ch]: Break up circular dependency between Box and
index 43ef10feb1ff2a7161a5f805ba42f8025c6c6ba9..9402b5d72816f8ad119d78c2bdbd3d43e93d6865 100644 (file)
@@ -16,7 +16,7 @@
 #include "debug.h"
 #include "gettext.h"
 
-#include "support/globbing.h"
+#include "support/filefilterlist.h"
 #include "support/lstrings.h"
 
 using lyx::support::rsplit;
index a517664ff44f977448a5056ef93475a436774fcd..3703e07f82708cf34b7ec67ba64724e708ce2668 100644 (file)
@@ -22,7 +22,6 @@
 #include "xformsBC.h"
 
 #include "support/filetools.h"
-#include "support/globbing.h"
 #include "support/lstrings.h"
 #include "support/lyxalgo.h"
 
index df009195aa5b5286a33eaa655dde17130236689b..e75b9f3e1901919dd8907188f29b81bf3ba87da5 100644 (file)
@@ -20,6 +20,7 @@
 #include "frontends/Dialogs.h"
 
 #include "support/FileInfo.h"
+#include "support/filefilterlist.h"
 #include "support/filetools.h"
 #include "support/globbing.h"
 #include "support/lstrings.h"
index 6988a430e707ba0d934820dcf5b6c7f586ca5c31..6ed9e153994bf0a7f7f52e60ccbe913d09bfb680 100644 (file)
 #include "frontends/lyx_gui.h"
 #include "frontends/LyXView.h"
 
+#include "support/filefilterlist.h"
 #include "support/FileInfo.h"
 #include "support/filetools.h"
 #include "support/forkedcall.h"
-#include "support/globbing.h"
 #include "support/lyxlib.h"
 #include "support/os.h"
 #include "support/path.h"
index fb7343aab1542eb94adec58a41753ef5c4dc1a49..55960792938045393bfea833a889bfbba0545e49 100644 (file)
 #include "frontends/Menubar.h"
 #include "frontends/Toolbars.h"
 
+#include "support/filefilterlist.h"
 #include "support/FileInfo.h"
 #include "support/filetools.h"
 #include "support/forkedcontr.h"
-#include "support/globbing.h"
 #include "support/lstrings.h"
 #include "support/path.h"
 #include "support/path_defines.h"
index 52d1d79f78ff7578fdcf4c6b6d8168c33b5a8cb7..5e5a357c05351594262ba4ea0f9c4b762d9f93bf 100644 (file)
@@ -1,3 +1,10 @@
+2004-11-25  Angus Leeming  <leeming@lyx.org>
+
+       * filefilterlist.[Ch]:
+       * globbing.[Ch]: split FileFilterList into its own .[Ch] files.
+
+       * Makefile.am: add filefilterlist.[Ch].
+
 2004-11-16  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
 
        * textutils.h (isKommaChar): remove
index 8dd8cbc26a9056ad9d0895ca9d3be3d405e50850..8c2d922f63822114f4930b823652d868aabbd727 100644 (file)
@@ -28,6 +28,8 @@ libsupport_la_SOURCES = \
        copied_ptr.h \
        cow_ptr.h \
        debugstream.h \
+       filefilterlist.C \
+       filefilterlist.h \
        filename.C \
        filename.h \
        filetools.C \
diff --git a/src/support/filefilterlist.C b/src/support/filefilterlist.C
new file mode 100644 (file)
index 0000000..168a95e
--- /dev/null
@@ -0,0 +1,107 @@
+/**
+ * \file filefilterlist.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "support/filefilterlist.h"
+#include "support/globbing.h"
+#include "support/lstrings.h"
+
+// FIXME Interface violation
+#include "gettext.h"
+
+#include <boost/regex.hpp>
+
+#include </usr/include/glob.h>
+
+#include <sstream>
+
+using std::distance;
+using std::ostringstream;
+using std::string;
+using std::vector;
+
+
+namespace lyx {
+namespace support {
+
+FileFilterList::FileFilterList(string const & qt_style_filter)
+{
+       string const filter = qt_style_filter
+               + (qt_style_filter.empty() ? string() : ";;")
+               + _("All files (*)");
+
+       // Split data such as "TeX documents (*.tex);;LyX Documents (*.lyx)"
+       // into individual filters.
+       static boost::regex const separator_re(";;");
+
+       string::const_iterator it = filter.begin();
+       string::const_iterator const end = filter.end();
+       while (true) {
+               boost::match_results<string::const_iterator> what;
+
+               if (!boost::regex_search(it, end, what, separator_re)) {
+                       parse_filter(string(it, end));
+                       break;
+               }
+
+               // Everything from the start of the input to
+               // the start of the match.
+               parse_filter(string(what[-1].first, what[-1].second));
+
+               // Increment the iterator to the end of the match.
+               it += distance(it, what[0].second);
+       }
+}
+
+
+void FileFilterList::parse_filter(string const & filter)
+{
+       // Matches "TeX documents (*.tex)",
+       // storing "TeX documents " as group 1 and "*.tex" as group 2.
+       static boost::regex const filter_re("([^(]*)\\(([^)]+)\\) *$");
+
+       boost::match_results<string::const_iterator> what;
+       if (!boost::regex_search(filter, what, filter_re)) {
+               // Just a glob, no description.
+               filters_.push_back(Filter(string(), trim(filter)));
+       } else {
+               string const desc = string(what[1].first, what[1].second);
+               string const globs = string(what[2].first, what[2].second);
+               filters_.push_back(Filter(trim(desc), trim(globs)));
+       }
+}
+
+
+string const FileFilterList::str(bool expand) const
+{
+       ostringstream ss;
+
+       vector<Filter>::const_iterator const begin = filters_.begin();
+       vector<Filter>::const_iterator const end = filters_.end();
+       vector<Filter>::const_iterator it = begin;
+       for (; it != end; ++it) {
+               string const globs = expand ?
+                       convert_brace_glob(it->globs()) : it->globs();
+               if (it != begin)
+                       ss << ";;";
+               bool const has_description = !it->description().empty();
+               if (has_description)
+                       ss << it->description() << " (";
+               ss << globs;
+               if (has_description)
+                       ss << ')';
+       }
+
+       return ss.str();
+}
+
+} // namespace support
+} // namespace lyx
diff --git a/src/support/filefilterlist.h b/src/support/filefilterlist.h
new file mode 100644 (file)
index 0000000..984d139
--- /dev/null
@@ -0,0 +1,59 @@
+// -*- C++ -*-
+/**
+ * \file filefilterlist.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef FILE_FILTER_LIST_H
+#define FILE_FILTER_LIST_H
+
+#include <string>
+#include <vector>
+
+namespace lyx {
+namespace support {
+
+/** \c FileFilterList parses a Qt-style list of available file filters
+ *  to generate the corresponding vector.
+ *  For example "TeX documents (*.tex);;LyX Documents (*.lyx)"
+ *  will be parsed to fill a vector of size 2, whilst "*.{p[bgp]m} *.pdf"
+ *  will result in a vector of size 1 in which the description field is empty.
+ */
+class FileFilterList {
+public:
+       class Filter {
+               std::string desc_;
+               std::string globs_;
+       public:
+               Filter(std::string const & d, std::string const & g)
+                       : desc_(d), globs_(g) {}
+               std::string const & description() const { return desc_; }
+               std::string const & globs() const { return globs_; }
+       };
+
+       /** \param qt_style_filter a list of available file filters.
+        *  Eg. "TeX documents (*.tex);;LyX Documents (*.lyx)".
+        *  The "All files (*)" filter is always added to the list.
+        */
+       explicit FileFilterList(std::string const & qt_style_filter = std::string());
+       std::vector<Filter> const & filters() const { return filters_; }
+
+       /** \param expand pass each glob through \c convert_brace_glob.
+        *  \returns the equivalent of the string passed to the c-tor.
+        */
+       std::string const str(bool expand) const;
+
+private:
+       void parse_filter(std::string const & filter);
+       std::vector<Filter> filters_;
+};
+
+} // namespace support
+} // namespace lyx
+
+#endif // NOT FILE_FILTER_LIST_H
index 190b38e5e448f107ab71c5cb1966257f47f2dcfc..8e663a0cc319dbebc001ce1bfbca963d949a7a4e 100644 (file)
 #include "support/lstrings.h"
 #include "support/path.h"
 
-// FIXME Interface violation
-#include "gettext.h"
-
 #include <boost/regex.hpp>
 #include <boost/tokenizer.hpp>
 
 #include <glob.h>
 
-#include <sstream>
-
 using std::distance;
-using std::ostringstream;
 using std::string;
 using std::vector;
 
@@ -111,77 +105,5 @@ vector<string> const expand_globs(string const & mask,
        return matches;
 }
 
-
-FileFilterList::FileFilterList(string const & qt_style_filter)
-{
-       string const filter = qt_style_filter
-               + (qt_style_filter.empty() ? string() : ";;")
-               + _("All files (*)");
-
-       // Split data such as "TeX documents (*.tex);;LyX Documents (*.lyx)"
-       // into individual filters.
-       static boost::regex const separator_re(";;");
-
-       string::const_iterator it = filter.begin();
-       string::const_iterator const end = filter.end();
-       while (true) {
-               boost::match_results<string::const_iterator> what;
-
-               if (!boost::regex_search(it, end, what, separator_re)) {
-                       parse_filter(string(it, end));
-                       break;
-               }
-
-               // Everything from the start of the input to
-               // the start of the match.
-               parse_filter(string(what[-1].first, what[-1].second));
-
-               // Increment the iterator to the end of the match.
-               it += distance(it, what[0].second);
-       }
-}
-
-
-void FileFilterList::parse_filter(string const & filter)
-{
-       // Matches "TeX documents (*.tex)",
-       // storing "TeX documents " as group 1 and "*.tex" as group 2.
-       static boost::regex const filter_re("([^(]*)\\(([^)]+)\\) *$");
-
-       boost::match_results<string::const_iterator> what;
-       if (!boost::regex_search(filter, what, filter_re)) {
-               // Just a glob, no description.
-               filters_.push_back(Filter(string(), trim(filter)));
-       } else {
-               string const desc = string(what[1].first, what[1].second);
-               string const globs = string(what[2].first, what[2].second);
-               filters_.push_back(Filter(trim(desc), trim(globs)));
-       }
-}
-
-
-string const FileFilterList::str(bool expand) const
-{
-       ostringstream ss;
-
-       vector<Filter>::const_iterator const begin = filters_.begin();
-       vector<Filter>::const_iterator const end = filters_.end();
-       vector<Filter>::const_iterator it = begin;
-       for (; it != end; ++it) {
-               string const globs = expand ?
-                       convert_brace_glob(it->globs()) : it->globs();
-               if (it != begin)
-                       ss << ";;";
-               bool const has_description = !it->description().empty();
-               if (has_description)
-                       ss << it->description() << " (";
-               ss << globs;
-               if (has_description)
-                       ss << ')';
-       }
-
-       return ss.str();
-}
-
 } // namespace support
 } // namespace lyx
index a5f7b04e58b29383236f65869c248755156515c5..0ee11415124c9e69814a20e241080bd5f69c9408 100644 (file)
@@ -48,42 +48,6 @@ std::vector<std::string> const
 expand_globs(std::string const & mask,
             std::string const & directory = std::string());
 
-
-/** \c FileFilterList parses a Qt-style list of available file filters
- *  to generate the corresponding vector.
- *  For example "TeX documents (*.tex);;LyX Documents (*.lyx)"
- *  will be parsed to fill a vector of size 2, whilst "*.{p[bgp]m} *.pdf"
- *  will result in a vector of size 1 in which the description field is empty.
- */
-class FileFilterList {
-public:
-       class Filter {
-               std::string desc_;
-               std::string globs_;
-       public:
-               Filter(std::string const & d, std::string const & g)
-                       : desc_(d), globs_(g) {}
-               std::string const & description() const { return desc_; }
-               std::string const & globs() const { return globs_; }
-       };
-
-       /** \param qt_style_filter a list of available file filters.
-        *  Eg. "TeX documents (*.tex);;LyX Documents (*.lyx)".
-        *  The "All files (*)" filter is always added to the list.
-        */
-       explicit FileFilterList(std::string const & qt_style_filter = std::string());
-       std::vector<Filter> const & filters() const { return filters_; }
-
-       /** \param expand pass each glob through \c convert_brace_glob.
-        *  \returns the equivalent of the string passed to the c-tor.
-        */
-       std::string const str(bool expand) const;
-
-private:
-       void parse_filter(std::string const & filter);
-       std::vector<Filter> filters_;
-};
-
 } // namespace support
 } // namespace lyx