summaryrefslogtreecommitdiffstats
path: root/quanta/project/projectlist.h
blob: 87593daf4c00863822d61f5355ba6bd4a79f55fe (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
/***********************************************************************
                          projectlist.h  -  List of ProjectURL's
                             -------------------
    begin                : June 19 2004
    copyright            : (C) 2004 by Jens Herden <[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; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef PROJECTLIST_H
#define PROJECTLIST_H

#include "projecturl.h"
#include "qextfileinfo.h"

class QDomDocument;


/**
       @short Container for the project files.

       For fast lookup this container is based on TQDict.
       The key is generated without a trailing '/' so it doesn't matter if you
       search for a folder in this container with or without trailing '/'
*/

class ProjectList : public ProjectUrlList
{
public:
  /** 1009 is a guess for maximum files in an average project, this number should be prime (@ref TQDict)
  */
  ProjectList( int size = 1009 );
  ~ProjectList() {};

  typedef TQDictIterator<ProjectURL> Iterator;

  /** resets @ref m_baseURL */
  void clear();

  /**
       reads entries from the dom tree
       invalid entries gets removed!
       @return true if an old structure was found
   */
  bool readFromXML(TQDomDocument &dom, const KURL &baseURL,
                     const KURL &templateURL, const TQRegExp &excludeRx);
  /**
       @return the relative URL
  */
  KURL toRelative(const KURL &url) const
  {
    return QExtFileInfo::toRelative(url, m_baseURL, false);
  }

  /**
      removes an url from the list and deletes the corresponding node

       @return true if url was in list
  */
  bool removeFromListAndXML(const KURL &url);

  /**   @return true if url is in container
  */
  bool contains(const KURL &url) const;

  /**   @return pointer to the entry or 0 if not found
  */
  ProjectURL * find(const KURL &url) const;

  /**
        Attention: never delete the object you have given here because the
        container takes ownership and deletes it later!

        @param the ProjectURL to add to the container
  */
  void insert(ProjectURL *url);

  /**   @return true if url is in container and a folder
  */
  bool isFolder(const KURL &url) const;

private:
  KURL m_baseURL;

  /**
       private because I want to control the key.
       use insert(ProjectURL *url) instead.
  */
  void insert(const TQString & key, const ProjectURL * item);

  /**
       private because I want to control the key.
       use find(const KURL &url) instead.
  */
  ProjectURL *find ( const TQString & key ) const;

  /**
       private because I want to control the key.
  */
  bool remove ( const TQString & key );

  /**
       private because I want to control the key.
  */
  void replace(const TQString & key, const ProjectURL * item);
};

#endif // PROJECTFILES_H