knewmenu.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998-2000 David Faure <faure@kde.org>
00003                  2003      Sven Leiber <s.leiber@web.de>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License version 2 as published by the Free Software Foundation.
00008 
00009    This library 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 GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017    Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef __knewmenu_h
00021 #define __knewmenu_h
00022 
00023 #include <qintdict.h>
00024 #include <qstringlist.h>
00025 
00026 #include <kaction.h>
00027 #include <kdialogbase.h>
00028 #include <kurl.h>
00029 #include <libkonq_export.h>
00030 
00031 namespace KIO { class Job; }
00032 
00033 class KDirWatch;
00034 class KLineEdit;
00035 class KURLRequester;
00036 class QPopupMenu;
00037 
00052 class LIBKONQ_EXPORT KNewMenu : public KActionMenu
00053 {
00054   Q_OBJECT
00055 public:
00056 
00060     KNewMenu( KActionCollection * _collec, const char *name=0L );
00061     KNewMenu( KActionCollection * _collec, QWidget *parentWidget, const char *name=0L );
00062     virtual ~KNewMenu();
00063 
00068     void setPopupFiles(KURL::List & _files) {
00069         popupFiles = _files;
00070     }
00071     void setPopupFiles(const KURL & _file) {
00072         popupFiles.clear();
00073         popupFiles.append( _file );
00074     }
00075 
00076 public slots:
00081     void slotCheckUpToDate( );
00082 
00083 protected slots:
00087     void slotNewDir();
00088 
00092     void slotNewFile();
00093 
00097     void slotFillTemplates();
00098 
00099     void slotResult( KIO::Job * );
00100     // Special case (filename conflict when creating a link=url file)
00101     void slotRenamed( KIO::Job *, const KURL&, const KURL& );
00102 
00103 private:
00104 
00108     void fillMenu();
00109 
00114     void parseFiles();
00115 
00119     void makeMenus();
00120 
00128     enum { LINKTOTEMPLATE = 1, TEMPLATE, SEPARATOR };
00129 
00130     struct Entry {
00131         QString text;
00132         QString filePath; // empty for SEPARATOR
00133         QString templatePath; // same as filePath for TEMPLATE
00134         QString icon;
00135         int entryType;
00136         QString comment;
00137     };
00138     // NOTE: only filePath is known before we call parseFiles
00139 
00144     static QValueList<Entry> * s_templatesList;
00145 
00146     class KNewMenuPrivate;
00147     KNewMenuPrivate* d;
00148 
00154     static int s_templatesVersion;
00155 
00160     static bool s_filesParsed;
00161 
00162     int menuItemsVersion;
00163 
00168     KURL::List popupFiles;
00169 
00173     bool m_isURLDesktopFile;
00174     QString m_linkURL; // the url to put in the file
00175 
00176     static KDirWatch * s_pDirWatch;
00177 };
00178 
00185 class KURLDesktopFileDlg : public KDialogBase
00186 {
00187     Q_OBJECT
00188 public:
00189     KURLDesktopFileDlg( const QString& textFileName, const QString& textUrl );
00190     KURLDesktopFileDlg( const QString& textFileName, const QString& textUrl, QWidget *parent );
00191     virtual ~KURLDesktopFileDlg() {}
00192 
00196     QString fileName() const;
00200     QString url() const;
00201 
00202 protected slots:
00203     void slotClear();
00204     void slotNameTextChanged( const QString& );
00205     void slotURLTextChanged( const QString& );
00206 private:
00207     void initDialog( const QString& textFileName, const QString& defaultName, const QString& textUrl, const QString& defaultUrl );
00208 
00212     KLineEdit *m_leFileName;
00216     KURLRequester *m_urlRequester;
00217 
00221     bool m_fileNameEdited;
00222 };
00223 
00224 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys