Main Page | Class Hierarchy | Compound List | File List | Compound Members

MP7Doc.hpp

Go to the documentation of this file.
00001  /***********************************************************************
00002  *                                                                      *
00003  * MuViNo - ViTooKi Video Annotation Tool                               *
00004  *                                                                      *
00005  * title:   MP7Doc.hpp                                              *
00006  *                                                                      *
00007  * $Id: MP7Doc_8hpp-source.html,v 1.1 2004/09/27 07:24:51 mtaschwer Exp $
00008  *                                                                      *
00009  * ITEC institute of the University of Klagenfurt (Austria)             *
00010  * http://www.itec.uni-klu.ac.at                                        *
00011  *                                                                      *
00012  *                                                                      *
00013  * For more information visit the ViTooKi homepage:                     *
00014  * http://ViTooKi.sourceforge.net                                       *
00015  * vitooki-user@lists.sourceforge.net                                   *
00016  * vitooki-devel@lists.sourceforge.net                                  *
00017  *                                                                      *
00018  * This file is part of ViTooKi, a free video toolkit.                  *
00019  * ViTooKi is free software; you can redistribute it and/or             *
00020  * modify it under the terms of the GNU General Public License          *
00021  * as published by the Free Software Foundation; either version 2       *
00022  * of the License, or (at your option) any later version.               *
00023  *                                                                      *
00024  * This program is distributed in the hope that it will be useful,      *
00025  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
00026  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the         *
00027  * GNU General Public License for more details.                         *
00028  *                                                                      *
00029  * You should have received a copy of the GNU General Public License    *
00030  * along with this program; if not, write to the Free Software          *
00031  * Foundation, Inc., 59 Temple Place - Suite 330, Boston,               *
00032  * MA  02111-1307, USA.                                                 *
00033  *                                                                      *
00034  ***********************************************************************/
00035 
00036 #ifndef _MP7DOC_HPP_
00037 #define _MP7DOC_HPP_
00038 
00043 #include <qdom.h>
00044 #include <qobject.h>
00045 #include <qptrdict.h>
00046 #include <qptrlist.h>
00047 
00048 class QListView;
00049 class QListViewItem;
00050 class QString;
00051 class MP7ListViewItem;
00052 
00061 class MP7Doc : public QObject
00062 {
00063   Q_OBJECT
00064 
00065 public:
00074   MP7Doc(QListView *listView);
00075 
00076   /* Destructor.
00077    * Deletes all QListViewItem objects corresponding to this
00078    * MPEG-7 document.
00079    */
00080   ~MP7Doc();
00081 
00087   bool parse(const QString &filename);
00088 
00092   bool save(const QString &filename);
00093 
00097   QString filePath() const;
00098 
00102   QString dirPath() const;
00103 
00105   bool isModified() const;
00106 
00113   MP7ListViewItem *addElement(MP7ListViewItem *parent, MP7ListViewItem *after,
00114                   const QString &name);
00115   
00123   MP7ListViewItem *addElement(MP7ListViewItem *parent, const QString &name, int pos = -1);
00124   
00134   int setElementValue(MP7ListViewItem *item, const QString &value);
00135 
00139   bool setAttribute(MP7ListViewItem *item, const QString &attribute,
00140             const QString &value);
00141 
00151   bool moveElement(MP7ListViewItem *item, MP7ListViewItem *newParent,
00152            MP7ListViewItem *newSibling = NULL);
00153 
00157   bool removeElementDeep(MP7ListViewItem *item);
00158 
00166   int removeChildrenDeep(MP7ListViewItem *parent,
00167              const QString &name = QString::null);
00168   
00185   MP7ListViewItem *nodeByPath(const QString &path, MP7ListViewItem *root = NULL,
00186                   bool create = false);
00187 
00193   QPtrList<MP7ListViewItem> children(MP7ListViewItem *parent,
00194                      const QString &name = QString::null) const;
00195 
00205   MP7ListViewItem *nearestElement(MP7ListViewItem *start, const QString &name,
00206                   bool searchUp) const;
00207 
00217   MP7ListViewItem *nearestElement(MP7ListViewItem *start, const QStringList &names,
00218                   bool searchUp) const;
00219 
00220 signals:
00225   void modificationChanged(bool m);
00226 
00227 protected:
00231   void updateTreeWidget();
00232 
00236   void setModified(bool modified);
00237 
00238 private:
00242   void updateTreeWidget(QDomElement &elem, MP7ListViewItem *item);
00243 
00252   MP7ListViewItem *searchBreadthFirst(QPtrList<MP7ListViewItem> &nodes,
00253                       QStringList &names) const;
00254 
00256   QDomDocument doc;
00257 
00259   struct docMeta {
00260     QString filepath;
00261     bool modified;
00262   } docMeta;
00263 
00265   QListView *listView;
00266 
00268   static const QString emptyMP7Doc;
00269 
00274   static bool isElementOf(const QString &string, QStringList &list);
00275 
00276 };
00277 
00278 #endif /* _MP7DOC_HPP_ */

Generated on Mon Sep 27 09:12:05 2004 for Muvino by doxygen 1.3.2