]> git.lyx.org Git - features.git/commitdiff
Sort the files in the TeXInfo and BibTeX dialogs correctly and remove empty items...
authorJürgen Spitzmüller <spitz@lyx.org>
Wed, 27 Jul 2005 17:46:15 +0000 (17:46 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Wed, 27 Jul 2005 17:46:15 +0000 (17:46 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10365 a592a061-630c-0410-9148-cb99ea01b6c8

13 files changed:
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlBibtex.C
src/frontends/controllers/ControlTexinfo.C
src/frontends/controllers/ControlTexinfo.h
src/frontends/controllers/tex_helpers.C
src/frontends/gtk/ChangeLog
src/frontends/gtk/GTexinfo.C
src/frontends/qt2/ChangeLog
src/frontends/qt2/QBibtex.C
src/frontends/qt2/QTexinfo.C
src/frontends/qt2/QTexinfoDialog.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormTexinfo.C

index a35e0e9b4b7ef614c90d1961488f8844ec6099fa..9461c9c9b78c4d87fd52b1c8394af778a6d27d00 100644 (file)
@@ -1,3 +1,15 @@
+2005-07-27  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
+
+       * ControlBibtex.C: sort bst files (bug 1936)
+
+       * ControlTeXInfo.[Ch]: new member getFileType that returns the extension
+       of the supported files.
+       * ControlTeXInfo.[Ch] (getTeXFileList): takes bool withPath and sorts 
+       correctly when no path is requested (bug 1936)
+
+       * tex_helpers.C (getTeXFileList): remove empty items from the list 
+       (bug 1936); proper support the other file types than *cls.
+
 2005-07-27  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
        * ControlToc.[Ch]: getGuiName takes a type argument now.
index 6d4c4328f0521c97857b1da88e1e9e4be4cfc0e0..0573d240042379777aeb64ffba5574fa0dcd3f5f 100644 (file)
@@ -79,6 +79,8 @@ void ControlBibtex::getBibStyles(vector<string> & data) const
        for (; it != end; ++it) {
                *it = OnlyFilename(*it);
        }
+       // sort on filename only (no path)
+       std::sort(data.begin(), data.end());
 }
 
 
@@ -97,6 +99,8 @@ void ControlBibtex::getBibFiles(vector<string> & data) const
        for (; it != end; ++it) {
                *it = OnlyFilename(*it);
        }
+       // sort on filename only (no path)
+       std::sort(data.begin(), data.end());
 }
 
 
index 68120c25d2ecbc44a2a90eb5bbd17edaa4a08e33..3e1e03bfb102382cb0e87e501913be76ec1540a0 100644 (file)
 #include "ControlTexinfo.h"
 #include "funcrequest.h"
 
+#include "support/filetools.h"
+
 
 using std::string;
+using std::vector;
 
 namespace lyx {
+
+using support::OnlyFilename;
+
 namespace frontend {
 
 void getTexFileList(ControlTexinfo::texFileSuffix type,
-                   std::vector<string> & list)
+                   std::vector<string> & list, bool withPath)
 {
        string filename;
        switch (type) {
@@ -42,6 +48,15 @@ void getTexFileList(ControlTexinfo::texFileSuffix type,
                rescanTexStyles();
                getTexFileList(filename, list);
        }
+       if (withPath)
+               return;
+       vector<string>::iterator it  = list.begin();
+       vector<string>::iterator end = list.end();
+       for (; it != end; ++it) {
+               *it = OnlyFilename(*it);
+       }
+       // sort on filename only (no path)
+       std::sort(list.begin(), list.end());
 }
 
 
@@ -62,5 +77,23 @@ string const ControlTexinfo::getClassOptions(string const & filename) const
        return getListOfOptions(filename, "cls");
 }
 
+
+string const ControlTexinfo::getFileType(ControlTexinfo::texFileSuffix type) const
+{
+       string ftype;
+       switch (type) {
+       case ControlTexinfo::bst:
+               ftype = "bst";
+               break;
+       case ControlTexinfo::cls:
+               ftype = "cls";
+               break;
+       case ControlTexinfo::sty:
+               ftype = "sty";
+               break;
+       }
+       return ftype;
+}
+
 } // namespace frontend
 } // namespace lyx
index 2172dcbfdcf0fef7ed85d4ae4a3fe4d97b2541df..0b000e197a9ea3f84db15e767e884edae59454c1 100644 (file)
@@ -41,6 +41,8 @@ public:
        void viewFile(std::string const & filename) const;
        /// show all classoptions
        std::string const getClassOptions(std::string const & filename) const;
+       /// return file type as string
+       std::string const getFileType(ControlTexinfo::texFileSuffix type) const;
 private:
        ///
        virtual void apply() {}
@@ -51,7 +53,7 @@ private:
  *  Each entry in the file list is returned as a pair<name_with_path, name_only>
  */
 void getTexFileList(ControlTexinfo::texFileSuffix type,
-                   std::vector<std::string> & contents);
+                   std::vector<std::string> & contents, bool withPath);
 
 } // namespace frontend
 } // namespace lyx
index 4cd9453da71fc4b4022f244ea1ff5603ea47525c..90e9635c846dfbbccc946be15c2c74e3858d99db 100644 (file)
@@ -30,6 +30,7 @@ using std::endl;
 namespace lyx {
 
 using support::contains;
+using support::GetExtension;
 using support::GetFileContents;
 using support::getVectorFromString;
 using support::LibFileSearch;
@@ -82,6 +83,8 @@ void getTexFileList(string const & filename, std::vector<string> & list)
                *it = regex.Merge((*it), "/");
        }
 
+       // remove empty items and duplicates
+       list.erase(std::remove(list.begin(), list.end(), ""), list.end());
        eliminate_duplicates(list);
 }
 
@@ -108,12 +111,22 @@ string const getListOfOptions(string const & classname, string const & type)
 string const getTexFileFromList(string const & file,
                            string const & type)
 {
-       string const file_ = (type == "cls") ? file + ".cls" : file + ".sty";
-
-       lyxerr << "Search for classfile " << file_ << endl;
-
-       string const lstfile =
-               ((type == "cls") ? "clsFiles.lst" : "styFiles.lst");
+       string file_ = file;
+       // do we need to add the suffix?
+       if (!(GetExtension(file) == type))
+               file_ += '.' + type;
+
+       lyxerr << "Searching for file " << file_ << endl;
+
+       string lstfile;
+       if (type == "cls")
+               lstfile = "clsFiles.lst";
+       else if (type == "sty")
+               lstfile = "styFiles.lst";
+       else if (type == "bst")
+               lstfile = "bstFiles.lst";
+       else if (type == "bib")
+               lstfile = "bibFiles.lst";
        string const allClasses = GetFileContents(LibFileSearch(string(),
                                                                lstfile));
        int entries = 0;
index 19453e8c75eef75bd3475b9bf2de44b4a37f814a..73b26950d7eb2c3d4c7f06a42e0a204b056100a0 100644 (file)
@@ -1,3 +1,8 @@
+2005-07-27  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
+
+       * GTexInfo.C: Load and display full-path and no-path
+       lists correctly (bug 1936)
+
 2005-07-27  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
        * GToc.C (update, updateContents): Do not compare against 
index 1062f4807b285f08d2cf9bc2b834079343488ae7..38890916fbe5238550eca9f03666a7a9ac4df17f 100644 (file)
@@ -106,8 +106,14 @@ void GTexinfo::onItemActivate(
                (*itemsstore_->get_iter(path))[listColIndex_];
 
        ContentsType const & data = texdata_[activeStyle];
+
+       string file = data[choice];
+       if (!fullpathcheck_->get_active())
+               file = getTexFileFromList(data[choice],
+                               controller().getFileType(activeStyle));
+
        if (choice >= 0 && choice <= data.size() - 1)
-               controller().viewFile(data[choice]);
+               controller().viewFile(file);
 }
 
 
@@ -133,17 +139,15 @@ void GTexinfo::onRefresh()
 void GTexinfo::updateStyles()
 {
        ContentsType & data = texdata_[activeStyle];
-       getTexFileList(activeStyle, data);
-
        bool const withFullPath = fullpathcheck_->get_active();
+       getTexFileList(activeStyle, data, withFullPath);
 
        itemsstore_->clear();
        ContentsType::const_iterator it  = data.begin();
        ContentsType::const_iterator end = data.end();
        for (int rowindex = 0; it != end; ++it, ++rowindex) {
-               string const line = withFullPath ? *it : OnlyFilename(*it);
                Gtk::TreeModel::iterator row = itemsstore_->append();
-               (*row)[listCol_] = line;
+               (*row)[listCol_] = *it;
                (*row)[listColIndex_] = rowindex;
        }
 }
index 9e009c2727278d42cb45c9a7a7dc578e21a42987..58b1a7bcc99bafcfca7e3a786955f8070eb2585b 100644 (file)
@@ -1,3 +1,11 @@
+2005-07-27  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
+
+       * QBibTeX.C: Do not insert empty items to bst combo.
+       
+       * QTexInfo.C: 
+       * QTexInfoDialog.c: Load and display full-path and no-path
+       lists correctly (bug 1936)
+
 2005-07-27  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
        * QToc.C (update_contents): fix missing qstring->string translation.
index feb7bbc9ad4784880d69754bac906b10fb205152..fe87c707959ffe893cc5b6e3a98b19c2ba776b15 100644 (file)
@@ -141,12 +141,15 @@ void QBibtex::update_contents()
                dialog_->styleCB->insertItem(toqstr(item));
        }
 
-       if (item_nr == -1) {
+       if (item_nr == -1 && !bibstyle.empty()) {
                dialog_->styleCB->insertItem(toqstr(bibstyle));
                item_nr = dialog_->styleCB->count() - 1;
        }
 
-       dialog_->styleCB->setCurrentItem(item_nr);
+       if (item_nr != -1)
+               dialog_->styleCB->setCurrentItem(item_nr);
+       else
+               dialog_->styleCB->clearEdit();
 }
 
 
index 6ffd783f2fcca6ac829bd0af4ea3cc3c8d7e9aaf..4a993f7bb57b0e34a4b5e845a93aac2ac80634c7 100644 (file)
@@ -50,17 +50,15 @@ void QTexinfo::build_dialog()
 void QTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
 {
        ContentsType & data = texdata_[whichStyle];
-       getTexFileList(whichStyle, data);
-
        bool const withFullPath = dialog_->path->isChecked();
 
+       getTexFileList(whichStyle, data, withFullPath);
+
        dialog_->fileList->clear();
        ContentsType::const_iterator it  = data.begin();
        ContentsType::const_iterator end = data.end();
-       for (; it != end; ++it) {
-               string const line = withFullPath ? *it : OnlyFilename(*it);
-               dialog_->fileList->insertItem(toqstr(line));
-       }
+       for (; it != end; ++it)
+               dialog_->fileList->insertItem(toqstr(*it));
 
        activeStyle = whichStyle;
 }
index b9f15db0e222fda64acc4c4c9db55c29f4779403..a02d5691a370ee1bdc52cd58d9e1effaa358a85d 100644 (file)
@@ -13,6 +13,7 @@
 #include "QTexinfoDialog.h"
 #include "QTexinfo.h"
 
+#include <qcheckbox.h>
 #include <qcombobox.h>
 #include <qlistbox.h>
 #include <qpushbutton.h>
@@ -59,7 +60,11 @@ void QTexinfoDialog::viewClicked()
 {
        vector<string>::size_type const fitem = fileList->currentItem();
        vector<string> const & data = form_->texdata_[form_->activeStyle];
-       form_->controller().viewFile(data[fitem]);
+       string file = data[fitem];
+       if (!path->isChecked())
+               file = getTexFileFromList(data[fitem],
+                       form_->controller().getFileType(form_->activeStyle));
+       form_->controller().viewFile(file);
 }
 
 
index 666a6a1ba1f5a60a26cbf8d3687901f4222dd221..6619a1bc4437c53977099d9a1b28442a9640dea4 100644 (file)
@@ -1,3 +1,8 @@
+2005-07-27  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
+
+       * FormTexInfo.C: Load and display full-path and no-path
+       lists correctly (bug 1936)
+
 2005-07-27  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
        * FormToc.C (updateType, update_contents): Do not compare against 
index 037dda5971a79b669501b5d50b486489dffc1714..c0b1ad6cd1fdb7d953187bde6c545ce32ffe7f97 100644 (file)
@@ -89,8 +89,12 @@ ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long ob_value) {
                // double click in browser: view selected file
                ContentsType::size_type const sel = fl_get_browser(ob);
                ContentsType const & data = texdata_[activeStyle];
+               string file = data[sel-1];
+               if (!fl_get_button(dialog_->check_fullpath))
+                       file = getTexFileFromList(data[sel-1],
+                               controller().getFileType(activeStyle));
                if (sel >= 1 && sel <= data.size())
-                       controller().viewFile(data[sel-1]);
+                       controller().viewFile(file);
 
                // reset the browser so that the following single-click
                // callback doesn't do anything
@@ -125,17 +129,14 @@ ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long ob_value) {
 void FormTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
 {
        ContentsType & data = texdata_[whichStyle];
-       getTexFileList(whichStyle, data);
-
        bool const withFullPath = fl_get_button(dialog_->check_fullpath);
+       getTexFileList(whichStyle, data, withFullPath);
 
        fl_clear_browser(dialog_->browser);
        ContentsType::const_iterator it  = data.begin();
        ContentsType::const_iterator end = data.end();
-       for (; it != end; ++it) {
-               string const line = withFullPath ? *it : OnlyFilename(*it);
-               fl_add_browser_line(dialog_->browser, line.c_str());
-       }
+       for (; it != end; ++it)
+               fl_add_browser_line(dialog_->browser, (*it).c_str());
 
        activeStyle = whichStyle;
 }