blob: 1c66c2bf772a25c3d1480719b5b48d0131861173 (
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
/***************************************************************************
knowittree.cpp - description
-------------------
begin : sob gru 20 2003
copyright : (C) 2003 by Micha³ Rudolf
email : mrudolf@kdewebdev.org
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#include <tdelocale.h>
#include <tqevent.h>
#include <tqdragobject.h>
#include <tqheader.h>
#include <tqwhatsthis.h>
#include "knowittree.h"
KnowitTree::KnowitTree(TQWidget* parent, const char* name)
: TDEListView(parent, name)
{
setMinimumSize(150, 150);
addColumn(i18n("Notes"));
setRootIsDecorated(true);
setItemsRenameable(true);
setDragEnabled(true);
setAcceptDrops(true);
setFullWidth(true);
setSorting(-1);
setDragAutoScroll(true);
prevItem = 0;
TQWhatsThis::add(this, i18n("<h2>Notes hierarchy</h2>"
"Here you can browse notes tree. "
"You can also add notes using right-click menu, or reorganize them using "
"drag and drop."));
}
void KnowitTree::takeNode(TQListViewItem* item)
{
if (item->parent())
item->parent()->takeItem(item);
else
takeItem(item);
}
void KnowitTree::insertNode(TQListViewItem* parent, TQListViewItem* item, TQListViewItem* after)
{
if (parent)
parent->insertItem(item);
else
insertItem(item);
if (after)
item->moveItem(after);
}
void KnowitTree::contentsDragMoveEvent(TQDragMoveEvent* event)
{
TQListViewItem* item = itemAt(event->pos());
/* check if on root decoration */
if (!item || event->pos().x() > header()->cellPos(header()->mapToActual(0)) +
treeStepSize() * (item->depth() + 1) + itemMargin() ||
event->pos().x() < header()->cellPos(header()->mapToActual(0)))
return;
if (item && item->childCount() && !item->isOpen())
item->setOpen(true);
}
void KnowitTree::slotCollapseAll()
{
TQListViewItem* it = firstChild();
while(it) {
it->setOpen(false);
it = it->nextSibling();
}
}
void KnowitTree::slotCollapse()
{
if (currentItem())
currentItem()->setOpen(false);
}
void KnowitTree::slotExpandAll()
{
TQListViewItem* it = firstChild();
while(it) {
it->setOpen(true);
it = it->nextSibling();
}
}
void KnowitTree::slotExpand()
{
if (currentItem())
currentItem()->setOpen(true);
}
void KnowitTree::slotItemUp()
{
if (currentItem())
setCurrentItem(currentItem()->itemAbove());
}
void KnowitTree::slotItemDown()
{
if (currentItem())
setCurrentItem(currentItem()->itemBelow());
}
void KnowitTree::slotItemBegin()
{
setCurrentItem(firstChild());
}
void KnowitTree::slotItemEnd()
{
TQListViewItem* elt = firstChild();
if (elt)
while (elt->itemBelow())
elt = elt->itemBelow();
setCurrentItem(elt);
}
void KnowitTree::slotItemLeft()
{
if (currentItem())
setCurrentItem(currentItem()->parent());
}
void KnowitTree::slotItemRight()
{
if (currentItem())
setCurrentItem(currentItem()->firstChild());
}
#include "knowittree.moc"
|