summaryrefslogtreecommitdiffstats
path: root/kbfxlib/data/kbfxdatasource.h
blob: ea121a4c77f8ffe183e7a7286e5084a9df4949a8 (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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
 *   Copyright (C) 2006
 *   Siraj Razick <siraj@kdemail.net>
 *   PhobosK <phobosk@mail.kbfx.org>
 *   see Also AUTHORS
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License version 2 as
 *   published by the Free Software Foundation
 *
 *   This program 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 General Public License for more details
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#ifndef KBFX_DATA_SOURCE_H
#define KBFX_DATA_SOURCE_H

#include <tqvaluelist.h>
#include <tqstring.h>

class KbfxDataSource
{


	public:
		typedef enum
		{ DESKTOP = 0, NONDESKTOP } Type;
		typedef TQValueList < KbfxDataSource > DataSourceList;
		/**
		 * Constructs a new DataSource. Data source is a simple class that holds
		 * a .desktop file and also you can include a custom commmand that can be 
		 * exectuted 
		 * @return a pointer to a new data source
		 */
		KbfxDataSource ();
		virtual ~ KbfxDataSource ();

		/**
		 * Sets the name of a data source and should not be used if your dara is 
		 *  a desktop file use KbfxDataSource::setDesktopPath() functions instead
		 * @param name should be the name of the data source
		 */
		void setName ( TQString name )
		{
			m_text = name;
		}
		/**
		 * Sets the desktop file of for the data source. Note that u do not have to check 
		 * parameters such as if the the desktop is kiosk allowed. the this function internally 
		 * abstracts such functions.
		 * @param path should be the absolute path of a valid desktop file
		 */
		void setDesktopPath ( TQString path )
		{
			m_desktopPath = path;
			m_type = DESKTOP;
			loadDesktopFile ();
		}

		virtual void setCommand ( TQString cmd )
		{
			m_command = cmd;
		}


		void setContentPath ( TQString path )
		{
			m_contentPath = path;
		}
		TQString contentPath ()
		{
			return m_contentPath;
		}

		virtual void setType ( Type t )
		{
			m_type = t;
		}

		virtual void exec ();

		void setComment ( TQString comment )
		{
			m_comment = comment;
		};

		void setDescription ( TQString desc )
		{
			m_description = desc;
		}

		void setIconPath ( TQString path )
		{
			m_iconPath = path;
		}

		TQString desktopFile ()
		{
			return m_desktopPath;
		}
		//out
		TQString name ()
		{
			return m_text;
		}
		TQString icon ()
		{
			return m_iconPath;
		};
		TQString command ()
		{
			return m_command;
		}
		Type type ()
		{
			return m_type;
		}
		/**
		 * Use this function to get the comment of the a data soruce. this 
		 * functio will NOT return NULL so no checking needed
		 * @return the comment of the data source or empty string 
		 */
		TQString comment ()
		{
			return m_comment;
		}
		bool lookup ( TQString str );
	private:
//TODO
//MOve to private D
		void loadDesktopFile ();
		TQString m_text;
		TQString m_desktopPath;
		TQString m_command;
		TQString m_iconPath;
		TQString m_comment;
		TQString m_description;
		TQString m_keyWords;
		Type m_type;
		TQString m_contentPath;


};
#endif