summaryrefslogtreecommitdiffstats
path: root/quanta/treeviews/templatestreeview.h
blob: efccc56afeca67eacb4b5f7ccb2cf8b257631215 (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
/***************************************************************************
                          templatestreeview.h  -  description
                             -------------------
    begin                : Thu Dec 20 2001
    copyright            : (C) 2001-2004 by Andras Mantia <amantia@kde.org>
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 TEMPLATESTREEVIEW_H
#define TEMPLATESTREEVIEW_H

//own includes
#include "basetreeview.h"
#include "quantacommon.h"

//forward declarations
class QuantaPropertiesPage;
class KMainWindow;

class TemplatesTreeBranch : public BaseTreeBranch {

public:
  TemplatesTreeBranch(KFileTreeView *tqparent, const KURL& url,
                      const TQString& name, const TQPixmap& pix,
                      bool showHidden = false, KFileTreeViewItem *branchRoot = 0L);

  /** read the mimetype */
  virtual KFileTreeViewItem* createTreeViewItem(KFileTreeViewItem *tqparent,
                                                KFileItem *fileItem );
};


class TemplatesTreeView : public BaseTreeView  {
   Q_OBJECT
  TQ_OBJECT

public:

  /**
   *  since this class is a singleton you must use this function to access it
   *
   *  the parameter are only used at the first call to create the class
   *
   */
  static TemplatesTreeView* const ref(KMainWindow *tqparent = 0L, const char *name = 0L)
  {
    static TemplatesTreeView *m_ref;
    if (!m_ref) m_ref = new TemplatesTreeView (tqparent, name);
    return m_ref;
  }

  ~TemplatesTreeView();
  /** Writes a .dirinfo file from the selected item's path */
  bool writeDirInfo(const TQString& dirInfoFile = TQString());
  /** Reads a .dirinfo file from the selected item's path */
  DirInfo readDirInfo(const TQString& dir = TQString());


public slots:

  /**  Inserts the content of the selected template into the
    *  activ document
    */
  void slotInsertInDocument();

  /**
   *  displays the RBM
   *
   *
   *  @param listView KListView where the event comes from
   *
   *  @param item TQListViewItem where the mousepointer is hovering
   *
   *  @param point TQPoint coordinates of the event
   *
   */
  void slotMenu(KListView *listView, TQListViewItem *item, const TQPoint &point);
  /** Creates a new document based in the selected template. */
  void slotNewDocument();
  /** Insert the template as text, image, new document. */
  void slotInsert();
  /** Extracts the site template to an user specified directory */
  void slotExtractSiteTemplate();
  /** No descriptions */
  void slotNewDir();
 /** Handles dropping on the document from the template tree */
  void slotDragInsert(TQDropEvent *);

  /**
   *  slot for the RBM
   *
   *  packs and sends files or folders as attachment to an email
   */
  void slotSendInMail();
  void slotUploadTemplate();
  virtual void slotSelectFile(TQListViewItem *item);
  void slotOpen();
  void slotPaste();
  void slotDelete();
  /** Properties dialog for template view */
  virtual void slotProperties();
  /** Property application for template view */
  virtual void slotPropertiesApplied();
  void slotInsertTag();

  /** Sets the project template directory */
  void slotNewProjectLoaded(const TQString &, const KURL &, const KURL &);

private:

  /** The constructor is privat because we use singleton pattern.
   *  If you need the class use TemplatesTreeView::ref() for
   *  construction and reference
   */
  TemplatesTreeView(KMainWindow *tqparent, const char *name = 0L);
  /** Filters the template through and action, and returns the modified/filtered
  template file */
  KURL filterTemplate();
  void writeTemplateInfo();
  void updateTypeDescription(KFileTreeViewItem *item, const TQString &typeString);

  BaseTreeBranch *m_projectDir;
  int m_deleteMenuId;
  int m_openId;
  int m_reloadMenuId;
  int m_downloadMenuId;
  QuantaPropertiesPage *m_quantaProperties;
  TQString m_projectName;
  KURL localURL;
  KURL globalURL;
  KPopupMenu *m_fileMenu;
  KPopupMenu *m_folderMenu;
  KPopupMenu *m_emptyAreaMenu;
  KMainWindow *m_mainWindow;
  DirInfo m_dirInfo;
  DirInfo m_parentDirInfo;
  int m_insertFileInProject;
  int m_insertFolderInProject;
  int m_menuClose;                ///< remembers the menu entry
  int m_menuPasteFolder;          ///< remembers the menu entry

signals: // Signals
  void insertFile(const KURL &);
  void downloadTemplate();
  void uploadTemplate(const TQString&);

protected: // Protected methods
  KFileTreeBranch* newBranch(const KURL& url);
  virtual TQDragObject * dragObject();
//  virtual void startDrag();
  void contentsDropEvent(TQDropEvent *event);
  bool acceptDrag(TQDropEvent* e ) const;
  TQString createTemplateTarball();
};

#endif