summaryrefslogtreecommitdiffstats
path: root/quanta/treeviews/scripttreeview.h
blob: 589f165df56627d1e188fb551d00599753c367ef (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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/***************************************************************************
                          scripttreeview.h  -  description
                             -------------------
    begin                : Thu Sep 16 2003
    copyright            : (C) 2003-2004 by Andras Mantia <[email protected]>
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; version 2 of the License.               *
 *                                                                         *
 ***************************************************************************/
#ifndef SCRIPTTREEVIEW_H
#define SCRIPTTREEVIEW_H

//own includes
#include "basetreeview.h"

/**
 * @short treeview with all in Quanta available scripts.
 *
 *   You can manage and excecute scripts from here.
 *
 *   There are local and global scripts in different branches.
 *
 *   For every script should exist an .info file!
 *
 *   The .info file is an xhtml file with the extention .info and
 *   must be in one folder together with the script.
 *
 *   Inside of your .info file should be an options tag like this
 *   example:
 *
 *   <options editor="kmdr-editor" interpreter="kmdr-executor" />
 *
 *   Here is defined which program is used for editing and executing the script.
 *
 * @author Andras Mantia <[email protected]>
 */
class ScriptTreeView : public BaseTreeView  {
   TQ_OBJECT
  


public:
   ScriptTreeView(TQWidget *parent, const char *name = 0L);
  ~ScriptTreeView();

protected slots:

  /**
   *  displays the RBM
   *
   *
   *  @param listView TDEListView where the event comes from
   *
   *  @param item TQListViewItem where the mousepointer is hovering
   *
   *  @param point TQPoint coordinates of the event
   *
   */
  virtual void slotMenu(TDEListView *listView, TQListViewItem *item, const TQPoint &point);

  /**
   *  slot of TQListView
   *
   *  shows the .info file for the script
   *
   *  @param item the selected TQListViewItem
   */
  virtual void slotSelectFile(TQListViewItem *item);

  /**
   *  slot for the RBM
   *
   *  invokes the editor for a script
   */
  void slotEditScript();

  /**
   *  slot for the RBM
   *
   *  opens the script in Quanta
   *
   *  if @ref infoOptionValue can not find the definition of the editor
   *  in the .info file the script will be opened in Quanta
   */
  void slotEditInQuanta();

  /**
   *  slot for the RBM
   *
   *  opens the .info file of the script in Quanta
   */
  void slotEditDescription();

  /**
   *  slot for the RBM
   *
   *  excecutes the script
   *
   *  If @ref infoOptionValue can not find the definition of the interpreter
   *  in the .info file you will get a open-with dialog to choose a program.
   */
  void slotRun();

  /**
   *  slot for the RBM
   *
   *  opens an dialog to assign an action to this script
   */
  void slotAssignAction();

  /**
   *  slot for the RBM
   *
   *  packs and sends the script as attachment to an email
   */
  void slotSendScriptInMail();

  /**
   *  slot for the RBM
   *
   *  packs and uploads the script to the main server
   */
  void slotUploadScript();
  
  /**
   *  slot for the RBM
   *
   *  shows .info file for the script
   *
   *  calls @ref slotSelectFile
   */
  void slotProperties();

protected:

  /**
   *  don't need this in the class but it is abstract in the base class
   *  so I need to implement it
   */
  virtual KFileTreeBranch* newBranch(const KURL& url)
  {
    Q_UNUSED(url)
    return 0l;
  };

signals:

  /**
   *  emited from @ref slotSelectFile to display the .info file
   */
  void openFileInPreview(const KURL&);

  /**
   *  emited from @ref slotAssignAction to open the assignment dialog
   */
  void assignActionToScript(const KURL&, const TQString&);

  /**
   *  emited to make the script describtion visible
   */
  void showPreviewWidget(bool);
  
  /**
  *  emitted to request downloading of a script from the main server
  */
  void downloadScript();
  
  /** 
  *  request to upload the @ref fileName script tarball
  */
  void uploadScript(const TQString& fileName);

private:
   /**
    * make the default constructor private to force the use of the other one
    */
   ScriptTreeView() { };

  /**
   *  creates the URL of the .info file
   *
   *  @param url URL of the script file
   *  @param htmlVersion if true returns the HTML version of the file
   *
   *  @return URL of the matching .info file (no check is done if the file exists)
   */
  KURL infoFile(const KURL& url, bool htmlVersion = false);

  /**
   *  query options from the .info file
   *
   *  inside of your .info file only the first options tag is located
   *
   *  @param infoURL URL of the .info file
   *
   *  @param optionName name of the option you want to query
   *
   *  @return the value of the option
   */
  TQString infoOptionValue(const KURL& infoURL, const TQString& optionName);
  
  /** Create a script tarball which can be uploaded or sent in email. Returns
   *   the name of the created file or TQString() if creation has failed.
   */
  TQString createScriptTarball();

  /**
   *  remember the menu for manipulation
   */
  TDEPopupMenu *m_fileMenu;
  TDEPopupMenu *m_folderMenu;

  int m_downloadMenuId;
};

#endif