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 / kencodingfiledialog.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  13.0 KB  |  314 lines

  1. // -*- c++ -*-
  2. /* This file is part of the KDE libraries
  3.     Copyright (C) 2003 Joseph Wenninger <jowenn@kde.org>
  4.           2003 Andras Mantia <amantia@freemail.hu>
  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. #ifndef __KENCODINGFILEDIALOG_H__
  23. #define __KENCODINGFILEDIALOG_H__
  24.  
  25. #include <kfiledialog.h>
  26.  
  27. struct KEncodingFileDialogPrivate;
  28.  
  29. /**
  30.  * Provides a user (and developer) friendly way to
  31.  * select files with support for choosing encoding
  32.  *
  33.  *
  34.  * The dialog has been designed to allow applications to customise it
  35.  * by subclassing. It uses geometry management to ensure that subclasses
  36.  * can easily add children that will be incorporated into the layout.
  37.  */
  38.  
  39. class KIO_EXPORT KEncodingFileDialog : public KFileDialog
  40. {
  41.     Q_OBJECT
  42.  
  43. public:
  44.     class Result {
  45.     public:
  46.         QStringList fileNames;
  47.         KURL::List  URLs;
  48.         QString encoding;
  49.     };
  50.  
  51.     /**
  52.       * Constructs a file dialog for text files with encoding selection possibility.
  53.       *
  54.       * @param startDir This can either be
  55.       *         @li The URL of the directory to start in.
  56.       *         @li QString::null to start in the current working
  57.       *            directory, or the last directory where a file has been
  58.       *            selected.
  59.       *         @li ':<keyword>' to start in the directory last used
  60.       *             by a filedialog in the same application that specified
  61.       *             the same keyword.
  62.       *         @li '::<keyword>' to start in the directory last used
  63.       *             by a filedialog in any application that specified the
  64.       *             same keyword.
  65.       *
  66.       * @param encoding The encoding shown in the encoding combo. If it's
  67.       *            QString::null, the global default encoding will be shown.
  68.       *
  69.       * @param filter This is a space separated list of shell globs.
  70.       *             You can set the text to be displayed for the glob, and
  71.       *             provide multiple globs.  See setFilter() for details on
  72.       *             how to do this...
  73.       *
  74.       * @param caption The caption of the dialog
  75.       *
  76.       * @param type This can either be
  77.       *        @li Opening (open dialog, the default setting)
  78.       *        @li Saving
  79.       * @param parent The parent widget of this dialog
  80.       * @param name The name of this object
  81.       * @param modal Whether to create a modal dialog or not
  82.       *
  83.       * @since 3.2
  84.       */
  85.     KEncodingFileDialog (const QString& startDir = QString::null,
  86.                     const QString& encoding = QString::null,
  87.             const QString& filter = QString::null,
  88.             const QString& caption = QString::null, KFileDialog::OperationMode type = KFileDialog::Opening,
  89.                     QWidget *parent= 0, const char *name="", bool modal = true);
  90.     /**
  91.      * Destructs the file dialog.
  92.      */
  93.     ~KEncodingFileDialog();
  94.  
  95.  
  96.     /**
  97.     * @returns The selected encoding if the constructor with the encoding parameter was used, otherwise QString::null.
  98.     */
  99.     QString selectedEncoding() const;
  100.  
  101.  
  102.     /**
  103.      * Creates a modal file dialog and return the selected
  104.      * filename or an empty string if none was chosen additionally a chosen
  105.      * encoding value is returned.
  106.      *
  107.      * Note that with
  108.      * this method the user must select an existing filename.
  109.      *
  110.      * @param startDir This can either be
  111.      *         @li The URL of the directory to start in.
  112.      *         @li QString::null to start in the current working
  113.      *            directory, or the last directory where a file has been
  114.      *            selected.
  115.      *         @li ':<keyword>' to start in the directory last used
  116.      *             by a filedialog in the same application that specified
  117.      *             the same keyword.
  118.      *         @li '::<keyword>' to start in the directory last used
  119.      *             by a filedialog in any application that specified the
  120.      *             same keyword.
  121.      * @param encoding The encoding shown in the encoding combo.
  122.      * @param filter This is a space separated list of shell globs.
  123.      * You can set the text to be displayed for the glob, and
  124.      * provide multiple globs.  See setFilter() for details on
  125.      * how to do this...
  126.      * @param parent The widget the dialog will be centered on initially.
  127.      * @param caption The name of the dialog widget.
  128.      */
  129.     static Result getOpenFileNameAndEncoding(const QString& encoding=QString::null,
  130.                       const QString& startDir= QString::null,
  131.                    const QString& filter= QString::null,
  132.                    QWidget *parent= 0,
  133.                    const QString& caption = QString::null);
  134.  
  135.     /**
  136.      * Creates a modal file dialog and returns the selected encoding and the selected
  137.      * filenames or an empty list if none was chosen.
  138.      *
  139.      * Note that with
  140.      * this method the user must select an existing filename.
  141.      *
  142.      * @param startDir This can either be
  143.      *         @li The URL of the directory to start in.
  144.      *         @li QString::null to start in the current working
  145.      *            directory, or the last directory where a file has been
  146.      *            selected.
  147.      *         @li ':<keyword>' to start in the directory last used
  148.      *             by a filedialog in the same application that specified
  149.      *             the same keyword.
  150.      *         @li '::<keyword>' to start in the directory last used
  151.      *             by a filedialog in any application that specified the
  152.      *             same keyword.
  153.      * @param encoding The encoding shown in the encoding combo.
  154.      * @param filter This is a space separated list of shell globs.
  155.      * You can set the text to be displayed for the glob, and
  156.      * provide multiple globs.  See setFilter() for details on
  157.      * how to do this.
  158.      * @param parent The widget the dialog will be centered on initially.
  159.      * @param caption The name of the dialog widget.
  160.      */
  161.     static Result getOpenFileNamesAndEncoding(const QString& encoding=QString::null,
  162.                     const QString& startDir= QString::null,
  163.                     const QString& filter= QString::null,
  164.                     QWidget *parent = 0,
  165.                     const QString& caption= QString::null);
  166.  
  167.     /**
  168.      * Creates a modal file dialog and returns the selected encoding and
  169.      * URL or an empty string if none was chosen.
  170.      *
  171.      * Note that with
  172.      * this method the user must select an existing URL.
  173.      *
  174.      * @param startDir This can either be
  175.      *         @li The URL of the directory to start in.
  176.      *         @li QString::null to start in the current working
  177.      *            directory, or the last directory where a file has been
  178.      *            selected.
  179.      *         @li ':<keyword>' to start in the directory last used
  180.      *             by a filedialog in the same application that specified
  181.      *             the same keyword.
  182.      *         @li '::<keyword>' to start in the directory last used
  183.      *             by a filedialog in any application that specified the
  184.      *             same keyword.
  185.      * @param encoding The encoding shown in the encoding combo.
  186.      * @param filter This is a space separated list of shell globs.
  187.      * You can set the text to be displayed for the glob, and
  188.      * provide multiple globs.  See setFilter() for details on
  189.      * how to do this...
  190.      * @param parent The widget the dialog will be centered on initially.
  191.      * @param caption The name of the dialog widget.
  192.      */
  193.     static Result getOpenURLAndEncoding(const QString& encoding=QString::null,
  194.                const QString& startDir = QString::null,
  195.                const QString& filter= QString::null,
  196.                QWidget *parent= 0,
  197.                const QString& caption = QString::null);
  198.  
  199.  
  200.  
  201.  
  202.     /**
  203.      * Creates a modal file dialog and returns the selected encoding
  204.      * URLs or an empty list if none was chosen.
  205.      *
  206.      * Note that with
  207.      * this method the user must select an existing filename.
  208.      *
  209.      * @param startDir This can either be
  210.      *         @li The URL of the directory to start in.
  211.      *         @li QString::null to start in the current working
  212.      *            directory, or the last directory where a file has been
  213.      *            selected.
  214.      *         @li ':<keyword>' to start in the directory last used
  215.      *             by a filedialog in the same application that specified
  216.      *             the same keyword.
  217.      *         @li '::<keyword>' to start in the directory last used
  218.      *             by a filedialog in any application that specified the
  219.      *             same keyword.
  220.      * @param encoding The encoding shown in the encoding combo.
  221.      * @param filter This is a space separated list of shell globs.
  222.      * You can set the text to be displayed for the glob, and
  223.      * provide multiple globs.  See setFilter() for details on
  224.      * how to do this...
  225.      * @param parent The widget the dialog will be centered on initially.
  226.      * @param caption The name of the dialog widget.
  227.      */
  228.     static Result getOpenURLsAndEncoding(const QString& encoding=QString::null,
  229.                   const QString& startDir= QString::null,
  230.                   const QString& filter= QString::null,
  231.                   QWidget *parent = 0,
  232.                   const QString& caption= QString::null);
  233.  
  234.  
  235.  
  236.     /**
  237.      * Creates a modal file dialog and returns the selected encoding and
  238.      * filename or an empty string if none was chosen.
  239.      *
  240.      * Note that with this
  241.      * method the user need not select an existing filename.
  242.      *
  243.      * @param startDir This can either be
  244.      *         @li The URL of the directory to start in.
  245.      *         @li a relative path or a filename determining the
  246.      *             directory to start in and the file to be selected.
  247.      *         @li QString::null to start in the current working
  248.      *            directory, or the last directory where a file has been
  249.      *            selected.
  250.      *         @li ':<keyword>' to start in the directory last used
  251.      *             by a filedialog in the same application that specified
  252.      *             the same keyword.
  253.      *         @li '::<keyword>' to start in the directory last used
  254.      *             by a filedialog in any application that specified the
  255.      *             same keyword.
  256.      * @param encoding The encoding shown in the encoding combo.
  257.      * @param filter This is a space separated list of shell globs.
  258.      * You can set the text to be displayed for the glob, and
  259.      * provide multiple globs.  See setFilter() for details on
  260.      * how to do this...
  261.      * @param parent The widget the dialog will be centered on initially.
  262.      * @param caption The name of the dialog widget.
  263.      */
  264.     static Result getSaveFileNameAndEncoding(const QString& encoding=QString::null,
  265.                    const QString& startDir=QString::null,
  266.                    const QString& filter= QString::null,
  267.                    QWidget *parent= 0,
  268.                    const QString& caption = QString::null);
  269.  
  270.  
  271.     /**
  272.      * Creates a modal file dialog and returns the selected encoding and
  273.      * filename or an empty string if none was chosen.
  274.      *
  275.      * Note that with this
  276.      * method the user need not select an existing filename.
  277.      *
  278.      * @param startDir This can either be
  279.      *         @li The URL of the directory to start in.
  280.      *         @li a relative path or a filename determining the
  281.      *             directory to start in and the file to be selected.
  282.      *         @li QString::null to start in the current working
  283.      *            directory, or the last directory where a file has been
  284.      *            selected.
  285.      *         @li ':<keyword>' to start in the directory last used
  286.      *             by a filedialog in the same application that specified
  287.      *             the same keyword.
  288.      *         @li '::<keyword>' to start in the directory last used
  289.      *             by a filedialog in any application that specified the
  290.      *             same keyword.
  291.      * @param encoding The encoding shown in the encoding combo.
  292.      * @param filter This is a space separated list of shell globs.
  293.      * You can set the text to be displayed for the glob, and
  294.      * provide multiple globs.  See setFilter() for details on
  295.      * how to do this...
  296.      * @param parent The widget the dialog will be centered on initially.
  297.      * @param caption The name of the dialog widget.
  298.      */
  299.     static Result getSaveURLAndEncoding(const QString& encoding=QString::null,
  300.                const QString& startDir= QString::null,
  301.                const QString& filter= QString::null,
  302.                QWidget *parent= 0,
  303.                const QString& caption = QString::null);
  304.  
  305.  
  306.  
  307. protected:
  308.     virtual void virtual_hook( int id, void* data );
  309. private:
  310.     KEncodingFileDialogPrivate *d;
  311. };
  312.  
  313. #endif
  314.