@Devola
Here are my qefilebrowser.h and .cpp which used in QEZXPlayer and hope this would help you 
qefilebrowser.h
PHP Code:
/***************************************************************************
* *
* (c) 2007, Thanomsub Noppaburana <donga.nb@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef __QEFILEBROWSER_H__
#define __QEFILEBROWSER_H__
#include <qimage.h>
#include <qpixmap.h>
#include <qwidget.h>
#include <qlabel.h>
#include <qscrollview.h>
#include <ezxutilcst.h>
#include <zapplication.h>
#include "lib/qeglobal.h"
#include "lib/qewidget.h"
#include "lib/qelistbox.h"
/**
*****************************************************************************
Variables definitions
*****************************************************************************
*/
#define DIR_BASE_PHONE "/ezxlocal/download/mystuff"
#define DIR_BASE_MEMCARD "/mmc/mmca1"
static int baseItemCount = 4;
static const char *listBaseItems[] = {
QT_TR_NOOP("MyVideo"),
QT_TR_NOOP("MyAudio"),
QT_TR_NOOP("My playlists"),
QT_TR_NOOP("Memory card")
};
static const char *listBaseIcons[] = {
"FMMS_Folder_Video_S.gif",
"FMMS_Folder_Audio_S.gif",
"FMMS_Personal_Folder_S.gif",
"FMMS_Personal_Folder_S.gif"
};
static const char *itemBasePath[] = {
"/ezxlocal/download/mystuff/MyPhotos",
"/ezxlocal/download/mystuff/MyRingTone",
"/ezxlocal/download/mystuff/MyPlaylist",
"/mmc/mmca1"
};
/**
***********************************************
QEFileBrowser class definition
***********************************************
*/
class QEFileBrowser : public QEUTIL_ListBox
{
Q_OBJECT
public:
QEFileBrowser(QWidget *parent, const char *name = 0);
~QEFileBrowser();
void setFileFilters(const QString &filter);
void initFileList(const QString &filter="*"); // for start list files
void changeDir(const QString &path, bool goUpDir = FALSE);
int getPathLevel() { return m_pathLevel; };
void setPathLevel(int level);
void changeToUpDir(int step = 0);
QString getCurrentFile() const { return QString(m_currentFile); };
QString getCurrentPath() const;
bool selectPrevItem(bool click=FALSE);
bool selectNextItem(bool click=FALSE);
public slots:
void slotItemClicked(QEListBoxItem *, const QPoint &);
signals:
void dirItemClicked(const QString &);
void fileItemClicked(const QString &);
private:
QString m_nameFilter;
QString m_basePath;
char m_currentFile[256];
bool m_isloopItems;
int m_pathLevel;
};
#endif //__QEFILEBROWSER_H__
and qefilebrowser.cpp
PHP Code:
/***************************************************************************
* *
* (c) 2007, Thanomsub Noppaburana <donga.nb@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <qdir.h>
#include <ezxres.h>
#include "qefilebrowser.h"
/**
*****************************************************************************
class QEFileBrowser implementation
*****************************************************************************
*/
QEFileBrowser::QEFileBrowser(QWidget *parent, const char *name)
: QEUTIL_ListBox(parent, name),
m_isloopItems(FALSE),
m_pathLevel(0)
{
m_nameFilter = "*";
widget()->setFrameStyle(QFrame::NoFrame);
connect(this, SIGNAL(clicked(QEListBoxItem *, const QPoint &)), this, SLOT(slotItemClicked(QEListBoxItem *, const QPoint &)));
}
QEFileBrowser::~QEFileBrowser()
{
}
void QEFileBrowser::setFileFilters(const QString &filter)
{
if (m_nameFilter == filter) return;
m_nameFilter = filter;
changeDir("");
}
void QEFileBrowser::initFileList(const QString &filter)
{
if (m_nameFilter == filter) return;
m_nameFilter = filter;
changeDir("");
}
QString QEFileBrowser::getCurrentPath() const
{
return m_pathLevel==0 ? "BASEPATH" : m_basePath;
}
void QEFileBrowser::changeToUpDir(int step)
{
for (int i=0; i<=step; i++) changeDir(m_basePath, TRUE);
emit dirItemClicked(m_basePath);
}
void QEFileBrowser::setPathLevel(int level)
{
if (level >= m_pathLevel) level = m_pathLevel;
if (level <= 0) level = 0;
if (level != m_pathLevel) {
changeToUpDir(m_pathLevel - level - 1);
}
}
void QEFileBrowser::changeDir(const QString &path, bool goUpDir)
{
RES_ICON_Reader resIcon;
QEListBoxItem *item;
QString itemPath;
QString iconName;
if (goUpDir) m_pathLevel--;
if (m_pathLevel == 0) {
widget()->clear();
for (int i=0; i< baseItemCount; i++){
item = new QEListBoxItem(widget(), tr(listBaseItems[i]), resIcon.getIcon(listBaseIcons[i], FALSE));
widget()->insertItem(item);
}
}
else {
QDir dir;
dir.cd(path);
if (goUpDir) dir.cdUp();
dir.setNameFilter(m_nameFilter);
dir.setSorting(QDir::DirsFirst);
dir.setMatchAllDirs(TRUE);
if (!dir.isReadable()) return;
m_basePath = dir.canonicalPath();
widget()->clear();
QStringList entries = dir.entryList();
QStringList::ConstIterator it = entries.begin();
while (it != entries.end()) {
if ((*it != ".") && (*it != "..")) {
itemPath = m_basePath + "/" + *it;
iconName =
(QFileInfo(itemPath).isDir()) ?
"FMMS_Personal_Folder_S.g" :
(itemPath.right(4)==".wav" || itemPath.right(4)==".mp3" || itemPath.right(4)==".ogg" || itemPath.right(4)==".wma") ?
"FMMS_File_Audio_S.g" :
"FMMS_File_Video_S.g";
item = new QEListBoxItem(widget(), *it, resIcon.getIcon(iconName, FALSE), FALSE );
//if (!QFileInfo(itemPath).isDir()) item->setItemCheckable(TRUE);
widget()->insertItem(item);
}
++it;
}
}
}
bool QEFileBrowser::selectPrevItem(bool click)
{
int curIdx = widget()->currentItem();
if (curIdx <= 0) return FALSE; // first item ?
QListBoxItem *item = widget()->item(--curIdx);
if (item != NULL) {
if (click) slotItemClicked((QEListBoxItem *)item, QPoint(0,0));
widget()->setSelected(item, TRUE);
widget()->centerCurrentItem();
return TRUE;
}
return FALSE;
}
bool QEFileBrowser::selectNextItem(bool click)
{
int count = widget()->count();
int curIdx = widget()->currentItem();
if (curIdx == count-1) return FALSE; // last item ?
QListBoxItem *item = widget()->item(++curIdx);
if (item != NULL) {
if (click) slotItemClicked((QEListBoxItem *)item, QPoint(0,0));
widget()->setSelected(item, TRUE);
widget()->centerCurrentItem();
return TRUE;
}
return FALSE;
}
void QEFileBrowser::slotItemClicked(QEListBoxItem *item, const QPoint &)
{
if (m_pathLevel == 0) {
m_basePath = itemBasePath[widget()->index(item)];
m_pathLevel++;
changeDir(m_basePath);
emit dirItemClicked(m_basePath);
}
else {
QString path = m_basePath + "/" + item->text();
if (QFileInfo(path).isDir()) { // dir selected
strcpy(m_currentFile, "NOTFILE");
m_pathLevel++;
changeDir(path);
emit dirItemClicked(m_basePath);
}
else { // file selected
strcpy(m_currentFile, path.local8Bit());
emit fileItemClicked(path);
}
}
}