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 QSpacerItem;
00042 class QTextBrowser;
00043 class QToolButton;
00044 class QWidgetStack;
00045
00046 class YQAlignment;
00047 class YQReplacePoint;
00048 class YQWizardButton;
00049 class QY2ListView;
00050
00051
00052 class YQWizard : public QVBox, public YWizard
00053 {
00054 Q_OBJECT
00055
00056 class Step;
00057 class TreeItem;
00058
00059 public:
00063 YQWizard( QWidget * parent,
00064 const YWidgetOpt & opt,
00065 const YCPValue & backButtonId, const YCPString & backButtonLabel,
00066 const YCPValue & abortButtonId, const YCPString & abortButtonLabel,
00067 const YCPValue & nextButtonId, const YCPString & nextButtonLabel );
00068
00072 virtual ~YQWizard();
00073
00074
00075 enum Direction { Forward, Backward };
00076
00082 Direction direction() const { return _direction; }
00083
00091 virtual YCPValue command( const YCPTerm & command );
00092
00098 virtual std::string debugLabel();
00099
00104 void addChild( YWidget * child );
00105
00111 long nicesize( YUIDimension dim );
00112
00116 void setSize( long newWidth, long newHeight );
00117
00121 bool eventFilter( QObject * obj, QEvent * ev );
00122
00126 void setDialogIcon( const char * iconName );
00127
00131 void setDialogHeading( const QString & headingText );
00132
00137 bool stepsEnabled() const { return _stepsEnabled; }
00138
00144 void addStep( const QString & text, const QString & id );
00145
00151 void addStepHeading( const QString & text );
00152
00157 void deleteSteps();
00158
00162 void setCurrentStep( const QString & id );
00163
00168 void updateSteps();
00169
00174 bool treeEnabled() const { return _treeEnabled; }
00175
00179 YQWizardButton * nextButton() const { return _nextButton; }
00180
00184 YQWizardButton * backButton() const { return _backButton; }
00185
00189 YQWizardButton * abortButton() const { return _abortButton; }
00190
00191
00195 void setVerboseCommands( bool verbose ) { _verboseCommands = verbose; }
00196
00203 void addTreeItem( const QString & parentID,
00204 const QString & text,
00205 const QString & id );
00206
00210 void selectTreeItem( const QString & id );
00211
00215 void deleteTreeItems();
00216
00217
00224 void addMenu( const QString & text,
00225 const QString & id );
00226
00230 void addSubMenu( const QString & parentMenuID,
00231 const QString & text,
00232 const QString & id );
00233
00238 void addMenuEntry( const QString & parentMenuID,
00239 const QString & text,
00240 const QString & id );
00241
00245 void addMenuSeparator( const QString & parentMenuID );
00246
00250 void deleteMenus();
00251
00252
00253 public slots:
00254
00255
00259 void setHelpText( QString helpText );
00260
00265 void resizeClientArea();
00266
00273 void showHelp();
00274
00279 void showSteps();
00280
00285 void showTree();
00286
00291 static void setGradient( QWidget * widget, const QPixmap & pixmap );
00292
00298 static void setBottomCroppedGradient( QWidget * widget,
00299 const QPixmap & pixmap,
00300 int croppedHeight );
00301
00306 static QPixmap bottomCropPixmap( const QPixmap & pixmap, int croppedHeight );
00307
00312 static QColor pixelColor( const QPixmap & pixmap, int x, int y );
00313
00314
00315 protected slots:
00316
00320 void backClicked();
00321
00325 void abortClicked();
00326
00330 void nextClicked();
00331
00336 void releaseNotesClicked();
00337
00343 void sendTreeEvent( QListViewItem * item );
00344
00351 void treeSelectionChanged();
00352
00357 void sendMenuEvent( int numID );
00358
00359
00366 void retranslateInternalButtons();
00367
00368 protected:
00369
00370
00371
00372 void layoutTitleBar ( QWidget * parent );
00373 void layoutSideBar ( QWidget * parent );
00374 void layoutSideBarButtonBox ( QWidget * parent, QPushButton * button );
00375 void layoutStepsPanel();
00376 void layoutHelpPanel();
00377 void layoutTreePanel();
00378 void layoutWorkArea ( QHBox * parentHBox );
00379 void layoutClientArea( QWidget * parent );
00380 void layoutButtonBox( QWidget * parent );
00381
00382
00386 void loadGradientPixmaps();
00387
00391 void loadStepsIcons();
00392
00396 void destroyButtons();
00397
00401 void updateStepStates();
00402
00411 QWidget * addGradientColumn( QWidget * parent, int width = 8 );
00412
00416 void sendEvent( YCPValue id );
00417
00418
00424 bool runningEmbedded() const { return _runningEmbedded; }
00425
00430 bool YQWizard::highColorDisplay() const;
00431
00432
00433
00434
00435
00436
00449 bool isCommand( QString declaration, const YCPTerm & term );
00450
00454 QString YQWizard::qStringArg( const YCPTerm & term, int argNo );
00455
00459 std::string stringArg( const YCPTerm & term, int argNo );
00460
00464 bool boolArg( const YCPTerm & term, int argNo );
00465
00469 YCPValue YQWizard::anyArg( const YCPTerm & term, int argNo );
00470
00474 void setButtonLabel( YQWizardButton * button, const QString & newLabel );
00475
00479 void setButtonID( YQWizardButton * button, const YCPValue & id );
00480
00484 void enableButton( YQWizardButton * button, bool enabled );
00485
00489 void setButtonFocus( YQWizardButton * button );
00490
00494 void setStepStatus( YQWizard::Step * step, const QPixmap & icon, const QColor & color );
00495
00499 YQWizard::Step * findStep( const QString & id );
00500
00506 YQWizard::TreeItem * findTreeItem( const QString & id );
00507
00514 YCPString currentTreeSelection();
00515
00521 void showReleaseNotesButton( string label, const YCPValue & id );
00522
00526 void hideReleaseNotesButton();
00527
00528
00529
00530
00531
00532
00533 bool _stepsEnabled;
00534 bool _treeEnabled;
00535 bool _verboseCommands;
00536 bool _protectNextButton;
00537 bool _stepsDirty;
00538 bool _runningEmbedded;
00539 Direction _direction;
00540
00541 QPixmap _titleBarGradientPixmap;
00542 QPixmap _topGradientPixmap;
00543 QColor _gradientCenterColor;
00544 QPixmap _bottomGradientPixmap;
00545
00546 QPixmap _stepCurrentIcon;
00547 QPixmap _stepToDoIcon;
00548 QPixmap _stepDoneIcon;
00549
00550 QColor _stepCurrentColor;
00551 QColor _stepToDoColor;
00552 QColor _stepDoneColor;
00553
00554 QString _currentStepID;
00555
00556
00557 QWidgetStack * _sideBar;
00558 QVBox * _stepsPanel;
00559 QVBox * _stepsBox;
00560 QGridLayout * _stepsGrid;
00561 QPushButton * _releaseNotesButton;
00562 YCPValue _releaseNotesButtonId;
00563 QPushButton * _helpButton;
00564 QHBox * _helpPanel;
00565 QTextBrowser * _helpBrowser;
00566 QPushButton * _stepsButton;
00567 QPushButton * _treeButton;
00568 QHBox * _treePanel;
00569 QY2ListView * _tree;
00570
00571 QVBox * _clientArea;
00572 QWidget * _menuBarBox;
00573 QMenuBar * _menuBar;
00574 QLabel * _dialogIcon;
00575 QLabel * _dialogHeading;
00576 YQAlignment * _contents;
00577 YQWizardButton * _backButton;
00578 QSpacerItem * _backButtonSpacer;
00579 YQWizardButton * _abortButton;
00580 YQWizardButton * _nextButton;
00581
00582 QPtrList<YQWizard::Step> _stepsList;
00583 QDict<YQWizard::Step> _stepsIDs;
00584 QDict<YQWizard::TreeItem> _treeIDs;
00585 QDict<QPopupMenu> _menuIDs;
00586 vector<QString> _menuEntryIDs;
00587
00588
00589 protected:
00590
00594 class Step
00595 {
00596 public:
00597
00598 Step( const QString & name = "", const QString & id = "" )
00599 : _name( name )
00600 , _statusLabel( 0 )
00601 , _nameLabel(0)
00602 , _enabled( true )
00603 , _idList( id )
00604 {}
00605
00609 virtual ~Step() {}
00610
00611 virtual bool isHeading() const { return false; }
00612
00613 QString name() const { return _name; }
00614 QLabel * statusLabel() const { return _statusLabel; }
00615 QLabel * nameLabel() const { return _nameLabel; }
00616 bool isEnabled() const { return _enabled; }
00617 const QStringList & id() const { return _idList; }
00618 void addID( const QString & id ) { _idList.append( id ); }
00619 virtual bool hasID( const QString & id ) { return _idList.find( id ) != _idList.end(); }
00620
00621 void setStatusLabel( QLabel * label ) { _statusLabel = label; }
00622 void setNameLabel ( QLabel * label ) { _nameLabel = label; }
00623 void setEnabled( bool enabled ) { _enabled = enabled; }
00624
00625 protected:
00626
00627 QString _name;
00628 QLabel * _statusLabel;
00629 QLabel * _nameLabel;
00630 bool _enabled;
00631 QStringList _idList;
00632 };
00633
00634
00638 class StepHeading: public Step
00639 {
00640 public:
00641
00642 StepHeading( const QString & name = "" )
00643 : Step( name, "" )
00644 {}
00645
00646 virtual ~StepHeading() {}
00647 virtual bool isHeading() const { return true; }
00648 virtual bool hasID( const QString & id ) { return false; }
00649 };
00650
00651
00655 class TreeItem: public QY2ListViewItem
00656 {
00657 public:
00658 TreeItem( QY2ListView * parent,
00659 const QString & text,
00660 const QString & id )
00661 : QY2ListViewItem( parent, text, true )
00662 , _id( id )
00663 {}
00664
00665 TreeItem( YQWizard::TreeItem * parent,
00666 const QString & text,
00667 const QString & id )
00668 : QY2ListViewItem( parent, text, true )
00669 , _id( id )
00670 {}
00671
00672 QString text() const { return QListViewItem::text(0); }
00673 QString id() const { return _id; }
00674
00675 private:
00676 QString _id;
00677 };
00678
00679 };
00680
00681
00682
00683 #endif // YQWizard_h