libkonq Library API Documentation

knewmenu.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998-2000 David Faure <faure@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00016    Boston, MA 02111-1307, USA.
00017 */
00018 
00019 #ifndef __knewmenu_h
00020 #define __knewmenu_h
00021 
00022 #include <qintdict.h>
00023 #include <qstringlist.h>
00024 
00025 #include <kaction.h>
00026 #include <kdialogbase.h>
00027 #include <kurl.h>
00028 
00029 namespace KIO { class Job; }
00030 
00031 class KDirWatch;
00032 class KLineEdit;
00033 class KURLRequester;
00034 
00035 
00050 class KNewMenu : public KActionMenu
00051 {
00052   Q_OBJECT
00053 public:
00057     KNewMenu( KActionCollection * _collec, const char *name=0L );
00058     KNewMenu( KActionCollection * _collec, QWidget *parentWidget, const char *name=0L );
00059     virtual ~KNewMenu();
00060 
00065     void setPopupFiles(KURL::List & _files) {
00066         popupFiles = _files;
00067     }
00068     void setPopupFiles(const KURL & _file) {
00069         popupFiles.clear();
00070         popupFiles.append( _file );
00071     }
00072 
00073 public slots:
00078     void slotCheckUpToDate( );
00079 
00080 protected slots:
00084     void slotNewFile();
00085 
00089     void slotFillTemplates();
00090 
00091     void slotResult( KIO::Job * );
00092     // Special case (filename conflict when creating a link=url file)
00093     void slotRenamed( KIO::Job *, const KURL&, const KURL& );
00094 
00095 private:
00096 
00100     void fillMenu();
00101 
00106     void parseFiles();
00107 
00115     enum { LINKTOTEMPLATE = 1, TEMPLATE, SEPARATOR };
00116 
00117     struct Entry {
00118         QString text;
00119         QString filePath; // empty for SEPARATOR
00120         QString templatePath; // same as filePath for TEMPLATE
00121         QString icon;
00122         int entryType;
00123         QString comment;
00124     };
00125     // NOTE: only filePath is known before we call parseFiles
00126 
00131     static QValueList<Entry> * s_templatesList;
00132 
00133     class KNewMenuPrivate;
00134     KNewMenuPrivate* d;
00135 
00141     static int s_templatesVersion;
00142 
00147     static bool s_filesParsed;
00148 
00149     int menuItemsVersion;
00150 
00155     KURL::List popupFiles;
00156 
00160     bool m_isURLDesktopFile;
00161     QString m_linkURL; // the url to put in the file
00162 
00163     static KDirWatch * s_pDirWatch;
00164 };
00165 
00172 class KURLDesktopFileDlg : public KDialogBase
00173 {
00174     Q_OBJECT
00175 public:
00176     KURLDesktopFileDlg( const QString& textFileName, const QString& textUrl );
00177     KURLDesktopFileDlg( const QString& textFileName, const QString& textUrl, QWidget *parent );
00178     virtual ~KURLDesktopFileDlg() {}
00179 
00183     QString fileName() const;
00187     QString url() const;
00188 
00189 protected slots:
00190     void slotClear();
00191     void slotNameTextChanged( const QString& );
00192     void slotURLTextChanged( const QString& );
00193 private:
00194     void initDialog( const QString& textFileName, const QString& defaultName, const QString& textUrl, const QString& defaultUrl );
00195 private:
00199     KLineEdit *m_leFileName;
00203     KURLRequester *m_urlRequester;
00204 
00208     bool m_fileNameEdited;
00209 };
00210 
00211 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Thu Jan 29 23:03:28 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001