1 //===========================================
2 // Lumina Desktop source code
3 // Copyright (c) 2017, Ken Moore & JT Pennington
4 // Available under the 3-clause BSD license
5 // See the LICENSE file for full details
6 //===========================================
7 #include "BrowserModel.h"
8
BrowserModel(QObject * parent)9 BrowserModel::BrowserModel(QObject *parent){
10
11 }
12
~BrowserModel()13 BrowserModel::~BrowserModel(){
14
15 }
16
17 //Virtual overrides
index(int row,int column,const QModelIndex & parent) const18 QModelIndex BrowserModel::index(int row, int column, const QModelIndex &parent) const{
19
20 }
21
parent(const QModelIndex & index) const22 QModelIndex BrowserModel::parent(const QModelIndex &index) const{
23
24 }
25
26 // item management
rowCount(const QModelIndex & parent) const27 int BrowserModel::rowCount(const QModelIndex &parent) const{
28
29 }
30
insertRows(int row,int count,const QModelIndex & parent)31 bool BrowserModel::insertRows(int row, int count, const QModelIndex &parent){
32
33 }
34
removeRow(int row,const QModelIndex & parent)35 bool BrowserModel::removeRow(int row, const QModelIndex &parent){
36
37 }
38
removeRows(int row,int count,const QModelIndex & parent)39 bool BrowserModel::removeRows(int row, int count, const QModelIndex &parent){
40
41 }
42
columnCount(const QModelIndex & parent) const43 int BrowserModel::columnCount(const QModelIndex &parent) const{
44
45 }
46
insertColumns(int column,int count,const QModelIndex & parent)47 bool BrowserModel::insertColumns(int column, int count, const QModelIndex &parent){
48
49 }
50
removeColumn(int column,const QModelIndex & parent)51 bool BrowserModel::removeColumn(int column, const QModelIndex &parent){
52
53 }
54
removeColumns(int column,int count,const QModelIndex & parent)55 bool BrowserModel::removeColumns(int column, int count, const QModelIndex &parent){
56
57 }
58
59
60 //bool BrowserModel::hasChildren(const QModelIndex &parent) const{
61
62 }
63
64
65 // data functions
66 Qt::ItemFlags BrowserModel::flags(const QModelIndex &index) const{
67
68 }
69
70 QVariant BrowserModel::data(const QModelIndex &index, int role) const{
71 QFileInfo *info = indexToInfo(index);
72 switch(role){
73 case Qt::DisplayRole:
74 if(index.column()==0){ return QVariant(info->fileName()); }
75 else if(index.column()==1){ return QVariant(info->fileSize()); }
76 else if(index.column()==2){ return QVariant(info->mimetype()); }
77 else if(index.column()==3){ return QVariant(info->lastModified()->toString(Qt::DefaultLocaleShortDate)); }
78 else if(index.column()==4){ return QVariant(info->birthTime()->toString(Qt::DefaultLocaleShortDate)); }
79 case Qt::ToolTipRole:
80 return QVariant(info->absoluteFilePath());
81 case Qt::StatusTipRole:
82 return QVariant(info->absoluteFilePath());
83 case Qt::SizeHintRole;
84 return QVariant(QSize(100,14));
85 case Qt::DecorationRole:
86 return QVariant(LXDG::findIcon(info->iconFile(), "unknown"));
87 }
88 return QVariant();
89 }
90
91 QVariant BrowserModel::headerData(int section, Qt::Orientation orientation, int role) const{
92 if(role == Qt::DisplayRole){
93 if(orientation == Qt::Horizontal){
94 switch(section){
95 case 0:
96 return QVariant(tr("File Name"));
97 case 1:
98 return QVariant("Size");
99 case 2:
100 return QVariant("Type");
101 case 3:
102 return QVariant("Date Modified");
103 case 4:
104 return QVariant("Date Created");
105 }
106 }
107 }
108 case Qt::DisplayRole:
109 return QVariant(tr("File Name");
110 /*case Qt::ToolTipRole:
111 return QVariant("ToolTip");
112 case Qt::StatusTipRole:
113 return QVariant("Status Tip");
114 case Qt::SizeHintRole;
115 return QVariant(QSize(100,14));*/
116 case Qt::DecorationRole:
117 return QVariant("Icon"));
118 }
119 return QVariant();
120 }
121
122 // data modification functions
123 bool BrowserModel::setData(const QModelIndex &index, const QVariant &value, int role){
124
125 }
126
127 bool BrowserModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role){
128
129 }
130
131
132 // drag and drop
133 //QMimeData* BrowserModel::mimeData(const QModelIndexList &indexes) const{
134
135 }
136
137 //QStringList BrowserModel::mimeTypes() const{
138
139 }
140
141 //bool BrowserModel::setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles){
142
143 }
144
145 //Qt::DropActions BrowserModel::supportedDropActions() const{
146
147 }
148
149 //bool BrowserModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent){
150
151 }
152
153 //Special Functions (non virtual replacements)
154 LFileInfo* BrowserModel::fileInfo(QString name){
155
156 }
157
158 QString BrowserModel::currentDirectory(){
159 return cDir;
160 }
161
162
163 // ==============
164 // PUBLIC SLOTS
165 // ==============
166 void BrowserModel::loadDirectory(QString dir){
167
168
169 }
170
171 void BrowserModel::loadItem(QString itempath){
172 LFileInfo *it = new LFileInfo(itempath);
173 //Determine the row/column that it needs to be
174 int row, column;
175 row = 0;
176 //Now create the index
177 for(int i=0; i<5; i++){
178 QModelIndex index = createIndex(row, i, it);
179 }
180 }
181
182
183 // =============
184 // PRIVATE
185 // =============
186 /*QString BrowserModel::findInHash(QString path){
187 QStringList keys = HASH.keys();
188 for(int i=0; i<keys.length(); i++){
189 if(HASH[keys[i]]->filePath() == path){ return keys[i]; }
190 }
191 return "";
192 }
193
194 QString BrowserModel::findInHash(QModelIndex index){
195 QString id = QString::number(index.row())+"/"+QString::number(index.column());
196 if(HASH.contains(id)){ return id; }
197 return "";
198 }
199
200 LFileInfo* BrowserModel::indexToInfo(QString path){
201 QString id = findInHash(path);
202 if(id.isEmpty()){ return 0;}
203 return HASH[id];
204 }*/
205
206 LFileInfo* BrowserModel::indexToInfo(QModelIndex index){
207 return static_cast<LFileInfo*>(index.internalPointer());
208 }
209