Kross

form.h
1 /***************************************************************************
2  * form.h
3  * This file is part of the KDE project
4  * copyright (C)2006-2007 by Sebastian Sauer ([email protected])
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  * You should have received a copy of the GNU Library General Public License
15  * along with this program; see the file COPYING. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  ***************************************************************************/
19 
20 #ifndef KROSS_FORM_H
21 #define KROSS_FORM_H
22 
23 #include <QWidget>
24 #include <QUrl>
25 #include <QListWidget>
26 
27 #include <kpagedialog.h>
28 #include <kassistantdialog.h>
29 //#include <kfilewidget.h>
30 
31 class QAbstractButton;
32 
33 namespace Kross
34 {
35 
39 class FormListView : public QListWidget
40 {
41  Q_OBJECT
42 public:
43  explicit FormListView(QWidget *parent);
44  virtual ~FormListView();
45 public Q_SLOTS:
46  void clear();
47  void remove(int index);
48  void addItem(const QString &text);
49  int count();
50  int current();
51  void setCurrent(int row);
52  QString text(int row);
53 };
54 
58 class FormFileWidget : public QWidget
59 {
60  Q_OBJECT
61  Q_ENUMS(Mode)
62 
63 public:
64  FormFileWidget(QWidget *parent, const QString &startDirOrVariable);
65  virtual ~FormFileWidget();
66 
70  enum Mode { Other = 0, Opening, Saving };
71 
72 public Q_SLOTS:
73 
78  void setMode(const QString &mode);
79 
83  QString currentFilter() const;
84 
88  void setFilter(const QString &filter);
89 
93  QString currentMimeFilter() const;
94 
98  void setMimeFilter(const QStringList &filter);
99 
103  QString selectedFile() const;
104 
105  //QStringList selectedFiles() const { return KFileDialog::selectedFiles(); }
106  //QString selectedUrl() const { return KFileDialog::selectedUrl().toLocalFile(); }
107 
108 Q_SIGNALS:
109 
114  void fileSelected(const QString &file);
115 
119  void fileHighlighted(const QString &);
120 
124  void selectionChanged();
125 
130  void filterChanged(const QString &filter);
131 
132 private Q_SLOTS:
133  void slotFileSelected(const QUrl &);
134  void slotFileHighlighted(const QUrl &);
135 
136 private:
138  class Private;
140  Private *const d;
141 };
142 
160 {
161  Q_OBJECT
162 public:
163  FormProgressDialog(const QString &caption, const QString &labelText);
164  virtual ~FormProgressDialog();
165  void done(int r) override;
166 public Q_SLOTS:
170  void setValue(int progress);
174  void setRange(int minimum, int maximum);
178  void setText(const QString &text);
182  void addText(const QString &text);
191  int exec() override;
197  int exec_loop()
198  {
199  return exec();
200  }
204  bool isCanceled();
205 Q_SIGNALS:
209  void canceled();
210 private:
212  class Private;
214  Private *const d;
215 };
216 
239 class FormDialog: public KPageDialog
240 {
241  Q_OBJECT
242 
243 public:
244  FormDialog(const QString &caption);
245  virtual ~FormDialog();
246 
247 public Q_SLOTS:
248 
257  bool setButtons(const QString &buttons);
258 
275  bool setButtonText(const QString &button, const QString &text);
276 
283  bool setFaceType(const QString &facetype);
284 
289  QString currentPage() const;
290 
296  bool setCurrentPage(const QString &name);
297 
302  QWidget *page(const QString &name) const;
303 
316  QWidget *addPage(const QString &name, const QString &header = QString(), const QString &iconname = QString());
317 
326  int exec() override
327  {
328  return QDialog::exec();
329  }
330 
336  int exec_loop()
337  {
338  return exec();
339  }
340 
344  QString result();
345 
346 private Q_SLOTS:
347  virtual void slotButtonClicked(QAbstractButton *button);
348  void slotCurrentPageChanged(KPageWidgetItem *current);
349 
350 private:
352  class Private;
354  Private *const d;
355 };
356 
390 {
391  Q_OBJECT
392  Q_ENUMS(AssistantButtonCode)
393 public:
394  enum AssistantButtonCode {
395  None = 0x00000000,
396  Help = 0x00000001,
397  Default = 0x00000002,
398  Cancel = 0x00000020,
399  Finish = 0x00001000,
400  Next = 0x00002000,
401  Back = 0x00004000,
402  NoDefault = 0x00008000
403  };
404  Q_DECLARE_FLAGS(AssistantButtonCodes, AssistantButtonCode)
405 
406 public:
407  FormAssistant(const QString &caption);
408  virtual ~FormAssistant();
409 
410 public Q_SLOTS:
411 
412  void showHelpButton(bool);
413 
418  QString currentPage() const;
419 
425  bool setCurrentPage(const QString &name);
426 
431  QWidget *page(const QString &name) const;
432 
445  QWidget *addPage(const QString &name, const QString &header = QString(), const QString &iconname = QString());
446 
450  bool isAppropriate(const QString &name) const;
454  void setAppropriate(const QString &name, bool appropriate);
458  bool isValid(const QString &name) const;
462  void setValid(const QString &name, bool enable);
463 
472  int exec() override
473  {
474  return QDialog::exec();
475  }
476 
482  int exec_loop()
483  {
484  return exec();
485  }
486 
490  QString result();
491 
495  void back() override;
499  void next() override;
500 
501 private Q_SLOTS:
502  virtual void slotButtonClicked(QAbstractButton *button);
503  void slotCurrentPageChanged(KPageWidgetItem *current);
504 
505 Q_SIGNALS:
509  void nextClicked();
510  void backClicked();
511 
512 private:
514  class Private;
516  Private *const d;
517 };
518 
535 class FormModule: public QObject
536 {
537  Q_OBJECT
538 
539 public:
540  explicit FormModule();
541  virtual ~FormModule();
542 
543 public Q_SLOTS:
544 
549  QWidget *activeModalWidget();
550 
555  QWidget *activeWindow();
556 
560  QString tr(const QString &str);
561 
565  QString tr(const QString &str, const QString &comment);
566 
590  QString showMessageBox(const QString &dialogtype, const QString &caption, const QString &message, const QString &details = QString());
591 
600  QWidget *showProgressDialog(const QString &caption, const QString &labelText);
601 
607  QWidget *createDialog(const QString &caption);
608 
614  QWidget *createAssistant(const QString &caption);
615 
627  QObject *createLayout(QWidget *parent, const QString &layout);
628 
638  QWidget *createWidget(const QString &className);
639 
649  QWidget *createWidget(QWidget *parent, const QString &className, const QString &name = QString());
650 
658  QWidget *createWidgetFromUI(QWidget *parent, const QString &xml);
659 
667  QWidget *createWidgetFromUIFile(QWidget *parent, const QString &filename);
668 
677  QWidget *createFileWidget(QWidget *parent, const QString &startDirOrVariable = QString());
678 
686  QWidget *createListView(QWidget *parent);
687 
694  QObject *loadPart(QWidget *parent, const QString &name, const QUrl &url = QUrl());
695 
703  QAction *createAction(QObject *parent);
704 
705 private:
707  class Private;
709  Private *const d;
710 };
711 }
712 
713 #endif
714 
QLayout * layout() const const
int exec_loop()
Same as the exec() method above provided for Python-lovers (python does not like functions named "exe...
Definition: form.h:336
int exec() override
Shows the dialog as a modal dialog, blocking until the user closes it and returns the execution resul...
Definition: form.h:326
Definition: action.cpp:36
virtual int exec()
The FormFileWidget class provides access to a KFileWidget.
Definition: form.h:58
The FormDialog class provides access to KPageDialog objects as top-level containers.
Definition: form.h:239
Q_SIGNALSQ_SIGNALS
QString tr(const char *sourceText, const char *disambiguation, int n)
int exec_loop()
Same as the exec() method above provided for Python-lovers (python does not like functions named "exe...
Definition: form.h:197
Q_OBJECTQ_OBJECT
int exec() override
Shows the dialog as a modal dialog, blocking until the user closes it and returns the execution resul...
Definition: form.h:472
The FormModule provides access to UI functionality like dialogs or widgets.
Definition: form.h:535
int row(const QListWidgetItem *item) const const
Q_ENUMS(...)
The FormListView class provides access to a ListView.
Definition: form.h:39
The FormProgressDialog class provides access to progressbar.
Definition: form.h:159
Q_SLOTSQ_SLOTS
QObject * parent() const const
Mode
The Mode the FormFileWidget could have.
Definition: form.h:70
virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override
int exec_loop()
Same as the exec() method above provided for Python-lovers (python does not like functions named "exe...
Definition: form.h:482
The FormAssistant class provides access to KAssistantDialog objects as top-level containers.
Definition: form.h:389
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Oct 27 2020 23:03:58 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.