]> git.lyx.org Git - lyx.git/blob - src/bufferlist.h
Minimal fix needed to give Qt a label dialog again.
[lyx.git] / src / bufferlist.h
1 // -*- C++ -*-
2 /** \file
3  *  Copyright 2002 the LyX Team
4  *  Read the file COPYING
5  *
6  *  \author Lars Gullik Bjønnes
7 */
8
9 #ifndef BUFFER_LIST_H
10 #define BUFFER_LIST_H
11
12 #include "LString.h"
13
14 #include <boost/utility.hpp>
15
16 #include <vector>
17
18 class Buffer;
19
20 /**
21  * The class holds all all open buffers, and handles construction
22  * and deletions of new ones.
23  */
24 class BufferList : boost::noncopyable {
25 public:
26         BufferList();
27
28         /**
29            Loads a LyX file or...
30
31            \param filename The filename to read from.
32            \param tolastfiles Wether the file should be put in the
33            last opened files list or not.
34            \return The newly loaded LyX file.
35         */
36         Buffer * loadLyXFile(string const & filename,
37                              bool tolastfiles = true);
38
39         /// write all buffers, asking the user
40         bool qwriteAll();
41
42         /// create a new buffer
43         Buffer * newBuffer(string const & s, bool ronly = false);
44
45         /// delete a buffer
46         void release(Buffer * b);
47
48         /// Close all open buffers.
49         void closeAll();
50
51         /// read the given file
52         Buffer * readFile(string const &, bool ro);
53
54         /// Make a new file (buffer) using a template
55         Buffer * newFile(string const &, string, bool isNamed = false);
56         /// returns a vector with all the buffers filenames
57         std::vector<string> const getFileNames() const;
58
59         /// FIXME
60         void updateIncludedTeXfiles(string const &);
61
62         /// emergency save for all buffers
63         void emergencyWriteAll();
64
65         /// close buffer. Returns false if cancelled by user
66         bool close(Buffer * buf);
67
68         /// return true if no buffers loaded
69         bool empty() const;
70
71         /// return head of buffer list if any
72         Buffer * first();
73
74         /// returns true if the buffer exists already
75         bool exists(string const &) const;
76
77         /// returns true if the buffer is loaded
78         bool isLoaded(Buffer const * b) const;
79
80         /// returns a pointer to the buffer with the given name.
81         Buffer * getBuffer(string const &);
82         /// returns a pointer to the buffer with the given number.
83         Buffer * getBuffer(unsigned int);
84
85         /// reset current author for all buffers
86         void setCurrentAuthor(string const & name, string const & email);
87
88 private:
89         /// ask to save a buffer on quit
90         bool qwriteOne(Buffer * buf, string const & fname,
91                        string & unsaved_list);
92
93         typedef std::vector<Buffer *> BufferStorage;
94
95         /// storage of all buffers
96         BufferStorage bstore;
97
98         /// save emergency file for the given buffer
99         void emergencyWrite(Buffer * buf);
100 };
101
102 #endif // BUFFERLIST_H