Theme Editor: Got project viewer displaying WPS files
[kugel-rb.git] / utils / themeeditor / projectfiles.cpp
blobb7168ac47d0d4236372f7da4ca51d04f93f02ec6
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ProjectNode* parent): parentLink(parent)
27 QList<QString> keys;
28 keys.append("wps");
29 keys.append("rwps");
30 keys.append("sbs");
31 keys.append("rsbs");
32 keys.append("fms");
33 keys.append("rfms");
35 for(int i = 0; i < keys.count(); i++)
37 QString file = settings.value(keys[i], "");
38 if(file != "" && file != "-")
40 file.replace("/.rockbox/", "");
41 children.append(new ProjectFile(file, this));
46 ProjectFiles::~ProjectFiles()
48 for(int i = 0; i < children.count(); i++)
49 delete children[i];
52 ProjectNode* ProjectFiles::parent() const
54 return parentLink;
57 ProjectNode* ProjectFiles::child(int row) const
59 if(row >= 0 && row < children.count())
60 return children[row];
62 return 0;
65 int ProjectFiles::numChildren() const
67 return children.count();
70 int ProjectFiles::row() const
72 return parentLink->indexOf(const_cast<ProjectFiles*>(this));
75 QVariant ProjectFiles::data(int column) const
77 if(column == 0)
78 return QObject::tr("Project Files");
79 else
80 return QVariant();
83 Qt::ItemFlags ProjectFiles::flags(int column) const
85 if(column == 0)
86 return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
87 else
88 return 0;
91 void ProjectFiles::activated()
96 /* Project File functions */
97 ProjectFile::ProjectFile(QString file, ProjectNode* parent) :
98 parentLink(parent), file(file)
103 ProjectFile::~ProjectFile()
108 QVariant ProjectFile::data(int column) const
110 if(column == 0)
111 return file;
112 else
113 return QVariant();
116 Qt::ItemFlags ProjectFile::flags(int column) const
118 if(column == 0)
119 return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
120 else
121 return 0;
124 void ProjectFile::activated()