1 // case - file manager for N900
2 // Copyright (C) 2010 Lukas Hrazky <lukkash@email.cz>
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <QHeaderView>
21 #include <QVBoxLayout>
22 #include <QMessageBox>
23 #include <QInputDialog>
24 #include <QDesktopServices>
31 Pane::Pane(QWidget *theCase, QWidget *parent) :
35 location(new AddressBar),
36 up(new Button("go_up", 0, 70, 60)),
37 fileList(new FileList)
39 QVBoxLayout *layout = new QVBoxLayout;
40 layout->setContentsMargins(2, 1, 2, 2);
41 layout->setSpacing(0);
44 QHBoxLayout *topLine = new QHBoxLayout;
46 location->setText(fileList->path());
48 topLine->addWidget(location);
49 topLine->addWidget(up);
50 layout->addLayout(topLine);
51 layout->addWidget(fileList);
53 connect(location, SIGNAL(pathEntered(QString)), fileList, SLOT(changePath(QString)));
54 connect(up, SIGNAL(pressed()), fileList, SLOT(goUp()));
55 connect(fileList, SIGNAL(pathChanged(QString)), location, SLOT(setText(QString)));
57 location->installEventFilter(this);
58 up->installEventFilter(this);
59 // doesn't work in QT 4.6.2 - mouse events wont get through the kinetic scroller
60 //fileList->installEventFilter(this);
61 connect(fileList, SIGNAL(mousePressed()), this, SLOT(fileListMouseHackaround()));
65 const QString Pane::path() const {
66 return fileList->path();
70 const QFileInfoList Pane::selection() const {
71 return fileList->selection();
75 void Pane::paintEvent(QPaintEvent *) {
77 QPainter painter(this);
78 painter.setPen(palette().highlight().color());
79 QRect g = this->geometry();
81 g.adjust(0, 0, -1, -1);
82 painter.drawRoundedRect(g, 3, 3);
87 bool Pane::eventFilter(QObject *object, QEvent *event) {
88 if (!active && event->type() == QEvent::MouseButtonPress) {
90 if (object == fileList) return true;
96 void Pane::toggleActive() {
102 void Pane::toggleShowHiddenFiles() {
103 fileList->toggleShowHiddenFiles();
107 void Pane::fileListMouseHackaround() {
109 fileList->preventNextSelection();
115 bool Pane::changePath(QString path) {
116 location->setText(path);
117 return fileList->changePath(path);