~ubuntu-branches/ubuntu/breezy/kdemultimedia/breezy

« back to all changes in this revision

Viewing changes to noatun/noatun/library/mimetypetree.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-03-24 04:48:58 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050324044858-8ff88o9jxej6ii3d
Tags: 4:3.4.0-0ubuntu3
Add kubuntu_02_hide_arts_menu_entries.diff to hide artsbuilder and artscontrol k-menu entries

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include "mimetypetree.h"
2
 
#include <kmimetype.h>
3
 
#include <qdict.h>
4
 
#include <qheader.h>
5
 
 
6
 
 
7
 
MimeTypeTree::MimeTypeTree(QWidget *parent)
8
 
        : KListView(parent)
9
 
{
10
 
        KMimeType::List list=KMimeType::allMimeTypes();
11
 
        QDict<QListViewItem> map;
12
 
        setRootIsDecorated(true);
13
 
 
14
 
        addColumn("-");
15
 
        header()->hide();
16
 
    QValueListIterator<KMimeType::Ptr> i(list.begin());
17
 
        for (; i != list.end(); ++i)
18
 
        {
19
 
                QString mimetype = (*i)->name();
20
 
                int slash = mimetype.find("/");
21
 
                QString major = mimetype.left(slash);
22
 
                
23
 
                // hide all and inode majors
24
 
                if (major == "all" || major=="inode")
25
 
                        continue;
26
 
 
27
 
                QString minor = mimetype.mid(slash+1);
28
 
                QListViewItem *majorItem=map[major];
29
 
                if (!majorItem)
30
 
                {
31
 
                        majorItem=addMajor(major);
32
 
                        map.insert(major, majorItem);
33
 
                }
34
 
                
35
 
                new QListViewItem(majorItem, minor);
36
 
        }
37
 
}
38
 
 
39
 
void MimeTypeTree::sel(QListViewItem *item)
40
 
{
41
 
        QListViewItem *p=item->parent();
42
 
        if (!p) return;
43
 
        QString major=p->text(0);
44
 
        QString minor=item->text(0);
45
 
        
46
 
        emit selected(major+'/'+minor);
47
 
}
48
 
 
49
 
QListViewItem* MimeTypeTree::addMajor(const QString &name)
50
 
{
51
 
        return new QListViewItem(this, name);
52
 
}
53
 
 
54
 
 
55
 
// GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666
56
 
// 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 
57
 
// GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666
58
 
// 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 
59
 
// GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666
60
 
// 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 
61
 
// GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666
62
 
// 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 666 GPL 
63
 
 
64
 
#include "mimetypetree.moc"