• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeio/tdefile
 

tdeio/tdefile

  • tdeio
  • tdefile
kcombiview.cpp
1/* This file is part of the KDE libraries
2 Copyright (C) 1998 Stephan Kulow <coolo@kde.org>
3 1998 Daniel Grana <grana@ie.iwi.unibe.ch>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21// $Id$
22
23#include <assert.h>
24
25#include "tdefileitem.h"
26#include "kcombiview.h"
27#include "tdefileiconview.h"
28#include "tdefiledetailview.h"
29#include "config-tdefile.h"
30
31#include <tqevent.h>
32
33#include <tqdir.h>
34
35#include <tdeapplication.h>
36#include <tdeconfig.h>
37#include <kdebug.h>
38#include <tdeglobal.h>
39
40#include <tqvaluelist.h>
41
42KCombiView::KCombiView( TQWidget *parent, const char *name)
43 : TQSplitter( parent, name),
44 KFileView(),
45 right(0),
46 m_lastViewForNextItem(0),
47 m_lastViewForPrevItem(0)
48{
49 left = new KFileIconView( this, "left" );
50 left->setAcceptDrops(false);
51 left->viewport()->setAcceptDrops(false);
52 left->setGridX( 160 );
53 left->KFileView::setViewMode( Directories );
54 left->setArrangement( TQIconView::LeftToRight );
55 left->setParentView( this );
56 left->setAcceptDrops(false);
57 left->installEventFilter( this );
58
59 connect( sig, TQ_SIGNAL( sortingChanged( TQDir::SortSpec ) ),
60 TQ_SLOT( slotSortingChanged( TQDir::SortSpec ) ));
61}
62
63KCombiView::~KCombiView()
64{
65 delete right;
66}
67
68void KCombiView::setRight(KFileView *view)
69{
70 delete right;
71 right = view;
72 right->KFileView::setViewMode( Files );
73 setViewName( right->viewName() );
74
75 TQValueList<int> lst;
76 lst << left->gridX() + 2 * left->spacing();
77 setSizes( lst );
78 setResizeMode( left, TQSplitter::KeepSize );
79
80 right->setParentView( this );
81 right->widget()->setAcceptDrops(acceptDrops());
82 right->setDropOptions(dropOptions());
83 right->widget()->installEventFilter( this );
84}
85
86
87void KCombiView::insertItem( KFileItem *item )
88{
89 KFileView::insertItem( item );
90
91 if ( item->isDir() ) {
92 left->updateNumbers( item );
93 left->insertItem( item );
94 }
95 else {
96 right->updateNumbers( item );
97 right->insertItem( item );
98 }
99}
100
101void KCombiView::setSorting( TQDir::SortSpec sort )
102{
103 if ( !right )
104 kdFatal() << "You need to call setRight( someview ) before!" << endl;
105 right->setSorting( sort );
106 left->setSorting( sort );
107
108 KFileView::setSorting( right->sorting() );
109}
110
111void KCombiView::clearView()
112{
113 left->clearView();
114 if ( right )
115 right->clearView();
116}
117
118void KCombiView::updateView( bool b )
119{
120 left->updateView( b );
121 if ( right )
122 right->updateView( b );
123}
124
125void KCombiView::updateView( const KFileItem *i )
126{
127 left->updateView( i );
128 if ( right )
129 right->updateView( i );
130}
131
132void KCombiView::removeItem( const KFileItem *i )
133{
134 left->removeItem( i );
135 if ( right )
136 right->removeItem( i );
137 KFileView::removeItem( i );
138}
139
140void KCombiView::listingCompleted()
141{
142 left->listingCompleted();
143 if ( right )
144 right->listingCompleted();
145}
146
147void KCombiView::clear()
148{
149 KFileView::clear();
150 left->KFileView::clear();
151 if ( right )
152 right->clear();
153}
154
155void KCombiView::clearSelection()
156{
157 left->clearSelection();
158 if ( right )
159 right->clearSelection();
160}
161
162void KCombiView::selectAll()
163{
164 left->selectAll();
165 if ( right )
166 right->selectAll();
167}
168
169void KCombiView::invertSelection()
170{
171 left->invertSelection();
172 if ( right )
173 right->invertSelection();
174}
175
176bool KCombiView::isSelected( const KFileItem *item ) const
177{
178 assert( right ); // for performance reasons no if ( right ) check.
179 return (right->isSelected( item ) || left->isSelected( item ));
180}
181
182void KCombiView::setSelectionMode( KFile::SelectionMode sm )
183{
184 // I think the left view (directories should always be in
185 // Single-Mode, right?
186 // left->setSelectionMode( sm );
187 if ( !right )
188 kdFatal() << "You need to call setRight( someview ) before!" << endl;
189 right->setSelectionMode( sm );
190}
191
192void KCombiView::setSelected( const KFileItem *item, bool enable )
193{
194 left->setSelected( item, enable );
195 if ( right )
196 right->setSelected( item, enable );
197}
198
199void KCombiView::setCurrentItem( const KFileItem *item )
200{
201 left->setCurrentItem( item );
202 if ( right )
203 right->setCurrentItem( item );
204}
205
206KFileItem * KCombiView::currentFileItem() const
207{
208 // we can actually have two current items, one in each view. So we simply
209 // prefer the fileview's item over the directory's.
210 // Smarter: if the right view has focus, prefer that over the left.
211 if ( !right )
212 return left->currentFileItem();
213
214 KFileView *preferredView = focusView( right );
215 KFileItem *item = preferredView->currentFileItem();
216 if ( !item && preferredView != left )
217 item = left->currentFileItem();
218
219 return item;
220}
221
222void KCombiView::ensureItemVisible(const KFileItem *item)
223{
224 left->ensureItemVisible( item );
225 if ( right )
226 right->ensureItemVisible( item );
227}
228
229KFileItem * KCombiView::firstFileItem() const
230{
231 if ( !right )
232 return left->firstFileItem();
233
234 KFileView *preferredView = focusView( left );
235 KFileView *otherView = (preferredView == left) ? right : left;
236 KFileItem *item = preferredView->firstFileItem();
237 if ( !item )
238 item = otherView->firstFileItem();
239
240 return item;
241}
242
243KFileItem * KCombiView::nextItem( const KFileItem *fileItem ) const
244{
245 if ( !right )
246 return left->nextItem( fileItem );
247
248 KFileView *preferredView = focusView( left );
249 KFileView *otherView = (preferredView == left) ? right : left;
250 KFileItem *item = preferredView->nextItem( fileItem );
251
252 if ( item )
253 m_lastViewForNextItem = preferredView;
254 else { // no item, check other view
255 // when changing from one to another view, we need to continue
256 // with the next view's first item!
257 if ( m_lastViewForNextItem != otherView ) {
258 m_lastViewForNextItem = otherView;
259 return otherView->firstFileItem();
260 }
261
262 item = otherView->nextItem( fileItem );
263 m_lastViewForNextItem = otherView;
264 }
265
266 return item;
267}
268
269KFileItem * KCombiView::prevItem( const KFileItem *fileItem ) const
270{
271 if ( !right )
272 return left->nextItem( fileItem );
273
274 KFileView *preferredView = focusView( left );
275 KFileView *otherView = (preferredView == left) ? right : left;
276 KFileItem *item = preferredView->prevItem( fileItem );
277 if ( item )
278 m_lastViewForPrevItem = preferredView;
279
280 else { // no item, check other view
281 // when changing from one to another view, we need to continue
282 // with the next view's last item!
283 if ( m_lastViewForPrevItem != otherView ) {
284 fileItem = otherView->firstFileItem();
285 while ( otherView->nextItem( fileItem ) ) // find the last item
286 fileItem = otherView->nextItem( fileItem );
287 }
288
289 item = otherView->prevItem( fileItem );
290 m_lastViewForPrevItem = otherView;
291 }
292
293 return item;
294}
295
296void KCombiView::slotSortingChanged( TQDir::SortSpec sorting )
297{
298 KFileView::setSorting( sorting );
299}
300
301KFileView *KCombiView::focusView( KFileView *preferred ) const
302{
303 TQWidget *w = focusWidget();
304 KFileView *other = (right == preferred) ? left : right;
305 return (preferred && w == preferred->widget()) ? preferred : other;
306}
307
308void KCombiView::readConfig( TDEConfig *config, const TQString& group )
309{
310 left->readConfig( config, group );
311 if ( right )
312 right->readConfig( config, group );
313}
314
315void KCombiView::writeConfig( TDEConfig *config, const TQString& group )
316{
317 left->writeConfig( config, group );
318 if ( right )
319 right->writeConfig( config, group );
320}
321
322TDEActionCollection * KCombiView::actionCollection() const
323{
324 return focusView( right )->actionCollection();
325}
326
327void KCombiView::setAcceptDrops(bool b)
328{
329 left->setAcceptDrops(b);
330 if (right)
331 right->widget()->setAcceptDrops(b);
332 TQSplitter::setAcceptDrops(b);
333}
334
335void KCombiView::setDropOptions_impl(int options)
336{
337 KFileView::setDropOptions_impl(options);
338 left->setDropOptions(options);
339 if (right)
340 right->setDropOptions(options);
341}
342
343void KCombiView::virtual_hook( int id, void* data )
344{
345 switch(id) {
346 case VIRTUAL_SET_DROP_OPTIONS:
347 setDropOptions_impl(*(int *)data);
348 break;
349 default:
350 KFileView::virtual_hook( id, data );
351 }
352}
353
354bool KCombiView::eventFilter( TQObject *o, TQEvent *e )
355{
356 int type = e->type();
357
358 // only the focused view may have a selection
359 if ( type == TQEvent::FocusIn )
360 {
361 if ( o == left )
362 right->clearSelection();
363 else if ( o == right->widget() )
364 left->clearSelection();
365 }
366
367 return TQSplitter::eventFilter( o, e );
368}
369
370#include "kcombiview.moc"
371
KCombiView::setCurrentItem
virtual void setCurrentItem(const KFileItem *)
Reimplement this to set item the current item in the view, e.g.
Definition: kcombiview.cpp:199
KCombiView::setRight
void setRight(KFileView *view)
Sets the view to be shown in the right.
Definition: kcombiview.cpp:68
KCombiView::clearSelection
virtual void clearSelection()
Clears any selection, unhighlights everything.
Definition: kcombiview.cpp:155
KCombiView::setSelected
virtual void setSelected(const KFileItem *, bool)
Tells the view that it should highlight the item.
Definition: kcombiview.cpp:192
KCombiView::clearView
virtual void clearView()
pure virtual function, that should be implemented to clear the view.
Definition: kcombiview.cpp:111
KCombiView::selectAll
virtual void selectAll()
Selects all items.
Definition: kcombiview.cpp:162
KCombiView::insertItem
virtual void insertItem(KFileItem *i)
The derived view must implement this function to add the file in the widget.
Definition: kcombiview.cpp:87
KCombiView::isSelected
virtual bool isSelected(const KFileItem *) const
Definition: kcombiview.cpp:176
KCombiView::setSorting
virtual void setSorting(TQDir::SortSpec sort)
Sets the sorting order of the view.
Definition: kcombiview.cpp:101
KCombiView::clear
virtual void clear()
Clears the view and all item lists.
Definition: kcombiview.cpp:147
KCombiView::removeItem
virtual void removeItem(const KFileItem *)
Removes an item from the list; has to be implemented by the view.
Definition: kcombiview.cpp:132
KCombiView::updateView
virtual void updateView(bool)
does a repaint of the view.
Definition: kcombiview.cpp:118
KCombiView::actionCollection
virtual TDEActionCollection * actionCollection() const
Definition: kcombiview.cpp:322
KCombiView::listingCompleted
virtual void listingCompleted()
This hook is called when all items of the currently listed directory are listed and inserted into the...
Definition: kcombiview.cpp:140
KCombiView::currentFileItem
virtual KFileItem * currentFileItem() const
Definition: kcombiview.cpp:206
KCombiView::ensureItemVisible
void ensureItemVisible(const KFileItem *)
pure virtual function, that should be implemented to make item i visible, i.e.
Definition: kcombiview.cpp:222
KCombiView::invertSelection
virtual void invertSelection()
Inverts the current selection, i.e.
Definition: kcombiview.cpp:169
KFileIconView
An icon-view capable of showing KFileItem's.
Definition: tdefileiconview.h:83
KFileIconView::insertItem
virtual void insertItem(KFileItem *i)
The derived view must implement this function to add the file in the widget.
Definition: tdefileiconview.cpp:335
KFileIconView::ensureItemVisible
void ensureItemVisible(const KFileItem *)
pure virtual function, that should be implemented to make item i visible, i.e.
Definition: tdefileiconview.cpp:508
KFileIconView::isSelected
virtual bool isSelected(const KFileItem *i) const
Definition: tdefileiconview.cpp:429
KFileIconView::setCurrentItem
virtual void setCurrentItem(const KFileItem *)
Reimplement this to set item the current item in the view, e.g.
Definition: tdefileiconview.cpp:374
KFileIconView::clearView
virtual void clearView()
pure virtual function, that should be implemented to clear the view.
Definition: tdefileiconview.cpp:327
KFileIconView::listingCompleted
virtual void listingCompleted()
This hook is called when all items of the currently listed directory are listed and inserted into the...
Definition: tdefileiconview.cpp:719
KFileIconView::removeItem
virtual void removeItem(const KFileItem *)
Removes an item from the list; has to be implemented by the view.
Definition: tdefileiconview.cpp:466
KFileIconView::clearSelection
virtual void clearSelection()
Clears any selection, unhighlights everything.
Definition: tdefileiconview.cpp:317
KFileIconView::setSorting
virtual void setSorting(TQDir::SortSpec sort)
Sets the sorting order of the view.
Definition: tdefileiconview.cpp:677
KFileIconView::updateView
virtual void updateView(bool)
does a repaint of the view.
Definition: tdefileiconview.cpp:435
KFileIconView::currentFileItem
virtual KFileItem * currentFileItem() const
Definition: tdefileiconview.cpp:381
KFileIconView::selectAll
virtual void selectAll()
Selects all items.
Definition: tdefileiconview.cpp:308
KFileIconView::setSelected
virtual void setSelected(const KFileItem *, bool)
Tells the view that it should highlight the item.
Definition: tdefileiconview.cpp:301
KFileIconView::invertSelection
virtual void invertSelection()
Inverts the current selection, i.e.
Definition: tdefileiconview.cpp:322
KFileView
This class defines an interface to all file views.
Definition: tdefileview.h:97
KFileView::clearSelection
virtual void clearSelection()=0
Clears any selection, unhighlights everything.
KFileView::viewName
TQString viewName() const
Definition: tdefileview.h:233
KFileView::setViewName
void setViewName(const TQString &name)
Sets the name of the view, which could be displayed somewhere.
Definition: tdefileview.h:239
KFileView::insertItem
virtual void insertItem(KFileItem *i)
The derived view must implement this function to add the file in the widget.
Definition: tdefileview.cpp:147
KFileView::listingCompleted
virtual void listingCompleted()
This hook is called when all items of the currently listed directory are listed and inserted into the...
Definition: tdefileview.cpp:360
KFileView::setCurrentItem
void setCurrentItem(const TQString &filename)
Sets filename the current item in the view, if available.
Definition: tdefileview.cpp:268
KFileView::sorting
TQDir::SortSpec sorting() const
Returns the sorting order of the internal list.
Definition: tdefileview.h:176
KFileView::currentFileItem
virtual KFileItem * currentFileItem() const =0
KFileView::updateView
virtual void updateView(bool f=true)
does a repaint of the view.
Definition: tdefileview.cpp:259
KFileView::setDropOptions
void setDropOptions(int options)
Specify DND options.
Definition: tdefileview.cpp:397
KFileView::widget
virtual TQWidget * widget()=0
a pure virtual function to get a TQWidget, that can be added to other widgets.
KFileView::updateNumbers
bool updateNumbers(const KFileItem *i)
increases the number of dirs and files.
Definition: tdefileview.cpp:110
KFileView::dropOptions
int dropOptions()
Returns the DND options in effect.
Definition: tdefileview.cpp:407
KFileView::removeItem
virtual void removeItem(const KFileItem *item)
Removes an item from the list; has to be implemented by the view.
Definition: tdefileview.cpp:346
KFileView::ensureItemVisible
virtual void ensureItemVisible(const KFileItem *i)=0
pure virtual function, that should be implemented to make item i visible, i.e.
KFileView::setSorting
virtual void setSorting(TQDir::SortSpec sort)
Sets the sorting order of the view.
Definition: tdefileview.cpp:151
KFileView::actionCollection
virtual TDEActionCollection * actionCollection() const
Definition: tdefileview.cpp:365
KFileView::clear
virtual void clear()
Clears the view and all item lists.
Definition: tdefileview.cpp:156
KFileView::selectAll
virtual void selectAll()
Selects all items.
Definition: tdefileview.cpp:312
KFileView::setSelected
virtual void setSelected(const KFileItem *, bool enable)=0
Tells the view that it should highlight the item.
KFileView::isSelected
virtual bool isSelected(const KFileItem *) const =0
KFileView::clearView
virtual void clearView()=0
pure virtual function, that should be implemented to clear the view.
KFileView::invertSelection
virtual void invertSelection()
Inverts the current selection, i.e.
Definition: tdefileview.cpp:323

tdeio/tdefile

Skip menu "tdeio/tdefile"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeio/tdefile

Skip menu "tdeio/tdefile"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/tdefile by doxygen 1.9.4
This website is maintained by Timothy Pearson.