1 // File : SALOME_ProgressView.cxx
2 // Created : Thu Dec 18 12:01:00 2002
3 // Author : Vadim SANDLER
4 // Project : PAL/SALOME
5 // Module : InstallWizard
6 // Copyright : 2004 CEA
9 #include "SALOME_ProgressView.hxx"
13 // ================================================================
15 * ProgressViewItem::ProgressViewItem
17 * <parent> - parent progress view
18 * <productName> - full name of the product
19 * <smbName> - alias for he product used by the script
20 * <status> - initial status of the product, default is 'Waiting'
22 // ================================================================
23 ProgressViewItem::ProgressViewItem( ProgressView* parent,
25 const QString installType,
26 const QString scriptName,
28 : QListViewItem( parent, productName, installType ), myScript( scriptName )
32 // ================================================================
34 * ProgressViewItem::setStatus
35 * Sets new status for the item
37 // ================================================================
38 void ProgressViewItem::setStatus( Status status )
43 setText( 2, ProgressView::tr( "Waiting" ) ); break;
45 setText( 2, ProgressView::tr( "Processing" ) ); break;
47 setText( 2, ProgressView::tr( "Completed" ) ); break;
49 setText( 2, ProgressView::tr( "Aborted" ) ); break;
55 // ================================================================
57 * ProgressViewItem::paintCell
58 * Paints the cell of the list view item
60 // ================================================================
61 void ProgressViewItem::paintCell( QPainter* painter,
62 const QColorGroup& cg,
67 QColorGroup acg( cg );
71 acg.setColor( QColorGroup::Text, ( ( ProgressView* )listView() )->getWaitingColor() ); break;
73 acg.setColor( QColorGroup::Text, ( ( ProgressView* )listView() )->getProcessingColor() ); break;
75 acg.setColor( QColorGroup::Text, ( ( ProgressView* )listView() )->getCompletedColor() ); break;
77 acg.setColor( QColorGroup::Text, ( ( ProgressView* )listView() )->getWaitingColor() ); break;
82 QListViewItem::paintCell( painter, acg, column, width, align );
86 // ================================================================
88 * ProgressView::ProgressView
91 // ================================================================
92 ProgressView::ProgressView( QWidget* parent ) : QListView( parent )
94 addColumn( tr( "Product" ) ); addColumn( tr( "Type" ) ); addColumn( tr( "Status" ) );
96 setSelectionMode( QListView::NoSelection );
98 setResizeMode( QListView::AllColumns );
99 setFocusPolicy( QWidget::NoFocus );
100 setColors( QColor( "red" ), QColor( "orange" ), QColor( "green" ) );
102 // ================================================================
104 * ProgressView::setColors
107 // ================================================================
108 void ProgressView::setColors( QColor wColor, QColor pColor, QColor cColor ) {
109 myWaitingColor = wColor;
110 myProcessingColor = pColor;
111 myCompletedColor = cColor;
114 // ================================================================
116 * ProgressView::addProduct
119 // ================================================================
120 void ProgressView::addProduct( const QString product, const QString type, const QString script ) {
121 QListViewItem* lastItem = this->lastItem();
122 ProgressViewItem* newItem = new ProgressViewItem( this, product, type, script );
124 newItem->moveItem( lastItem );
126 // ================================================================
128 * ProgressView::findStatus
129 * Finds the first item with given status
131 // ================================================================
132 QString ProgressView::findStatus( Status status ) {
133 ProgressViewItem* item = ( ProgressViewItem* )firstChild();
135 if ( item->getStatus() == status )
136 return item->getProduct();
137 item = ( ProgressViewItem* )( item->nextSibling() );
139 return QString::null;
141 // ================================================================
143 * ProgressView::findStatus
144 * Sets new status for the product item
146 // ================================================================
147 void ProgressView::setStatus( const QString product, Status status ) {
148 ProgressViewItem* item = findItem( product );
150 item->setStatus( status );
155 Scrolls the view to make item visible if necessary
157 void ProgressView::ensureVisible( const QString product ) {
158 ProgressViewItem* item = findItem( product );
160 ensureItemVisible( item );
164 Finds the item by the product name
166 ProgressViewItem* ProgressView::findItem( const QString product ) {
167 ProgressViewItem* item = ( ProgressViewItem* )firstChild();
169 if ( item->getProduct() == product )
171 item = ( ProgressViewItem* )( item->nextSibling() );
176 Gets the product script
178 QString ProgressView::getScript( const QString product ) {
179 ProgressViewItem* item = ( ProgressViewItem* )firstChild();
181 if ( item->getProduct() == product )
182 return item->getScript();
183 item = ( ProgressViewItem* )( item->nextSibling() );
185 return QString::null;