krenamemodel.h (krename-4.0.9) | : | krenamemodel.h (krename-4.90.90) | ||
---|---|---|---|---|
skipping to change at line 44 | skipping to change at line 44 | |||
eSortMode_Unsorted, | eSortMode_Unsorted, | |||
eSortMode_Ascending, | eSortMode_Ascending, | |||
eSortMode_Descending, | eSortMode_Descending, | |||
eSortMode_Numeric, | eSortMode_Numeric, | |||
eSortMode_Random, | eSortMode_Random, | |||
eSortMode_AscendingDate, | eSortMode_AscendingDate, | |||
eSortMode_DescendingDate, | eSortMode_DescendingDate, | |||
eSortMode_Token | eSortMode_Token | |||
}; | }; | |||
class KRenameModel : public QAbstractListModel { | class KRenameModel : public QAbstractListModel | |||
{ | ||||
Q_OBJECT | Q_OBJECT | |||
public: | public: | |||
KRenameModel( KRenameFile::List* vector ); | explicit KRenameModel(KRenameFile::List *vector); | |||
~KRenameModel(); | ~KRenameModel(); | |||
/** | /** | |||
* Set the batchrenamer instance. | * Set the batchrenamer instance. | |||
*/ | */ | |||
inline void setRenamer( BatchRenamer* renamer ); | inline void setRenamer(BatchRenamer *renamer); | |||
/** Add a KRenameFile to the model | /** Add a KRenameFile to the model | |||
* | * | |||
* @param files a KRenameFile::List which is added to the internal list | * @param files a KRenameFile::List which is added to the internal list | |||
*/ | */ | |||
void addFiles( const KRenameFile::List & files ); | void addFiles(const KRenameFile::List &files); | |||
/** Remove items in the model | /** Remove items in the model | |||
* | * | |||
* @param remove list of indexes to remove | * @param remove list of indexes to remove | |||
*/ | */ | |||
void removeFiles( const QList<int> & remove ); | void removeFiles(const QList<int> &remove); | |||
/** Sort the data in the model | /** Sort the data in the model | |||
* using the selected sort mode. | * using the selected sort mode. | |||
* | * | |||
* @param mode the sort mode to use | * @param mode the sort mode to use | |||
* @param customSortToken customSortToken if mode is eSortMode_Token | * @param customSortToken customSortToken if mode is eSortMode_Token | |||
* @param customSortMode mode for sorting if mode is eSortMode_Token | * @param customSortMode mode for sorting if mode is eSortMode_Token | |||
*/ | */ | |||
void sortFiles( ESortMode mode, const QString & customSortToken, | void sortFiles(ESortMode mode, const QString &customSortToken, | |||
KRenameTokenSorter::ESimpleSortMode customSortMode ); | KRenameTokenSorter::ESimpleSortMode customSortMode); | |||
/** Get the current sort mode. | /** Get the current sort mode. | |||
* @returns the current sort mode | * @returns the current sort mode | |||
*/ | */ | |||
inline ESortMode getSortMode() const; | inline ESortMode getSortMode() const; | |||
inline QString getSortModeCustomToken() const; | inline QString getSortModeCustomToken() const; | |||
inline KRenameTokenSorter::ESimpleSortMode getSortModeCustomMode() const; | inline KRenameTokenSorter::ESimpleSortMode getSortModeCustomMode() const; | |||
/** Move each file in a list of indeces upwards | /** Move each file in a list of indices upwards | |||
* @param files list of file indeces. Each file is moved up one position | * @param files list of file indices. Each file is moved up one position | |||
*/ | */ | |||
void moveFilesUp( const QList<int> & files ); | void moveFilesUp(const QList<int> &files); | |||
/** Move each file in a list of indeces downwards | /** Move each file in a list of indices downwards | |||
* @param files list of file indeces. Each file is moved down one position | * @param files list of file indices. Each file is moved down one position | |||
*/ | */ | |||
void moveFilesDown( const QList<int> & files ); | void moveFilesDown(const QList<int> &files); | |||
/** Creates a new model index | /** Creates a new model index | |||
* | * | |||
* @param row the index of the requested file | * @param row the index of the requested file | |||
* @returns the model index for a certain row | * @returns the model index for a certain row | |||
*/ | */ | |||
const QModelIndex createIndex( int row ) const; | const QModelIndex createIndex(int row) const; | |||
/** Get the file at position index. | /** Get the file at position index. | |||
* | * | |||
* @param a valid index in the internal vector | * @param a valid index in the internal vector | |||
* | * | |||
* @returns a KRenameFile object | * @returns a KRenameFile object | |||
*/ | */ | |||
inline const KRenameFile & file( int index ) const; | inline const KRenameFile &file(int index) const; | |||
/** Get the file at position index. | /** Get the file at position index. | |||
* | * | |||
* @param a valid index in the internal vector | * @param a valid index in the internal vector | |||
* | * | |||
* @returns a KRenameFile object | * @returns a KRenameFile object | |||
*/ | */ | |||
inline KRenameFile & file( int index ); | inline KRenameFile &file(int index); | |||
virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const; | virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; | |||
virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRol | virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) | |||
e ) const; | const; | |||
Qt::DropActions supportedDropActions() const; | Qt::DropActions supportedDropActions() const; | |||
QStringList mimeTypes() const; | QStringList mimeTypes() const; | |||
Qt::ItemFlags flags(const QModelIndex &index) const; | Qt::ItemFlags flags(const QModelIndex &index) const; | |||
bool dropMimeData(const QMimeData *data, Qt::DropAction action, | bool dropMimeData(const QMimeData *data, Qt::DropAction action, | |||
int row, int column,const QModelIndex &parent); | int row, int column, const QModelIndex &parent); | |||
bool setData(const QModelIndex &index, const QVariant &value, int role); | bool setData(const QModelIndex &index, const QVariant &value, int role); | |||
/** Enable the preview of KRenameFile objects. | /** Enable the preview of KRenameFile objects. | |||
* | * | |||
* @param preview enable/disable preview | * @param preview enable/disable preview | |||
* @param filenames if preview is true this items decides | * @param filenames if preview is true this items decides | |||
* if the filename text is displayed next to the preview | * if the filename text is displayed next to the preview | |||
*/ | */ | |||
inline void setEnablePreview( bool preview, bool filenames ); | inline void setEnablePreview(bool preview, bool filenames); | |||
/** Test if the preview of KRenameFile objects is enabled. | ||||
* | ||||
* @return preview enabled? | ||||
*/ | ||||
inline bool isPreviewEnabled() const; | ||||
/** Run/open the file which is pointed to by the passed modelinex | /** Run/open the file which is pointed to by the passed modelinex | |||
* | * | |||
* @param index a modelindex specifying a file to open | * @param index a modelindex specifying a file to open | |||
* @param window a window used to cache authentication information | * @param window a window used to cache authentication information | |||
*/ | */ | |||
void run(const QModelIndex & index, QWidget* window ) const; | void run(const QModelIndex &index, QWidget *window) const; | |||
/** | /** | |||
* Specify the extension split mode. | * Specify the extension split mode. | |||
* \param splitMode split mode | * \param splitMode split mode | |||
* \param dot dot t use for eSplitMode_CustomDot | * \param dot dot t use for eSplitMode_CustomDot | |||
*/ | */ | |||
inline void setExtensionSplitMode( ESplitMode splitMode, unsigned int dot ); | inline void setExtensionSplitMode(ESplitMode splitMode, unsigned int dot); | |||
inline ESplitMode splitMode(); | inline ESplitMode splitMode(); | |||
inline unsigned int splitDot(); | inline unsigned int splitDot(); | |||
signals: | Q_SIGNALS: | |||
/** This signal is emitted when the maximum number of | /** This signal is emitted when the maximum number of | |||
* dots in a filename that can be used to separate | * dots in a filename that can be used to separate | |||
* filename and extension has changed (by adding a new file). | * filename and extension has changed (by adding a new file). | |||
* | * | |||
* @param dots the maximum number of dots in a filename | * @param dots the maximum number of dots in a filename | |||
*/ | */ | |||
void maxDotsChanged( int dots ); | void maxDotsChanged(int dots); | |||
/** Emitted when files have been added using drag and drop | /** Emitted when files have been added using drag and drop | |||
*/ | */ | |||
void filesDropped(); | void filesDropped(); | |||
private slots: | private Q_SLOTS: | |||
void slotListerDone( ThreadedLister* lister ); | void slotListerDone(ThreadedLister *lister); | |||
void gotPreview (const KFileItem &item, const QPixmap &preview); | void gotPreview(const KFileItem &item, const QPixmap &preview); | |||
private: | private: | |||
BatchRenamer* m_renamer; | BatchRenamer *m_renamer; | |||
KRenameFile::List* m_vector; | KRenameFile::List *m_vector; | |||
bool m_preview; | bool m_preview; | |||
bool m_text; | bool m_text; | |||
int m_maxDots; ///< The maximum number of dots in a filename which can be used to separate filename and extension | int m_maxDots; ///< The maximum number of dots in a filename which can be used to separate filename and extension | |||
const char* m_mimeType; ///< MIME type for drag and drop operations | const char *m_mimeType; ///< MIME type for drag and drop operations | |||
ESortMode m_eSortMode; ///< Last used sort mode | ESortMode m_eSortMode; ///< Last used sort mode | |||
QString m_customSortToken; ///< if m_eSortMode = eSortMode_Token | QString m_customSortToken; ///< if m_eSortMode = eSortMode_Token | |||
KRenameTokenSorter::ESimpleSortMode m_eCustomSortMode; ///< if m_eSortMode = eSortMode_Token | KRenameTokenSorter::ESimpleSortMode m_eCustomSortMode; ///< if m_eSortMode = eSortMode_Token | |||
ESplitMode m_eSplitMode; | ESplitMode m_eSplitMode; | |||
unsigned int m_dot; | unsigned int m_dot; | |||
}; | }; | |||
void KRenameModel::setRenamer( BatchRenamer* renamer ) | void KRenameModel::setRenamer(BatchRenamer *renamer) | |||
{ | { | |||
m_renamer = renamer; | m_renamer = renamer; | |||
} | } | |||
ESortMode KRenameModel::getSortMode() const | ESortMode KRenameModel::getSortMode() const | |||
{ | { | |||
return m_eSortMode; | return m_eSortMode; | |||
} | } | |||
QString KRenameModel::getSortModeCustomToken() const | QString KRenameModel::getSortModeCustomToken() const | |||
{ | { | |||
return m_customSortToken; | return m_customSortToken; | |||
} | } | |||
KRenameTokenSorter::ESimpleSortMode KRenameModel::getSortModeCustomMode() const | KRenameTokenSorter::ESimpleSortMode KRenameModel::getSortModeCustomMode() const | |||
{ | { | |||
return m_eCustomSortMode; | return m_eCustomSortMode; | |||
} | } | |||
const KRenameFile & KRenameModel::file( int index ) const | const KRenameFile &KRenameModel::file(int index) const | |||
{ | { | |||
return m_vector->at(index); | return m_vector->at(index); | |||
} | } | |||
KRenameFile & KRenameModel::file( int index ) | KRenameFile &KRenameModel::file(int index) | |||
{ | { | |||
return (*m_vector)[index]; | return (*m_vector)[index]; | |||
} | } | |||
void KRenameModel::setEnablePreview( bool preview, bool filenames ) | bool KRenameModel::isPreviewEnabled() const | |||
{ | ||||
return m_preview; | ||||
} | ||||
void KRenameModel::setEnablePreview(bool preview, bool filenames) | ||||
{ | { | |||
bool update = false; | bool update = false; | |||
if( m_preview != preview || filenames != m_text ) | if (m_preview != preview || filenames != m_text) { | |||
update = true; | update = true; | |||
} | ||||
m_preview = preview; | m_preview = preview; | |||
m_text = filenames; | m_text = filenames; | |||
if( update ) | if (update) { | |||
{ | ||||
// TODO: update the model | // TODO: update the model | |||
; | ; | |||
} | } | |||
} | } | |||
void KRenameModel::setExtensionSplitMode( ESplitMode splitMode, unsigned int dot ) | void KRenameModel::setExtensionSplitMode(ESplitMode splitMode, unsigned int dot) | |||
{ | { | |||
m_eSplitMode = splitMode; | m_eSplitMode = splitMode; | |||
m_dot = dot; | m_dot = dot; | |||
} | } | |||
ESplitMode KRenameModel::splitMode() | ESplitMode KRenameModel::splitMode() | |||
{ | { | |||
return m_eSplitMode; | return m_eSplitMode; | |||
} | } | |||
unsigned int KRenameModel::splitDot() | unsigned int KRenameModel::splitDot() | |||
{ | { | |||
return m_dot; | return m_dot; | |||
} | } | |||
class KRenamePreviewModel : public QAbstractTableModel { | class KRenamePreviewModel : public QAbstractTableModel | |||
{ | ||||
Q_OBJECT | Q_OBJECT | |||
public: | public: | |||
KRenamePreviewModel( KRenameFile::List* vector ); | explicit KRenamePreviewModel(KRenameFile::List *vector); | |||
~KRenamePreviewModel(); | ~KRenamePreviewModel(); | |||
void refresh(); | void refresh(); | |||
virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const; | virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; | |||
virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const | virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; | |||
; | virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) | |||
virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRol | const; | |||
e ) const; | ||||
virtual QModelIndex parent ( const QModelIndex & index ) const; | virtual QModelIndex parent(const QModelIndex &index) const; | |||
virtual QModelIndex sibling ( int row, int column, const QModelIndex & index | virtual QModelIndex sibling(int row, int column, const QModelIndex &index) c | |||
) const; | onst; | |||
virtual QVariant headerData ( int section, Qt::Orientation orientation, int role ) const; | virtual QVariant headerData(int section, Qt::Orientation orientation, int ro le) const; | |||
private: | private: | |||
KRenameFile::List* m_vector; | KRenameFile::List *m_vector; | |||
}; | }; | |||
#endif // KRENAMEMODEL_H | #endif // KRENAMEMODEL_H | |||
End of changes. 37 change blocks. | ||||
53 lines changed or deleted | 64 lines changed or added |