summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--archiveeditdialog.cpp9
-rw-r--r--archiveeditdialog.h1
-rw-r--r--filesystemdirproxy.cpp4
-rw-r--r--filesystemfileproxy.cpp6
-rw-r--r--filesystemwidget.cpp26
-rw-r--r--filesystemwidget.h11
-rw-r--r--fileview.cpp12
-rw-r--r--fileview.h2
-rw-r--r--shemov.cpp13
9 files changed, 28 insertions, 56 deletions
diff --git a/archiveeditdialog.cpp b/archiveeditdialog.cpp
index dbcc613..458bbbf 100644
--- a/archiveeditdialog.cpp
+++ b/archiveeditdialog.cpp
@@ -151,7 +151,6 @@ void ArchiveEditDialog::archive(){
vAList << a;
}
mMovieModel->addMovie(data, vAList, covers);
- QStringList refreshDirs;
foreach(QString f, files){
QFileInfo file(f);
QString hash = md5Sums.value(f);
@@ -167,14 +166,6 @@ void ArchiveEditDialog::archive(){
destFileS = QString("%1/%2/%3/%4_%5.%6").arg(archivePath).arg(hash[0]).arg(hash[1]).arg(destFile.completeBaseName()).arg(hash).arg(destFile.suffix());
}
QFile::rename(f, destFileS);
- QString refreshDir = file.absoluteFilePath();
- if(!refreshDirs.contains(refreshDir)){
- refreshDirs << refreshDir;
- }
- }
- foreach(QString r, refreshDirs){
- QModelIndex idx = mDirModel->index(r);
- mDirModel->refresh(idx);
}
}
}
diff --git a/archiveeditdialog.h b/archiveeditdialog.h
index ce0fd43..eba4824 100644
--- a/archiveeditdialog.h
+++ b/archiveeditdialog.h
@@ -27,7 +27,6 @@ class ArchiveEditDialog : public QDialog {
~ArchiveEditDialog() {};
void setFiles(const QStringList &files);
void setMovieModel(MovieModel *model) { mMovieModel = model; };
- void setDirModel(QDirModel *model) { mDirModel = model; };
private slots:
void archive();
diff --git a/filesystemdirproxy.cpp b/filesystemdirproxy.cpp
index 6e9a714..ae5d188 100644
--- a/filesystemdirproxy.cpp
+++ b/filesystemdirproxy.cpp
@@ -5,7 +5,7 @@
2 of the License, or (at your option) any later version.
*/
-#include <QDirModel>
+#include <QFileSystemModel>
#include <QModelIndex>
#include "filesystemdirproxy.h"
@@ -13,7 +13,7 @@
FilesystemDirProxy::FilesystemDirProxy(QObject *parent) : QSortFilterProxyModel(parent) {};
bool FilesystemDirProxy::filterAcceptsRow(int sourcerow, const QModelIndex &sourceparent) const {
- QDirModel *m = static_cast<QDirModel*>(sourceModel());
+ QFileSystemModel *m = static_cast<QFileSystemModel*>(sourceModel());
QModelIndex idx = m->index(sourcerow, 0, sourceparent);
if(!idx.isValid()){
return false;
diff --git a/filesystemfileproxy.cpp b/filesystemfileproxy.cpp
index 25fb12b..31059ec 100644
--- a/filesystemfileproxy.cpp
+++ b/filesystemfileproxy.cpp
@@ -7,7 +7,7 @@
#include <QModelIndex>
#include <QVariant>
-#include <QDirModel>
+#include <QFileSystemModel>
#include <QFileInfo>
#include "filesystemfileproxy.h"
@@ -16,7 +16,7 @@ FilesystemFileProxy::FilesystemFileProxy(QObject *parent) : QSortFilterProxyMode
bool FilesystemFileProxy::lessThan(const QModelIndex &left, const QModelIndex &right) const {
if(left.model()->headerData(left.column(), Qt::Horizontal).toString() == tr("Name")){
- QDirModel *source = static_cast<QDirModel*>(sourceModel());
+ QFileSystemModel *source = static_cast<QFileSystemModel*>(sourceModel());
if(source->isDir(left) && source->isDir(right)){
return left.data().toString().toLower() < right.data().toString().toLower();
}
@@ -29,7 +29,7 @@ bool FilesystemFileProxy::lessThan(const QModelIndex &left, const QModelIndex &r
return left.data().toString().toLower() < right.data().toString().toLower();
}
if(left.model()->headerData(left.column(), Qt::Horizontal).toString() == tr("Size")){
- QDirModel *source = static_cast<QDirModel*>(sourceModel());
+ QFileSystemModel *source = static_cast<QFileSystemModel*>(sourceModel());
QFileInfo lInfo = source->fileInfo(left);
QFileInfo rInfo = source->fileInfo(right);
if(lInfo.isDir() && rInfo.isDir()){
diff --git a/filesystemwidget.cpp b/filesystemwidget.cpp
index 63bef46..29a8e6e 100644
--- a/filesystemwidget.cpp
+++ b/filesystemwidget.cpp
@@ -5,7 +5,7 @@
2 of the License, or (at your option) any later version.
*/
-#include <QDirModel>
+#include <QFileSystemModel>
#include <QTreeView>
#include <QSettings>
#include <QDir>
@@ -33,9 +33,9 @@
#include "archiveeditdialog.h"
FilesystemWidget::FilesystemWidget(QWidget *parent) : QWidget(parent) {
- mModel = new QDirModel;
+ mModel = new QFileSystemModel;
+ mModel->setRootPath("/");
mModel->setFilter(QDir::AllEntries | QDir::NoDotAndDotDot);
- mModel->setSorting(QDir::DirsFirst | QDir::IgnoreCase);
mModel->setReadOnly(false);
SheMovIconProvider *p = new SheMovIconProvider;
mModel->setIconProvider(p);
@@ -50,6 +50,8 @@ FilesystemWidget::FilesystemWidget(QWidget *parent) : QWidget(parent) {
mDirView->setRootIsDecorated(false);
mDirView->setSelectionMode(QAbstractItemView::SingleSelection);
mDirView->setEditTriggers(QAbstractItemView::NoEditTriggers);
+ mDirView->setSortingEnabled(true);
+ mDirView->sortByColumn(0, Qt::AscendingOrder);
mFileView = new FileView;
mFileProxy = new FilesystemFileProxy;
@@ -105,7 +107,6 @@ FilesystemWidget::FilesystemWidget(QWidget *parent) : QWidget(parent) {
void FilesystemWidget::setArchiveDialog(ArchiveEditDialog *dlg){
mAEDialog = dlg;
- mAEDialog->setDirModel(mModel);
}
void FilesystemWidget::directoryChanged(const QModelIndex &selected, const QModelIndex & /* deselected */){
@@ -113,6 +114,7 @@ void FilesystemWidget::directoryChanged(const QModelIndex &selected, const QMode
if(!real.isValid()){
return;
}
+ mModel->setRootPath(mModel->filePath(real));
mDirEdit->setText(mModel->filePath(real));
setWindowTitle(mModel->filePath(real));
mFileView->selectionModel()->clear();
@@ -177,7 +179,6 @@ void FilesystemWidget::deleteFiles(){
int count(0);
if(!selected.isEmpty()){
count = selected.count();
- mRefreshAction->setEnabled(false);
QString message = QString(tr("Really delete %1 files?")).arg(QString::number(selected.count()));
int retval = QMessageBox::question(this, tr("Question"), message, QMessageBox::Yes | QMessageBox::No);
if(retval == QMessageBox::Yes){
@@ -187,8 +188,6 @@ void FilesystemWidget::deleteFiles(){
}
}
mFileView->selectionModel()->clearSelection();
- mModel->refresh(QModelIndex());
- mRefreshAction->setEnabled(true);
}else{
count = 1;
QModelIndex cur = mFileView->currentIndex();
@@ -197,7 +196,6 @@ void FilesystemWidget::deleteFiles(){
int retval = QMessageBox::question(this, tr("Question"), message, QMessageBox::Yes | QMessageBox::No);
if(retval == QMessageBox::Yes){
deleteRecursive(mModel->fileInfo(real));
- mModel->refresh(real.parent());
}
}
QString message = QString(tr("Deleted %1 file(s)")).arg(count);
@@ -216,7 +214,6 @@ void FilesystemWidget::copyFiles(){
QString message = QString(tr("Really copy %1 files to %2?")).arg(selected.count()).arg(root.absoluteFilePath());
int retval = QMessageBox::question(this, tr("Question"), message, QMessageBox::Yes | QMessageBox::No);
if(retval == QMessageBox::Yes){
- mRefreshAction->setEnabled(false);
int files(0), dirs(0), failed(0);
foreach(QModelIndex idx, selected){
QModelIndex real = proxy->mapToSource(idx);
@@ -236,8 +233,6 @@ void FilesystemWidget::copyFiles(){
QString message = QString(tr("Successfully copied %1 files and %2 directories, %3 errors")).arg(files).arg(dirs).arg(failed);
statusbarMessage(message);
mFileView->selectionModel()->clearSelection();
- mModel->refresh(rootIndex);
- mRefreshAction->setEnabled(true);
}
}
@@ -253,7 +248,6 @@ void FilesystemWidget::moveFiles(){
QString message = QString(tr("Really move %1 file(s) to %2?")).arg(selected.count()).arg(root.absoluteFilePath());
int retval = QMessageBox::question(this, tr("Question"), message, QMessageBox::Yes | QMessageBox::No);
if(retval == QMessageBox::Yes){
- mRefreshAction->setEnabled(false);
int success(0), failed(0);
foreach(QModelIndex cur, selected){
QModelIndex real = proxy->mapToSource(cur);
@@ -267,9 +261,7 @@ void FilesystemWidget::moveFiles(){
}
QString message = QString(tr("Successfully moved %1 file(s), %2 errors")).arg(success).arg(failed);
emit statusbarMessage(message);
- mRefreshAction->setEnabled(true);
mFileView->selectionModel()->clearSelection();
- mModel->refresh(QModelIndex());
}
}
@@ -316,7 +308,6 @@ void FilesystemWidget::renameCover(const QString &infix){
if(QFile::rename(info.absoluteFilePath(), newFilename)){
QString message = QString(tr("Successfully renamed %1 to %2")).arg(info.fileName()).arg(nf.fileName());
emit statusbarMessage(message);
- mModel->refresh(real.parent());
}else{
QString message = QString(tr("Failed to rename %1 to %2")).arg(info.fileName()).arg(nf.fileName());
emit statusbarMessage(message);
@@ -367,10 +358,10 @@ void FilesystemWidget::archiveFiles(){
mAEDialog->activateWindow();
}
-void FilesystemWidget::refreshDir(const QString &dir){
+/*void FilesystemWidget::refreshDir(const QString &dir){
QModelIndex idx = mModel->index(dir);
mModel->refresh(idx);
-}
+}*/
void FilesystemWidget::playSelected(const QString &player){
QStringList files = selectedFiles();
@@ -504,7 +495,6 @@ void FilesystemWidget::doRenameFile(){
if(QFile::rename(info.absoluteFilePath(), newName)){
QString message = QString(tr("Renamed %1 to %2")).arg(info.absoluteFilePath()).arg(newName);
emit statusbarMessage(message);
- mModel->refresh(real.parent());
}
QFileInfo n(newName);
mTemplate = n.completeBaseName();
diff --git a/filesystemwidget.h b/filesystemwidget.h
index 8baae88..5badd0a 100644
--- a/filesystemwidget.h
+++ b/filesystemwidget.h
@@ -11,7 +11,7 @@
#include <QWidget>
#include <QPair>
-class QDirModel;
+class QFileSystemModel;
class QTreeView;
class FilesystemDirProxy;
class FileView;
@@ -31,11 +31,9 @@ class FilesystemWidget : public QWidget {
~FilesystemWidget() {};
FileView *fileView() { return mFileView; };
FilesystemFileProxy *fileProxy() { return mFileProxy; };
- QDirModel *dirModel() { return mModel; };
+ QFileSystemModel *dirModel() { return mModel; };
const QString windowTitle() const { return mWindowTitle; };
void setArchiveDialog(ArchiveEditDialog *dlg);
- void setRefreshAction(QAction *refreshAction) { mRefreshAction = refreshAction; }
- QAction *refreshAction() { return mRefreshAction; }
signals:
void windowTitle(const QString &);
@@ -55,7 +53,7 @@ class FilesystemWidget : public QWidget {
void setTemplate();
void extract(const QString &destDir);
void archiveFiles();
- void refreshDir(const QString &dir);
+ //void refreshDir(const QString &dir);
void playSelected(const QString &player = QString());
void readSettings();
void writeSettings();
@@ -72,8 +70,7 @@ class FilesystemWidget : public QWidget {
QPair<QString, QStringList> programData(const QString &prefix, const QString &preferred);
QStringList selectedFiles();
QStringList mExpandedDirs;
- //QAction *action(QWidget *widget, const QVariant &data) const;
- QDirModel *mModel;
+ QFileSystemModel *mModel;
QTreeView *mDirView;
FileView *mFileView;
FilesystemDirProxy *mDirProxy;
diff --git a/fileview.cpp b/fileview.cpp
index 649ef3c..7853504 100644
--- a/fileview.cpp
+++ b/fileview.cpp
@@ -11,7 +11,7 @@
#include <QKeyEvent>
#include <QModelIndex>
#include <QRegExp>
-#include <QDirModel>
+#include <QFileSystemModel>
#include <QSortFilterProxyModel>
#include <QAction>
#include <QApplication>
@@ -42,13 +42,13 @@ void FileView::createFolder(){
mCreateFolderDialog->show();
}
-void FileView::refresh(){
+/*void FileView::refresh(){
QSortFilterProxyModel *proxy = static_cast<QSortFilterProxyModel*>(model());
- QDirModel *model = static_cast<QDirModel*>(proxy->sourceModel());
+ QFileSystemModel *model = static_cast<QFileSystemModel*>(proxy->sourceModel());
QModelIndex root = rootIndex();
QModelIndex real = proxy->mapToSource(root);
model->refresh(root);
-}
+}*/
void FileView::doMark(){
int rowCount = model()->rowCount(rootIndex());
@@ -56,7 +56,7 @@ void FileView::doMark(){
if(rowCount && !sRegex.isEmpty()){
QRegExp re(sRegex);
QSortFilterProxyModel *proxy = static_cast<QSortFilterProxyModel*>(model());
- QDirModel *model = static_cast<QDirModel*>(proxy->sourceModel());
+ QFileSystemModel *model = static_cast<QFileSystemModel*>(proxy->sourceModel());
bool match(false);
for(int i = 0; i < rowCount; ++i){
QModelIndex cur = rootIndex().child(i, 0);
@@ -86,7 +86,7 @@ void FileView::doCreateFolder(){
return;
}
QSortFilterProxyModel *proxy = static_cast<QSortFilterProxyModel*>(model());
- QDirModel *model = static_cast<QDirModel*>(proxy->sourceModel());
+ QFileSystemModel *model = static_cast<QFileSystemModel*>(proxy->sourceModel());
QModelIndex sRoot = proxy->mapToSource(rootIndex());
QModelIndex newIdx = model->mkdir(sRoot, folderName);
if(newIdx == QModelIndex()){
diff --git a/fileview.h b/fileview.h
index da5a483..2bf81b2 100644
--- a/fileview.h
+++ b/fileview.h
@@ -33,7 +33,7 @@ class FileView : public QTreeView {
void markFiles();
void unmarkFiles();
void createFolder();
- void refresh();
+ //void refresh();
private slots:
void doMark();
diff --git a/shemov.cpp b/shemov.cpp
index 409245f..43906cc 100644
--- a/shemov.cpp
+++ b/shemov.cpp
@@ -26,6 +26,8 @@
#include <QLocale>
#include <QCloseEvent>
#include <QActionGroup>
+#include <QFileSystemModel>
+
#include <sys/vfs.h>
#include "shemov.h"
@@ -95,7 +97,6 @@ SheMov::SheMov(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, fla
connect(mFSWidget, SIGNAL(statusbarMessage(const QString &)), this, SLOT(statusbarMessage(const QString &)));
connect(mFSWidget, SIGNAL(newTemplate(const QString &)), this, SLOT(setTemplate(const QString &)));
connect(mAVWidget, SIGNAL(statusbarMessage(const QString &)), this, SLOT(statusbarMessage(const QString &)));
- connect(mAVWidget, SIGNAL(refreshDir(const QString &)), mFSWidget, SLOT(refreshDir(const QString &)));
connect(mTab, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
QWidget *centralWidget = new QWidget;
@@ -278,11 +279,6 @@ void SheMov::createActions(){
mDeleteFilesA = new QAction(tr("Delete selected..."), this);
mDeleteFilesA->setShortcut(tr("CTRL+d"));
connect(mDeleteFilesA, SIGNAL(triggered()), mFSWidget, SLOT(deleteFiles()));
- mRefreshA = new QAction(tr("Refresh"), this);
- mRefreshA->setShortcut(Qt::Key_F4);
- mFSWidget->setRefreshAction(mRefreshA);
- connect(mRefreshA, SIGNAL(triggered()), mFSWidget->fileView(), SLOT(refresh()));
- connect(mRefreshA, SIGNAL(triggered()), this, SLOT(setFsFree()));
mCopyA = new QAction(tr("Copy file(s)..."), this);
mCopyA->setShortcut(tr("CTRL+v"));
connect(mCopyA, SIGNAL(triggered()), mFSWidget, SLOT(copyFiles()));
@@ -364,6 +360,8 @@ void SheMov::createActions(){
mOpenWithGroup = new QActionGroup(this);
mOpenWithMapper = new QSignalMapper(this);
connect(mOpenWithMapper, SIGNAL(mapped(QString)), mFSWidget, SLOT(playSelected(QString)));
+ connect(mFSWidget->dirModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(setFsFree()));
+ connect(mFSWidget->dirModel(), SIGNAL(layoutChanged()), this, SLOT(setFsFree()));
}
void SheMov::createMenus(){
@@ -395,8 +393,6 @@ void SheMov::createMenus(){
mEditFSMenu->addSeparator();
mEditFSMenu->addMenu(mExtractMenu);
mEditFSMenu->addSeparator();
- mEditFSMenu->addAction(mRefreshA);
- mEditFSMenu->addSeparator();
mEditFSMenu->addAction(mConfigA);
mEditArchiveMenu = new QMenu(tr("&Edit archive"), this);
@@ -444,7 +440,6 @@ void SheMov::createMenus(){
mFSWidget->fileView()->addAction(mCreateFolderA);
mFSWidget->fileView()->addAction(mDeleteFilesA);
mFSWidget->fileView()->addAction(mRenameA);
- mFSWidget->fileView()->addAction(mRefreshA);
mFSWidget->fileView()->addAction(mCopyA);
mFSWidget->fileView()->addAction(mMoveA);
mFSWidget->fileView()->addAction(mRenameMenuA);