"Fossies" - the Fresh Open Source Software Archive 
Member "regexxer-0.10/src/filetreeprivate.h" (6 Oct 2011, 6120 Bytes) of package /linux/privat/old/regexxer-0.10.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "filetreeprivate.h" see the
Fossies "Dox" file reference documentation.
1 /*
2 * Copyright (c) 2002-2007 Daniel Elstner <daniel.kitta@gmail.com>
3 *
4 * This file is part of regexxer.
5 *
6 * regexxer is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * regexxer is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with regexxer; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #ifndef REGEXXER_FILETREEPRIVATE_H_INCLUDED
22 #define REGEXXER_FILETREEPRIVATE_H_INCLUDED
23
24 #include "filetree.h"
25
26 #include <gtkmm/treerowreference.h>
27 #include <gtkmm/treestore.h>
28 #include <utility>
29
30 namespace Regexxer
31 {
32
33 /*
34 * This namespace contains all types and functions which are used exclusively by
35 * the FileTree implementation, but aren't members of class Regexxer::FileTree.
36 */
37 namespace FileTreePrivate
38 {
39
40 // Normally I don't like global using declarations, but it's
41 // reasonable to make an exception for the smart pointer casts.
42 using Util::shared_dynamic_cast;
43 using Util::shared_polymorphic_cast;
44
45 struct FileTreeColumns : public Gtk::TreeModel::ColumnRecord
46 {
47 Gtk::TreeModelColumn<Glib::ustring> filename;
48 Gtk::TreeModelColumn<std::string> collatekey;
49 Gtk::TreeModelColumn<int> matchcount;
50 Gtk::TreeModelColumn<FileInfoBasePtr> fileinfo;
51
52 static const FileTreeColumns& instance();
53
54 private:
55 FileTreeColumns() { add(filename); add(collatekey); add(matchcount); add(fileinfo); }
56 };
57
58 inline
59 FileInfoPtr get_fileinfo_from_iter(const Gtk::TreeModel::iterator& iter)
60 {
61 const FileInfoBasePtr base ((*iter)[FileTreeColumns::instance().fileinfo]);
62 return shared_dynamic_cast<FileInfo>(base);
63 }
64
65 int default_sort_func (const Gtk::TreeModel::iterator& a, const Gtk::TreeModel::iterator& b);
66 int collatekey_sort_func(const Gtk::TreeModel::iterator& a, const Gtk::TreeModel::iterator& b);
67
68 bool next_match_file(Gtk::TreeModel::iterator& iter, Gtk::TreeModel::Path* collapse = 0);
69 bool prev_match_file(Gtk::TreeModel::iterator& iter, Gtk::TreeModel::Path* collapse = 0);
70
71 typedef std::pair<std::string, Gtk::TreeModel::iterator> DirNodePair;
72 typedef std::list<DirNodePair> DirStack;
73
74 class ScopedPushDir
75 {
76 private:
77 DirStack& dirstack_;
78
79 ScopedPushDir(const ScopedPushDir&);
80 ScopedPushDir& operator=(const ScopedPushDir&);
81
82 public:
83 ScopedPushDir(DirStack& dirstack, const std::string& dirname)
84 : dirstack_ (dirstack)
85 { dirstack_.push_back(DirNodePair(dirname, Gtk::TreeModel::iterator())); }
86
87 ~ScopedPushDir() { dirstack_.pop_back(); }
88 };
89
90 } // namespace FileTreePrivate
91
92 /* This is just a Gtk::TreeRowReference wrapper that can be used with Util::SharedPtr<>.
93 */
94 class FileTree::TreeRowRef : public Util::SharedObject, public Gtk::TreeRowReference
95 {
96 public:
97 TreeRowRef(const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path);
98 ~TreeRowRef();
99
100 private:
101 TreeRowRef(const FileTree::TreeRowRef&);
102 FileTree::TreeRowRef& operator=(const FileTree::TreeRowRef&);
103 };
104
105 /* This is just a std::list<> wrapper that can be used with Util::SharedPtr<>.
106 */
107 class FileTree::MessageList : public Util::SharedObject, public std::list<Glib::ustring>
108 {
109 public:
110 MessageList();
111 ~MessageList();
112
113 private:
114 MessageList(const FileTree::MessageList&);
115 FileTree::MessageList& operator=(const FileTree::MessageList&);
116 };
117
118 struct FileTree::FindData
119 {
120 FindData(const Glib::RefPtr<Glib::Regex>& pattern_, bool recursive_, bool hidden_);
121 ~FindData();
122
123 const Glib::RefPtr<Glib::Regex>& pattern;
124 const bool recursive;
125 const bool hidden;
126 FileTreePrivate::DirStack dirstack;
127 Util::SharedPtr<FileTree::MessageList> error_list;
128
129 private:
130 FindData(const FileTree::FindData&);
131 FileTree::FindData& operator=(const FileTree::FindData&);
132 };
133
134 struct FileTree::FindMatchesData
135 {
136 FindMatchesData(const Glib::RefPtr<Glib::Regex>& pattern_, bool multiple_);
137
138 const Glib::RefPtr<Glib::Regex>& pattern;
139 const bool multiple;
140 bool path_match_first_set;
141
142 private:
143 FindMatchesData(const FileTree::FindMatchesData&);
144 FileTree::FindMatchesData& operator=(const FileTree::FindMatchesData&);
145 };
146
147 struct FileTree::ReplaceMatchesData
148 {
149 ReplaceMatchesData(FileTree& filetree_, const Glib::ustring& substitution_);
150 ~ReplaceMatchesData();
151
152 FileTree& filetree;
153 const Glib::ustring substitution;
154 FileTree::TreeRowRefPtr row_reference;
155 UndoStackPtr undo_stack;
156 const sigc::slot<void, UndoActionPtr> slot_undo_stack_push;
157
158 void undo_stack_push(UndoActionPtr undo_action);
159
160 private:
161 ReplaceMatchesData(const FileTree::ReplaceMatchesData&);
162 FileTree::ReplaceMatchesData& operator=(const FileTree::ReplaceMatchesData&);
163 };
164
165 class FileTree::ScopedBlockSorting
166 {
167 public:
168 explicit ScopedBlockSorting(FileTree& filetree);
169 ~ScopedBlockSorting();
170
171 private:
172 FileTree& filetree_;
173 int sort_column_;
174 Gtk::SortType sort_order_;
175
176 ScopedBlockSorting(const FileTree::ScopedBlockSorting&);
177 FileTree::ScopedBlockSorting& operator=(const FileTree::ScopedBlockSorting&);
178 };
179
180 class FileTree::BufferActionShell : public UndoAction
181 {
182 public:
183 BufferActionShell(FileTree& filetree, const FileTree::TreeRowRefPtr& row_reference,
184 const UndoActionPtr& buffer_action);
185 virtual ~BufferActionShell();
186
187 private:
188 FileTree& filetree_;
189 FileTree::TreeRowRefPtr row_reference_;
190 UndoActionPtr buffer_action_;
191
192 virtual bool do_undo(const sigc::slot<bool>& pulse);
193 };
194
195 } // namespace Regexxer
196
197 #endif /* REGEXXER_FILETREEPRIVATE_H_INCLUDED */