Clean up libmad/mad.h to avoid double or inconsistent definitions of types, functions...
[kugel-rb.git] / utils / themeeditor / projectfiles.cpp
blobf687e23767b0298bcbca51ecb29ecc9cff739dce
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 ProjectModel* model, ProjectNode* parent)
26 : parentLink(parent)
28 base = settings.value("themebase");
30 QList<QString> keys;
31 keys.append("wps");
32 keys.append("rwps");
33 keys.append("sbs");
34 keys.append("rsbs");
35 keys.append("fms");
36 keys.append("rfms");
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++)
52 delete children[i];
55 ProjectNode* ProjectFiles::parent() const
57 return parentLink;
60 ProjectNode* ProjectFiles::child(int row) const
62 if(row >= 0 && row < children.count())
63 return children[row];
65 return 0;
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
80 if(column == 0)
81 return QObject::tr("Project Files");
82 else
83 return QVariant();
86 Qt::ItemFlags ProjectFiles::flags(int column) const
88 if(column == 0)
89 return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
90 else
91 return 0;
94 void ProjectFiles::activated()
99 /* Project File functions */
100 ProjectFile::ProjectFile(QString file, ProjectModel* model,
101 ProjectNode* parent)
102 :parentLink(parent), file(file)
104 this->model = model;
107 ProjectFile::~ProjectFile()
112 QVariant ProjectFile::data(int column) const
114 if(column == 0)
115 return file;
116 else
117 return QVariant();
120 Qt::ItemFlags ProjectFile::flags(int column) const
122 if(column == 0)
123 return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
124 else
125 return 0;
128 void ProjectFile::activated()
130 QString base = dynamic_cast<ProjectFiles*>(parentLink)->getBase();
131 model->loadFile(base + "/" + file);