summaryrefslogtreecommitdiffstats
path: root/demos/embedded/desktopservices
diff options
context:
space:
mode:
authorJanne Anttila <janne.anttila@digia.com>2009-06-10 06:53:50 (GMT)
committerJanne Anttila <janne.anttila@digia.com>2009-06-10 06:53:50 (GMT)
commit2d34a0f7cc4a7302871c942a827bd4278cdde10b (patch)
tree8de799055cdfc22bf3e9e7c1b757b7c568ca0c38 /demos/embedded/desktopservices
parentdcaa6ab545e7532b5455734bd8d234cb76b152fa (diff)
downloadQt-2d34a0f7cc4a7302871c942a827bd4278cdde10b.zip
Qt-2d34a0f7cc4a7302871c942a827bd4278cdde10b.tar.gz
Qt-2d34a0f7cc4a7302871c942a827bd4278cdde10b.tar.bz2
Implemented content filters for desktopservices example.
Now only the relevant files are shown under images and music tabs, even the folder would contain other content types.
Diffstat (limited to 'demos/embedded/desktopservices')
-rw-r--r--demos/embedded/desktopservices/contenttab.cpp6
-rw-r--r--demos/embedded/desktopservices/contenttab.h1
-rw-r--r--demos/embedded/desktopservices/desktopwidget.cpp10
3 files changed, 13 insertions, 4 deletions
diff --git a/demos/embedded/desktopservices/contenttab.cpp b/demos/embedded/desktopservices/contenttab.cpp
index 12e80f6..450a080 100644
--- a/demos/embedded/desktopservices/contenttab.cpp
+++ b/demos/embedded/desktopservices/contenttab.cpp
@@ -66,9 +66,13 @@ ContentTab::~ContentTab()
// NEW PUBLIC METHODS
void ContentTab::init(const QDesktopServices::StandardLocation &location,
+ const QString &filter,
const QString &icon)
{
setContentDir(location);
+ QStringList filterList;
+ filterList = filter.split(";");
+ m_ContentDir.setNameFilters(filterList);
setIcon(icon);
connect(this, SIGNAL(itemClicked(QListWidgetItem *)),
@@ -90,7 +94,7 @@ void ContentTab::setIcon(const QString &icon)
void ContentTab::populateListWidget()
{
- QFileInfoList fileList = m_ContentDir.entryInfoList(QStringList(), QDir::Files, QDir::Time);
+ QFileInfoList fileList = m_ContentDir.entryInfoList(QDir::Files, QDir::Time);
foreach(QFileInfo item, fileList) {
new QListWidgetItem(m_Icon, itemName(item), this);
}
diff --git a/demos/embedded/desktopservices/contenttab.h b/demos/embedded/desktopservices/contenttab.h
index af1b7bb..a5a402e 100644
--- a/demos/embedded/desktopservices/contenttab.h
+++ b/demos/embedded/desktopservices/contenttab.h
@@ -74,6 +74,7 @@ public: // Constructors & Destructors
public: // New Methods
virtual void init(const QDesktopServices::StandardLocation &location,
+ const QString &filter,
const QString &icon);
protected: // New Methods
diff --git a/demos/embedded/desktopservices/desktopwidget.cpp b/demos/embedded/desktopservices/desktopwidget.cpp
index e8a654e..3abe591 100644
--- a/demos/embedded/desktopservices/desktopwidget.cpp
+++ b/demos/embedded/desktopservices/desktopwidget.cpp
@@ -59,18 +59,22 @@ DesktopWidget::DesktopWidget(QWidget *parent) : QWidget(parent)
// Images
ContentTab* imageTab = new ContentTab(tabWidget);
- imageTab->init(QDesktopServices::PicturesLocation, ":/resources/photo.png");
+ imageTab->init(QDesktopServices::PicturesLocation,
+ "*.png;*.jpg;*.jpeg;*.bmp;*.gif",
+ ":/resources/photo.png");
tabWidget->addTab(imageTab, tr("Images"));
// Music
ContentTab* musicTab = new ContentTab(tabWidget);
- musicTab->init(QDesktopServices::MusicLocation, ":/resources/music.png");
+ musicTab->init(QDesktopServices::MusicLocation,
+ "*.wav;*.mp3;*.mp4",
+ ":/resources/music.png");
tabWidget->addTab(musicTab, tr("Music"));
// Links
LinkTab* othersTab = new LinkTab(tabWidget);;
// Given icon file will be overriden by LinkTab
- othersTab->init(QDesktopServices::PicturesLocation, "");
+ othersTab->init(QDesktopServices::PicturesLocation, "", "");
tabWidget->addTab(othersTab, tr("Links"));
// Layout