summaryrefslogtreecommitdiffstats
path: root/krusader/Panel/krbriefview.h
blob: 5cb61f1efd63d033bcbac49a4fccaf5bade27bfd (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
/***************************************************************************
                              krbriefview.h
                           -------------------
  copyright            : (C) 2000-2007 by Shie Erlich & Rafi Yanai & Csaba Karai
  e-mail               : krusader@users.sourceforge.net
  web site             : http://krusader.sourceforge.net
---------------------------------------------------------------------------
Description
***************************************************************************

A

   db   dD d8888b. db    db .d8888.  .d8b.  d8888b. d88888b d8888b.
   88 ,8P' 88  `8D 88    88 88'  YP d8' `8b 88  `8D 88'     88  `8D
   88,8P   88oobY' 88    88 `8bo.   88ooo88 88   88 88ooooo 88oobY'
   88`8b   88`8b   88    88   `Y8b. 88~~~88 88   88 88~~~~~ 88`8b
   88 `88. 88 `88. 88b  d88 db   8D 88   88 88  .8D 88.     88 `88.
   YP   YD 88   YD ~Y8888P' `8888Y' YP   YP Y8888D' Y88888P 88   YD

                                                   H e a d e r    F i l e

***************************************************************************
*                                                                         *
*   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.                                   *
*                                                                         *
***************************************************************************/
#ifndef KRBRIEFVIEW_H
#define KRBRIEFVIEW_H

#include "krview.h"
#include "krviewitem.h"
#include <kiconview.h>
#include <tqtimer.h>

// extends KrViewProperties to add detailedview-only properties
class KrBriefViewProperties: public KrViewProperties {
public:
	int numberOfColumns; // the number of columns in the view
};

class KrBriefViewItem;
class TQDragMoveEvent;
class TQToolTip;
class TQHeader;

/**
 * KrBriefView implements everthing and anything regarding a brief view in a filemananger.
 * IT MUST USE KrViewItem as the children to it's *TDEIconView. KrBriefView and KrViewItem are
 * tightly coupled and the view will not work with other kinds of items.
 * Apart from this, the view is self-reliant and you can use the vast interface to get whatever
 * information is necessery from it.
 */
class KrBriefView: public TDEIconView, public KrView {
	friend class KrBriefViewItem;
	Q_OBJECT
  
public:
	KrBriefView( TQHeader *header, TQWidget *parent, bool &left, TDEConfig *cfg = krConfig, const char *name = 0 );
	virtual ~KrBriefView();
	virtual inline KrViewItem *getFirst() { return dynamic_cast<KrViewItem*>( firstItem() ); }
	virtual inline KrViewItem *getLast() { return dynamic_cast<KrViewItem*>( lastItem() ); }
	virtual inline KrViewItem *getNext( KrViewItem *current ) { return dynamic_cast<KrViewItem*>( dynamic_cast<TQIconViewItem*>( current ) ->nextItem() ); }
	virtual inline KrViewItem *getPrev( KrViewItem *current ) { return dynamic_cast<KrViewItem*>( dynamic_cast<TQIconViewItem*>( current ) ->prevItem() ); }
	virtual inline KrViewItem *getCurrentKrViewItem() { return dynamic_cast<KrViewItem*>( currentItem() ); }
	virtual KrViewItem *getKrViewItemAt(const TQPoint &vp);
	virtual inline KrViewItem *findItemByName(const TQString &name) { return dynamic_cast<KrViewItem*>( findItem( name, TQt::ExactMatch ) ); }
	virtual void addItems(vfs* v, bool addUpDir = true);
	virtual void delItem(const TQString &);
	virtual TQString getCurrentItem() const;
	virtual void makeItemVisible(const KrViewItem * item );
	virtual void setCurrentItem(const TQString& name );
	virtual void updateView();
	virtual void updateItem(KrViewItem* item );
	virtual void clear();
	virtual void sort()                        { if( sortDirection() ) sortOrderChanged();TDEIconView::sort( true ); }
	virtual void sort( bool ascending )        { if( sortDirection() != ascending ) sortOrderChanged();TDEIconView::sort( ascending ); }
	virtual void prepareForActive();
	virtual void prepareForPassive();
	virtual void saveSettings() {}
	virtual void restoreSettings() {}
	virtual TQString nameInTDEConfig() {return _nameInTDEConfig;}
	virtual void resizeEvent ( TQResizeEvent * );

signals:
	void middleButtonClicked( KrViewItem *item );
	void currentChanged( KrViewItem *item );

protected:
	virtual void setup();
	virtual void initProperties();
	virtual void initOperator();
	virtual KrViewItem *preAddItem(vfile * vf);
	virtual bool preDelItem(KrViewItem * item );

	void setColumnNr();
	void redrawColumns();

	virtual void keyPressEvent( TQKeyEvent *e );
	virtual void imStartEvent( TQIMEvent* e );
	virtual void imEndEvent( TQIMEvent *e );
	virtual void imComposeEvent( TQIMEvent *e );
	virtual void contentsMousePressEvent( TQMouseEvent *e );
	virtual void contentsMouseReleaseEvent (TQMouseEvent *e);
	virtual void contentsMouseMoveEvent ( TQMouseEvent * e );
	virtual void contentsMouseDoubleClickEvent ( TQMouseEvent * e );
	virtual bool acceptDrag( TQDropEvent* e ) const;
	virtual void contentsDropEvent( TQDropEvent *e );
	virtual void contentsDragMoveEvent( TQDragMoveEvent *e );
	virtual void contentsDragLeaveEvent ( TQDragLeaveEvent * );
	virtual void startDrag() { op()->startDrag(); }
	virtual bool event( TQEvent *e );
	virtual bool eventFilter( TQObject * watched, TQEvent * e );
	TQMouseEvent * transformMouseEvent( TQMouseEvent * );

protected slots:
	void rename( TQIconViewItem *item );
	void slotClicked( TQIconViewItem *item );
	void slotDoubleClicked( TQIconViewItem *item );
	void slotItemDescription( TQIconViewItem * );
	void slotCurrentChanged( TQIconViewItem *item );
	void handleContextMenu( TQIconViewItem*, const TQPoint& );
	virtual void renameCurrentItem();
	virtual void showContextMenu( );
	void inplaceRenameFinished( TQIconViewItem *it );
	void setNameToMakeCurrent( TQIconViewItem *it );
	void sortOrderChanged();
	void slotRightButtonPressed(TQIconViewItem*, const TQPoint& point);
	void transformCurrentChanged( TQIconViewItem * item ) { emit currentChanged( dynamic_cast<KrViewItem *>(item ) ); }

	/**
	  * used internally to produce the signal middleButtonClicked()
	 */
	void slotMouseClicked( int button, TQIconViewItem * item, const TQPoint & pos );
	inline void slotExecuted( TQIconViewItem* i ) {
		TQString tmp = dynamic_cast<KrViewItem*>( i ) ->name();
		op()->emitExecuted( tmp );
	}

public slots:
	void refreshColors();
	void quickSearch( const TQString &, int = 0 );
	void stopQuickSearch( TQKeyEvent* );
	void handleQuickSearchEvent( TQKeyEvent* );
	void changeSortOrder();

  
signals:
	void letsDrag(TQStringList items, TQPixmap icon);
	void gotDrop(TQDropEvent *);

private:
	TQHeader * header;
	bool swushSelects;
	TQPoint dragStartPos;
	TQIconViewItem *lastSwushPosition;
	KrViewItem *_currDragItem;
	bool singleClicked;
	bool modifierPressed;
	TQTime clickTime;
	TQIconViewItem *clickedItem;
	TQTimer renameTimer;
	TQTimer contextMenuTimer;
	TQPoint contextMenuPoint;
	KrBriefViewItem *currentlyRenamedItem;
	TQIconViewItem *pressedItem;
	TQMouseEvent *mouseEvent;
	TQToolTip *toolTip;
};

#endif