xref: /glogg/src/sessioninfo.h (revision b57881fa285fa8240ff86bc3a7c4f5766388e84d)
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     /*
39     QByteArray geometry() const
40     { return geometry_; }
41     void setGeometry( const QByteArray& geometry )
42     { geometry_ = geometry; }
43     // Geometry of the CrawlerWidget
44     QByteArray crawlerState() const
45     { return crawlerState_; }
46     void setCrawlerState( const QByteArray& geometry )
47     { crawlerState_ = geometry; }
48     */
49     struct OpenFile
50     {
51         std::string fileName;
52         uint64_t    topLine;
53     };
54 
55     // List of the loaded files
56     std::vector<OpenFile> openFiles() const
57     { return openFiles_; }
58     void setOpenFiles( const std::vector<OpenFile>& loaded_files );
59     { openFiles_ = loaded_files; }
60 
61     // Reads/writes the current config in the QSettings object passed
62     virtual void saveToStorage( QSettings& settings ) const;
63     virtual void retrieveFromStorage( QSettings& settings );
64 
65   private:
66     static const int OPENFILES_VERSION;
67 
68     QByteArray geometry_;
69     QByteArray crawlerState_;
70     std::vector<OpenFile> openFiles_;
71 };
72 
73 #endif
74