00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef YQWizard_h
00022 #define YQWizard_h
00023
00024 #include "YWizard.h"
00025 #include <qvbox.h>
00026 #include <qpixmap.h>
00027 #include <qptrlist.h>
00028 #include <qstringlist.h>
00029 #include <qdict.h>
00030 #include "QY2ListView.h"
00031
00032 #include <string>
00033 #include <vector>
00034
00035 class QGridLayout;
00036 class QHBox;
00037 class QLabel;
00038 class QMenuBar;
00039 class QPopupMenu;
00040 class QPushButton;
00041 class QTextBrowser;
00042 class QToolButton;
00043 class QWidgetStack;
00044
00045 class YQAlignment;
00046 class YQReplacePoint;
00047 class YQWizardButton;
00048 class QY2ListView;
00049
00050
00051 class YQWizard : public QVBox, public YWizard
00052 {
00053 Q_OBJECT
00054
00055 class Step;
00056 class TreeItem;
00057
00058 public:
00062 YQWizard( QWidget * parent,
00063 const YWidgetOpt & opt,
00064 const YCPValue & backButtonId, const YCPString & backButtonLabel,
00065 const YCPValue & abortButtonId, const YCPString & abortButtonLabel,
00066 const YCPValue & nextButtonId, const YCPString & nextButtonLabel );
00067
00071 virtual ~YQWizard();
00072
00073
00074 enum Direction { Forward, Backward };
00075
00081 Direction direction() const { return _direction; }
00082
00090 virtual YCPValue command( const YCPTerm & command );
00091
00092
00097 void addChild( YWidget * child );
00098
00104 long nicesize( YUIDimension dim );
00105
00109 void setSize( long newWidth, long newHeight );
00110
00114 bool eventFilter( QObject * obj, QEvent * ev );
00115
00119 void setDialogIcon( const char * iconName );
00120
00124 void setDialogHeading( const QString & headingText );
00125
00130 bool stepsEnabled() const { return _stepsEnabled; }
00131
00137 void addStep( const QString & text, const QString & id );
00138
00144 void addStepHeading( const QString & text );
00145
00150 void deleteSteps();
00151
00155 void setCurrentStep( const QString & id );
00156
00161 void updateSteps();
00162
00167 bool treeEnabled() const { return _treeEnabled; }
00168
00172 YQWizardButton * nextButton() const { return _nextButton; }
00173
00177 YQWizardButton * backButton() const { return _backButton; }
00178
00182 YQWizardButton * abortButton() const { return _abortButton; }
00183
00184
00188 void setVerboseCommands( bool verbose ) { _verboseCommands = verbose; }
00189
00196 void addTreeItem( const QString & parentID,
00197 const QString & text,
00198 const QString & id );
00199
00203 void selectTreeItem( const QString & id );
00204
00208 void deleteTreeItems();
00209
00210
00217 void addMenu( const QString & text,
00218 const QString & id );
00219
00223 void addSubMenu( const QString & parentMenuID,
00224 const QString & text,
00225 const QString & id );
00226
00231 void addMenuEntry( const QString & parentMenuID,
00232 const QString & text,
00233 const QString & id );
00234
00238 void addMenuSeparator( const QString & parentMenuID );
00239
00243 void deleteMenus();
00244
00245
00246 public slots:
00247
00248
00252 void setHelpText( QString helpText );
00253
00258 void resizeClientArea();
00259
00266 void showHelp();
00267
00272 void showSteps();
00273
00278 void showTree();
00279
00284 static void setGradient( QWidget * widget, const QPixmap & pixmap );
00285
00291 static void setBottomCroppedGradient( QWidget * widget,
00292 const QPixmap & pixmap,
00293 int croppedHeight );
00294
00299 static QPixmap bottomCropPixmap( const QPixmap & pixmap, int croppedHeight );
00300
00305 static QColor pixelColor( const QPixmap & pixmap, int x, int y );
00306
00307
00308 protected slots:
00309
00313 void backClicked();
00314
00318 void abortClicked();
00319
00323 void nextClicked();
00324
00330 void sendTreeEvent( QListViewItem * item );
00331
00338 void treeSelectionChanged();
00339
00344 void sendMenuEvent( int numID );
00345
00346
00347 protected:
00348
00349
00350
00351 void layoutTitleBar ( QWidget * parent );
00352 void layoutSideBar ( QWidget * parent );
00353 void layoutStepsPanel();
00354 void layoutHelpPanel();
00355 void layoutTreePanel();
00356 void layoutWorkArea ( QHBox * parentHBox );
00357 void layoutClientArea( QWidget * parent );
00358 void layoutButtonBox();
00359
00360
00364 void loadGradientPixmaps();
00365
00369 void loadStepsIcons();
00370
00374 void destroyButtons();
00375
00379 void updateStepStates();
00380
00389 QWidget * addGradientColumn( QWidget * parent, int width = 8 );
00390
00398 QGridLayout * centerAtBottom( QWidget * parent, QWidget * child, int margin );
00399
00403 void sendEvent( YCPValue id );
00404
00405
00411 bool runningEmbedded() const { return _runningEmbedded; }
00412
00417 bool YQWizard::highColorDisplay() const;
00418
00419
00420
00421
00422
00423
00436 bool isCommand( QString declaration, const YCPTerm & term );
00437
00441 QString YQWizard::qStringArg( const YCPTerm & term, int argNo );
00442
00446 std::string stringArg( const YCPTerm & term, int argNo );
00447
00451 bool boolArg( const YCPTerm & term, int argNo );
00452
00456 YCPValue YQWizard::anyArg( const YCPTerm & term, int argNo );
00457
00461 void setButtonLabel( YQWizardButton * button, const QString & newLabel );
00462
00466 void setButtonID( YQWizardButton * button, const YCPValue & id );
00467
00471 void enableButton( YQWizardButton * button, bool enabled );
00472
00476 void setButtonFocus( YQWizardButton * button );
00477
00481 void setStepStatus( YQWizard::Step * step, const QPixmap & icon, const QColor & color );
00482
00486 YQWizard::Step * findStep( const QString & id );
00487
00493 YQWizard::TreeItem * findTreeItem( const QString & id );
00494
00501 YCPString currentTreeSelection();
00502
00503
00504
00505
00506
00507
00508 bool _stepsEnabled;
00509 bool _treeEnabled;
00510 bool _verboseCommands;
00511 bool _protectNextButton;
00512 bool _stepsDirty;
00513 bool _runningEmbedded;
00514 Direction _direction;
00515
00516 QPixmap _titleBarGradientPixmap;
00517 QPixmap _topGradientPixmap;
00518 QColor _gradientCenterColor;
00519 QPixmap _bottomGradientPixmap;
00520
00521 QPixmap _stepCurrentIcon;
00522 QPixmap _stepToDoIcon;
00523 QPixmap _stepDoneIcon;
00524
00525 QColor _stepCurrentColor;
00526 QColor _stepToDoColor;
00527 QColor _stepDoneColor;
00528
00529 QString _currentStepID;
00530
00531
00532 QWidgetStack * _sideBar;
00533 QVBox * _stepsPanel;
00534 QVBox * _stepsBox;
00535 QGridLayout * _stepsGrid;
00536 QHBox * _helpPanel;
00537 QTextBrowser * _helpBrowser;
00538 QHBox * _treePanel;
00539 QY2ListView * _tree;
00540
00541 QVBox * _clientArea;
00542 QWidget * _menuBarBox;
00543 QMenuBar * _menuBar;
00544 QLabel * _dialogIcon;
00545 QLabel * _dialogHeading;
00546 YQAlignment * _contents;
00547 QHBox * _buttonBox;
00548 YQWizardButton * _backButton;
00549 QWidget * _backButtonSpacer;
00550 YQWizardButton * _abortButton;
00551 YQWizardButton * _nextButton;
00552
00553 QPtrList<YQWizard::Step> _stepsList;
00554 QDict<YQWizard::Step> _stepsIDs;
00555 QDict<YQWizard::TreeItem> _treeIDs;
00556 QDict<QPopupMenu> _menuIDs;
00557 vector<QString> _menuEntryIDs;
00558
00559
00560 protected:
00561
00565 class Step
00566 {
00567 public:
00568
00569 Step( const QString & name = "", const QString & id = "" )
00570 : _name( name )
00571 , _statusLabel( 0 )
00572 , _nameLabel(0)
00573 , _enabled( true )
00574 , _idList( id )
00575 {}
00576
00580 virtual ~Step() {}
00581
00582 virtual bool isHeading() const { return false; }
00583
00584 QString name() const { return _name; }
00585 QLabel * statusLabel() const { return _statusLabel; }
00586 QLabel * nameLabel() const { return _nameLabel; }
00587 bool isEnabled() const { return _enabled; }
00588 const QStringList & id() const { return _idList; }
00589 void addID( const QString & id ) { _idList.append( id ); }
00590 virtual bool hasID( const QString & id ) { return _idList.find( id ) != _idList.end(); }
00591
00592 void setStatusLabel( QLabel * label ) { _statusLabel = label; }
00593 void setNameLabel ( QLabel * label ) { _nameLabel = label; }
00594 void setEnabled( bool enabled ) { _enabled = enabled; }
00595
00596 protected:
00597
00598 QString _name;
00599 QLabel * _statusLabel;
00600 QLabel * _nameLabel;
00601 bool _enabled;
00602 QStringList _idList;
00603 };
00604
00605
00609 class StepHeading: public Step
00610 {
00611 public:
00612
00613 StepHeading( const QString & name = "" )
00614 : Step( name, "" )
00615 {}
00616
00617 virtual ~StepHeading() {}
00618 virtual bool isHeading() const { return true; }
00619 virtual bool hasID( const QString & id ) { return false; }
00620 };
00621
00622
00626 class TreeItem: public QY2ListViewItem
00627 {
00628 public:
00629 TreeItem( QY2ListView * parent,
00630 const QString & text,
00631 const QString & id )
00632 : QY2ListViewItem( parent, text, true )
00633 , _id( id )
00634 {}
00635
00636 TreeItem( YQWizard::TreeItem * parent,
00637 const QString & text,
00638 const QString & id )
00639 : QY2ListViewItem( parent, text, true )
00640 , _id( id )
00641 {}
00642
00643 QString text() const { return QListViewItem::text(0); }
00644 QString id() const { return _id; }
00645
00646 private:
00647 QString _id;
00648 };
00649
00650 };
00651
00652
00653
00654 #endif // YQWizard_h