1 // File : SALOME_ProgressView.cxx
2 // Created : Thu Dec 18 12:01:00 2002
3 // Author : Vadim SANDLER
5 // Module : Installation Wizard
6 // Copyright : 2004-2005 CEA
8 #include "SALOME_ProgressView.hxx"
12 // ================================================================
14 * ProgressViewItem::ProgressViewItem
16 * <parent> - parent progress view
17 * <productName> - full name of the product
18 * <smbName> - alias for he product used by the script
19 * <status> - initial status of the product, default is 'Waiting'
21 // ================================================================
22 ProgressViewItem::ProgressViewItem( ProgressView* parent,
24 const QString installType,
25 const QString scriptName,
27 : QListViewItem( parent, productName, installType ), myScript( scriptName )
31 // ================================================================
33 * ProgressViewItem::setStatus
34 * Sets new status for the item
36 // ================================================================
37 void ProgressViewItem::setStatus( Status status )
42 setText( 2, ProgressView::tr( "Waiting" ) ); break;
44 setText( 2, ProgressView::tr( "Processing" ) ); break;
46 setText( 2, ProgressView::tr( "Completed" ) ); break;
48 setText( 2, ProgressView::tr( "Aborted" ) ); break;
54 // ================================================================
56 * ProgressViewItem::paintCell
57 * Paints the cell of the list view item
59 // ================================================================
60 void ProgressViewItem::paintCell( QPainter* painter,
61 const QColorGroup& cg,
66 QColorGroup acg( cg );
70 acg.setColor( QColorGroup::Text, ( ( ProgressView* )listView() )->getWaitingColor() ); break;
72 acg.setColor( QColorGroup::Text, ( ( ProgressView* )listView() )->getProcessingColor() ); break;
74 acg.setColor( QColorGroup::Text, ( ( ProgressView* )listView() )->getCompletedColor() ); break;
76 acg.setColor( QColorGroup::Text, ( ( ProgressView* )listView() )->getWaitingColor() ); break;
81 QListViewItem::paintCell( painter, acg, column, width, align );
85 // ================================================================
87 * ProgressView::ProgressView
90 // ================================================================
91 ProgressView::ProgressView( QWidget* parent ) : QListView( parent )
93 addColumn( tr( "Product" ) ); addColumn( tr( "Type" ) ); addColumn( tr( "Status" ) );
95 setSelectionMode( QListView::NoSelection );
97 setResizeMode( QListView::AllColumns );
98 setFocusPolicy( QWidget::NoFocus );
99 setColors( QColor( "red" ), QColor( "orange" ), QColor( "green" ) );
101 // ================================================================
103 * ProgressView::setColors
106 // ================================================================
107 void ProgressView::setColors( QColor wColor, QColor pColor, QColor cColor ) {
108 myWaitingColor = wColor;
109 myProcessingColor = pColor;
110 myCompletedColor = cColor;
113 // ================================================================
115 * ProgressView::addProduct
118 // ================================================================
119 void ProgressView::addProduct( const QString product, const QString type, const QString script ) {
120 QListViewItem* lastItem = this->lastItem();
121 ProgressViewItem* newItem = new ProgressViewItem( this, product, type, script );
123 newItem->moveItem( lastItem );
125 // ================================================================
127 * ProgressView::findStatus
128 * Finds the first item with given status
130 // ================================================================
131 QString ProgressView::findStatus( Status status ) {
132 ProgressViewItem* item = ( ProgressViewItem* )firstChild();
134 if ( item->getStatus() == status )
135 return item->getProduct();
136 item = ( ProgressViewItem* )( item->nextSibling() );
138 return QString::null;
140 // ================================================================
142 * ProgressView::findStatus
143 * Sets new status for the product item
145 // ================================================================
146 void ProgressView::setStatus( const QString product, Status status ) {
147 ProgressViewItem* item = findItem( product );
149 item->setStatus( status );
154 Scrolls the view to make item visible if necessary
156 void ProgressView::ensureVisible( const QString product ) {
157 ProgressViewItem* item = findItem( product );
159 ensureItemVisible( item );
163 Finds the item by the product name
165 ProgressViewItem* ProgressView::findItem( const QString product ) {
166 ProgressViewItem* item = ( ProgressViewItem* )firstChild();
168 if ( item->getProduct() == product )
170 item = ( ProgressViewItem* )( item->nextSibling() );
175 Gets the product script
177 QString ProgressView::getScript( const QString product ) {
178 ProgressViewItem* item = ( ProgressViewItem* )firstChild();
180 if ( item->getProduct() == product )
181 return item->getScript();
182 item = ( ProgressViewItem* )( item->nextSibling() );
184 return QString::null;