F:/KPlato/koffice/libs/kofficeui/KoTemplateChooseDia.h

Aller à la documentation de ce fichier.
00001 /*
00002    This file is part of the KDE project
00003    Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
00004    2000, 2001 Werner Trobin <trobin@kde.org>
00005    2002, 2003 Thomas Nagy <tnagy@eleve.emn.fr>
00006    2004 David Faure <faure@kde.org>
00007 
00008    This library is free software; you can redistribute it and/or
00009    modify it under the terms of the GNU Library General Public
00010    License as published by the Free Software Foundation; either
00011    version 2 of the License, or (at your option) any later version.
00012 
00013    This library is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016    Library General Public License for more details.
00017 
00018    You should have received a copy of the GNU Library General Public License
00019    along with this library; see the file COPYING.LIB.  If not, write to
00020    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00021  * Boston, MA 02110-1301, USA.
00022    */
00023 
00024 #ifndef koTemplateChooseDia_h
00025 #define koTemplateChooseDia_h
00026 
00027 #include <kpagedialog.h>
00028 #include <kicondialog.h>
00029 #include <k3iconview.h>
00030 #include <koffice_export.h>
00031 //Added by qt3to4:
00032 #include <QPixmap>
00033 #include <QHideEvent>
00034 #include <QKeyEvent>
00035 #include <QByteArray>
00036 
00037 // KoTCD : KoTemplateChooseDia
00038 
00039 class KoTCDIconViewItem;
00040 class KoTemplateTree;
00041 class KoTemplateGroup;
00042 class QGridLayout;
00043 
00048 class KoTCDIconCanvas : public KIconCanvas
00049 {
00050     Q_OBJECT
00051     public:
00052         KoTCDIconCanvas( QWidget *parent = 0, const char *name = 0L )
00053             : KIconCanvas( parent ) { Q_UNUSED(name) }
00054 
00055         bool isCurrentValid() { return currentItem(); }
00056         Q3IconViewItem * load(KoTemplateGroup *group, const QString& name, KInstance* instance);
00057 
00058     protected:
00059         virtual void keyPressEvent( QKeyEvent *e ) {
00060             if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter )
00061                 e->ignore();
00062             else
00063                 KIconCanvas::keyPressEvent( e );
00064         }
00065 };
00066 
00068 class KoTCDIconViewItem : public K3IconViewItem
00069 {
00070     public:
00071         KoTCDIconViewItem(Q3IconView *parent=0)
00072             : K3IconViewItem ( parent )
00073             {}
00074 
00075         KoTCDIconViewItem(Q3IconView *parent=0, const QString &text=0, const QPixmap &icon=0,
00076                       const QString &descr=0, const QString &fullname=0)
00077             : K3IconViewItem(parent, text, icon)
00078             {
00079             m_descr = descr;
00080             m_full = fullname;
00081             }
00082 
00083         QString getDescr() const { return m_descr; }
00084         QString getFName() const { return m_full; }
00085 
00086     private :
00087         QString m_descr;
00088         QString m_full;
00089 
00090 };
00091 
00092 #include <kfileiconview.h>
00093 #include <QLabel>
00099 class KoTCDRecentFilesIconView : public KFileIconView {
00100     Q_OBJECT
00101     public:
00102         KoTCDRecentFilesIconView( QWidget* parent, const char* name ) :
00103                 KFileIconView( parent, name ), toolTip(0)
00104         {
00105             connect( this, SIGNAL( onItem( Q3IconViewItem * ) ),
00106                      SLOT( showToolTip( Q3IconViewItem * ) ) );
00107             connect( this, SIGNAL( onViewport() ),
00108                      SLOT( removeToolTip() ) );
00109         }
00110         virtual ~KoTCDRecentFilesIconView();
00111     protected:
00115         virtual void hideEvent( QHideEvent * );
00116 
00117     private slots:
00118         void showToolTip( Q3IconViewItem* );
00119         void removeToolTip();
00120     private:
00121         QLabel* toolTip;
00122 };
00123 
00124 class KInstance;
00125 class KoTemplateChooseDiaPrivate;
00126 
00136 class KOFFICEUI_EXPORT KoTemplateChooseDia : public KPageDialog
00137 {
00138     Q_OBJECT
00139 
00140 public:
00149     enum ReturnType { Cancel, Template, File, Empty };
00156     enum DialogType { Everything, OnlyTemplates, NoTemplates };
00157 
00158     ~KoTemplateChooseDia();
00159 
00176     static ReturnType choose(KInstance* instance, QString &file,
00177                              const DialogType &dialogType,
00178                              const QByteArray& templateType,
00179                              QWidget* parent);
00180 
00181 private:
00183     static ReturnType choose(KInstance* instance, QString &file,
00184                              const QByteArray &format,
00185                              const QString &nativeName,
00186                              const QStringList& extraNativeMimeTypes,
00187                              const DialogType &dialogType=Everything,
00188                              const QByteArray& templateType="",
00189                              QWidget* parent = 0);
00190 public:
00191 
00195     QString getTemplate() const;
00199     QString getFullTemplate() const;
00203     ReturnType getReturnType() const;
00207     DialogType getDialogType() const;
00208 
00209 protected slots:
00213     virtual void slotOk();
00214 
00215 private:
00229     KoTemplateChooseDia(QWidget *parent, const char *name, KInstance* instance,
00230                         const QByteArray &format,
00231                         const QString &nativeName,
00232                         const QStringList &extraNativeMimeTypes,
00233                         const DialogType &dialogType=Everything,
00234                         const QByteArray& templateType="");
00235 
00236 private:
00237     KoTemplateChooseDiaPrivate *d;
00238 
00239     QString descriptionText(const QString &name, const QString &description);
00240     void setupDialog();
00241     void setupTemplateDialog(QWidget * widgetbase, QGridLayout * layout);
00242     void setupFileDialog(QWidget * widgetbase, QGridLayout * layout);
00243     void setupRecentDialog(QWidget * widgetbase, QGridLayout * layout);
00244     bool collectInfo();
00245     bool noStartupDlg() const;
00246 
00247 private slots:
00248 
00249     void chosen(Q3IconViewItem *);
00250     void currentChanged( Q3IconViewItem * );
00251     void recentSelected( Q3IconViewItem * );
00252 };
00253 
00254 #endif
00255 

Généré le Wed Nov 22 23:41:05 2006 pour KPlato par  doxygen 1.5.1-p1