summaryrefslogtreecommitdiffstats
path: root/kpackage/kplview.h
blob: 239e743969a738056a080dd2c328fb3aeedb3c2f (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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/*
** Copyright (C) 1999,2000 Toivo Pedaste <toivo@ucs.uwa.edu.au>
**
*/

/*
** 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.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program in a file called COPYING; if not, write to
** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
** MA 02110-1301, USA.
*/

/*
** Bug reports and questions can be sent to kde-devel@kde.org
*/


#ifndef KPLVITEM_H
#define KPLVITEM_H

#include "../config.h"
// Standard Headers

// TQt Headers
#include <tqframe.h>
#include <tqpushbutton.h>
#include <tqptrlist.h>
#include <tqstring.h>
#include <tqlayout.h>

// KDE headers
#include "klistview.h"

// ksetup headers
#include "packageInfo.h"

class packageDisplayWidget;

////////////////////////////////////////////////////////////////////////
class KpTreeList: public TDEListView
{
  Q_OBJECT
  

public:
  KpTreeList ( TQWidget * parent = 0);

  void contentsMousePressEvent ( TQMouseEvent * e );

  bool inMark(int x);

  KpTreeListItem *firstChild();
  KpTreeListItem *currentItem();
  void clear();

  KpTreeListItem *markPkg;

  TQPtrList<KpTreeListItem> stack;
  // Stack of jumped to packages

  void sweep(bool init);
  // sweep tree adjusting visibility
  void expand();
  // sweep tree expanding everything

  void findMarked(KpTreeListItem *item, TQPtrList<KpTreeListItem> &selList);
  // generate list of marked tree items
  void clearMarked(KpTreeListItem *item);
  // unmark marked tree items

  // mark all packages in the selected view
  void markAll(KpTreeListItem *item) ;

  void expandTree(KpTreeList *list);
  // expand package tree

  void expandTree(KpTreeListItem *item);
  // expand package sub-tree

  void collapseTree(KpTreeList *list);
  // semi-collapse package tree

  void collapseTree(KpTreeListItem *item);
  // semi-collapse package sub-tree

  void countMarked(KpTreeListItem *, int &cntInstall, int &cntUnInstall);
  // Count marked packages that can be installed/uninstalled

  void packageHighlighted(TQListViewItem *item, packageDisplayWidget *packageDisplay);
  // A package has been highlighted in the list tree

  KpTreeListItem *search(const TQString &str, const TQString &head,
			KpTreeListItem  *start = 0);
  KpTreeListItem *search(const TQString &str, bool subStr, bool wrap, bool start);
  // search for a package in tree
  KpTreeListItem *changePack(KpTreeListItem *searchResult, bool push = true);
  // Change to other package

  void stackRemove(KpTreeListItem *pack);
  // Remove entry from package stack

  void readTreeType();
  void writeTreeType();
  // config: Tree display type

  void writeTreeConfig();
  void readTreeConfig();
  // save and restore column positions

 int treeType;

public slots:
  void next();
  // Package stack forward

  void previous();
  // Package stack back

private:
  int  sweepChild(KpTreeListItem *it);
  void  expandChild(KpTreeListItem *it);

  bool searchChild(KpTreeListItem *it);
  // recurse thru the display tree looking for 'str'

  bool notPress;
  // flag to packageHighlighted

  KpTreeListItem *searchCitem;
  bool searchSkip, searchSubstr;
  TQString searchStr;
  KpTreeListItem  *searchResult;
  // globals used by searchChild for start from current position,
  // skip to current item before search flag, substring search flag,
  // search string, result item (if found)

  // flag skipping in searchChild


signals:
  void updateMarked();
  void cleared();
};

////////////////////////////////////////////////////////////////////////
class KpTreeListItem : public TQListViewItem
{
public:
  KpTreeListItem( TQListViewItem *parent, packageInfo* pinfo,
	    const TQPixmap& thePixmap,
	    TQString label1 = 0, TQString label2  = 0,
	    TQString label3  = 0, TQString label4  = 0,
	    TQString label5  = 0, TQString label6  = 0,
	    TQString label7  = 0, TQString label8 = 0);


  KpTreeListItem( TDEListView *parent, packageInfo* pinfo,
	    const TQPixmap& thePixmap,
	    TQString label1 = 0, TQString label2  = 0,
	    TQString label3  = 0, TQString label4  = 0,
	    TQString label5  = 0, TQString label6  = 0,
	    TQString label7  = 0, TQString label8 = 0);


  KpTreeListItem *firstChild();
  KpTreeListItem *nextSibling();

  void toggleMark();
  void setMark(bool mark);
  // flag for install/uninstall

  void hide();
  void show();

  virtual int compare( TQListViewItem *i, int col, bool ascending ) const;

  packageInfo *info;
  bool marked;
};


#endif