diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | e2de64d6f1beb9e492daf5b886e19933c1fa41dd (patch) | |
tree | 9047cf9e6b5c43878d5bf82660adae77ceee097a /noatun/library/mimetypetree.cpp | |
download | tdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.tar.gz tdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'noatun/library/mimetypetree.cpp')
-rw-r--r-- | noatun/library/mimetypetree.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/noatun/library/mimetypetree.cpp b/noatun/library/mimetypetree.cpp new file mode 100644 index 00000000..c2b60c81 --- /dev/null +++ b/noatun/library/mimetypetree.cpp @@ -0,0 +1,64 @@ +#include "mimetypetree.h" +#include <kmimetype.h> +#include <qdict.h> +#include <qheader.h> + + +MimeTypeTree::MimeTypeTree(QWidget *parent) + : KListView(parent) +{ + KMimeType::List list=KMimeType::allMimeTypes(); + QDict<QListViewItem> map; + setRootIsDecorated(true); + + addColumn("-"); + header()->hide(); + QValueListIterator<KMimeType::Ptr> i(list.begin()); + for (; i != list.end(); ++i) + { + QString mimetype = (*i)->name(); + int slash = mimetype.find("/"); + QString major = mimetype.left(slash); + + // hide all and inode majors + if (major == "all" || major=="inode") + continue; + + QString minor = mimetype.mid(slash+1); + QListViewItem *majorItem=map[major]; + if (!majorItem) + { + majorItem=addMajor(major); + map.insert(major, majorItem); + } + + new QListViewItem(majorItem, minor); + } +} + +void MimeTypeTree::sel(QListViewItem *item) +{ + QListViewItem *p=item->parent(); + if (!p) return; + QString major=p->text(0); + QString minor=item->text(0); + + emit selected(major+'/'+minor); +} + +QListViewItem* MimeTypeTree::addMajor(const QString &name) +{ + return new QListViewItem(this, name); +} + + +// GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 +// 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL +// GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 +// 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL +// GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 +// 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL +// GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 +// 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL + +#include "mimetypetree.moc" |