konq_propsview.h

00001 /*  This file is part of the KDE project
00002     Copyright (C) 1997 David Faure <faure@kde.org>
00003 
00004     This program is free software; you can redistribute it and/or modify
00005     it under the terms of the GNU General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or
00007     (at your option) any later version.
00008 
00009     This program is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012     GNU General Public License for more details.
00013 
00014     You should have received a copy of the GNU General Public License
00015     along with this program; if not, write to the Free Software
00016     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00017 
00018 */
00019 
00020 #ifndef __konq_viewprops_h__
00021 #define __konq_viewprops_h__
00022 
00023 #include <qpixmap.h>
00024 #include <qstringlist.h>
00025 
00026 #include <kurl.h>
00027 #include <libkonq_export.h>
00028 
00029 class KInstance;
00030 class KConfigBase;
00031 class KConfig;
00032 
00044 class LIBKONQ_EXPORT KonqPropsView
00045 {
00046 public:
00047 
00054   KonqPropsView( KInstance * instance, KonqPropsView * defaultProps /*= 0L*/ );
00055 
00057   virtual ~KonqPropsView();
00058 
00062   bool isDefaultProperties() const {
00063       // No parent -> we are the default properties
00064       return m_defaultProps == 0L;
00065   }
00066 
00074   bool enterDir( const KURL & dir );
00075 
00080   void setSaveViewPropertiesLocally( bool value );
00081 
00083 
00084   void setIconSize( int size ); // in pixel, 0 for default
00085   int iconSize() const { return m_iIconSize; }
00086 
00087   void setItemTextPos( int pos ); // QIconView::Bottom or QIconView::Right, currently
00088   int itemTextPos() const { return m_iItemTextPos; }
00089 
00090   void setSortCriterion( const QString &criterion );
00091   const QString& sortCriterion() const;
00092 
00093   void setDirsFirst ( bool first );
00094   bool isDirsFirst() const;
00095 
00096   void setDescending (bool descending);
00097   bool isDescending() const;
00098 
00099   void setShowingDotFiles( bool show );
00100   bool isShowingDotFiles() const { return m_bShowDot; }
00101 
00102   void setCaseInsensitiveSort( bool show );
00103   bool isCaseInsensitiveSort() const;
00104 
00105   void setShowingDirectoryOverlays( bool show );
00106   bool isShowingDirectoryOverlays() const { return m_bShowDirectoryOverlays; }
00107 
00108   void setShowingPreview( const QString &preview, bool show );
00109   void setShowingPreview( bool show );
00110   bool isShowingPreview( const QString &preview ) const { return ! m_dontPreview.contains(preview); }
00111   bool isShowingPreview();
00112   const QStringList &previewSettings();
00113 
00114   void setBgColor( const QColor & color );
00115   const QColor& bgColor(QWidget * widget) const;
00116   void setTextColor( const QColor & color );
00117   const QColor& textColor(QWidget * widget) const;
00118   void setBgPixmapFile( const QString & file );
00119   const QString& bgPixmapFile() const { return m_bgPixmapFile; }
00120 
00121   // Applies bgcolor, textcolor, pixmap to the @p widget
00122   void applyColors( QWidget * widget ) const;
00123 
00124 protected:
00125 
00126   QPixmap loadPixmap() const;
00127 
00128   // Current config object for _saving_
00129   KConfigBase * currentConfig();
00130 
00131   // Current config object for _saving_ settings related to colors
00132   KConfigBase * currentColorConfig();
00133 
00134   QString currentGroup() const {
00135       return isDefaultProperties() ? 
00136           QString::fromLatin1("Settings") : QString::fromLatin1("URL properties");
00137   }
00138 
00139 private:
00140   // The actual properties
00141 
00142   int m_iIconSize;
00143   int m_iItemTextPos;
00144   bool m_bShowDot;
00145   bool m_bShowDirectoryOverlays;
00146   QStringList m_dontPreview;
00147   QColor m_textColor;
00148   QColor m_bgColor;
00149   QString m_bgPixmapFile;
00150 
00151   // Path to .directory file, whether it exists or not
00152   QString dotDirectory;
00153 
00154   bool m_bSaveViewPropertiesLocally;
00155 
00156   // True if we found a .directory file to read
00157   bool m_dotDirExists;
00158 
00159   // Points to the current .directory file if we are in
00160   // save-view-properties-locally mode, otherwise to the global config
00161   // It is set to 0L to mark it as "needs to be constructed".
00162   // This is to be used for SAVING only.
00163   // Can be a KConfig or a KSimpleConfig
00164   KConfigBase * m_currentConfig;
00165 
00166   // If this is not a "default properties" instance (but one used by a view)
00167   // then m_defaultProps points to the "default properties" instance
00168   // Otherwise it's 0L.
00169   KonqPropsView * m_defaultProps;
00170 
00175   struct Private;
00176 
00177   Private *d;
00178 
00179 private:
00180   KonqPropsView( const KonqPropsView & );
00181   KonqPropsView();
00182 };
00183 
00184 
00185 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys