diff options
author | am <am@f440f766-f032-0410-8965-dc7d17de2ca0> | 2009-07-10 15:53:58 +0000 |
---|---|---|
committer | am <am@f440f766-f032-0410-8965-dc7d17de2ca0> | 2009-07-10 15:53:58 +0000 |
commit | 4f1e2ee030f01facefab808f687d301c37707f74 (patch) | |
tree | de032f70dc137e433b1875e3067e3cf33d130989 | |
parent | b6a85b8b76a4e86783c4c83048918d30bb36bdb8 (diff) | |
download | SheMov-4f1e2ee030f01facefab808f687d301c37707f74.tar.gz SheMov-4f1e2ee030f01facefab808f687d301c37707f74.tar.bz2 SheMov-4f1e2ee030f01facefab808f687d301c37707f74.zip |
-fixed selection handling
-implemented proper window titles (not yet working)
git-svn-id: file:///var/svn/repos2/shemov/trunk@382 f440f766-f032-0410-8965-dc7d17de2ca0
-rw-r--r-- | filesystemwidget.cpp | 15 | ||||
-rw-r--r-- | filesystemwidget.h | 4 | ||||
-rw-r--r-- | fileview.cpp | 7 | ||||
-rw-r--r-- | fileview.h | 2 | ||||
-rw-r--r-- | shemov.cpp | 5 | ||||
-rw-r--r-- | shemov.h | 1 |
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); } @@ -24,7 +24,7 @@ class FileView : public QTreeView { signals: void upDir(); - void show(); + void enterPressed(const QModelIndex &); public slots: void markFiles(); @@ -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"); @@ -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(); |