]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiRef.cpp
Complete the removal of the embedding stuff. Maybe. It's hard to be sure we got every...
[lyx.git] / src / frontends / qt4 / GuiRef.cpp
index 630256f6ae9f3b90efb69d73f8adca3fca997c58..759b668d01fc695115b1b4bd202192e18b1cf831 100644 (file)
 
 #include "insets/InsetRef.h"
 
+#include "support/FileName.h"
 #include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
 
-#include <boost/filesystem/operations.hpp>
-
 #include <QLineEdit>
 #include <QCheckBox>
 #include <QListWidget>
 #include <QToolTip>
 #include <QCloseEvent>
 
-#include <algorithm>
-
-using std::find;
-using std::vector;
-using std::string;
+using namespace std;
+using namespace lyx::support;
 
 namespace lyx {
 namespace frontend {
 
-using support::makeAbsPath;
-using support::makeDisplayPath;
-
-//FIXME It should be possible to eliminate lfun_name_
-//now and recover that information from params().insetType().
-//But let's not do that quite yet.
-/// Flags what action is taken by Kernel::dispatch()
-static std::string const lfun_name_ = "ref";
-
-GuiRef::GuiRef(LyXView & lv)
-       : GuiDialog(lv, "ref"), params_("ref")
+GuiRef::GuiRef(GuiView & lv)
+       : GuiCommand(lv, "ref", qt_("Cross-reference"))
 {
        setupUi(this);
-       setViewTitle(_("Cross-reference"));
 
        sort_ = false;
        at_ref_ = false;
@@ -132,7 +118,7 @@ void GuiRef::selectionChanged()
 
 void GuiRef::refHighlighted(QListWidgetItem * sel)
 {
-       if (controller().isBufferReadonly())
+       if (isBufferReadonly())
                return;
 
 /*     int const cur_item = refsLW->currentRow();
@@ -194,7 +180,7 @@ void GuiRef::closeEvent(QCloseEvent * e)
 {
        slotClose();
        reset_dialog();
-       GuiDialog::closeEvent(e);
+       e->accept();
 }
 
 
@@ -228,10 +214,12 @@ void GuiRef::updateContents()
 
        // restore the buffer combo setting for new insets
        if (params_["reference"].empty() && restored_buffer_ != -1
-       && restored_buffer_ < bufferCO->count())
+           && restored_buffer_ < bufferCO->count()) 
                bufferCO->setCurrentIndex(restored_buffer_);
-       else
-               bufferCO->setCurrentIndex(bufferNum());
+       else {
+               int num = theBufferList().bufferNum(buffer().absFileName());
+               bufferCO->setCurrentIndex(num);
+       }
 
        updateRefs();
        bc().setValid(false);
@@ -310,7 +298,7 @@ void GuiRef::redoRefs()
        // the first item inserted
        QString const oldSelection(referenceED->text());
 
-       for (std::vector<docstring>::const_iterator iter = refs_.begin();
+       for (vector<docstring>::const_iterator iter = refs_.begin();
                iter != refs_.end(); ++iter) {
                refsLW->addItem(toqstr(*iter));
        }
@@ -379,41 +367,7 @@ void GuiRef::gotoBookmark()
 }
 
 
-int GuiRef::bufferNum() const
-{
-       vector<string> buffers = theBufferList().getFileNames();
-       string const name = buffer().fileName();
-       vector<string>::const_iterator cit =
-               std::find(buffers.begin(), buffers.end(), name);
-       if (cit == buffers.end())
-               return 0;
-       return int(cit - buffers.begin());
-}
-
-
-bool GuiRef::initialiseParams(string const & data)
-{
-       // The name passed with LFUN_INSET_APPLY is also the name
-       // used to identify the mailer.
-       InsetCommandMailer::string2params(lfun_name_, data, params_);
-       return true;
-}
-
-
-void GuiRef::clearParams()
-{
-       params_.clear();
-}
-
-
-void GuiRef::dispatchParams()
-{
-       string const lfun = InsetCommandMailer::params2string(lfun_name_, params_);
-       dispatch(FuncRequest(getLfun(), lfun));
-}
-
-
-Dialog * createGuiRef(LyXView & lv) { return new GuiRef(lv); }
+Dialog * createGuiRef(GuiView & lv) { return new GuiRef(lv); }
 
 
 } // namespace frontend