File indexing completed on 2024-12-22 04:17:30

0001 /***************************************************************************
0002  *                                                                         *
0003  *   copyright : (C) 2007 The University of Toronto                        *
0004  *                   netterfield@astro.utoronto.ca                         *
0005  *                                                                         *
0006  *   This program is free software; you can redistribute it and/or modify  *
0007  *   it under the terms of the GNU General Public License as published by  *
0008  *   the Free Software Foundation; either version 2 of the License, or     *
0009  *   (at your option) any later version.                                   *
0010  *                                                                         *
0011  ***************************************************************************/
0012 
0013 #ifndef DIALOG_H
0014 #define DIALOG_H
0015 
0016 #include <QDialog>
0017 
0018 #include "kst_export.h"
0019 
0020 #include "ui_dialog.h"
0021 
0022 template<class Key, class Value>
0023 class QHash;
0024 
0025 namespace Kst {
0026 
0027 class DialogPage;
0028 
0029 class Dialog : public QDialog, public Ui::Dialog
0030 {
0031   Q_OBJECT
0032   public:
0033     friend class DialogSI;
0034     friend class ScriptServer;
0035     explicit Dialog(QWidget *parent = 0);
0036     virtual ~Dialog();
0037 
0038     void addDialogPage(DialogPage *page, bool addMinSize = true);
0039     void removeDialogPage(DialogPage *page);
0040     DialogPage* getDialogPage(const QString &pageName);
0041     void selectDialogPage(DialogPage *page);
0042 
0043     void setAlwaysAllowApply(const bool allow);
0044 
0045     // dialogs should implement the following if
0046     // they have validation threads that scripting
0047     // needs to wait for.
0048     virtual void waitForValidation() {return;}
0049 
0050   Q_SIGNALS:
0051     void ok();
0052     void apply();
0053     void cancel();
0054 
0055   protected:
0056     void setVisible(bool visible);
0057 
0058     QWidget *leftCustomWidget() const;
0059     QWidget *rightCustomWidget() const;
0060     QWidget *topCustomWidget() const;
0061     QWidget *bottomCustomWidget() const;
0062     QWidget *extensionWidget() const;
0063     QDialogButtonBox *buttonBox() const;
0064 
0065   private Q_SLOTS:
0066     void selectPageForItem(QListWidgetItem *item);
0067     void buttonClicked(QAbstractButton *button);
0068     void modified();
0069 
0070   private:
0071     void resetListWidget();
0072 
0073     QHash<QListWidgetItem*, DialogPage*> _itemHash;
0074     bool _allowApply;
0075 };
0076 
0077 }
0078 
0079 #endif
0080 
0081 // vim: ts=2 sw=2 et