summaryrefslogtreecommitdiffstats
path: root/noatun/library/mimetypetree.cpp
blob: c89842d0a65f548d8dbbc10af5ab47fa6eae55b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "mimetypetree.h"
#include <kmimetype.h>
#include <tqdict.h>
#include <tqheader.h>


MimeTypeTree::MimeTypeTree(TQWidget *parent)
	: TDEListView(parent)
{
	KMimeType::List list=KMimeType::allMimeTypes();
	TQDict<TQListViewItem> map;
	setRootIsDecorated(true);

	addColumn("-");
	header()->hide();
    TQValueListIterator<KMimeType::Ptr> i(list.begin());
	for (; i != list.end(); ++i)
	{
		TQString mimetype = (*i)->name();
		int slash = mimetype.find("/");
		TQString major = mimetype.left(slash);
		
		// hide all and inode majors
		if (major == "all" || major=="inode")
			continue;

		TQString minor = mimetype.mid(slash+1);
		TQListViewItem *majorItem=map[major];
		if (!majorItem)
		{
			majorItem=addMajor(major);
			map.insert(major, majorItem);
		}
		
		new TQListViewItem(majorItem, minor);
	}
}

void MimeTypeTree::sel(TQListViewItem *item)
{
	TQListViewItem *p=item->parent();
	if (!p) return;
	TQString major=p->text(0);
	TQString minor=item->text(0);
	
	emit selected(major+'/'+minor);
}

TQListViewItem* MimeTypeTree::addMajor(const TQString &name)
{
	return new TQListViewItem(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"