PCManFM-Qt
dirtreemodelitem.h
1 /*
2  * <one line to give the program's name and a brief idea of what it does.>
3  * Copyright (C) 2014 <copyright holder> <email>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  */
20 
21 #ifndef FM_DIRTREEMODELITEM_H
22 #define FM_DIRTREEMODELITEM_H
23 
24 #include "libfmqtglobals.h"
25 #include <libfm/fm.h>
26 #include <QIcon>
27 #include <QList>
28 #include <QModelIndex>
29 
30 namespace Fm {
31 
32 class DirTreeModel;
33 class DirTreeView;
34 
35 class LIBFM_QT_API DirTreeModelItem {
36 public:
37  friend class DirTreeModel; // allow direct access of private members in DirTreeModel
38  friend class DirTreeView; // allow direct access of private members in DirTreeView
39 
40  explicit DirTreeModelItem();
41  explicit DirTreeModelItem(FmFileInfo* info, DirTreeModel* model, DirTreeModelItem* parent = NULL);
43 
44  void loadFolder();
45  void unloadFolder();
46 
47  bool isPlaceHolder() {
48  return (fileInfo_ == NULL);
49  }
50 
51  void setShowHidden(bool show);
52 
53 private:
54  void freeFolder();
55  void addPlaceHolderChild();
56  DirTreeModelItem* childFromName(const char* utf8_name, int* pos);
57  DirTreeModelItem* childFromPath(FmPath* path, bool recursive) const;
58 
59  DirTreeModelItem* insertFileInfo(FmFileInfo* fi);
60  int insertItem(Fm::DirTreeModelItem* newItem);
61  QModelIndex index();
62 
63  static void onFolderFinishLoading(FmFolder* folder, gpointer user_data);
64  static void onFolderFilesAdded(FmFolder* folder, GSList* files, gpointer user_data);
65  static void onFolderFilesRemoved(FmFolder* folder, GSList* files, gpointer user_data);
66  static void onFolderFilesChanged(FmFolder* folder, GSList* files, gpointer user_data);
67 
68 private:
69  FmFileInfo* fileInfo_;
70  FmFolder* folder_;
71  QString displayName_ ;
72  QIcon icon_;
73  bool expanded_;
74  bool loaded_;
75  DirTreeModelItem* parent_;
76  DirTreeModelItem* placeHolderChild_;
77  QList<DirTreeModelItem*> children_;
78  QList<DirTreeModelItem*> hiddenChildren_;
79  DirTreeModel* model_;
80 };
81 
82 }
83 
84 #endif // FM_DIRTREEMODELITEM_H
Definition: appchoosercombobox.cpp:26
Definition: dirtreeview.h:36
Definition: dirtreemodel.h:37
Definition: dirtreemodelitem.h:35