1
/* This file is part of the KDE project
3
* Copyright (C) 2005 Christoph Cullmann <cullmann@kde.org>
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.
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.
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.
21
#ifndef __KATE_SESSION_H__
22
#define __KATE_SESSION_H__
24
#include <QExplicitlySharedDataPointer>
27
#include "kateprivate_export.h"
31
class KATE_TESTS_EXPORT KateSession : public QSharedData
35
* Define a Shared-Pointer type
37
typedef QExplicitlySharedDataPointer<KateSession> Ptr;
44
* @return name for this session
46
const QString &name() const {
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.
61
* count of documents in this session
62
* @return documents count
64
unsigned int documents() const {
69
* update @number of openned documents in session
71
void setDocuments(const unsigned int number);
74
* @return true if this is anonymouse/new session
76
bool isAnonymous() const {
81
* @return path to session file
83
const QString &file() const;
86
* returns last save time of this session
88
const QDateTime ×tamp() const {
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);
101
static bool compareByName(const KateSession::Ptr &s1, const KateSession::Ptr &s2);
102
static bool compareByTimeDesc(const KateSession::Ptr &s1, const KateSession::Ptr &s2);
105
friend class KateSessionManager;
106
friend class KateSessionTest;
110
void setName(const QString &name);
113
* set's new session file to @filename
115
void setFile(const QString &filename);
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
124
KateSession(const QString &file, const QString &name, const bool anonymous, const KConfig *config = 0);
130
unsigned int m_documents;
132
QDateTime m_timestamp;