X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fpane.cpp;h=4b192a3c53fbd5d8b764bc8d9e1214eab929489a;hb=17b7f9ef9141bfb49bc224cbbc7b3eece045784d;hp=67039c0236aac017118e4012792450defcac2ed6;hpb=0165f80ba290e71a933f6e5c676cce60334cc825;p=case diff --git a/src/pane.cpp b/src/pane.cpp index 67039c0..4b192a3 100644 --- a/src/pane.cpp +++ b/src/pane.cpp @@ -25,12 +25,13 @@ #include #include #include +#include Pane::Pane(QWidget *theCase, QWidget *parent) : QWidget(parent), - theCase(theCase), active(false), + theCase(theCase), location(new AddressBar), up(new Button("go_up", 0, 70, 60)), fileList(new FileList) @@ -54,7 +55,21 @@ Pane::Pane(QWidget *theCase, QWidget *parent) : connect(up, SIGNAL(pressed()), fileList, SLOT(goUp())); connect(fileList, SIGNAL(pathChanged(QString)), location, SLOT(setText(QString))); - activationConnect(); + location->installEventFilter(this); + up->installEventFilter(this); + // doesn't work in QT 4.6.2 - mouse events wont get through the kinetic scroller + //fileList->installEventFilter(this); + connect(fileList, SIGNAL(mousePressed()), this, SLOT(fileListMouseHackaround())); +} + + +const QString Pane::path() const { + return fileList->path(); +} + + +const QFileInfoList Pane::selection() const { + return fileList->selection(); } @@ -71,23 +86,17 @@ void Pane::paintEvent(QPaintEvent *) { } -void Pane::activationConnect() { - connect(up, SIGNAL(clicked()), theCase, SLOT(switchActivePane())); - connect(location, SIGNAL(mousePressed()), theCase, SLOT(switchActivePane())); - connect(fileList, SIGNAL(mousePressed()), theCase, SLOT(switchActivePane())); -} - - -void Pane::activationDisconnect() { - disconnect(up, SIGNAL(clicked()), theCase, SLOT(switchActivePane())); - disconnect(location, SIGNAL(mousePressed()), theCase, SLOT(switchActivePane())); - disconnect(fileList, SIGNAL(mousePressed()), theCase, SLOT(switchActivePane())); +bool Pane::eventFilter(QObject *object, QEvent *event) { + if (!active && event->type() == QEvent::MouseButtonPress) { + emit switchPanes(); + if (object == fileList) return true; + } + return false; } void Pane::toggleActive() { active = !active; - if (active) activationDisconnect(); else activationConnect(); update(); } @@ -97,8 +106,11 @@ void Pane::toggleShowHiddenFiles() { } -const QFileInfoList Pane::selection() const { - return fileList->selection(); +void Pane::fileListMouseHackaround() { + if (!active) { + fileList->preventNextSelection(); + emit switchPanes(); + } } @@ -106,8 +118,3 @@ bool Pane::changePath(QString path) { location->setText(path); return fileList->changePath(path); } - - -const QString Pane::path() const { - return fileList->path(); -}