summaryrefslogtreecommitdiffstats
path: root/fileview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fileview.cpp')
-rw-r--r--fileview.cpp34
1 files changed, 30 insertions, 4 deletions
diff --git a/fileview.cpp b/fileview.cpp
index 5995d60..adc8eeb 100644
--- a/fileview.cpp
+++ b/fileview.cpp
@@ -13,19 +13,33 @@
#include <QRegExp>
#include <QDirModel>
#include <QSortFilterProxyModel>
+#include <QAction>
+#include <QApplication>
#include <QDebug>
#include "fileview.h"
#include "messagedialog.h"
-FileView::FileView(QWidget *parent) : QTreeView(parent) {
+FileView::FileView(QWidget *parent) : QTreeView(parent), mDeleteA(0) {
setRootIsDecorated(false);
- mMarkDialog = new MessageDialog(tr("Enter pattern to mark"), this);
+ QString title = QString("%1 - %2");
+ QString markTitle = title.arg(qApp->applicationName(), tr("Mark files"));
+ mMarkDialog = new MessageDialog(tr("Enter pattern to mark"), markTitle, this);
connect(mMarkDialog, SIGNAL(accepted()), this, SLOT(doMark()));
- mCreateFolderDialog = new MessageDialog(tr("Enter folder name"), this);
+ QString folderTitle = title.arg(qApp->applicationName(), tr("Create folder"));
+ mCreateFolderDialog = new MessageDialog(tr("Enter folder name"), folderTitle, this);
connect(mCreateFolderDialog, SIGNAL(accepted()), this, SLOT(doCreateFolder()));
}
+void FileView::findActions(){
+ foreach(QAction *a, actions()){
+ if(a->data().toString() == "DA"){
+ mDeleteA = a;
+ }
+ }
+ Q_ASSERT(mDeleteA != 0);
+}
+
void FileView::markFiles(){
mMarkDialog->show();
}
@@ -38,6 +52,14 @@ void FileView::createFolder(){
mCreateFolderDialog->show();
}
+void FileView::refresh(){
+ QSortFilterProxyModel *proxy = static_cast<QSortFilterProxyModel*>(model());
+ QDirModel *model = static_cast<QDirModel*>(proxy->sourceModel());
+ QModelIndex root = rootIndex();
+ QModelIndex real = proxy->mapToSource(root);
+ model->refresh(root);
+}
+
void FileView::doMark(){
int rowCount = model()->rowCount(rootIndex());
QString sRegex = mMarkDialog->text();
@@ -91,7 +113,7 @@ void FileView::contextMenuEvent(QContextMenuEvent *e){
int ctr(0);
foreach(QAction *a, actions()){
contextMenu.addAction(a);
- if((ctr == 1)){
+ if((ctr == 1) || (ctr == 2)){
contextMenu.addSeparator();
}
++ctr;
@@ -110,6 +132,10 @@ void FileView::keyPressEvent(QKeyEvent *e){
emit enterPressed(currentIndex());
e->accept();
break;
+ case Qt::Key_Delete:
+ mDeleteA->trigger();
+ e->accept();
+ break;
default:
QTreeView::keyPressEvent(e);
}