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 protected:
00057 class Step;
00058 class TreeItem;
00059
00060 public:
00064 YQWizard( QWidget * parent,
00065 const YWidgetOpt & opt,
00066 const YCPValue & backButtonId, const YCPString & backButtonLabel,
00067 const YCPValue & abortButtonId, const YCPString & abortButtonLabel,
00068 const YCPValue & nextButtonId, const YCPString & nextButtonLabel );
00069
00073 virtual ~YQWizard();
00074
00075
00076 enum Direction { Forward, Backward };
00077
00083 Direction direction() const { return _direction; }
00084
00092 virtual YCPValue command( const YCPTerm & command );
00093
00099 virtual std::string debugLabel();
00100
00105 void addChild( YWidget * child );
00106
00112 long nicesize( YUIDimension dim );
00113
00117 void setSize( long newWidth, long newHeight );
00118
00122 bool eventFilter( QObject * obj, QEvent * ev );
00123
00127 void setDialogIcon( const char * iconName );
00128
00132 void setDialogHeading( const QString & headingText );
00133
00138 bool stepsEnabled() const { return _stepsEnabled; }
00139
00145 void addStep( const QString & text, const QString & id );
00146
00152 void addStepHeading( const QString & text );
00153
00158 void deleteSteps();
00159
00163 void setCurrentStep( const QString & id );
00164
00169 void updateSteps();
00170
00175 bool treeEnabled() const { return _treeEnabled; }
00176
00180 YQWizardButton * nextButton() const { return _nextButton; }
00181
00185 YQWizardButton * backButton() const { return _backButton; }
00186
00190 YQWizardButton * abortButton() const { return _abortButton; }
00191
00192
00196 void setVerboseCommands( bool verbose ) { _verboseCommands = verbose; }
00197
00204 void addTreeItem( const QString & parentID,
00205 const QString & text,
00206 const QString & id );
00207
00211 void selectTreeItem( const QString & id );
00212
00216 void deleteTreeItems();
00217
00218
00225 void addMenu( const QString & text,
00226 const QString & id );
00227
00231 void addSubMenu( const QString & parentMenuID,
00232 const QString & text,
00233 const QString & id );
00234
00239 void addMenuEntry( const QString & parentMenuID,
00240 const QString & text,
00241 const QString & id );
00242
00246 void addMenuSeparator( const QString & parentMenuID );
00247
00251 void deleteMenus();
00252
00253
00254 public slots:
00255
00256
00260 void setHelpText( QString helpText );
00261
00266 void resizeClientArea();
00267
00274 void showHelp();
00275
00280 void showSteps();
00281
00286 void showTree();
00287
00292 static void setGradient( QWidget * widget, const QPixmap & pixmap );
00293
00299 static void setBottomCroppedGradient( QWidget * widget,
00300 const QPixmap & pixmap,
00301 int croppedHeight );
00302
00307 static QPixmap bottomCropPixmap( const QPixmap & pixmap, int croppedHeight );
00308
00313 static QColor pixelColor( const QPixmap & pixmap, int x, int y );
00314
00315
00316 protected slots:
00317
00321 void backClicked();
00322
00326 void abortClicked();
00327
00331 void nextClicked();
00332
00337 void releaseNotesClicked();
00338
00344 void sendTreeEvent( QListViewItem * item );
00345
00352 void treeSelectionChanged();
00353
00358 void sendMenuEvent( int numID );
00359
00360
00367 void retranslateInternalButtons();
00368
00369 protected:
00370
00371
00372
00373 void layoutTitleBar ( QWidget * parent );
00374 void layoutSideBar ( QWidget * parent );
00375 void layoutSideBarButtonBox ( QWidget * parent, QPushButton * button );
00376 void layoutStepsPanel();
00377 void layoutHelpPanel();
00378 void layoutTreePanel();
00379 void layoutWorkArea ( QHBox * parentHBox );
00380 void layoutClientArea( QWidget * parent );
00381 void layoutButtonBox( QWidget * parent );
00382
00383
00387 void loadGradientPixmaps();
00388
00392 void loadStepsIcons();
00393
00397 void destroyButtons();
00398
00402 void updateStepStates();
00403
00412 void addGradientColumn( QWidget * parent, int width = 8 );
00413
00417 void sendEvent( YCPValue id );
00418
00419
00425 bool runningEmbedded() const { return _runningEmbedded; }
00426
00431 bool YQWizard::highColorDisplay() const;
00432
00433
00434
00435
00436
00437
00450 bool isCommand( QString declaration, const YCPTerm & term );
00451
00455 QString YQWizard::qStringArg( const YCPTerm & term, int argNo );
00456
00460 std::string stringArg( const YCPTerm & term, int argNo );
00461
00465 bool boolArg( const YCPTerm & term, int argNo );
00466
00470 YCPValue YQWizard::anyArg( const YCPTerm & term, int argNo );
00471
00475 void setButtonLabel( YQWizardButton * button, const QString & newLabel );
00476
00480 void setButtonID( YQWizardButton * button, const YCPValue & id );
00481
00485 void enableButton( YQWizardButton * button, bool enabled );
00486
00490 void setButtonFocus( YQWizardButton * button );
00491
00495 void setStepStatus( YQWizard::Step * step, const QPixmap & icon, const QColor & color );
00496
00500 YQWizard::Step * findStep( const QString & id );
00501
00507 YQWizard::TreeItem * findTreeItem( const QString & id );
00508
00515 YCPString currentTreeSelection();
00516
00522 void showReleaseNotesButton( string label, const YCPValue & id );
00523
00527 void hideReleaseNotesButton();
00528
00529
00530
00531
00532
00533
00534 bool _stepsEnabled;
00535 bool _treeEnabled;
00536 bool _verboseCommands;
00537 bool _protectNextButton;
00538 bool _stepsDirty;
00539 bool _runningEmbedded;
00540 Direction _direction;
00541
00542 QPixmap _titleBarGradientPixmap;
00543 QPixmap _topGradientPixmap;
00544 QColor _gradientCenterColor;
00545 QPixmap _bottomGradientPixmap;
00546
00547 QPixmap _stepCurrentIcon;
00548 QPixmap _stepToDoIcon;
00549 QPixmap _stepDoneIcon;
00550
00551 QColor _stepCurrentColor;
00552 QColor _stepToDoColor;
00553 QColor _stepDoneColor;
00554
00555 QString _currentStepID;
00556
00557
00558 QWidgetStack * _sideBar;
00559 QVBox * _stepsPanel;
00560 QVBox * _stepsBox;
00561 QGridLayout * _stepsGrid;
00562 QPushButton * _releaseNotesButton;
00563 YCPValue _releaseNotesButtonId;
00564 QPushButton * _helpButton;
00565 QHBox * _helpPanel;
00566 QTextBrowser * _helpBrowser;
00567 QPushButton * _stepsButton;
00568 QPushButton * _treeButton;
00569 QHBox * _treePanel;
00570 QY2ListView * _tree;
00571
00572 QVBox * _clientArea;
00573 QWidget * _menuBarBox;
00574 QMenuBar * _menuBar;
00575 QLabel * _dialogIcon;
00576 QLabel * _dialogHeading;
00577 YQAlignment * _contents;
00578 YQWizardButton * _backButton;
00579 QSpacerItem * _backButtonSpacer;
00580 YQWizardButton * _abortButton;
00581 YQWizardButton * _nextButton;
00582
00583 QPtrList<YQWizard::Step> _stepsList;
00584 QDict<YQWizard::Step> _stepsIDs;
00585 QDict<YQWizard::TreeItem> _treeIDs;
00586 QDict<QPopupMenu> _menuIDs;
00587 vector<QString> _menuEntryIDs;
00588
00589
00590 protected:
00591
00595 class Step
00596 {
00597 public:
00598
00599 Step( const QString & name = "", const QString & id = "" )
00600 : _name( name )
00601 , _statusLabel( 0 )
00602 , _nameLabel(0)
00603 , _enabled( true )
00604 , _idList( id )
00605 {}
00606
00610 virtual ~Step() {}
00611
00612 virtual bool isHeading() const { return false; }
00613
00614 QString name() const { return _name; }
00615 QLabel * statusLabel() const { return _statusLabel; }
00616 QLabel * nameLabel() const { return _nameLabel; }
00617 bool isEnabled() const { return _enabled; }
00618 const QStringList & id() const { return _idList; }
00619 void addID( const QString & id ) { _idList.append( id ); }
00620 virtual bool hasID( const QString & id ) { return _idList.find( id ) != _idList.end(); }
00621
00622 void setStatusLabel( QLabel * label ) { _statusLabel = label; }
00623 void setNameLabel ( QLabel * label ) { _nameLabel = label; }
00624 void setEnabled( bool enabled ) { _enabled = enabled; }
00625
00626 protected:
00627
00628 QString _name;
00629 QLabel * _statusLabel;
00630 QLabel * _nameLabel;
00631 bool _enabled;
00632 QStringList _idList;
00633 };
00634
00635
00639 class StepHeading: public Step
00640 {
00641 public:
00642
00643 StepHeading( const QString & name = "" )
00644 : Step( name, "" )
00645 {}
00646
00647 virtual ~StepHeading() {}
00648 virtual bool isHeading() const { return true; }
00649 virtual bool hasID( const QString & id ) { return false; }
00650 };
00651
00652
00656 class TreeItem: public QY2ListViewItem
00657 {
00658 public:
00659 TreeItem( QY2ListView * parent,
00660 const QString & text,
00661 const QString & id )
00662 : QY2ListViewItem( parent, text, true )
00663 , _id( id )
00664 {}
00665
00666 TreeItem( YQWizard::TreeItem * parent,
00667 const QString & text,
00668 const QString & id )
00669 : QY2ListViewItem( parent, text, true )
00670 , _id( id )
00671 {}
00672
00673 QString text() const { return QListViewItem::text(0); }
00674 QString id() const { return _id; }
00675
00676 private:
00677 QString _id;
00678 };
00679
00680 };
00681
00682
00683
00684 #endif // YQWizard_h