/*
   Copyright 2000 Peter Putzer <putzer@kde.org>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#ifndef KSV_DATA_H
#define KSV_DATA_H

class QDataStream;

class KSVData
{
public:
  KSVData ();
  KSVData (const QString& file, const QString& path, const QString& label, qint8 nr);
  KSVData (const KSVData& rhs);
  inline ~KSVData () {}

  const KSVData& operator= (const KSVData& rhs);
  bool operator== (const KSVData& rhs) const;
  bool operator< (const KSVData& rhs) const;

  inline QString filenameAndPath () const { return mPath + "/" + mFilename; }

  inline const QString& path () const { return mPath; }
  inline const QString& label () const { return mLabel; }
  inline const QString& filename () const { return mFilename; }
  inline const QString& runlevel () const { return mRunlevel; }
  inline qint8 number () const { return mNr; }

  inline const QString& numberString () const { return mNumberString; }

  inline const QString& oldLabel () const { return mOldLabel; }
  inline const QString& oldFilename () const { return mOldFilename; }
  inline const QString& originalRunlevel () const { return mOldFilename; }
  inline qint8 oldNumber () const { return mOldNr; }
  
  inline bool numberChanged () const { return mNrChanged; }
  inline bool labelChanged () const { return mLabelChanged; }
  inline bool otherChanged () const { return mOtherChanged; }
  inline bool filenameChanged () const { return mFilenameChanged; }
  inline bool newEntry () const { return mNewEntry; }

  inline bool changed () const { return mNrChanged || mLabelChanged || mFilenameChanged; }

  inline void setNumberChanged (bool val) { mNrChanged = val; }
  inline void setNewEntry (bool val) { mNewEntry = val; }
  void setPath (const QString&);
  void setLabel (const QString&);
  void setFilename (const QString&);
  void setRunlevel (const QString&);
  void setOriginalRunlevel (const QString&);
  void setNumber (qint8 nr);
  void setChanged (bool);
 
private:
  friend QDataStream& operator<< (QDataStream&, const KSVData&);
  friend QDataStream& operator>> (QDataStream&, KSVData&);

  QString mPath;
  QString mLabel;
  QString mFilename;
  QString mRunlevel;
  qint8 mNr;
  QString mOldLabel;
  QString mOldFilename;
  QString mOriginalRunlevel;
  qint8 mOldNr;
  
  bool mNrChanged;
  bool mLabelChanged;
  bool mOtherChanged;
  bool mFilenameChanged;
  bool mNewEntry;

  QString mNumberString;
};

QDataStream& operator<< (QDataStream& stream, const KSVData& data);
QDataStream& operator>> (QDataStream& stream, KSVData& data);

#endif // KSV_DATA_H
