summaryrefslogtreecommitdiffstats
path: root/kexi/core/kexiprojectdata.h
blob: 32e5ed7ed83e6a9100c2644de94572e59278b1a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* This file is part of the KDE project
   Copyright (C) 2003 Lucijan Busch <lucijan@gmx.at>
   Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

#ifndef KEXIPROJECTDATA_H
#define KEXIPROJECTDATA_H

#include <kexidb/connectiondata.h>
#include <kexidb/schemadata.h>

#include <tqdatetime.h>

class KexiProjectDataPrivate;

/** @short Kexi project core data member

 Contains:
 - project name
 - database name
 - connection data
 - date and time of last opening
*/
class KEXICORE_EXPORT KexiProjectData : public TQObject, public KexiDB::SchemaData
{
	public:
		typedef TQPtrList<KexiProjectData> List;
		typedef TQMap<TQCString,TQString> ObjectInfo;
		
		KexiProjectData();

		KexiProjectData( const KexiDB::ConnectionData &cdata, 
			const TQString& dbname = TQString(), const TQString& caption = TQString() );
			
		/*! Constructs a copy of \a pdata */
		KexiProjectData( const KexiProjectData& pdata );

		~KexiProjectData();

		KexiProjectData& operator=(const KexiProjectData& pdata);

		/*! \return true if there is the User Mode set in internal 
		 project settings. */
		bool userMode() const;
		
		KexiDB::ConnectionData* connectionData();

		const KexiDB::ConnectionData* constConnectionData() const;

		/*! \return database name. 
		 In fact, this is the same as KexiDB::SchemaData::name() */
		TQString databaseName() const;
		void setDatabaseName(const TQString& dbName);

		/*! \return user-visible string better describing the project than just databaseName(). 
		 For server-based projects returns i18n'd string: 
		 "<project name>" (connection: user\@server:port).
		 For file-based projects returns project's filename. 
		 If \a nobr is true, \<nobr\> tags are added around '(connection: user\@server:port)'
		 (useful for displaying in message boxes). */
		TQString infoString(bool nobr = true) const;

		TQDateTime lastOpened() const;
		void setLastOpened(const TQDateTime& lastOpened);

		TQString description() const;
		void setDescription(const TQString& desc);

		/*! If \a set is true, sets readonly flag for this data, so any connection opened for the project will 
		 be readonly. Change this flag before using this data in KexiProject instance, 
		 otherwise you will need to reopen the project. */
		void setReadOnly(bool set);

		/*! \return readonly flag. False by default.
		 @see setReadOnly() */
		bool isReadOnly() const;

		/*! objects to open on startup (come from command line "-open" option)
		 It's public for convenience */
		TQValueList<ObjectInfo> autoopenObjects;

		/*! @internal
		 Format version used when saving the data to a shortcut file.
		 This is set to 0 by default what means KexiDBShortcutFile_version should be used on saving.
		 If KexiDBShortcutFile was used to create this KexiProjectData object,
		 the version information is be retrieved from the file. */
		uint formatVersion;

	private:
		KexiProjectDataPrivate *d;
};

#endif