BufferList::bufferNum() and getFileNames(): migrate to FileName/FileNameList

Inset.h : fix erroneous forward declaration.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25959 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2008-07-29 08:52:25 +00:00
parent d56faa70c4
commit 64e1fc3bf4
4 changed files with 20 additions and 18 deletions

View File

@ -24,8 +24,9 @@
#include "support/ExceptionMessage.h"
#include "support/debug.h"
#include "support/filetools.h"
#include "support/FileName.h"
#include "support/FileNameList.h"
#include "support/filetools.h"
#include "support/gettext.h"
#include "support/lstrings.h"
#include "support/Package.h"
@ -122,12 +123,13 @@ void BufferList::closeAll()
}
vector<string> const BufferList::getFileNames() const
FileNameList const & BufferList::fileNames() const
{
vector<string> nvec;
static FileNameList nvec;
nvec.clear();
transform(bstore.begin(), bstore.end(),
back_inserter(nvec),
boost::bind(&Buffer::absFileName, _1));
boost::bind(&Buffer::fileName, _1));
return nvec;
}
@ -317,11 +319,11 @@ void BufferList::setCurrentAuthor(docstring const & name, docstring const & emai
}
int BufferList::bufferNum(string const & name) const
int BufferList::bufferNum(FileName const & fname) const
{
vector<string> buffers = getFileNames();
vector<string>::const_iterator cit =
find(buffers.begin(), buffers.end(), name);
FileNameList const & buffers = fileNames();
FileNameList::const_iterator cit =
find(buffers.begin(), buffers.end(), fname);
if (cit == buffers.end())
return 0;
return int(cit - buffers.begin());

View File

@ -24,6 +24,7 @@ class OutputParams;
namespace support {
class FileName;
class FileNameList;
}
/**
@ -59,7 +60,7 @@ public:
void closeAll();
/// returns a vector with all the buffers filenames
std::vector<std::string> const getFileNames() const;
support::FileNameList const & fileNames() const;
/// FIXME
void updateIncludedTeXfiles(std::string const &, OutputParams const &);
@ -89,7 +90,7 @@ public:
bool isLoaded(Buffer const * b) const;
/// return index of named buffer in buffer list
int bufferNum(std::string const & name) const;
int bufferNum(support::FileName const & name) const;
/// returns a pointer to the buffer with the given name.
Buffer * getBuffer(support::FileName const &) const;
/// returns a pointer to the buffer with the given number.

View File

@ -22,6 +22,7 @@
#include "insets/InsetRef.h"
#include "support/FileName.h"
#include "support/FileNameList.h"
#include "support/filetools.h" // makeAbsPath, makeDisplayPath
#include <QLineEdit>
@ -214,10 +215,10 @@ void GuiRef::updateContents()
// insert buffer list
bufferCO->clear();
vector<string> buffers = theBufferList().getFileNames();
for (vector<string>::iterator it = buffers.begin();
FileNameList const & buffers = theBufferList().fileNames();
for (FileNameList::const_iterator it = buffers.begin();
it != buffers.end(); ++it) {
bufferCO->addItem(toqstr(makeDisplayPath(*it)));
bufferCO->addItem(toqstr(makeDisplayPath(it->absFilename())));
}
// restore the buffer combo setting for new insets
@ -225,7 +226,7 @@ void GuiRef::updateContents()
&& restored_buffer_ < bufferCO->count())
bufferCO->setCurrentIndex(restored_buffer_);
else {
int num = theBufferList().bufferNum(buffer().absFileName());
int num = theBufferList().bufferNum(buffer().fileName());
bufferCO->setCurrentIndex(num);
}
@ -346,8 +347,8 @@ void GuiRef::redoRefs()
void GuiRef::updateRefs()
{
refs_.clear();
string const name = theBufferList().getFileNames()[bufferCO->currentIndex()];
Buffer const * buf = theBufferList().getBuffer(support::makeAbsPath(name));
FileName const & name = theBufferList().fileNames()[bufferCO->currentIndex()];
Buffer const * buf = theBufferList().getBuffer(name);
buf->getLabelList(refs_);
sortCB->setEnabled(!refs_.empty());
refsLW->setEnabled(!refs_.empty());

View File

@ -53,8 +53,6 @@ class ParConstIterator;
class ParIterator;
class Text;
class TocList;
class FileNameList;
namespace graphics { class PreviewLoader; }