DfRioWindow Class Reference

#include <DfRioWindow.h>

Public Member Functions

 DfRioWindow (QWidget *parent, FileWindow *rioFW, const char *name=0, WFlags f=0)
void getDiskInfo (void)
 This function calculates disk free space and populates dfList Uses RioExplorer::df method.
bool getDiskStatus (void)
 Returns true if had sucess in retrieving disk information.

Private Member Functions

void closeEvent (QCloseEvent *)
 Warns RioQt that this FileWindow has been closed.

Private Attributes

FileWindowrioFW
QListView * dfList
bool disk_status

Static Private Attributes

static const int MACHINE_COLUMN = 0
static const int DEVICE_COLUMN = 1
static const int USED_SIZE_COLUMN = 2
static const int FREE_SIZE_COLUMN = 3
static const int TOTAL_SIZE_COLUMN = 4
static const int PERCENT_USED_COLUMN = 5
static const int PERCENT_FREE_COLUMN = 6

Detailed Description

Definition at line 27 of file DfRioWindow.h.


Constructor & Destructor Documentation

DfRioWindow::DfRioWindow ( QWidget *  parent,
FileWindow rioFW,
const char *  name = 0,
WFlags  f = 0 
)

Definition at line 30 of file DfRioWindow.cpp.

00034     : QMainWindow( parent, name, f )
00035 {
00036     dfList = new QListView( this );
00037 
00038     this->rioFW = rioFW;
00039 
00040     setCaption( tr( "Disk information at server " ) + rioFW->getHost() );
00041     setCentralWidget( dfList );
00042 
00043     // Add columns
00044     dfList->addColumn( tr( "Machine"      ) );
00045     dfList->addColumn( tr( "Device"       ) );
00046     dfList->addColumn( tr( "Used Size"    ) );
00047     dfList->addColumn( tr( "Free Size"    ) );
00048     dfList->addColumn( tr( "Total Size"   ) );
00049     dfList->addColumn( tr( "Percent Used" ) );
00050     dfList->addColumn( tr( "Percent Free" ) );
00051 
00052     // Set alignments
00053     dfList->setColumnAlignment( USED_SIZE_COLUMN,    Qt::AlignRight );
00054     dfList->setColumnAlignment( FREE_SIZE_COLUMN,    Qt::AlignRight );
00055     dfList->setColumnAlignment( TOTAL_SIZE_COLUMN,   Qt::AlignRight );
00056     dfList->setColumnAlignment( PERCENT_USED_COLUMN, Qt::AlignRight );
00057     dfList->setColumnAlignment( PERCENT_FREE_COLUMN, Qt::AlignRight );
00058 
00059     dfList->setRootIsDecorated( true );
00060     dfList->setShowSortIndicator( true );
00061 
00062     getDiskInfo();
00063 }


Member Function Documentation

void DfRioWindow::closeEvent ( QCloseEvent *  closeEvent  )  [private]

Warns RioQt that this FileWindow has been closed.

Definition at line 68 of file DfRioWindow.cpp.

00069 {
00070     WindowClosedEvent *event;
00071 
00072     event = new WindowClosedEvent( this );
00073     QApplication::postEvent( rioFW->getRioQt(), event );
00074 
00075     closeEvent->accept();
00076 }

void DfRioWindow::getDiskInfo ( void   ) 

This function calculates disk free space and populates dfList Uses RioExplorer::df method.

Definition at line 83 of file DfRioWindow.cpp.

00084 {
00085     vector<DfInfo> info;
00086     double          percent_total;
00087     double          percent_free_total;            
00088     double          percent;
00089     RioObjectSize   usedsize_total;    
00090     RioObjectSize   freesize_total;                
00091     RioObjectSize   size_total;
00092 
00093     // Limpa o conteudo atual da lista
00094 
00095     dfList->clear();
00096     
00097     if( rioFW->df( &info ) )
00098     {
00099         for( unsigned int node = 0; node < info.size(); node++ )
00100         {
00101             percent_total        = 0;
00102             percent_free_total   = 0;            
00103             usedsize_total       = 0;    
00104             freesize_total       = 0;                
00105             size_total           = 0;
00106                         
00107             for( unsigned int disk = 0;
00108                  disk < info[ node ].storage_df_info.size();
00109                  disk++ )
00110             {
00111                 QListViewItem *item = new QListViewItem( dfList );
00112 
00113                 item->setText( MACHINE_COLUMN,
00114                                QString( info[node].storage_df_info[disk].hostname ) );
00115                 item->setText( DEVICE_COLUMN,
00116                                QString( info[node].storage_df_info[disk].diskname ) );
00117                 item->setText( USED_SIZE_COLUMN,
00118                                QString( rioFW->formatSize( info[node].storage_df_info[disk].used_size ).c_str() ) );
00119                 item->setText( FREE_SIZE_COLUMN,
00120                                QString( rioFW->formatSize( info[node].storage_df_info[disk].free_size ).c_str() ) );
00121                 item->setText( TOTAL_SIZE_COLUMN,
00122                                QString( rioFW->formatSize( info[node].storage_df_info[disk].size ).c_str() ) );
00123 
00124                 percent = info[node].storage_df_info[disk].used_blocks * 100.0
00125                         / info[node].storage_df_info[disk].total_blocks;
00126                 item->setText( PERCENT_USED_COLUMN,
00127                                QString( "%1 %%" ).arg( percent, 0, 'f', 2 ) );
00128 
00129                 percent_total += percent; 
00130                 percent = 100.0 - percent;
00131 
00132                 item->setText( PERCENT_FREE_COLUMN,
00133                                QString( "%1 %%" ).arg( percent, 0, 'f', 2 ) );
00134 
00135                 percent_free_total += percent;
00136 
00137                 usedsize_total += info[node].storage_df_info[disk].used_size;
00138                 freesize_total += info[node].storage_df_info[disk].free_size;
00139                 size_total += info[node].storage_df_info[disk].size;
00140             }
00141 
00142             QListViewItem *totalItem = new QListViewItem( dfList );
00143 
00144             totalItem->setText( MACHINE_COLUMN, "Total" );
00145             totalItem->setText( DEVICE_COLUMN, "" );
00146             totalItem->setText( USED_SIZE_COLUMN,
00147                            QString( rioFW->formatSize( usedsize_total ).c_str() ) );
00148             totalItem->setText( FREE_SIZE_COLUMN,
00149                            QString( rioFW->formatSize( freesize_total ).c_str() ) );
00150             totalItem->setText( TOTAL_SIZE_COLUMN,
00151                            QString( rioFW->formatSize( size_total ).c_str() ) );
00152 
00153             percent_total /= info[ node ].storage_df_info.size();
00154 
00155             totalItem->setText( PERCENT_USED_COLUMN,
00156                            QString( "%1 %%" ).arg( percent_total, 0, 'f', 2 ) );
00157 
00158             percent_free_total /= info[ node ].storage_df_info.size();
00159 
00160             totalItem->setText( PERCENT_FREE_COLUMN,
00161                            QString( "%1 %%" ).arg( percent_free_total, 0, 'f', 2 ) );
00162         }
00163 
00164         disk_status = true;
00165     }
00166     else
00167     {
00168         ShowMessageEvent * event = new ShowMessageEvent( ShowMessageEvent::ERROR,
00169                                                          tr( "Could not retrieve disk info from server " ) +
00170                                                          rioFW->getHost() + "." );
00171         QApplication::postEvent( rioFW->getRioQt(), event );
00172         disk_status = false;
00173     }
00174 }

bool DfRioWindow::getDiskStatus ( void   ) 

Returns true if had sucess in retrieving disk information.

Definition at line 179 of file DfRioWindow.cpp.

00180 {
00181     return disk_status;
00182 }


Field Documentation

const int DfRioWindow::DEVICE_COLUMN = 1 [static, private]

Definition at line 38 of file DfRioWindow.h.

QListView* DfRioWindow::dfList [private]

Definition at line 31 of file DfRioWindow.h.

bool DfRioWindow::disk_status [private]

Definition at line 32 of file DfRioWindow.h.

const int DfRioWindow::FREE_SIZE_COLUMN = 3 [static, private]

Definition at line 40 of file DfRioWindow.h.

const int DfRioWindow::MACHINE_COLUMN = 0 [static, private]

Definition at line 37 of file DfRioWindow.h.

const int DfRioWindow::PERCENT_FREE_COLUMN = 6 [static, private]

Definition at line 43 of file DfRioWindow.h.

const int DfRioWindow::PERCENT_USED_COLUMN = 5 [static, private]

Definition at line 42 of file DfRioWindow.h.

Definition at line 30 of file DfRioWindow.h.

const int DfRioWindow::TOTAL_SIZE_COLUMN = 4 [static, private]

Definition at line 41 of file DfRioWindow.h.

const int DfRioWindow::USED_SIZE_COLUMN = 2 [static, private]

Definition at line 39 of file DfRioWindow.h.


The documentation for this class was generated from the following files:
Generated on Wed Jul 4 16:03:34 2012 for RIO by  doxygen 1.6.3