home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kdirselectdialog.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  4.2 KB  |  132 lines

  1. /*
  2.   Copyright (C) 2001 Michael Jarrett <michaelj@corel.com>
  3.   Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org>
  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 version 2 as published by the Free Software Foundation.
  8.  
  9.   This library is distributed in the hope that it will be useful,
  10.   but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.   Library General Public License for more details.
  13.  
  14.   You should have received a copy of the GNU Library General Public License
  15.   along with this library; see the file COPYING.LIB.  If not, write to
  16.   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17.   Boston, MA 02110-1301, USA.
  18. */
  19.  
  20. #ifndef KDIRSELECTDIALOG_H
  21. #define KDIRSELECTDIALOG_H
  22.  
  23. #include <kdialogbase.h>
  24. #include <kurl.h>
  25.  
  26. class QPopupMenu;
  27. class QVBoxLayout;
  28. class KConfig;
  29. class KFileTreeBranch;
  30. class KFileTreeView;
  31. class KFileTreeViewItem;
  32. class KToggleAction;
  33.  
  34. /**
  35.  * A pretty dialog for a KDirSelect control for selecting directories.
  36.  * @author Michael Jarrett <michaelj@corel.com>
  37.  * @see KFileDialog
  38.  */
  39. class KIO_EXPORT KDirSelectDialog : public KDialogBase
  40. {
  41.     Q_OBJECT
  42.  
  43. public:
  44.     /**
  45.      * The constructor. Creates a dialog to select a directory (url).
  46.      * @internal use the static selectDirectory function
  47.      * @param startDir the directory, initially shown
  48.      * @param localOnly unused. You can only select paths below the startDir
  49.      * @param parent the parent for the dialog, usually 0L
  50.      * @param name the QObject::name
  51.      * @param modal if the dialog is modal or not
  52.      */
  53.     KDirSelectDialog(const QString& startDir = QString::null,
  54.                      bool localOnly = false,
  55.                      QWidget *parent = 0L,
  56.                      const char *name = 0, bool modal = false);
  57.  
  58.     /**
  59.      */
  60.     ~KDirSelectDialog();
  61.  
  62.     /**
  63.      * Returns the currently-selected URL, or a blank URL if none is selected.
  64.      * @return The currently-selected URL, if one was selected.
  65.      */
  66.     KURL url() const;
  67.  
  68.     KFileTreeView * view() const { return m_treeView; }
  69.  
  70.     bool localOnly() const { return m_localOnly; }
  71.  
  72.     /**
  73.      * Creates a KDirSelectDialog, and returns the result.
  74.      * @param startDir the directory, initially shown
  75.      * The tree will display this directory and subdirectories of it.
  76.      * @param localOnly unused. You can only select paths below the startDir
  77.      * @param parent the parent widget to use for the dialog, or NULL to create a parent-less dialog
  78.      * @param caption the caption to use for the dialog, or QString::null for the default caption
  79.      * @return The URL selected, or an empty URL if the user canceled
  80.      * or no URL was selected.
  81.      */
  82.     static KURL selectDirectory( const QString& startDir = QString::null,
  83.                                  bool localOnly = false, QWidget *parent = 0L,
  84.                                  const QString& caption = QString::null);
  85.  
  86.     /**
  87.      * @return The path for the root node
  88.      */
  89.     QString startDir() const { return m_startDir; }
  90.  
  91. public slots:
  92.     void setCurrentURL( const KURL& url );
  93.  
  94. protected slots:
  95.     virtual void slotUser1();
  96.  
  97. protected:
  98.     virtual void accept();
  99.  
  100.     // Layouts protected so that subclassing is easy
  101.     QVBoxLayout *m_mainLayout;
  102.     QString m_startDir;
  103.  
  104. private slots:
  105.     void slotCurrentChanged();
  106.     void slotURLActivated( const QString& );
  107.     void slotNextDirToList( KFileTreeViewItem *dirItem );
  108.     void slotComboTextChanged( const QString& text );
  109.     void slotContextMenu( KListView *, QListViewItem *, const QPoint & );
  110.     void slotShowHiddenFoldersToggled();
  111.     void slotMkdir();
  112.  
  113. private:
  114.     void readConfig( KConfig *config, const QString& group );
  115.     void saveConfig( KConfig *config, const QString& group );
  116.     void openNextDir( KFileTreeViewItem *parent );
  117.     KFileTreeBranch * createBranch( const KURL& url );
  118.  
  119.     KFileTreeView *m_treeView;
  120.     QPopupMenu *m_contextMenu;
  121.     KToggleAction *m_showHiddenFolders;
  122.     bool m_localOnly;
  123.  
  124. protected:
  125.     virtual void virtual_hook( int id, void* data );
  126. private:
  127.     class KDirSelectDialogPrivate;
  128.     KDirSelectDialogPrivate *d;
  129. };
  130.  
  131. #endif
  132.