"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/krenamefile.h" between
krename-4.0.9.tar.gz and krename-4.90.90.tar.gz

About: KRename is a batch file-renamer (KDE).

krenamefile.h  (krename-4.0.9):krenamefile.h  (krename-4.90.90)
skipping to change at line 18 skipping to change at line 18
/*************************************************************************** /***************************************************************************
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * * the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
* * * *
***************************************************************************/ ***************************************************************************/
#ifndef _KRENAME_FILE_H_ #ifndef KRENAME_FILE_H
#define _KRENAME_FILE_H_ #define KRENAME_FILE_H
#include <QVector> #include <QVector>
#include <kfileitem.h> #include <kfileitem.h>
#include <kurl.h> #include <QUrl>
#include <QPixmap> #include <QPixmap>
#include <kio/pixmaploader.h>
class KFileItem; class KFileItem;
/** An enum to describe the mode to split /** An enum to describe the mode to split
* filename and extension. * filename and extension.
*/ */
enum ESplitMode { enum ESplitMode {
eSplitMode_FirstDot, ///< Extension starts at the first dot found in the filename eSplitMode_FirstDot, ///< Extension starts at the first dot found in the filename
eSplitMode_LastDot, ///< Extension starts at the last dot found in the f ilename eSplitMode_LastDot, ///< Extension starts at the last dot found in the f ilename
eSplitMode_NoExtension, ///< Do not use file extension handling eSplitMode_NoExtension, ///< Do not use file extension handling
eSplitMode_CustomDot ///< Extension starts at a user defined dot in the f ilename eSplitMode_CustomDot ///< Extension starts at a user defined dot in the f ilename
skipping to change at line 49 skipping to change at line 51
/** /**
* Type of manual change made. * Type of manual change made.
* Specifies on what kind of filename, the manual changes are based. * Specifies on what kind of filename, the manual changes are based.
*/ */
enum EManualChangeMode { enum EManualChangeMode {
eManualChangeMode_None, ///< Use filename created by KRename eManualChangeMode_None, ///< Use filename created by KRename
eManualChangeMode_Input, ///< Use custom filename, based on input filename eManualChangeMode_Input, ///< Use custom filename, based on input filename
eManualChangeMode_Custom ///< Use custom filename eManualChangeMode_Custom ///< Use custom filename
}; };
class KRenameFile { class KRenameFile
{
struct TFileDescription { struct TFileDescription {
QString filename; QString filename;
QString extension; QString extension;
QString directory; QString directory;
KUrl url; QUrl url;
const TFileDescription & operator=( const TFileDescription & rhs ) const TFileDescription &operator=(const TFileDescription &rhs)
{ {
filename = rhs.filename; filename = rhs.filename;
extension = rhs.extension; extension = rhs.extension;
directory = rhs.directory; directory = rhs.directory;
url = rhs.url; url = rhs.url;
return *this; return *this;
} }
}; };
public: public:
/** A list of KRenameFile objects /** A list of KRenameFile objects
*/ */
typedef QVector<KRenameFile> List; typedef QVector<KRenameFile> List;
/** Empty default constructor /** Empty default constructor
* which creates an invalid KRenameFile. * which creates an invalid KRenameFile.
* *
* \see isValid * \see isValid
*/ */
KRenameFile() KRenameFile()
: m_bValid( false ) : m_bValid(false)
{ {
} }
/** Construct a new KRenameFile from an url. /** Construct a new KRenameFile from an url.
* *
* The url will be tested for existance
* and isValid() returns only true
* if the url is existing.
*
* \param src an url of a file or directory
* \param eSplitMode splitmode which is used to separate
* filename and extension
* \param dot dot to use as separator for eSplitMode_CustomDot
* \see isValid()
*/
KRenameFile( const KUrl & src, ESplitMode eSplitMode, unsigned int dot );
/** Construct a new KRenameFile from an url.
*
* The url is expected to exist and is not * The url is expected to exist and is not
* tested for existance. This is much faster than * tested for existence. This is much faster than
* the other constructor. * the other constructor.
* *
* \param src an url of a file or directory * \param src an url of a file or directory
* \param directory must be true if the url referes * \param directory must be true if the url referes
* to a directory. * to a directory.
* \param eSplitMode splitmode which is used to separate * \param eSplitMode splitmode which is used to separate
* filename and extension * filename and extension
* \param dot dot to use as separator for eSplitMode_CustomDot * \param dot dot to use as separator for eSplitMode_CustomDot
*/ */
KRenameFile( const KUrl & src, bool directory, ESplitMode eSplitMode, unsign ed int dot ); KRenameFile(const QUrl &src, bool directory, ESplitMode eSplitMode, unsigned int dot);
/** Construct a new KRenameFile form a KFileItem which is faster /** Construct a new KRenameFile form a KFileItem which is faster
* than construction from an URL. * than construction from an URL.
* *
* \param item a KFileItem * \param item a KFileItem
* \param eSplitMode splitmode which is used to separate * \param eSplitMode splitmode which is used to separate
* filename and extension * filename and extension
* \param dot dot to use as separator for eSplitMode_CustomDot * \param dot dot to use as separator for eSplitMode_CustomDot
*/ */
KRenameFile( const KFileItem& item, ESplitMode eSplitMode, unsigned int dot
); KRenameFile(const QUrl &src, ESplitMode eSplitMode, unsigned int dot);
KRenameFile(const KFileItem &item, ESplitMode eSplitMode, unsigned int dot);
/** Copy constructor /** Copy constructor
* \param rhs KRenameFile to copy * \param rhs KRenameFile to copy
*/ */
KRenameFile( const KRenameFile & rhs ); KRenameFile(const KRenameFile &rhs);
/** Set the splitmode to separate filename from fileextension /** Set the splitmode to separate filename from fileextension
* *
* \param eSplitMode splitmode which is used to separate * \param eSplitMode splitmode which is used to separate
* filename and extension * filename and extension
* \param dot dot to use as separator for eSplitMode_CustomDot * \param dot dot to use as separator for eSplitMode_CustomDot
* *
* \see srcFilename() * \see srcFilename()
* \see srcExtension() * \see srcExtension()
*/ */
void setCurrentSplitMode( ESplitMode eSplitMode, unsigned int dot = 1 ); void setCurrentSplitMode(ESplitMode eSplitMode, unsigned int dot = 1);
/** /**
* \returns the number of dots in this filename that can be used to separate filename and extension * \returns the number of dots in this filename that can be used to separate filename and extension
*/ */
int dots() const; int dots() const;
/** Convert the KRenameFile into a string /** Convert the KRenameFile into a string
* that can be displayed to the user. * that can be displayed to the user.
* *
* \returns original source url as string representation * \returns original source url as string representation
*/ */
inline const QString toString() const inline const QString toString() const
{ {
return m_src.url.prettyUrl(); return m_src.url.toDisplayString(QUrl::PreferLocalFile);
} }
/** Get a preview icon of the KRenameFile /** Get a preview icon of the KRenameFile
* *
* @returns a QPixmap containing a preview of this KRenameFile. * @returns a QPixmap containing a preview of this KRenameFile.
* This might be only a mimetype icon depending on the current KDE settings. * This might be only a mimetype icon depending on the current KDE settings.
*/ */
inline const QPixmap & icon() const inline const QPixmap &icon() const
{ {
if( m_icon.isNull() ) if (m_icon.isNull()) {
const_cast<KRenameFile*>(this)->loadPreviewIcon(); const_cast<KRenameFile *>(this)->loadPreviewIcon();
}
return m_icon; return m_icon;
} }
/** Set the preview icon of the KRenameFile /** Set the preview icon of the KRenameFile
* *
* @param icon a preview icon. * @param icon a preview icon.
* *
* This method is only here for performance reason * This method is only here for performance reason
* to easily and fast set the icon from one * to easily and fast set the icon from one
* KRenameFile onto another. * KRenameFile onto another.
* *
* Normally KRenameFile knows how to load the icon itselfs. * Normally KRenameFile knows how to load the icon itself.
*/ */
inline void setIcon( const QPixmap & icon ) inline void setIcon(const QPixmap &icon)
{ {
m_icon = icon; m_icon = icon;
} }
/** Set this error code to value != 0 /** Set this error code to value != 0
* if an error has occured during renaming this * if an error has occurred during renaming this
* particular file. * particular file.
* *
* @param error an error code (0 means no error) * @param error an error code (0 means no error)
*/ */
inline void setError( int error ) inline void setError(int error)
{ {
m_error = error;; m_error = error;;
} }
/** /**
* @returns true if an error code was set for this KRenameFile * @returns true if an error code was set for this KRenameFile
*/ */
inline bool hasError() const inline bool hasError() const
{ {
return m_error != 0; return m_error != 0;
} }
/** Assigns another KRenameFile to this KRenameFile /** Assigns another KRenameFile to this KRenameFile
* \param rhs object to assign * \param rhs object to assign
*/ */
const KRenameFile & operator=( const KRenameFile & rhs ); const KRenameFile &operator=(const KRenameFile &rhs);
/** Compare a KRenameFile object to a KFileItem /** Compare a KRenameFile object to a KFileItem
* *
* \returns true if the file item of this KRenameFile * \returns true if the file item of this KRenameFile
* is identical to the parameter * is identical to the parameter
*/ */
bool operator==( const KFileItem & item ) const; bool operator==(const KFileItem &item) const;
/** /**
* \returns true if this file references * \returns true if this file references
* an existing file or directory * an existing file or directory
*/ */
inline bool isValid() const inline bool isValid() const
{ {
return m_bValid; return m_bValid;
} }
/** /**
* \returns manualChanges the user has made to the filename * \returns manualChanges the user has made to the filename
*/ */
inline const QString & manualChanges() const inline const QString &manualChanges() const
{ {
return m_manual; return m_manual;
} }
/** /**
* Sets manual changes made by the user * Sets manual changes made by the user
* *
* \param manual manual changes for filename and extension * \param manual manual changes for filename and extension
* \param mode mode of change * \param mode mode of change
*/ */
inline void setManualChanges( const QString & manual, EManualChangeMode mode ) inline void setManualChanges(const QString &manual, EManualChangeMode mode)
{ {
m_manual = manual; m_manual = manual;
m_manualMode = mode; m_manualMode = mode;
} }
/** /**
* \returns the change mode * \returns the change mode
*/ */
inline EManualChangeMode manualChangeMode() const inline EManualChangeMode manualChangeMode() const
{ {
return m_manualMode; return m_manualMode;
} }
/** /**
* \returns always the original source directory * \returns always the original source directory
*/ */
inline const QString & realSrcDirectory() const inline const QString &realSrcDirectory() const
{ {
return m_src.directory; return m_src.directory;
} }
inline void setOverrideSrcDirectory( const QString & dir ) inline void setOverrideSrcDirectory(const QString &dir)
{ {
m_overrideDir = dir; m_overrideDir = dir;
} }
inline const QString & srcFilename() const inline const QString &srcFilename() const
{ {
return m_src.filename; return m_src.filename;
} }
inline const QString & srcExtension() const inline const QString &srcExtension() const
{ {
return m_src.extension; return m_src.extension;
} }
inline const QString & srcDirectory() const inline const QString &srcDirectory() const
{ {
return (m_overrideDir.isNull() ? m_src.directory : m_overrideDir); return (m_overrideDir.isNull() ? m_src.directory : m_overrideDir);
} }
const KUrl srcUrl() const; const QUrl srcUrl() const;
inline void setDstFilename( const QString & filename ) inline void setDstFilename(const QString &filename)
{ {
m_dst.filename = filename; m_dst.filename = filename;
} }
inline const QString & dstFilename() const inline const QString &dstFilename() const
{ {
return m_dst.filename; return m_dst.filename;
} }
inline void setDstExtension( const QString & extension ) inline void setDstExtension(const QString &extension)
{ {
m_dst.extension = extension; m_dst.extension = extension;
} }
inline const QString & dstExtension() const inline const QString &dstExtension() const
{ {
return m_dst.extension; return m_dst.extension;
} }
inline void setDstDirectory( const QString & directory ) inline void setDstDirectory(const QString &directory)
{ {
m_dst.directory = directory; m_dst.directory = directory;
} }
inline const QString & dstDirectory() const inline const QString &dstDirectory() const
{ {
return m_dst.directory; return m_dst.directory;
} }
inline void setDstUrl( const KUrl & url ) inline void setDstUrl(const QUrl &url)
{ {
m_dst.url = url; m_dst.url = url;
} }
inline const KUrl & dstUrl() const inline const QUrl &dstUrl() const
{ {
return m_dst.url; return m_dst.url;
} }
inline bool isDirectory() const inline bool isDirectory() const
{ {
return m_bDirectory; return m_bDirectory;
} }
/** /**
* Get access to the internal file item * Get access to the internal file item
* *
* @returns a KFileItem * @returns a KFileItem
*/ */
const KFileItem & fileItem() const; const KFileItem &fileItem() const;
/** /**
* Set the icon (preview) size
*
* @param size the icon size
*/
static void setIconSize(int size);
/**
* @returns the icon size
*/
static int iconSize();
/**
* @returns the default icon size * @returns the default icon size
*/ */
static int getDefaultIconSize(); static int getDefaultIconSize();
private: private:
void initFileDescription( TFileDescription & rDescription, const KUrl & url, void initFileDescription(TFileDescription &rDescription, const QUrl &url, ES
ESplitMode eSplitMode, unsigned int dot ) const; plitMode eSplitMode, unsigned int dot) const;
/** Load a preview icon for this KRenameFile object /** Load a preview icon for this KRenameFile object
* using KDEs preview loading mechanism. * using KDEs preview loading mechanism.
*/ */
void loadPreviewIcon(); void loadPreviewIcon();
static const int DEFAULT_ICON_SIZE; static const int DEFAULT_ICON_SIZE;
static const char* EXTRA_DATA_KEY; static const char *EXTRA_DATA_KEY;
private: private:
KFileItem m_fileItem; KFileItem m_fileItem;
static int m_iconSize;
TFileDescription m_src; TFileDescription m_src;
TFileDescription m_dst; TFileDescription m_dst;
QString m_overrideDir; ///< A changed sourcedirectory (required wh en renaming directories) QString m_overrideDir; ///< A changed sourcedirectory (required wh en renaming directories)
bool m_bDirectory; ///< If true this is a directory bool m_bDirectory; ///< If true this is a directory
bool m_bValid; ///< If true this item is valid bool m_bValid; ///< If true this item is valid
QPixmap m_icon; ///< This is the file preview icon QPixmap m_icon; ///< This is the file preview icon
int m_error; ///< This value is set to != 0 if an error occurred during renaming int m_error; ///< This value is set to != 0 if an error occurred during renaming
QString m_manual; ///< Manual changes to the filename+extensi on by the user are stored here QString m_manual; ///< Manual changes to the filename+extensi on by the user are stored here
EManualChangeMode m_manualMode; EManualChangeMode m_manualMode;
}; };
#endif // _KRENAME_FILE_H_ #endif // KRENAME_FILE_H
 End of changes. 47 change blocks. 
61 lines changed or deleted 64 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)