summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--filesystemwidget.cpp15
-rw-r--r--filesystemwidget.h4
-rw-r--r--fileview.cpp7
-rw-r--r--fileview.h2
-rw-r--r--shemov.cpp5
-rw-r--r--shemov.h1
6 files changed, 26 insertions, 8 deletions
diff --git a/filesystemwidget.cpp b/filesystemwidget.cpp
index 24e769b..365adaf 100644
--- a/filesystemwidget.cpp
+++ b/filesystemwidget.cpp
@@ -16,6 +16,7 @@
#include <QLabel>
#include <QCompleter>
#include <QProcess>
+#include <QApplication>
#include <QDebug>
#include "filesystemwidget.h"
@@ -68,13 +69,14 @@ FilesystemWidget::FilesystemWidget(QWidget *parent) : QWidget(parent) {
fileWidget->setLayout(fwLayout);
connect(mDirView->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(directoryChanged(const QModelIndex &, const QModelIndex &)));
- connect(mFileView, SIGNAL(activated(const QModelIndex &)), this, SLOT(fileViewActivated(const QModelIndex &)));
+ connect(mFileView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(fileViewActivated(const QModelIndex &)));
+ connect(mFileView, SIGNAL(enterPressed(const QModelIndex &)), this, SLOT(fileViewActivated(const QModelIndex &)));
connect(mFileView, SIGNAL(upDir()), this, SLOT(parentDir()));
- //connect(mFileView, SIGNAL(show()), this, SLOT(showItem()));
connect(mDirEdit, SIGNAL(returnPressed()), this, SLOT(directoryEdited()));
QSettings s;
QString startDir = s.value("paths/start", QDir::homePath()).toString();
+ windowTitle(startDir);
QModelIndex startIndex = mModel->index(startDir);
if(startIndex.isValid()){
QModelIndex proxyIndex = mDirProxy->mapFromSource(startIndex);
@@ -106,9 +108,9 @@ void FilesystemWidget::directoryChanged(const QModelIndex &selected, const QMode
return;
}
mDirEdit->setText(mModel->filePath(real));
+ windowTitle(mModel->filePath(real));
QModelIndex oldSelected = mDirProxy->mapToSource(deselected);
- mFileView->selectionModel()->clear();
- mFileView->setCurrentIndex(mFileProxy->mapFromSource(oldSelected));
+ mFileView->selectionModel()->setCurrentIndex(mFileProxy->mapFromSource(oldSelected), QItemSelectionModel::NoUpdate);
mFileView->setRootIndex(mFileProxy->mapFromSource(real));
}
@@ -154,3 +156,8 @@ void FilesystemWidget::parentDir(){
mFileView->selectionModel()->clearSelection();
}
+void FilesystemWidget::setWindowTitle(const QString &dir){
+ QString title = QString("%1 - %2").arg(qApp->applicationName(), dir);
+ emit windowTitle(title);
+}
+
diff --git a/filesystemwidget.h b/filesystemwidget.h
index cef32c4..916ca83 100644
--- a/filesystemwidget.h
+++ b/filesystemwidget.h
@@ -25,6 +25,9 @@ class FilesystemWidget : public QWidget {
~FilesystemWidget() {};
FileView *fileView() { return mFileView; };
+ signals:
+ void windowTitle(const QString &);
+
public slots:
void directoryChanged(const QModelIndex &selected, const QModelIndex &);
void directoryEdited();
@@ -32,6 +35,7 @@ class FilesystemWidget : public QWidget {
void parentDir();
private:
+ void setWindowTitle(const QString &dir);
QDirModel *mModel;
QTreeView *mDirView;
FileView *mFileView;
diff --git a/fileview.cpp b/fileview.cpp
index decf8e5..31c9aca 100644
--- a/fileview.cpp
+++ b/fileview.cpp
@@ -71,10 +71,11 @@ void FileView::keyPressEvent(QKeyEvent *e){
emit upDir();
e->accept();
break;
- /*case Qt::Key_Enter:
- emit showItem();
+ case Qt::Key_Enter:
+ case Qt::Key_Return:
+ emit enterPressed(currentIndex());
e->accept();
- break;*/
+ break;
default:
QTreeView::keyPressEvent(e);
}
diff --git a/fileview.h b/fileview.h
index ec89e10..242f0a7 100644
--- a/fileview.h
+++ b/fileview.h
@@ -24,7 +24,7 @@ class FileView : public QTreeView {
signals:
void upDir();
- void show();
+ void enterPressed(const QModelIndex &);
public slots:
void markFiles();
diff --git a/shemov.cpp b/shemov.cpp
index cafd47a..a005f8d 100644
--- a/shemov.cpp
+++ b/shemov.cpp
@@ -34,6 +34,7 @@ SheMov::SheMov(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, fla
createMenus();
connect(mFSWidget->fileView()->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(updateSelectionCount(const QItemSelection &, const QItemSelection &)));
+ connect(mFSWidget, SIGNAL(windowTitle(const QString &)), this, SLOT(newWindowTitle(const QString &)));
QWidget *centralWidget = new QWidget;
centralWidget->setLayout(mainLayout);
@@ -46,6 +47,10 @@ void SheMov::updateSelectionCount(const QItemSelection & /* sel */, const QItemS
mSelectedItems->setText(QString::number(mFSWidget->fileView()->selectionModel()->selectedRows().count()));
}
+void SheMov::newWindowTitle(const QString &title){
+ setWindowTitle(title);
+}
+
void SheMov::createStatusbar(){
QLabel *selCountL = new QLabel(tr("Sel. Items"));
mSelectedItems = new QLabel("0");
diff --git a/shemov.h b/shemov.h
index 9daf0a0..cc54643 100644
--- a/shemov.h
+++ b/shemov.h
@@ -24,6 +24,7 @@ class SheMov : public QMainWindow {
private slots:
void updateSelectionCount(const QItemSelection &sel, const QItemSelection &prev);
+ void newWindowTitle(const QString &title);
private:
void createStatusbar();