1 // case - file manager for N900
2 // Copyright (C) 2010 Lukas Hrazky
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>
30 Pane::Pane(QWidget *theCase, QWidget *parent) :
34 location(new AddressBar),
35 up(new Button("^", 0, 70, 60)),
36 fileList(new FileList)
38 QVBoxLayout *layout = new QVBoxLayout;
39 layout->setContentsMargins(3, 3, 3, 3);
40 layout->setSpacing(0);
43 QHBoxLayout *topLine = new QHBoxLayout;
45 location->setText(fileList->path());
46 layout->setSpacing(0);
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)));
61 void Pane::paintEvent(QPaintEvent *) {
63 QPainter painter(this);
64 painter.setPen(palette().color(QPalette::Highlight));
65 QRect g = this->geometry();
67 g.setWidth(g.width() - 3);
68 g.setHeight(g.height() - 3);
74 void Pane::activationConnect() {
75 connect(up, SIGNAL(clicked()), theCase, SLOT(switchActivePane()));
76 connect(location, SIGNAL(mousePressed()), theCase, SLOT(switchActivePane()));
77 connect(fileList, SIGNAL(mousePressed()), theCase, SLOT(switchActivePane()));
81 void Pane::activationDisconnect() {
82 disconnect(up, SIGNAL(clicked()), theCase, SLOT(switchActivePane()));
83 disconnect(location, SIGNAL(mousePressed()), theCase, SLOT(switchActivePane()));
84 disconnect(fileList, SIGNAL(mousePressed()), theCase, SLOT(switchActivePane()));
88 void Pane::toggleActive() {
90 if (active) activationDisconnect(); else activationConnect();
95 const QFileInfoList Pane::selection() const {
96 return fileList->selection();
100 bool Pane::changePath(QString path) {
101 location->setText(path);
102 return fileList->changePath(path);
106 const QString Pane::path() const {
107 return fileList->path();