summaryrefslogtreecommitdiffstats
path: root/konqueror/listview/konq_listview.h
blob: 7c1b27f16912c3255184be51cd9d1d2b14598c9c (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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/* This file is part of the KDE project
   Copyright (C) 1998, 1999 Torben Weis <weis@kde.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.

   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; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#ifndef __konq_listview_h__
#define __konq_listview_h__

#include <tdeparts/browserextension.h>
#include <tdeglobalsettings.h>
#include <konq_operations.h>
#include <tdeparts/factory.h>
#include <konq_dirpart.h>
#include <kmimetyperesolver.h>

#include <tqvaluelist.h>
#include <tqlistview.h>
#include <tqstringlist.h>

#include <konq_propsview.h>
#include "konq_listviewwidget.h"

class TDEAction;
class TDEToggleAction;
class ListViewBrowserExtension;

class KonqListViewFactory : public KParts::Factory
{
public:
  KonqListViewFactory();
  virtual ~KonqListViewFactory();

  virtual KParts::Part* createPartObject( TQWidget *parentWidget, const char *, TQObject *parent, const char *name, const char*, const TQStringList &args );

  static TDEInstance *instance();
  static KonqPropsView *defaultViewProps();

private:
  static TDEInstance *s_instance;
  static KonqPropsView *s_defaultViewProps;
};

/**
 * The part for the tree view. It does quite nothing, just the
 * konqueror interface. Most of the functionality is in the
 * widget, KonqListViewWidget.
 */
class KonqListView : public KonqDirPart
{
  friend class KonqBaseListViewWidget;
  friend class ListViewBrowserExtension;
  Q_OBJECT
  TQ_PROPERTY( bool supportsUndo READ supportsUndo )
public:
  KonqListView( TQWidget *parentWidget, TQObject *parent, const char *name, const TQString& mode );
  virtual ~KonqListView();

  virtual const KFileItem * currentItem();
  virtual KFileItemList selectedFileItems() {return m_pListView->selectedFileItems();};

  KonqBaseListViewWidget *listViewWidget() const { return m_pListView; }

  bool supportsUndo() const { return true; }

  virtual void saveState( TQDataStream &stream );
  virtual void restoreState( TQDataStream &stream );

  // "Cut" icons : disable those whose URL is in lst, enable the others
  virtual void disableIcons( const KURL::List & lst );

  // See KMimeTypeResolver
  void mimeTypeDeterminationFinished() {}
  //int iconSize() { return m_pListView->iconSize(); }
  void determineIcon( KonqBaseListViewItem * item );

  TQPtrList<KonqBaseListViewItem> & lstPendingMimeIconItems() { return m_mimeTypeResolver->m_lstPendingMimeIconItems; }
  void listingComplete();

  virtual void newIconSize( int );

protected:
  virtual bool doOpenURL( const KURL &url );
  virtual bool doCloseURL();
  virtual bool openFile() { return true; }

  void setupActions();
  void guiActivateEvent( KParts::GUIActivateEvent *event );

protected slots:
  void slotSelect();
  void slotUnselect();
  void slotSelectAll();
  void slotUnselectAll();
  void slotInvertSelection();
  void slotCaseInsensitive();
  void slotSelectionChanged();

  void slotShowDot();
  //this is called if a item in the submenu is toggled
  //it saves the new configuration according to the menu items
  //and calls createColumns()
  //it adjusts the indece of the remaining columns
  void slotColumnToggled();
  //this is called when the user changes the order of the
  //columns by dragging them
  //at this moment the columns haven't changed their order yet, so
  //it starts a singleshottimer, after which the columns changed their order
  //and then slotSaveAfterHeaderDrag is called
  void headerDragged(int sec, int from, int to);
  //saves the new order of the columns
  void slotSaveAfterHeaderDrag();
  // column width changed
  void slotHeaderSizeChanged();
  void slotSaveColumnWidths();  // delayed
  void slotHeaderClicked(int sec);

  //--------------------------------------------------------------------
  //--- Begin: listview sorting enhancements
  //--------------------------------------------------------------------
  void slot_Toggle_Display_Directories_1st() ;
  void slot_Toggle_Display_Hidden_1st() ;
  void slot_Toggle_Sort_DictionaryOrder() ;
  void slotSortAlternate() ;
  void slotSortReverse() ;
  //--------------------------------------------------------------------
  //--- End: listview sorting enhancements
  //--------------------------------------------------------------------

  // This comes from KonqDirPart, it's for the "Find" feature
  virtual void slotStarted() { m_pListView->slotStarted(); }
  virtual void slotCanceled() { m_pListView->slotCanceled(); }
  virtual void slotCompleted() { m_pListView->slotCompleted(); }
  virtual void slotNewItems( const KFileItemList& lst ) { m_pListView->slotNewItems( lst ); }
  virtual void slotDeleteItem( KFileItem * item ) { m_pListView->slotDeleteItem( item ); }
  virtual void slotRefreshItems( const KFileItemList& lst ) { m_pListView->slotRefreshItems( lst ); }
  virtual void slotClear() { m_pListView->slotClear(); }
  virtual void slotRedirection( const KURL & u ) { m_pListView->slotRedirection( u ); }

  // Connected to KonqDirPart
  void slotKFindOpened();
  void slotKFindClosed();

private:

  KonqBaseListViewWidget *m_pListView;
  KMimeTypeResolver<KonqBaseListViewItem,KonqListView> *m_mimeTypeResolver;
  TQTimer *m_headerTimer;

  TDEAction *m_paSelect;
  TDEAction *m_paUnselect;
  TDEAction *m_paSelectAll;
  TDEAction *m_paUnselectAll;
  TDEAction *m_paInvertSelection;

  //--------------------------------------------------------------------
  //--- Begin: listview sorting enhancements I
  //--------------------------------------------------------------------

  // User action-response handlers
  TDEAction *m_paSortAlternate; // triggers slotSortAlternate()
  TDEAction *m_paSortReverse;   // triggers slotSortReverse()

  // Variables utilized in SortListView()
  TQString SortColumnName_Primary  = "FileName" ; // by definition
  int      SortColumnIndex_Primary = 0          ; // always!
  TQString SortColumnName_Alternate       ; // reset in slotHeaderClicked()
  int      SortColumnIndex_Alternate = 1  ; // reset in slotHeaderClicked()

  // Specialized sorting functions
  void SortListView(uint which); // called by slotSort*()
  TQString DisplayColumn_Name( int DisplayColumn_Offset) ;

  //--------------------------------------------------------------------
  //--- Begin: listview sorting enhancements II
  //--------------------------------------------------------------------

  // User action-response handlers

  TDEToggleAction *m_paDisplay_Directories_1st;
    // triggers slot_Toggle_Display_Directories_1st()
  TDEToggleAction *m_paDisplay_Hidden_1st;
    // triggers slot_Toggle_Display_Hidden_1st()
  TDEToggleAction *m_pa_Sort_DictionaryOrder;
    // triggers slot_Toggle_Sort_DictionaryOrder()

  // Variables toggled by slot_Toggle_*()

  /*
   * Original TDE default affecting course sort groupings:
   *   .dir_hidden < dir < .file_hidden < file
   * The following variables allow user control over these groupings:
   */
  bool Display_Directories_1st = true ; // Start with original TDE behavior
  bool Display_Hidden_1st      = true ; // Start with original TDE behavior

  /*
   * Should we ignore leading special characters when sorting?
   * Gnu coreutils sort calls this "dictionary order".
   * FIXME: TO BE IMPLEMENTED
   */
  bool Sort_Dictionary_Order   = false ; // Start with original TDE behavior

  // Above variables are utilized in these functions:

  friend void KonqListViewItem::updateContents();
  friend int  KonqBaseListViewItem::compare( TQListViewItem* item, int col, bool ascending ) const;

  //--------------------------------------------------------------------
  //--- End: listview sorting enhancements
  //--------------------------------------------------------------------

  // These 2 actions are 'fake' actions. They are defined so that the keyboard shortcuts
  // can be set from the 'Configure Shortcuts..." dialog.
  // The real actions are performed in the TDEListViewLineEdit::keyPressEvent() in tdeui
  TDEAction *m_paRenameMoveNext;
  TDEAction *m_paRenameMovePrev;

  TDEToggleAction *m_paCaseInsensitive;

  TDEToggleAction *m_paShowDot;
  TDEToggleAction *m_paShowTime;
  TDEToggleAction *m_paShowType;
  TDEToggleAction *m_paShowMimeType;
  TDEToggleAction *m_paShowAccessTime;
  TDEToggleAction *m_paShowCreateTime;
  TDEToggleAction *m_paShowLinkDest;
  TDEToggleAction *m_paShowSize;
  TDEToggleAction *m_paShowOwner;
  TDEToggleAction *m_paShowGroup;
  TDEToggleAction *m_paShowPermissions;
  TDEToggleAction *m_paShowURL;
};

class ListViewBrowserExtension : public KonqDirPartBrowserExtension
{
   Q_OBJECT
   friend class KonqListView;
   friend class KonqBaseListViewWidget;
   public:
      ListViewBrowserExtension( KonqListView *listView );

      virtual int xOffset();
      virtual int yOffset();

   protected slots:
      void updateActions();

      void copy() { copySelection( false ); }
      void cut() { copySelection( true ); }
      void paste();
      void pasteTo( const KURL & );
      void rename();
      void trash();
      void del() { KonqOperations::del(m_listView->listViewWidget(),
                                       KonqOperations::DEL,
                                       m_listView->listViewWidget()->selectedUrls()); }

      void reparseConfiguration();
      void setSaveViewPropertiesLocally( bool value );
      void setNameFilter( const TQString &nameFilter );
      // void refreshMimeTypes is missing

      void properties();
      void editMimeType();

   private:
      void copySelection( bool move );

      KonqListView *m_listView;
};

#endif