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(3, 3, 3, 3);
41 layout->setSpacing(0);
44 QHBoxLayout *topLine = new QHBoxLayout;
46 location->setText(fileList->path());
47 layout->setSpacing(0);
49 topLine->addWidget(location);
50 topLine->addWidget(up);
51 layout->addLayout(topLine);
52 layout->addWidget(fileList);
54 connect(location, SIGNAL(pathEntered(QString)), fileList, SLOT(changePath(QString)));
55 connect(up, SIGNAL(pressed()), fileList, SLOT(goUp()));
56 connect(fileList, SIGNAL(pathChanged(QString)), location, SLOT(setText(QString)));
58 location->installEventFilter(this);
59 up->installEventFilter(this);
60 // doesn't work in QT 4.6.2 - mouse events wont get through the kinetic scroller
61 //fileList->installEventFilter(this);
62 connect(fileList, SIGNAL(mousePressed()), this, SLOT(fileListMouseHackaround()));
66 const QString Pane::path() const {
67 return fileList->path();
71 const QFileInfoList Pane::selection() const {
72 return fileList->selection();
76 void Pane::paintEvent(QPaintEvent *) {
78 QPainter painter(this);
79 painter.setPen(palette().color(QPalette::Highlight));
80 QRect g = this->geometry();
82 g.setWidth(g.width() - 3);
83 g.setHeight(g.height() - 3);
89 bool Pane::eventFilter(QObject *object, QEvent *event) {
90 if (!active && event->type() == QEvent::MouseButtonPress) {
92 if (object == fileList) return true;
98 void Pane::toggleActive() {
104 void Pane::toggleShowHiddenFiles() {
105 fileList->toggleShowHiddenFiles();
109 void Pane::fileListMouseHackaround() {
111 fileList->preventNextSelection();
117 bool Pane::changePath(QString path) {
118 location->setText(path);
119 return fileList->changePath(path);