1 // File : SALOME_ProgressView.cxx
2 // Created : Thu Dec 18 12:01:00 2002
3 // Author : Vadim SANDLER, Open CASCADE SAS (vadim.sandler@opencascade.com)
5 // Module : Installation Wizard
6 // Copyright : 2002-2009 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 scriptName,
26 : QListViewItem( parent, productName ), myScript( scriptName )
30 // ================================================================
32 * ProgressViewItem::setStatus
33 * Sets new status for the item
35 // ================================================================
36 void ProgressViewItem::setStatus( Status status )
41 setText( 1, ProgressView::tr( "Waiting" ) ); break;
43 setText( 1, ProgressView::tr( "Processing" ) ); break;
45 setText( 1, ProgressView::tr( "Completed" ) ); break;
47 setText( 1, ProgressView::tr( "Aborted" ) ); break;
53 // ================================================================
55 * ProgressViewItem::paintCell
56 * Paints the cell of the list view item
58 // ================================================================
59 void ProgressViewItem::paintCell( QPainter* painter,
60 const QColorGroup& cg,
65 QColorGroup acg( cg );
69 acg.setColor( QColorGroup::Text, ( ( ProgressView* )listView() )->getWaitingColor() ); break;
71 acg.setColor( QColorGroup::Text, ( ( ProgressView* )listView() )->getProcessingColor() ); break;
73 acg.setColor( QColorGroup::Text, ( ( ProgressView* )listView() )->getCompletedColor() ); break;
75 acg.setColor( QColorGroup::Text, ( ( ProgressView* )listView() )->getWaitingColor() ); break;
80 QListViewItem::paintCell( painter, acg, column, width, align );
84 // ================================================================
86 * ProgressView::ProgressView
89 // ================================================================
90 ProgressView::ProgressView( QWidget* parent ) : QListView( parent )
92 addColumn( tr( "Product" ) ); addColumn( tr( "Status" ) );
94 setSelectionMode( QListView::NoSelection );
96 setResizeMode( QListView::AllColumns );
97 setFocusPolicy( QWidget::NoFocus );
98 setColors( QColor( "red" ), QColor( "orange" ), QColor( "green" ) );
100 // ================================================================
102 * ProgressView::setColors
105 // ================================================================
106 void ProgressView::setColors( QColor wColor, QColor pColor, QColor cColor ) {
107 myWaitingColor = wColor;
108 myProcessingColor = pColor;
109 myCompletedColor = cColor;
112 // ================================================================
114 * ProgressView::addProduct
117 // ================================================================
118 ProgressViewItem* ProgressView::addProduct( const QString product, const QString script ) {
119 QListViewItem* lastItem = this->lastItem();
120 ProgressViewItem* newItem = new ProgressViewItem( this, product, script );
122 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;
187 To get visibility status of an item in the progress list view
189 bool ProgressView::isVisible( const QString product ) {
190 return findItem( product )->isVisible();