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
00413
00414
00415
00416
00417
00430 bool isCommand( QString declaration, const YCPTerm & term );
00431
00435 QString YQWizard::qStringArg( const YCPTerm & term, int argNo );
00436
00440 std::string stringArg( const YCPTerm & term, int argNo );
00441
00445 bool boolArg( const YCPTerm & term, int argNo );
00446
00450 YCPValue YQWizard::anyArg( const YCPTerm & term, int argNo );
00451
00455 void setButtonLabel( YQWizardButton * button, const QString & newLabel );
00456
00460 void setButtonID( YQWizardButton * button, const YCPValue & id );
00461
00465 void enableButton( YQWizardButton * button, bool enabled );
00466
00470 void setButtonFocus( YQWizardButton * button );
00471
00475 void setStepStatus( YQWizard::Step * step, const QPixmap & icon, const QColor & color );
00476
00480 YQWizard::Step * findStep( const QString & id );
00481
00487 YQWizard::TreeItem * findTreeItem( const QString & id );
00488
00495 YCPString currentTreeSelection();
00496
00497
00498
00499
00500
00501
00502 bool _stepsEnabled;
00503 bool _treeEnabled;
00504 bool _verboseCommands;
00505 bool _protectNextButton;
00506 bool _stepsDirty;
00507 bool _runningEmbedded;
00508 Direction _direction;
00509
00510 QPixmap _titleBarGradientPixmap;
00511 QPixmap _topGradientPixmap;
00512 QColor _gradientCenterColor;
00513 QPixmap _bottomGradientPixmap;
00514
00515 QPixmap _stepCurrentIcon;
00516 QPixmap _stepToDoIcon;
00517 QPixmap _stepDoneIcon;
00518
00519 QColor _stepCurrentColor;
00520 QColor _stepToDoColor;
00521 QColor _stepDoneColor;
00522
00523 QString _currentStepID;
00524
00525
00526 QWidgetStack * _sideBar;
00527 QVBox * _stepsPanel;
00528 QVBox * _stepsBox;
00529 QGridLayout * _stepsGrid;
00530 QHBox * _helpPanel;
00531 QTextBrowser * _helpBrowser;
00532 QHBox * _treePanel;
00533 QY2ListView * _tree;
00534
00535 QVBox * _clientArea;
00536 QWidget * _menuBarBox;
00537 QMenuBar * _menuBar;
00538 QLabel * _dialogIcon;
00539 QLabel * _dialogHeading;
00540 YQAlignment * _contents;
00541 QHBox * _buttonBox;
00542 YQWizardButton * _backButton;
00543 QWidget * _backButtonSpacer;
00544 YQWizardButton * _abortButton;
00545 YQWizardButton * _nextButton;
00546
00547 QPtrList<YQWizard::Step> _stepsList;
00548 QDict<YQWizard::Step> _stepsIDs;
00549 QDict<YQWizard::TreeItem> _treeIDs;
00550 QDict<QPopupMenu> _menuIDs;
00551 vector<QString> _menuEntryIDs;
00552
00553
00554 protected:
00555
00559 class Step
00560 {
00561 public:
00562
00563 Step( const QString & name = "", const QString & id = "" )
00564 : _name( name )
00565 , _statusLabel( 0 )
00566 , _nameLabel(0)
00567 , _enabled( true )
00568 , _idList( id )
00569 {}
00570
00574 virtual ~Step() {}
00575
00576 virtual bool isHeading() const { return false; }
00577
00578 QString name() const { return _name; }
00579 QLabel * statusLabel() const { return _statusLabel; }
00580 QLabel * nameLabel() const { return _nameLabel; }
00581 bool isEnabled() const { return _enabled; }
00582 const QStringList & id() const { return _idList; }
00583 void addID( const QString & id ) { _idList.append( id ); }
00584 virtual bool hasID( const QString & id ) { return _idList.find( id ) != _idList.end(); }
00585
00586 void setStatusLabel( QLabel * label ) { _statusLabel = label; }
00587 void setNameLabel ( QLabel * label ) { _nameLabel = label; }
00588 void setEnabled( bool enabled ) { _enabled = enabled; }
00589
00590 protected:
00591
00592 QString _name;
00593 QLabel * _statusLabel;
00594 QLabel * _nameLabel;
00595 bool _enabled;
00596 QStringList _idList;
00597 };
00598
00599
00603 class StepHeading: public Step
00604 {
00605 public:
00606
00607 StepHeading( const QString & name = "" )
00608 : Step( name, "" )
00609 {}
00610
00611 virtual ~StepHeading() {}
00612 virtual bool isHeading() const { return true; }
00613 virtual bool hasID( const QString & id ) { return false; }
00614 };
00615
00616
00620 class TreeItem: public QY2ListViewItem
00621 {
00622 public:
00623 TreeItem( QY2ListView * parent,
00624 const QString & text,
00625 const QString & id )
00626 : QY2ListViewItem( parent, text, true )
00627 , _id( id )
00628 {}
00629
00630 TreeItem( YQWizard::TreeItem * parent,
00631 const QString & text,
00632 const QString & id )
00633 : QY2ListViewItem( parent, text, true )
00634 , _id( id )
00635 {}
00636
00637 QString text() const { return QListViewItem::text(0); }
00638 QString id() const { return _id; }
00639
00640 private:
00641 QString _id;
00642 };
00643
00644 };
00645
00646
00647
00648 #endif // YQWizard_h