1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 by Dominik Riebeling
10 * $Id: installrb.cpp 13990 2007-07-25 22:26:10Z Dominik Wenger $
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
22 #include "browsedirtree.h"
23 #include "ui_browsedirtreefrm.h"
26 BrowseDirtree::BrowseDirtree(QWidget
*parent
) : QDialog(parent
)
30 ui
.tree
->setModel(&model
);
31 model
.setReadOnly(true);
32 // disable size / date / type columns
33 ui
.tree
->setColumnHidden(1, true);
34 ui
.tree
->setColumnHidden(2, true);
35 ui
.tree
->setColumnHidden(3, true);
39 void BrowseDirtree::setDir(QDir
&dir
)
41 qDebug() << "BrowseDirtree::setDir()" << model
.index(dir
.absolutePath());
43 // do not try to hilight directory if it's not valid.
44 if(!dir
.exists()) return;
45 // hilight the set directory if it's valid
46 if(model
.index(dir
.absolutePath()).isValid()) {
47 QModelIndex p
= model
.index(dir
.absolutePath());
48 ui
.tree
->setCurrentIndex(p
);
50 ui
.tree
->resizeColumnToContents(0);
55 void BrowseDirtree::setFilter(QDir::Filters filters
)
57 model
.setFilter(filters
);
61 void BrowseDirtree::accept()
64 path
= model
.filePath(ui
.tree
->currentIndex());
67 emit
itemChanged(QDir::toNativeSeparators(path
));
68 setResult(QDialog::Accepted
);
71 QString
BrowseDirtree::getSelected()
74 path
= model
.filePath(ui
.tree
->currentIndex());
75 return QDir::toNativeSeparators(path
);