• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kio/kfile
 

kio/kfile

  • kio
  • kfile
kfilepreview.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  2000 Werner Trobin <wtrobin@carinthia.com>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 #include <kaction.h>
23 #include <kfilepreview.h>
24 #include <kfilepreview.moc>
25 #include <klocale.h>
26 
27 #include <tqlabel.h>
28 
29 #include "config-kfile.h"
30 
31 KFilePreview::KFilePreview(KFileView *view, TQWidget *parent, const char *name)
32  : TQSplitter(parent, name), KFileView()
33 {
34  if ( view )
35  init( view );
36  else
37  init( new KFileIconView( (TQSplitter*) this, "left" ));
38 }
39 
40 
41 KFilePreview::KFilePreview(TQWidget *parent, const char *name) :
42  TQSplitter(parent, name), KFileView()
43 {
44  init( new KFileIconView((TQSplitter*)this, "left") );
45 }
46 
47 KFilePreview::~KFilePreview()
48 {
49  // Why copy the actions in the first place? --ellis, 13 Jan 02.
51  //for ( uint i = 0; i < left->actionCollection()->count(); i++ )
52  // actionCollection()->take( left->actionCollection()->action( i ));
53 
54  // don't delete the preview, we can reuse it
55  // (it will get deleted by ~KDirOperator)
56  if ( preview && preview->parentWidget() == this ) {
57  preview->reparent(0L, 0, TQPoint(0, 0), false);
58  }
59 }
60 
61 void KFilePreview::init( KFileView *view )
62 {
63  setViewName( i18n("Preview") );
64 
65  left = 0L;
66  setFileView( view );
67 
68  preview = new TQWidget((TQSplitter*)this, "preview");
69  TQString tmp = i18n("No preview available.");
70  TQLabel *l = new TQLabel(tmp, preview);
71  l->setMinimumSize(l->sizeHint());
72  l->move(10, 5);
73  preview->setMinimumWidth(l->sizeHint().width()+20);
74  setResizeMode(preview, TQSplitter::KeepSize);
75 
76  // Why copy the actions? --ellis, 13 Jan 02.
77  //for ( uint i = 0; i < view->actionCollection()->count(); i++ )
78  // actionCollection()->insert( view->actionCollection()->action( i ));
79 }
80 
81 void KFilePreview::setFileView( KFileView *view )
82 {
83  Q_ASSERT( view );
84 
85  // Why copy the actions? --ellis, 13 Jan 02.
86  //if ( left ) { // remove any previous actions
87  // for ( uint i = 0; i < left->actionCollection()->count(); i++ )
88  // actionCollection()->take( left->actionCollection()->action( i ));
89  //}
90 
91  delete left;
92  view->widget()->reparent( this, TQPoint(0,0) );
93  view->KFileView::setViewMode(All);
94  view->setParentView(this);
95  view->setSorting( sorting() );
96  left = view;
97 
98  connect( left->signaler(), TQT_SIGNAL( fileHighlighted(const KFileItem*) ),
99  TQT_SLOT( slotHighlighted( const KFileItem * )));
100 
101  // Why copy the actions? --ellis, 13 Jan 02.
102  //for ( uint i = 0; i < view->actionCollection()->count(); i++ )
103  // actionCollection()->insert( view->actionCollection()->action( i ));
104 }
105 
106 // this url parameter is useless... it's the url of the current directory.
107 // what for?
108 void KFilePreview::setPreviewWidget(const TQWidget *w, const KURL &)
109 {
110  left->setOnlyDoubleClickSelectsFiles( onlyDoubleClickSelectsFiles() );
111 
112  if (w) {
113  connect(this, TQT_SIGNAL( showPreview(const KURL &) ),
114  w, TQT_SLOT( showPreview(const KURL &) ));
115  connect( this, TQT_SIGNAL( clearPreview() ),
116  w, TQT_SLOT( clearPreview() ));
117  }
118  else {
119  preview->hide();
120  return;
121  }
122 
123  delete preview;
124  preview = const_cast<TQWidget*>(w);
125  preview->reparent((TQSplitter*)this, 0, TQPoint(0, 0), true);
126  preview->resize(preview->sizeHint());
127  preview->show();
128 }
129 
130 void KFilePreview::insertItem(KFileItem *item)
131 {
132  KFileView::insertItem( item );
133  left->insertItem(item);
134 }
135 
136 void KFilePreview::setSorting( TQDir::SortSpec sort )
137 {
138  left->setSorting( sort );
139  KFileView::setSorting( left->sorting() );
140 }
141 
142 void KFilePreview::clearView()
143 {
144  left->clearView();
145  emit clearPreview();
146 }
147 
148 void KFilePreview::updateView(bool b)
149 {
150  left->updateView(b);
151  if(preview)
152  preview->repaint(b);
153 }
154 
155 void KFilePreview::updateView(const KFileItem *i)
156 {
157  left->updateView(i);
158 }
159 
160 void KFilePreview::removeItem(const KFileItem *i)
161 {
162  if ( left->isSelected( i ) )
163  emit clearPreview();
164 
165  left->removeItem(i);
166  KFileView::removeItem( i );
167 }
168 
169 void KFilePreview::listingCompleted()
170 {
171  left->listingCompleted();
172 }
173 
174 void KFilePreview::clear()
175 {
176  KFileView::clear();
177  left->KFileView::clear();
178 }
179 
180 void KFilePreview::clearSelection()
181 {
182  left->clearSelection();
183  emit clearPreview();
184 }
185 
186 void KFilePreview::selectAll()
187 {
188  left->selectAll();
189 }
190 
191 void KFilePreview::invertSelection()
192 {
193  left->invertSelection();
194 }
195 
196 bool KFilePreview::isSelected( const KFileItem *i ) const
197 {
198  return left->isSelected( i );
199 }
200 
201 void KFilePreview::setSelectionMode(KFile::SelectionMode sm) {
202  left->setSelectionMode( sm );
203 }
204 
205 void KFilePreview::setSelected(const KFileItem *item, bool enable) {
206  left->setSelected( item, enable );
207 }
208 
209 void KFilePreview::setCurrentItem( const KFileItem *item )
210 {
211  left->setCurrentItem( item );
212 }
213 
214 KFileItem * KFilePreview::currentFileItem() const
215 {
216  return left->currentFileItem();
217 }
218 
219 void KFilePreview::slotHighlighted(const KFileItem* item)
220 {
221  if ( item )
222  emit showPreview( item->url() );
223 
224  else { // item = 0 -> multiselection mode
225  const KFileItemList *items = selectedItems();
226  if ( items->count() == 1 )
227  emit showPreview( items->getFirst()->url() );
228  else
229  emit clearPreview();
230  }
231 
232  // the preview widget appears and takes some space of the left view,
233  // so we may have to scroll to make the current item visible
234  left->ensureItemVisible(item);
235  }
236 
237 void KFilePreview::ensureItemVisible(const KFileItem *item)
238 {
239  left->ensureItemVisible(item);
240 }
241 
242 KFileItem * KFilePreview::firstFileItem() const
243 {
244  return left->firstFileItem();
245 }
246 
247 KFileItem * KFilePreview::nextItem( const KFileItem *item ) const
248 {
249  return left->nextItem( item );
250 }
251 
252 KFileItem * KFilePreview::prevItem( const KFileItem *item ) const
253 {
254  return left->prevItem( item );
255 }
256 
257 KActionCollection * KFilePreview::actionCollection() const
258 {
259  if ( left )
260  return left->actionCollection();
261  else {
262  kdWarning() << "KFilePreview::actionCollection(): called before setFileView()." << endl; //ellis
263  return KFileView::actionCollection();
264  }
265 }
266 
267 void KFilePreview::readConfig( KConfig *config, const TQString& group )
268 {
269  left->readConfig( config, group );
270 }
271 
272 void KFilePreview::writeConfig( KConfig *config, const TQString& group )
273 {
274  left->writeConfig( config, group );
275 }
276 
277 void KFilePreview::virtual_hook( int id, void* data )
278 { KFileView::virtual_hook( id, data ); }
279 
KFilePreview::isSelected
virtual bool isSelected(const KFileItem *) const
Definition: kfilepreview.cpp:196
KFileView::insertItem
virtual void insertItem(KFileItem *i)
The derived view must implement this function to add the file in the widget.
Definition: kfileview.cpp:147
KFileView::actionCollection
virtual KActionCollection * actionCollection() const
Definition: kfileview.cpp:365
KFilePreview::clearSelection
virtual void clearSelection()
Clears any selection, unhighlights everything.
Definition: kfilepreview.cpp:180
KFilePreview::listingCompleted
virtual void listingCompleted()
This hook is called when all items of the currently listed directory are listed and inserted into the...
Definition: kfilepreview.cpp:169
KFileView
This class defines an interface to all file views.
Definition: kfileview.h:98
KFilePreview::clearView
virtual void clearView()
pure virtual function, that should be implemented to clear the view.
Definition: kfilepreview.cpp:142
KFileView::clear
virtual void clear()
Clears the view and all item lists.
Definition: kfileview.cpp:156
KFilePreview::insertItem
virtual void insertItem(KFileItem *)
The derived view must implement this function to add the file in the widget.
Definition: kfilepreview.cpp:130
KFilePreview::clear
virtual void clear()
Clears the view and all item lists.
Definition: kfilepreview.cpp:174
KFilePreview::removeItem
virtual void removeItem(const KFileItem *)
Removes an item from the list; has to be implemented by the view.
Definition: kfilepreview.cpp:160
KFilePreview::updateView
virtual void updateView(bool)
does a repaint of the view.
Definition: kfilepreview.cpp:148
KFilePreview::selectAll
virtual void selectAll()
Selects all items.
Definition: kfilepreview.cpp:186
KFilePreview::ensureItemVisible
void ensureItemVisible(const KFileItem *)
pure virtual function, that should be implemented to make item i visible, i.e.
Definition: kfilepreview.cpp:237
KFilePreview::setCurrentItem
virtual void setCurrentItem(const KFileItem *)
Reimplement this to set item the current item in the view, e.g.
Definition: kfilepreview.cpp:209
KFileView::widget
virtual TQWidget * widget()=0
a pure virtual function to get a TQWidget, that can be added to other widgets.
KFilePreview::setSelected
virtual void setSelected(const KFileItem *, bool)
Tells the view that it should highlight the item.
Definition: kfilepreview.cpp:205
KFileView::removeItem
virtual void removeItem(const KFileItem *item)
Removes an item from the list; has to be implemented by the view.
Definition: kfileview.cpp:346
KFilePreview::currentFileItem
virtual KFileItem * currentFileItem() const
Definition: kfilepreview.cpp:214
KFilePreview::setSorting
virtual void setSorting(TQDir::SortSpec sort)
Sets the sorting order of the view.
Definition: kfilepreview.cpp:136
KFileView::setSorting
virtual void setSorting(TQDir::SortSpec sort)
Sets the sorting order of the view.
Definition: kfileview.cpp:151
KFilePreview::invertSelection
virtual void invertSelection()
Inverts the current selection, i.e.
Definition: kfilepreview.cpp:191
KFileIconView
An icon-view capable of showing KFileItem&#39;s.
Definition: kfileiconview.h:83
KFilePreview::actionCollection
virtual KActionCollection * actionCollection() const
This overrides KFileView::actionCollection() by returning the actionCollection() of the KFileView (me...
Definition: kfilepreview.cpp:257
KFilePreview::setFileView
void setFileView(KFileView *view)
Delets the current view and sets the view to the given view.
Definition: kfilepreview.cpp:81

kio/kfile

Skip menu "kio/kfile"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kio/kfile

Skip menu "kio/kfile"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kio/kfile by doxygen 1.8.11
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |