Kross
form.h
Go to the documentation of this file.
00001 /*************************************************************************** 00002 * form.h 00003 * This file is part of the KDE project 00004 * copyright (C)2006-2007 by Sebastian Sauer (mail@dipe.org) 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this program; see the file COPYING. If not, write to 00016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 ***************************************************************************/ 00019 00020 #ifndef KROSS_FORM_H 00021 #define KROSS_FORM_H 00022 00023 #include <QtGui/QWidget> 00024 #include <QtCore/QUrl> 00025 #include <QtGui/QListWidget> 00026 00027 #include <kpagedialog.h> 00028 #include <kassistantdialog.h> 00029 //#include <kfilewidget.h> 00030 00031 namespace Kross { 00032 00036 class FormListView : public QListWidget 00037 { 00038 Q_OBJECT 00039 public: 00040 explicit FormListView(QWidget* parent); 00041 virtual ~FormListView(); 00042 public Q_SLOTS: 00043 void clear(); 00044 void remove(int index); 00045 void addItem(const QString& text); 00046 int count(); 00047 int current(); 00048 void setCurrent(int row); 00049 QString text(int row); 00050 }; 00051 00055 class FormFileWidget : public QWidget 00056 { 00057 Q_OBJECT 00058 Q_ENUMS(Mode) 00059 00060 public: 00061 FormFileWidget(QWidget* parent, const QString& startDirOrVariable); 00062 virtual ~FormFileWidget(); 00063 00067 enum Mode { Other = 0, Opening, Saving }; 00068 00069 public Q_SLOTS: 00070 00075 void setMode(const QString& mode); 00076 00080 QString currentFilter() const; 00081 00085 void setFilter(const QString &filter); 00086 00090 QString currentMimeFilter() const; 00091 00095 void setMimeFilter(const QStringList& filter); 00096 00100 QString selectedFile() const; 00101 00102 //QStringList selectedFiles() const { return KFileDialog::selectedFiles(); } 00103 //QString selectedUrl() const { return KFileDialog::selectedUrl().toLocalFile(); } 00104 00105 Q_SIGNALS: 00106 00111 void fileSelected(const QString& file); 00112 00116 void fileHighlighted(const QString&); 00117 00121 void selectionChanged(); 00122 00127 void filterChanged(const QString& filter); 00128 00129 private Q_SLOTS: 00130 void slotFileSelected(const QString&); 00131 00132 private: 00134 class Private; 00136 Private* const d; 00137 }; 00138 00155 class FormProgressDialog : public KPageDialog 00156 { 00157 Q_OBJECT 00158 public: 00159 FormProgressDialog(const QString& caption, const QString& labelText); 00160 virtual ~FormProgressDialog(); 00161 virtual void done(int r); 00162 public Q_SLOTS: 00166 void setValue(int progress); 00170 void setRange(int minimum, int maximum); 00174 void setText(const QString& text); 00178 void addText(const QString& text); 00187 int exec(); 00193 int exec_loop() { return exec(); } 00197 bool isCanceled(); 00198 Q_SIGNALS: 00202 void canceled(); 00203 private: 00205 class Private; 00207 Private* const d; 00208 }; 00209 00232 class FormDialog: public KPageDialog 00233 { 00234 Q_OBJECT 00235 00236 public: 00237 FormDialog(const QString& caption); 00238 virtual ~FormDialog(); 00239 00240 public Q_SLOTS: 00241 00250 bool setButtons(const QString& buttons); 00251 00268 bool setButtonText(const QString& button, const QString& text); 00269 00276 bool setFaceType(const QString& facetype); 00277 00282 QString currentPage() const; 00283 00289 bool setCurrentPage(const QString& name); 00290 00295 QWidget* page(const QString& name) const; 00296 00309 QWidget* addPage(const QString& name, const QString& header = QString(), const QString& iconname = QString()); 00310 00315 void setMainWidget(QWidget *newMainWidget); 00316 00325 int exec() { return KDialog::exec(); } 00326 00332 int exec_loop() { return exec(); } 00333 00337 QString result(); 00338 00339 private Q_SLOTS: 00340 virtual void slotButtonClicked(int button); 00341 void slotCurrentPageChanged(KPageWidgetItem* current); 00342 00343 private: 00345 class Private; 00347 Private* const d; 00348 }; 00349 00350 00383 class FormAssistant: public KAssistantDialog 00384 { 00385 Q_OBJECT 00386 Q_ENUMS(AssistantButtonCode) 00387 public: 00388 enum AssistantButtonCode 00389 { 00390 None = 0x00000000, 00391 Help = 0x00000001, 00392 Default = 0x00000002, 00393 Cancel = 0x00000020, 00394 Finish = 0x00001000, 00395 Next = 0x00002000, 00396 Back = 0x00004000, 00397 NoDefault = 0x00008000 00398 }; 00399 Q_DECLARE_FLAGS(AssistantButtonCodes, AssistantButtonCode) 00400 00401 public: 00402 FormAssistant(const QString& caption); 00403 virtual ~FormAssistant(); 00404 00405 public Q_SLOTS: 00406 00407 void showHelpButton(bool); 00408 00413 QString currentPage() const; 00414 00420 bool setCurrentPage(const QString& name); 00421 00426 QWidget* page(const QString& name) const; 00427 00440 QWidget* addPage(const QString& name, const QString& header = QString(), const QString& iconname = QString()); 00441 00445 bool isAppropriate (const QString& name) const; 00449 void setAppropriate (const QString& name, bool appropriate); 00453 bool isValid (const QString& name) const; 00457 void setValid (const QString& name, bool enable); 00458 00467 int exec() { return KDialog::exec(); } 00468 00474 int exec_loop() { return exec(); } 00475 00479 QString result(); 00480 00484 void back(); 00488 void next(); 00489 00490 private Q_SLOTS: 00491 virtual void slotButtonClicked(int button); 00492 void slotCurrentPageChanged(KPageWidgetItem* current); 00493 00494 signals: 00498 void nextClicked(); 00499 void backClicked(); 00500 00501 private: 00503 class Private; 00505 Private* const d; 00506 }; 00507 00508 00525 class FormModule: public QObject 00526 { 00527 Q_OBJECT 00528 00529 public: 00530 explicit FormModule(); 00531 virtual ~FormModule(); 00532 00533 public Q_SLOTS: 00534 00539 QWidget* activeModalWidget(); 00540 00545 QWidget* activeWindow(); 00546 00547 00551 QString tr(const QString& str); 00552 00556 QString tr(const QString& str,const QString& comment); 00557 00558 00582 QString showMessageBox(const QString& dialogtype, const QString& caption, const QString& message, const QString& details = QString()); 00583 00592 QWidget* showProgressDialog(const QString& caption, const QString& labelText); 00593 00599 QWidget* createDialog(const QString& caption); 00600 00606 QWidget* createAssistant(const QString& caption); 00607 00619 QObject* createLayout(QWidget* parent, const QString& layout); 00620 00630 QWidget* createWidget(const QString& className); 00631 00641 QWidget* createWidget(QWidget* parent, const QString& className, const QString& name = QString()); 00642 00650 QWidget* createWidgetFromUI(QWidget* parent, const QString& xml); 00651 00659 QWidget* createWidgetFromUIFile(QWidget* parent, const QString& filename); 00660 00669 QWidget* createFileWidget(QWidget* parent, const QString& startDirOrVariable = QString()); 00670 00678 QWidget* createListView(QWidget* parent); 00679 00686 QObject* loadPart(QWidget* parent, const QString& name, const QUrl& url = QUrl()); 00687 00695 QAction* createAction(QObject* parent); 00696 00697 private: 00699 class Private; 00701 Private* const d; 00702 }; 00703 } 00704 00705 #endif 00706
KDE 4.6 API Reference