1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2010 Robert Bieber
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "projectfiles.h"
24 ProjectFiles::ProjectFiles(QHash
<QString
, QString
>& settings
,
25 ProjectModel
* model
, ProjectNode
* parent
)
28 base
= settings
.value("themebase");
38 for(int i
= 0; i
< keys
.count(); i
++)
40 QString file
= settings
.value(keys
[i
], "");
41 if(file
!= "" && file
!= "-")
43 file
.replace("/.rockbox/", "");
44 children
.append(new ProjectFile(file
, model
, this));
49 ProjectFiles::~ProjectFiles()
51 for(int i
= 0; i
< children
.count(); i
++)
55 ProjectNode
* ProjectFiles::parent() const
60 ProjectNode
* ProjectFiles::child(int row
) const
62 if(row
>= 0 && row
< children
.count())
68 int ProjectFiles::numChildren() const
70 return children
.count();
73 int ProjectFiles::row() const
75 return parentLink
->indexOf(const_cast<ProjectFiles
*>(this));
78 QVariant
ProjectFiles::data(int column
) const
81 return QObject::tr("Project Files");
86 Qt::ItemFlags
ProjectFiles::flags(int column
) const
89 return Qt::ItemIsEnabled
| Qt::ItemIsSelectable
;
94 void ProjectFiles::activated()
99 /* Project File functions */
100 ProjectFile::ProjectFile(QString file
, ProjectModel
* model
,
102 :parentLink(parent
), file(file
)
107 ProjectFile::~ProjectFile()
112 QVariant
ProjectFile::data(int column
) const
120 Qt::ItemFlags
ProjectFile::flags(int column
) const
123 return Qt::ItemIsEnabled
| Qt::ItemIsSelectable
;
128 void ProjectFile::activated()
130 QString base
= dynamic_cast<ProjectFiles
*>(parentLink
)->getBase();
131 model
->loadFile(base
+ "/" + file
);