File indexing completed on 2024-04-21 04:47:52

0001 /****************************************************************************************
0002  * Copyright (c) 2008 Nikolaj Hald Nielsen <nhn@kde.org>                                *
0003  * Copyright (c) 2009-2010 Bart Cerneels <bart.cerneels@kde.org>                        *
0004  *                                                                                      *
0005  * This program is free software; you can redistribute it and/or modify it under        *
0006  * the terms of the GNU General Public License as published by the Free Software        *
0007  * Foundation; either version 2 of the License, or (at your option) any later           *
0008  * version.                                                                             *
0009  *                                                                                      *
0010  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0012  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0013  *                                                                                      *
0014  * You should have received a copy of the GNU General Public License along with         *
0015  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0016  ****************************************************************************************/
0017 
0018 #ifndef OPMLOUTLINE_H
0019 #define OPMLOUTLINE_H
0020 
0021 #include "amarok_export.h"
0022 
0023 #include <QMap>
0024 #include <QString>
0025 
0026 enum OpmlNodeType
0027 {
0028     InvalidNode,
0029     UnknownNode,
0030     RssUrlNode, //leaf node that link to an RSS
0031     IncludeNode, //URL to an OPML file that will be loaded as a sub-tree upon expansion
0032     RegularNode //plain sub-tree which can be represented as a folder.
0033 };
0034 
0035 class AMAROK_EXPORT OpmlOutline
0036 {
0037     public:
0038         explicit OpmlOutline( OpmlOutline *parent = nullptr );
0039         ~OpmlOutline() {}
0040 
0041         OpmlOutline *parent() const { return m_parent; }
0042         void setParent( OpmlOutline *parent ) { m_parent = parent; }
0043         bool isRootItem() const { return m_parent == nullptr; }
0044 
0045         QMap<QString,QString> attributes() const { return m_attributes; }
0046 
0047         /** @return a modifiable reference to the attributes */
0048         QMap<QString,QString> &mutableAttributes() { return m_attributes; }
0049         void addAttribute( const QString &key, const QString &value )
0050                 { m_attributes.insert( key, value ); }
0051 
0052         QList<OpmlOutline *> children() const { return m_children; }
0053 
0054         /** @return a modifiable reference to the children */
0055         QList<OpmlOutline *> &mutableChildren() { return m_children; }
0056         void setHasChildren( bool hasChildren ) { m_hasChildren = hasChildren; }
0057         bool hasChildren() const { return m_hasChildren; }
0058         void addChild( OpmlOutline *outline ) { m_children << outline; }
0059         void addChildren( const QList<OpmlOutline *> &outlineList )
0060                 { m_children << outlineList; }
0061 
0062         OpmlNodeType opmlNodeType() const;
0063 
0064     private:
0065         OpmlOutline *m_parent;
0066         QMap<QString,QString> m_attributes;
0067 
0068         bool m_hasChildren;
0069         QList<OpmlOutline *> m_children;
0070 };
0071 
0072 #endif // OPMLOUTLINE_H