lib Library API Documentation

koTemplateChooseDia.h

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., 59 Temple Place - Suite 330,
00021    Boston, MA 02111-1307, USA.
00022    */
00023 
00024 #ifndef koTemplateChooseDia_h
00025 #define koTemplateChooseDia_h
00026 
00027 #include <kdialogbase.h>
00028 #include <kicondialog.h>
00029 #include <kiconview.h>
00030 #include <koffice_export.h>
00031 
00032 // KoTCD : KoTemplateChooseDia
00033 
00034 class KoTCDIconViewItem;
00035 class KoTemplateTree;
00036 class KoTemplateGroup;
00037 class QGridLayout;
00038 
00043 class KoTCDIconCanvas : public KIconCanvas
00044 {
00045     Q_OBJECT
00046     public:
00047     KoTCDIconCanvas( QWidget *parent = 0, const char *name = 0L )
00048         : KIconCanvas( parent, name ) {}
00049 
00050     bool isCurrentValid() { return currentItem(); }
00051     QIconViewItem * load(KoTemplateGroup *group, const QString& name, KInstance* instance);
00052 
00053     protected:
00054     virtual void keyPressEvent( QKeyEvent *e ) {
00055         if ( e->key() == Key_Return || e->key() == Key_Enter )
00056         e->ignore();
00057         else
00058         KIconCanvas::keyPressEvent( e );
00059     }
00060 };
00061 
00063 class KoTCDIconViewItem : public KIconViewItem
00064 {
00065     public:
00066     KoTCDIconViewItem(QIconView *parent=0)
00067         : KIconViewItem ( parent )
00068         {}
00069 
00070     KoTCDIconViewItem(QIconView *parent=0, const QString &text=0, const QPixmap &icon=0,
00071                       const QString &descr=0, const QString &fullname=0)
00072         : KIconViewItem(parent, text, icon)
00073         {
00074             m_descr = descr;
00075             m_full = fullname;
00076         }
00077 
00078     QString getDescr() const { return m_descr; }
00079     QString getFName() const { return m_full; }
00080 
00081     private :
00082     QString m_descr;
00083     QString m_full;
00084 
00085 };
00086 
00087 #include <kfileiconview.h>
00088 #include <qlabel.h>
00094 class KoTCDRecentFilesIconView : public KFileIconView {
00095     Q_OBJECT
00096     public:
00097     KoTCDRecentFilesIconView( QWidget* parent, const char* name ) :
00098         KFileIconView( parent, name ), toolTip(0)
00099     {
00100         connect( this, SIGNAL( onItem( QIconViewItem * ) ),
00101                      SLOT( showToolTip( QIconViewItem * ) ) );
00102         connect( this, SIGNAL( onViewport() ),
00103                      SLOT( removeToolTip() ) );
00104     }
00105         virtual ~KoTCDRecentFilesIconView();
00106     protected:
00110         virtual void hideEvent( QHideEvent * );
00111 
00112     private slots:
00113         void showToolTip( QIconViewItem* );
00114         void removeToolTip();
00115     private:
00116         QLabel* toolTip;
00117 };
00118 
00119 class KInstance;
00120 class KoTemplateChooseDiaPrivate;
00121 
00131 class KOFFICEUI_EXPORT KoTemplateChooseDia : public KDialogBase
00132 {
00133     Q_OBJECT
00134 
00135 public:
00144     enum ReturnType { Cancel, Template, File, Empty };
00151     enum DialogType { Everything, OnlyTemplates, NoTemplates };
00152 
00153     ~KoTemplateChooseDia();
00154 
00171     static ReturnType choose(KInstance* instance, QString &file,
00172                              const DialogType &dialogType,
00173                              const QCString& templateType,
00174                              QWidget* parent);
00175 
00176 private:
00178     static ReturnType choose(KInstance* instance, QString &file,
00179                              const QCString &format,
00180                              const QString &nativeName,
00181                              const QStringList& extraNativeMimeTypes,
00182                              const DialogType &dialogType=Everything,
00183                              const QCString& templateType="",
00184                              QWidget* parent = 0);
00185 public:
00186 
00190     QString getTemplate() const;
00194     QString getFullTemplate() const;
00198     ReturnType getReturnType() const;
00202     DialogType getDialogType() const;
00203 
00204 protected slots:
00208     virtual void slotOk();
00209 
00210 private:
00224     KoTemplateChooseDia(QWidget *parent, const char *name, KInstance* instance,
00225                         const QCString &format,
00226                         const QString &nativeName,
00227                         const QStringList &extraNativeMimeTypes,
00228                         const DialogType &dialogType=Everything,
00229                         const QCString& templateType="");
00230 
00231 private:
00232     KoTemplateChooseDiaPrivate *d;
00233 
00234     QString descriptionText(const QString &name, const QString &description);
00235     void setupDialog();
00236     void setupTemplateDialog(QWidget * widgetbase, QGridLayout * layout);
00237     void setupFileDialog(QWidget * widgetbase, QGridLayout * layout);
00238     void setupRecentDialog(QWidget * widgetbase, QGridLayout * layout);
00239     bool collectInfo();
00240     bool noStartupDlg() const;
00241 
00242 private slots:
00243 
00244     void chosen(QIconViewItem *);
00245     void currentChanged( QIconViewItem * );
00246     void recentSelected( QIconViewItem * );
00247 };
00248 
00249 #endif
00250 
KDE Logo
This file is part of the documentation for lib Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:40:08 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003