2010-03-24 00:11:46 +01:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-03-24 00:11:46 +01:00
|
|
|
|
|
|
|
Clementine 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 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2009-12-24 21:27:32 +01:00
|
|
|
#ifndef FILEVIEW_H
|
|
|
|
#define FILEVIEW_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
2010-04-21 13:57:35 +02:00
|
|
|
#include <QUndoCommand>
|
2010-05-10 23:50:31 +02:00
|
|
|
#include <QUrl>
|
|
|
|
#include <QModelIndex>
|
2009-12-24 21:27:32 +01:00
|
|
|
|
2010-08-09 23:50:46 +02:00
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
|
2010-08-14 13:51:50 +02:00
|
|
|
#include "core/song.h"
|
|
|
|
|
2010-07-31 18:12:16 +02:00
|
|
|
class FilesystemMusicStorage;
|
2010-08-09 23:50:46 +02:00
|
|
|
class MusicStorage;
|
2010-07-31 18:12:16 +02:00
|
|
|
class TaskManager;
|
2010-05-10 23:50:31 +02:00
|
|
|
class Ui_FileView;
|
2009-12-24 21:27:32 +01:00
|
|
|
|
|
|
|
class QFileSystemModel;
|
|
|
|
class QUndoStack;
|
|
|
|
|
|
|
|
class FileView : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
FileView(QWidget* parent = 0);
|
2010-05-10 23:50:31 +02:00
|
|
|
~FileView();
|
2009-12-24 21:27:32 +01:00
|
|
|
|
|
|
|
void SetPath(const QString& path);
|
2010-07-31 18:12:16 +02:00
|
|
|
void SetTaskManager(TaskManager* task_manager);
|
2009-12-24 21:27:32 +01:00
|
|
|
|
2010-08-27 18:15:54 +02:00
|
|
|
void showEvent(QShowEvent*);
|
2010-12-15 21:41:31 +01:00
|
|
|
void keyPressEvent(QKeyEvent* e);
|
2010-08-27 18:15:54 +02:00
|
|
|
|
2009-12-24 21:27:32 +01:00
|
|
|
signals:
|
|
|
|
void PathChanged(const QString& path);
|
|
|
|
|
2011-01-10 23:26:13 +01:00
|
|
|
void AddToPlaylist(QMimeData* data);
|
2009-12-24 23:26:58 +01:00
|
|
|
void CopyToLibrary(const QList<QUrl>& urls);
|
|
|
|
void MoveToLibrary(const QList<QUrl>& urls);
|
2010-09-18 11:54:33 +02:00
|
|
|
void CopyToDevice(const QList<QUrl>& urls);
|
2009-12-24 21:27:32 +01:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void FileUp();
|
|
|
|
void FileHome();
|
|
|
|
void ChangeFilePath(const QString& new_path);
|
|
|
|
void ItemActivated(const QModelIndex& index);
|
|
|
|
void ItemDoubleClick(const QModelIndex& index);
|
2010-08-14 13:51:50 +02:00
|
|
|
|
2010-07-31 18:12:16 +02:00
|
|
|
void Delete(const QStringList& filenames);
|
2010-08-14 13:51:50 +02:00
|
|
|
void DeleteFinished(const SongList& songs_with_errors);
|
2009-12-24 21:27:32 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
void ChangeFilePathWithoutUndo(const QString& new_path);
|
|
|
|
|
|
|
|
private:
|
2010-04-21 13:57:35 +02:00
|
|
|
class UndoCommand : public QUndoCommand {
|
|
|
|
public:
|
|
|
|
UndoCommand(FileView* view, const QString& new_path);
|
|
|
|
|
2010-04-21 14:03:48 +02:00
|
|
|
QString undo_path() const { return old_state_.path; }
|
|
|
|
|
2010-04-21 13:57:35 +02:00
|
|
|
void undo();
|
|
|
|
void redo();
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct State {
|
|
|
|
State() : scroll_pos(-1) {}
|
|
|
|
|
|
|
|
QString path;
|
|
|
|
QModelIndex index;
|
|
|
|
int scroll_pos;
|
|
|
|
};
|
|
|
|
|
|
|
|
FileView* view_;
|
|
|
|
State old_state_;
|
|
|
|
State new_state_;
|
|
|
|
};
|
|
|
|
|
2010-05-10 23:50:31 +02:00
|
|
|
Ui_FileView* ui_;
|
2009-12-24 21:27:32 +01:00
|
|
|
|
|
|
|
QFileSystemModel* model_;
|
|
|
|
QUndoStack* undo_stack_;
|
2010-07-31 18:12:16 +02:00
|
|
|
|
|
|
|
TaskManager* task_manager_;
|
2010-08-09 23:50:46 +02:00
|
|
|
boost::shared_ptr<MusicStorage> storage_;
|
2010-08-27 18:15:54 +02:00
|
|
|
|
|
|
|
QString lazy_set_path_;
|
2009-12-24 21:27:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // FILEVIEW_H
|