~ubuntu-branches/ubuntu/vivid/kate/vivid-updates

« back to all changes in this revision

Viewing changes to kate/src/session/katesession.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2014-12-04 16:49:41 UTC
  • mfrom: (1.6.6)
  • Revision ID: package-import@ubuntu.com-20141204164941-l3qbvsly83hhlw2v
Tags: 4:14.11.97-0ubuntu1
* New upstream release
* Update build-deps and use pkg-kde v3 for Qt 5 build
* kate-data now kate5-data for co-installability

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
 *
 
3
 *  Copyright (C) 2005 Christoph Cullmann <cullmann@kde.org>
 
4
 *
 
5
 *  This library is free software; you can redistribute it and/or
 
6
 *  modify it under the terms of the GNU Library General Public
 
7
 *  License as published by the Free Software Foundation; either
 
8
 *  version 2 of the License, or (at your option) any later version.
 
9
 *
 
10
 *  This library is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
 *  Library General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU Library General Public License
 
16
 *  along with this library; see the file COPYING.LIB.  If not, write to
 
17
 *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
18
 *  Boston, MA 02110-1301, USA.
 
19
 */
 
20
 
 
21
#ifndef __KATE_SESSION_H__
 
22
#define __KATE_SESSION_H__
 
23
 
 
24
#include <QExplicitlySharedDataPointer>
 
25
#include <QString>
 
26
#include <QDateTime>
 
27
#include "kateprivate_export.h"
 
28
 
 
29
class KConfig;
 
30
 
 
31
class KATE_TESTS_EXPORT KateSession : public QSharedData
 
32
{
 
33
public:
 
34
    /**
 
35
     * Define a Shared-Pointer type
 
36
     */
 
37
    typedef QExplicitlySharedDataPointer<KateSession> Ptr;
 
38
 
 
39
public:
 
40
    ~KateSession();
 
41
 
 
42
    /**
 
43
     * session name
 
44
     * @return name for this session
 
45
     */
 
46
    const QString &name() const {
 
47
        return m_name;
 
48
    }
 
49
 
 
50
    /**
 
51
     * session config
 
52
     * on first access, will create the config object, delete will be done automagic
 
53
     * return 0 if we have no file to read config from atm
 
54
     * @return correct KConfig, neverl null
 
55
     * @note never delete configRead(), because the return value might be
 
56
     *       KSharedConfig::openConfig(). Only delete the member variables directly.
 
57
     */
 
58
    KConfig *config();
 
59
 
 
60
    /**
 
61
     * count of documents in this session
 
62
     * @return documents count
 
63
     */
 
64
    unsigned int documents() const {
 
65
        return m_documents;
 
66
    }
 
67
 
 
68
    /**
 
69
     * update @number of openned documents in session
 
70
     */
 
71
    void setDocuments(const unsigned int number);
 
72
 
 
73
    /**
 
74
     * @return true if this is anonymouse/new session
 
75
     */
 
76
    bool isAnonymous() const {
 
77
        return m_anonymous;
 
78
    }
 
79
 
 
80
    /**
 
81
     * @return path to session file
 
82
     */
 
83
    const QString &file() const;
 
84
 
 
85
    /**
 
86
     * returns last save time of this session
 
87
     */
 
88
    const QDateTime &timestamp() const {
 
89
        return m_timestamp;
 
90
    };
 
91
 
 
92
    /**
 
93
     * Factories
 
94
     */
 
95
public:
 
96
    static KateSession::Ptr create(const QString &file, const QString &name);
 
97
    static KateSession::Ptr createFrom(const KateSession::Ptr &session, const QString &file, const QString &name);
 
98
    static KateSession::Ptr createAnonymous(const QString &file);
 
99
    static KateSession::Ptr createAnonymousFrom(const KateSession::Ptr &session, const QString &file);
 
100
 
 
101
    static bool compareByName(const KateSession::Ptr &s1, const KateSession::Ptr &s2);
 
102
    static bool compareByTimeDesc(const KateSession::Ptr &s1, const KateSession::Ptr &s2);
 
103
 
 
104
private:
 
105
    friend class KateSessionManager;
 
106
    friend class KateSessionTest;
 
107
    /**
 
108
     * set session name
 
109
     */
 
110
    void setName(const QString &name);
 
111
 
 
112
    /**
 
113
     * set's new session file to @filename
 
114
     */
 
115
    void setFile(const QString &filename);
 
116
 
 
117
    /**
 
118
     * create a session from given @file
 
119
     * @param file configuration file
 
120
     * @param name name of this session
 
121
     * @param anonymous anonymous flag
 
122
     * @param config if specified, the session will copy configuration from the KConfig instead of opening the file
 
123
     */
 
124
    KateSession(const QString &file, const QString &name, const bool anonymous, const KConfig *config = 0);
 
125
 
 
126
private:
 
127
    QString m_name;
 
128
    QString m_file;
 
129
    bool m_anonymous;
 
130
    unsigned int m_documents;
 
131
    KConfig *m_config;
 
132
    QDateTime m_timestamp;
 
133
};
 
134
 
 
135
#endif
 
136