summaryrefslogtreecommitdiffstats
path: root/libkonq/konq_propsview.h
blob: ae699f09ad0fedbeefd078442266ba4a0516325d (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
/*  This file is part of the KDE project
    Copyright (C) 1997 David Faure <faure@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; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

*/

#ifndef __konq_viewprops_h__
#define __konq_viewprops_h__

#include <tqpixmap.h>
#include <tqstringlist.h>

#include <kurl.h>
#include <libkonq_export.h>

#include "konq_sort_constants.h"

class TDEInstance;
class TDEConfigBase;
class TDEConfig;

/**
 * The class KonqPropsView holds the properties for a Konqueror View
 *
 * Separating them from the view class allows to store the default
 * values (the one read from \<kinstance\>rc) in one instance of this class
 * and to have another instance of this class in each view, storing the
 * current values of the view.
 *
 * The local values can be read from a desktop entry, if any (.directory,
 * bookmark, ...). [ .directory is implemented, bookmark isn't ].
 */
class LIBKONQ_EXPORT KonqPropsView
{
public:

  /**
   * Constructs a KonqPropsView instance from an instance config file.
   * defaultProps is a "parent" object. If non null, then this instance
   * is the one used by a view, and its value can differ from the default ones.
   * The instance parameter should be the same for both...
   */
  KonqPropsView( TDEInstance * instance, KonqPropsView * defaultProps /*= 0L*/ );

  /** Destructor */
  virtual ~KonqPropsView();

  /**
   * Is this the instance representing default properties ?
   */
  bool isDefaultProperties() const {
      // No parent -> we are the default properties
      return m_defaultProps == 0L;
  }

  /**
   * Called when entering a directory
   * Checks for a .directory, read it.
   * Don't do this on the default properties instance
   * Returns TRUE if the settings for the new directories are
   * different from the settings in the old directory.
   */
  bool enterDir( const KURL & dir );

  /**
   * Turn on/off saving properties locally
   * Don't do this on the default properties instance
   */
  void setSaveViewPropertiesLocally( bool value );

  ///

  void setIconSize( int size ); // in pixel, 0 for default
  int iconSize() const { return m_iIconSize; }

  void setItemTextPos( int pos ); // TQIconView::Bottom or TQIconView::Right, currently
  int itemTextPos() const { return m_iItemTextPos; }

  void setSortCriterion( const TQString &criterion );
  const TQString& sortCriterion() const;

  void setSortOrder( TextSortOrder order);
  TextSortOrder getSortOrder() const;

  void setDirsFirst ( bool first );
  bool isDirsFirst() const;

  void setHiddenFirst ( bool first );
  bool isHiddenFirst() const;

  void setDescending (bool descending);
  bool isDescending() const;

  void setHiddenFileSpec( const TQString &criteria );
  const TQString& hiddenFileSpec() const;

  void setShowingDotFiles( bool show );
  bool isShowingDotFiles() const { return m_bShowDot; }

  void setCaseInsensitiveSort( bool show );
  bool isCaseInsensitiveSort() const;

  void setShowingDirectoryOverlays( bool show );
  bool isShowingDirectoryOverlays() const { return m_bShowDirectoryOverlays; }

  void setShowingFreeSpaceOverlays( bool show );
  bool isShowingFreeSpaceOverlays() const { return m_bShowFreeSpaceOverlays; }

  void setShowingPreview( const TQString &preview, bool show );
  void setShowingPreview( bool show );
  bool isShowingPreview( const TQString &preview ) const { return ! m_dontPreview.contains(preview); }
  bool isShowingPreview();
  const TQStringList &previewSettings();

  void setBgColor( const TQColor & color );
  const TQColor& bgColor(TQWidget * widget) const;
  void setTextColor( const TQColor & color );
  const TQColor& textColor(TQWidget * widget) const;
  void setBgPixmapFile( const TQString & file );
  const TQString& bgPixmapFile() const { return m_bgPixmapFile; }

  // Applies bgcolor, textcolor, pixmap to the @p widget
  void applyColors( TQWidget * widget ) const;

protected:

  TQPixmap loadPixmap() const;

  // Current config object for _saving_
  TDEConfigBase * currentConfig();

  // Current config object for _saving_ settings related to colors
  TDEConfigBase * currentColorConfig();

  TQString currentGroup() const {
      return isDefaultProperties() ? 
          TQString::fromLatin1("Settings") : TQString::fromLatin1("URL properties");
  }

private:
  // The actual properties

  int m_iIconSize;
  int m_iItemTextPos;
  bool m_bShowDot;
  bool m_bShowDirectoryOverlays;
  bool m_bShowFreeSpaceOverlays;
  TQStringList m_dontPreview;
  TQColor m_textColor;
  TQColor m_bgColor;
  TQString m_bgPixmapFile;

  // Path to .directory file, whether it exists or not
  TQString dotDirectory;

  bool m_bSaveViewPropertiesLocally;

  // True if we found a .directory file to read
  bool m_dotDirExists;

  // Points to the current .directory file if we are in
  // save-view-properties-locally mode, otherwise to the global config
  // It is set to 0L to mark it as "needs to be constructed".
  // This is to be used for SAVING only.
  // Can be a TDEConfig or a KSimpleConfig
  TDEConfigBase * m_currentConfig;

  // If this is not a "default properties" instance (but one used by a view)
  // then m_defaultProps points to the "default properties" instance
  // Otherwise it's 0L.
  KonqPropsView * m_defaultProps;

  /**
   * Private data for KonqPropsView
   * Implementation in konq_propsview.cpp
   */
  struct Private;

  Private *d;

  /**
   *  FIXME
   *
   *  Why are some private class properties declared in the
   *  "Private" structure d in konq_propsview.cpp and not above?
   */

private:
  KonqPropsView( const KonqPropsView & );
  KonqPropsView();
};


#endif