xref: /glogg/src/sessioninfo.h (revision 84af0c9b75fb9369ab66df476dd881cd6d30efcf)
1 /*
2  * Copyright (C) 2011, 2014 Nicolas Bonnefon and other contributors
3  *
4  * This file is part of glogg.
5  *
6  * glogg is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * glogg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with glogg.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef SESSIONINFO_H
21 #define SESSIONINFO_H
22 
23 #include <vector>
24 #include <string>
25 
26 #include <QByteArray>
27 #include <QString>
28 
29 #include "persistable.h"
30 
31 // Simple component class containing information related to the session
32 // to be persisted and reloaded upon start
33 class SessionInfo : public Persistable {
34   public:
35     SessionInfo() : openFiles_() { }
36 
37     // Geometry of the main window
38     // (this is an opaque string which is interpreted by the
39     // MainWindow implementation)
40     QByteArray geometry() const
41     { return geometry_; }
42     void setGeometry( const QByteArray& geometry )
43     { geometry_ = geometry; }
44 
45     struct OpenFile
46     {
47         std::string fileName;
48         uint64_t    topLine;
49         // The view context contains parameter specific to the view's
50         // implementation (such as geometry...)
51         std::string viewContext;
52     };
53 
54     // List of the loaded files
55     std::vector<OpenFile> openFiles() const
56     { return openFiles_; }
57     void setOpenFiles( const std::vector<OpenFile>& loaded_files )
58     { openFiles_ = loaded_files; }
59 
60     // Reads/writes the current config in the QSettings object passed
61     virtual void saveToStorage( QSettings& settings ) const;
62     virtual void retrieveFromStorage( QSettings& settings );
63 
64   private:
65     static const int OPENFILES_VERSION;
66 
67     QByteArray geometry_;
68     QByteArray crawlerState_;
69     std::vector<OpenFile> openFiles_;
70 };
71 
72 #endif
73