File indexing completed on 2024-10-27 04:24:21

0001 /***************************************************************************
0002  *   Copyright (C) 2010 Ralf Engels <ralf-engels@gmx.de>                   *
0003  *                                                                         *
0004  *   This program is free software; you can redistribute it and/or modify  *
0005  *   it under the terms of the GNU General Public License as published by  *
0006  *   the Free Software Foundation; either version 2 of the License, or     *
0007  *   (at your option) any later version.                                   *
0008  *                                                                         *
0009  *   This program is distributed in the hope that it will be useful,       *
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0012  *   GNU General Public License for more details.                          *
0013  *                                                                         *
0014  *   You should have received a copy of the GNU General Public License     *
0015  *   along with this program; if not, write to the                         *
0016  *   Free Software Foundation, Inc.,                                       *
0017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
0018  ***************************************************************************/
0019 
0020 #ifndef COLLECTIONSCANNER_DIRECTORY_H
0021 #define COLLECTIONSCANNER_DIRECTORY_H
0022 
0023 #include "Album.h"
0024 #include "Playlist.h"
0025 #include "amarokshared_export.h"
0026 
0027 #include <QString>
0028 #include <QList>
0029 #include <QHash>
0030 #include <QXmlStreamReader>
0031 #include <QXmlStreamWriter>
0032 
0033 namespace CollectionScanner
0034 {
0035 
0036 class Track;
0037 class ScanningState;
0038 
0039 /**
0040  * @class Directory
0041  * @short Represents a scanned directory and it's contents
0042  */
0043 class AMAROKSHARED_EXPORT Directory
0044 {
0045 public:
0046     /**
0047      * This constructor actually scans the directory and is supposed only to be
0048      * called by CollectionScanner directly.
0049      */
0050     Directory( const QString &path, ScanningState *state, bool skip );
0051 
0052     /** Reads a directory from an xml stream.
0053      * @see toXml()
0054      */
0055     explicit Directory( QXmlStreamReader *reader );
0056 
0057     ~Directory();
0058 
0059     /** The absolute path to the file.
0060      *  Because of symbolic links the path could be outside the original scanning directories.
0061      */
0062     QString path() const;
0063 
0064     /** Returns the relative path at the point of scanning */
0065     QString rpath() const;
0066 
0067     /** Returns the modification time of the directory. */
0068     uint mtime() const;
0069 
0070     /** Returns true if the directory was skipped and not scanned.
0071      *  Usually this is being done because the directory was unmodified in an
0072      *  Incremental scan.
0073      */
0074     bool isSkipped() const;
0075 
0076     const QStringList& covers() const;
0077     const QList<Track*>& tracks() const;
0078     const QList<Playlist>& playlists() const;
0079 
0080     /** Writes the contents of this object to an xml stream.
0081      *  Only the content is written and no enclosing directory tags.
0082      *  This is done to make it mirror the constructor which does not read those
0083      *  tags either.
0084      */
0085     void toXml( QXmlStreamWriter *writer ) const;
0086 
0087 private:
0088     Q_DISABLE_COPY(Directory)
0089 
0090     QString m_path;
0091     QString m_rpath;
0092     uint m_mtime;
0093     bool m_skipped;
0094     bool m_ignored; // the directory was ignored e.g. because of "fmps_ignore"
0095 
0096     QStringList m_covers;
0097     QList<Track*> m_tracks;
0098     QList<Playlist> m_playlists;
0099 };
0100 
0101 }
0102 
0103 #endif // COLLECTIONSCANNER_DIRECTORY_H