#include <QUrl>
#include <QProcess>
#include <QPainter>
+#include <QEvent>
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)
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();
}
}
-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();
}
}
-const QFileInfoList Pane::selection() const {
- return fileList->selection();
+void Pane::fileListMouseHackaround() {
+ if (!active) {
+ fileList->preventNextSelection();
+ emit switchPanes();
+ }
}
location->setText(path);
return fileList->changePath(path);
}
-
-
-const QString Pane::path() const {
- return fileList->path();
-}