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 <QHBoxLayout>
21 #include <QVBoxLayout>
24 Case::Case(QWidget *parent) :
26 leftPane(new Pane(this)),
27 rightPane(new Pane(this)),
29 inactivePane(rightPane),
30 cloneBtn(new Button(">>", 0, 60, 70)),
31 moveBtn(new Button("mv>", 0, 60, 70)),
32 copyBtn(new Button("cp>", 0, 60, 70)),
33 delBtn(new Button("rm", 0, 60, 70)),
34 swapBtn(new Button("<>", 0, 60, 70)),
35 fileOperator(new FileOperator(this))
37 QVBoxLayout *layout = new QVBoxLayout;
38 layout->setContentsMargins(0, 0, 0, 0);
39 layout->setSpacing(0);
41 QHBoxLayout *paneLayout = new QHBoxLayout;
42 paneLayout->setContentsMargins(0, 0, 0, 0);
43 paneLayout->setSpacing(1);
45 QWidget *central = new QWidget;
46 setCentralWidget(central);
47 central->setLayout(layout);
48 layout->addLayout(paneLayout);
50 paneLayout->addWidget(leftPane);
51 leftPane->toggleActive();
53 QVBoxLayout *middleButtons = new QVBoxLayout;
54 paneLayout->addLayout(middleButtons);
55 middleButtons->setSpacing(10);
56 middleButtons->setContentsMargins(0, 0, 0, 0);
58 cloneBtn->setContentsMargins(0, 0, 0, 0);
60 middleButtons->addWidget(cloneBtn);
61 middleButtons->addWidget(moveBtn);
62 middleButtons->addWidget(copyBtn);
63 middleButtons->addWidget(delBtn);
64 middleButtons->addWidget(swapBtn);
66 paneLayout->addWidget(rightPane);
68 layout->addWidget(fileOperator);
70 connect(this, SIGNAL(activePaneSwitched()), leftPane, SLOT(toggleActive()));
71 connect(this, SIGNAL(activePaneSwitched()), rightPane, SLOT(toggleActive()));
73 connect(cloneBtn, SIGNAL(pressed()), this, SLOT(clonePane()));
74 connect(delBtn, SIGNAL(pressed()), this, SLOT(deleteFiles()));
75 connect(copyBtn, SIGNAL(pressed()), this, SLOT(copyFiles()));
76 connect(moveBtn, SIGNAL(pressed()), this, SLOT(moveFiles()));
77 connect(swapBtn, SIGNAL(pressed()), this, SLOT(swapPanes()));
81 void Case::switchActivePane() {
82 Pane *tmpPane = activePane;
83 activePane = inactivePane;
84 inactivePane = tmpPane;
86 if (leftPane == activePane) {
87 cloneBtn->setText(">>");
88 moveBtn->setText("mv>");
89 copyBtn->setText("cp>");
91 cloneBtn->setText("<<");
92 moveBtn->setText("<mv");
93 copyBtn->setText("<cp");
96 emit activePaneSwitched();
100 void Case::deleteFiles() {
101 if (activePane->selection().size()) {
102 fileOperator->deleteFiles(activePane->selection());
107 void Case::copyFiles() {
108 if (activePane->selection().size()) {
109 QDir dest = inactivePane->path();
110 fileOperator->copyFiles(activePane->selection(), dest);
115 void Case::moveFiles() {
116 if (activePane->selection().size()) {
117 QDir dest = inactivePane->path();
118 fileOperator->moveFiles(activePane->selection(), dest);
123 void Case::clonePane() {
124 inactivePane->changePath(activePane->path());
128 void Case::swapPanes() {
129 QString tmpPath = activePane->path();
130 activePane->changePath(inactivePane->path());
131 inactivePane->changePath(tmpPath);