lib

KoTemplateChooseDia.h
1/*
2 This file is part of the KDE project
3 Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
4 2000, 2001 Werner Trobin <trobin@kde.org>
5 2002, 2003 Thomas Nagy <tnagy@eleve.emn.fr>
6 2004 David Faure <faure@kde.org>
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details.
17
18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 */
23
24#ifndef koTemplateChooseDia_h
25#define koTemplateChooseDia_h
26
27#include <kdialogbase.h>
28#include <kicondialog.h>
29#include <kiconview.h>
30#include <koffice_export.h>
31
32// KoTCD : KoTemplateChooseDia
33
34class KoTCDIconViewItem;
35class KoTemplateTree;
36class KoTemplateGroup;
37class TQGridLayout;
38
43class KoTCDIconCanvas : public TDEIconCanvas
44{
45 TQ_OBJECT
46
47 public:
48 KoTCDIconCanvas( TQWidget *parent = 0, const char *name = 0L )
49 : TDEIconCanvas( parent, name ) {}
50
51 bool isCurrentValid() { return currentItem(); }
52 TQIconViewItem * load(KoTemplateGroup *group, const TQString& name, TDEInstance* instance);
53
54 protected:
55 virtual void keyPressEvent( TQKeyEvent *e ) {
56 if ( e->key() == Key_Return || e->key() == Key_Enter )
57 e->ignore();
58 else
59 TDEIconCanvas::keyPressEvent( e );
60 }
61};
62
64class KoTCDIconViewItem : public TDEIconViewItem
65{
66 public:
67 KoTCDIconViewItem(TQIconView *parent=0)
68 : TDEIconViewItem ( parent )
69 {}
70
71 KoTCDIconViewItem(TQIconView *parent=0, const TQString &text=0, const TQPixmap &icon=0,
72 const TQString &descr=0, const TQString &fullname=0)
73 : TDEIconViewItem(parent, text, icon)
74 {
75 m_descr = descr;
76 m_full = fullname;
77 }
78
79 TQString getDescr() const { return m_descr; }
80 TQString getFName() const { return m_full; }
81
82 private :
83 TQString m_descr;
84 TQString m_full;
85
86};
87
88#include <tdefileiconview.h>
89#include <tqlabel.h>
95class KoTCDRecentFilesIconView : public KFileIconView {
96 TQ_OBJECT
97
98 public:
99 KoTCDRecentFilesIconView( TQWidget* parent, const char* name ) :
100 KFileIconView( parent, name ), toolTip(0)
101 {
102 connect( this, TQ_SIGNAL( onItem( TQIconViewItem * ) ),
103 TQ_SLOT( showToolTip( TQIconViewItem * ) ) );
104 connect( this, TQ_SIGNAL( onViewport() ),
105 TQ_SLOT( removeToolTip() ) );
106 }
107 virtual ~KoTCDRecentFilesIconView();
108 protected:
112 virtual void hideEvent( TQHideEvent * );
113
114 private slots:
115 void showToolTip( TQIconViewItem* );
116 void removeToolTip();
117 private:
118 TQLabel* toolTip;
119};
120
121class TDEInstance;
122class KoTemplateChooseDiaPrivate;
123
133class KOFFICEUI_EXPORT KoTemplateChooseDia : public KDialogBase
134{
135 TQ_OBJECT
136
137
138public:
147 enum ReturnType { Cancel, Template, File, Empty };
154 enum DialogType { Everything, OnlyTemplates, NoTemplates };
155
157
174 static ReturnType choose(TDEInstance* instance, TQString &file,
175 const DialogType &dialogType,
176 const TQCString& templateType,
177 TQWidget* parent);
178
179private:
181 static ReturnType choose(TDEInstance* instance, TQString &file,
182 const TQCString &format,
183 const TQString &nativeName,
184 const TQStringList& extraNativeMimeTypes,
185 const DialogType &dialogType=Everything,
186 const TQCString& templateType="",
187 TQWidget* parent = 0);
188public:
189
193 TQString getTemplate() const;
197 TQString getFullTemplate() const;
201 ReturnType getReturnType() const;
205 DialogType getDialogType() const;
206
207protected slots:
211 virtual void slotOk();
212
213private:
227 KoTemplateChooseDia(TQWidget *parent, const char *name, TDEInstance* instance,
228 const TQCString &format,
229 const TQString &nativeName,
230 const TQStringList &extraNativeMimeTypes,
231 const DialogType &dialogType=Everything,
232 const TQCString& templateType="");
233
234private:
235 KoTemplateChooseDiaPrivate *d;
236
237 TQString descriptionText(const TQString &name, const TQString &description);
238 void setupDialog();
239 void setupTemplateDialog(TQWidget * widgetbase, TQGridLayout * layout);
240 void setupFileDialog(TQWidget * widgetbase, TQGridLayout * layout);
241 void setupRecentDialog(TQWidget * widgetbase, TQGridLayout * layout);
242 bool collectInfo();
243 bool noStartupDlg() const;
244
245private slots:
246
247 void chosen(TQIconViewItem *);
248 void currentChanged( TQIconViewItem * );
249 void recentSelected( TQIconViewItem * );
250};
251
252#endif
253
KDialogBase(TQWidget *parent=0, const char *name=0, bool modal=true, const TQString &caption=TQString::null, int buttonMask=Ok|Apply|Cancel, ButtonCode defaultButton=Ok, bool separator=false, const KGuiItem &user1=KGuiItem(), const KGuiItem &user2=KGuiItem(), const KGuiItem &user3=KGuiItem())
virtual void slotOk()
virtual void hideEvent(TQHideEvent *)
Reimplemented to remove an eventual tooltip.
This class is used to show the template dialog on startup.
ReturnType
The Dialog returns one of these values depending on the input of the user.
DialogType
To configure the dialog you have to use this enum.