RioQt Class Reference

#include <RioQt.h>

Public Slots

void createConnectionWindow (void)
 Create Window to Connect.
void createConfigureWindow (void)
void arrangeHorizontally (void)
 Tiles MDI windows horizontally.
void arrangeVertically (void)
 Tiles MDI windows vertically.
void arrangeCascade (void)
 Tiles MDI windows cascade.
void closeEvent (QCloseEvent *)
 Handle closeEvent Closes application.
void about (void)
 Show About Window.

Public Member Functions

 RioQt ()
ConfigDatagetConfig (void)
 Returns a pointer to ConfigData object.
void handle_SIGCHLD (int, int)
void appendEditor (Editor *)
 Appends an editor to editorList.
bool hasPendingEditor (FileWindow *)
 Returns true if there is some editor opened for 'file_window'.
int showMessage (int, string, string)
 Shows message in QMessageBox.

Static Public Attributes

static const int HORIZONTAL = 0
static const int VERTICAL = 1
static const int CASCADE = 2

Private Member Functions

void arrangeWindows (void)
 Arrange windows according to current state.
void customEvent (QCustomEvent *)
 Handles Custom Events.
void resizeEvent (QResizeEvent *)
 Handles resize event Rearrange MDI windows.

Private Attributes

QWorkspace * workspace
ConfigDataconfig
QPtrList< EditoreditorList
int windows_arrangement
QToolButton * tbTileHorizontally
QToolButton * tbTileVertically
QToolButton * tbCascade
int UpIntMonConnection

Detailed Description

Definition at line 36 of file RioQt.h.


Constructor & Destructor Documentation

RioQt::RioQt (  ) 

Definition at line 40 of file RioQt.cpp.

00041       : QMainWindow()
00042 {
00043     QString title = "Riosh ";
00044     title += VERSION;
00045     setCaption( title );
00046 
00047     // Read configuration file
00048     config = new ConfigData();
00049 
00050     config->readSettings();
00051 
00052     // Inicializando o intervalo de atualizacao da monitor connection
00053     UpIntMonConnection = config->getUpIntMonConnection();
00054 
00055     workspace = new QWorkspace( this, "workspace" );
00056     setCentralWidget( workspace );
00057 
00058     // Show Local Dir
00059     FileWindow *local = new FileWindow( workspace, this, FileWindow::LOCAL );
00060     local->show();
00061 
00062     // Creates Menu
00063     QPopupMenu *menuConnection = new QPopupMenu();
00064     menuConnection->insertItem( tr( "&Open new connection" ), this,
00065                                 SLOT( createConnectionWindow() ), CTRL+Key_O );
00066     menuConnection->insertSeparator();
00067     menuConnection->insertItem( tr( "&Quit" ), this,
00068                                 SLOT( close() ), CTRL+Key_Q );
00069 
00070     QPopupMenu *menuEdit = new QPopupMenu();
00071     menuEdit->insertItem( tr( "&Preferences" ), this,
00072                             SLOT( createConfigureWindow() ), CTRL+Key_P );
00073 
00074     QPopupMenu *menuWindow = new QPopupMenu();
00075     menuWindow->insertItem( tr( "&Tile vertically" ), this,
00076                             SLOT( arrangeVertically() ), CTRL+Key_T );
00077     menuWindow->insertItem( tr( "Tile &horizontally" ), this,
00078                             SLOT( arrangeHorizontally() ), CTRL+Key_H );
00079     menuWindow->insertItem( tr( "Cascad&e" ), this,
00080                             SLOT( arrangeCascade() ), CTRL+Key_E );
00081 
00082     QPopupMenu *menuHelp = new QPopupMenu();
00083     menuHelp->insertItem( tr( "A&bout" ), this,
00084                           SLOT( about() ), CTRL+Key_B );
00085 
00086     this->menuBar()->setSeparator( QMenuBar::InWindowsStyle );
00087     this->menuBar()->insertItem( tr( "&Connection" ), menuConnection );
00088     this->menuBar()->insertItem( tr( "&Edit" ), menuEdit );
00089     this->menuBar()->insertItem( tr( "&Window" ), menuWindow );
00090     this->menuBar()->insertSeparator();
00091     this->menuBar()->insertItem( tr( "&Help" ), menuHelp );
00092 
00093     // Toolbar
00094     QToolBar * toolbar = new QToolBar( this, "file operations" );
00095     // Arrangement
00096     tbTileHorizontally = new QToolButton( QIconSet( (const char **) image_view_top_bottom ),
00097                                           "Tile horizontally", QString::null,
00098                                           this, SLOT(arrangeHorizontally()),
00099                                           toolbar, "tile horizontally" );
00100     tbTileVertically   = new QToolButton( QIconSet( (const char **) image_view_left_right ),
00101                                           "Tile vertically", QString::null,
00102                                           this, SLOT(arrangeVertically()),
00103                                           toolbar, "tile vertically" );
00104     tbCascade          = new QToolButton( QIconSet( (const char **) image_view_cascade ),
00105                                           "Cascade", QString::null,
00106                                           this, SLOT(arrangeCascade()),
00107                                           toolbar, "cascade" );
00108     show();
00109 
00110     editorList.setAutoDelete( true );
00111 
00112     // Default arrangement is horizontal
00113     windows_arrangement = getConfig()->getRioshWindowArrangement();
00114     arrangeWindows();
00115 }


Member Function Documentation

void RioQt::about ( void   )  [slot]

Show About Window.

Definition at line 306 of file RioQt.cpp.

00307 {
00308     QString aboutText = tr( "Version " ) + QString( VERSION ) + "\n" + QString( STR_TXT_ABOUT );
00309     QMessageBox::about( this, STR_TTL_ABOUT, aboutText );
00310 }

void RioQt::appendEditor ( Editor editor  ) 

Appends an editor to editorList.

Definition at line 555 of file RioQt.cpp.

00556 {
00557     editorList.append( editor );
00558 }

void RioQt::arrangeCascade ( void   )  [slot]

Tiles MDI windows cascade.

Definition at line 256 of file RioQt.cpp.

00257 {
00258     windows_arrangement = CASCADE;
00259 
00260     workspace->cascade();
00261 }

void RioQt::arrangeHorizontally ( void   )  [slot]

Tiles MDI windows horizontally.

Definition at line 266 of file RioQt.cpp.

00267 {
00268     int y;
00269     int count;
00270     int heightForEach;
00271     int preferredHeight;
00272     int actHeight;
00273 
00274     windows_arrangement = HORIZONTAL;
00275 
00276     // primitive horizontal tiling
00277     count = workspace->windowList().count();
00278 
00279     if( count > 0 )
00280     {
00281         heightForEach = workspace->height() / count;
00282         y = 0;
00283         for( int i = 0; i < count; i++ )
00284         {
00285             QWidget *window = workspace->windowList().at( i );
00286             if( window->testWState( WState_Maximized ) )
00287             {
00288                 // prevent flicker
00289                 window->hide();
00290                 window->showNormal();
00291             }
00292             preferredHeight = window->minimumHeight()
00293                             + window->parentWidget()->baseSize().height();
00294             actHeight       = QMAX( heightForEach, preferredHeight );
00295 
00296             window->parentWidget()->setGeometry( 0, y,
00297                                                 workspace->width(), actHeight );
00298             y += actHeight;
00299         }
00300     }
00301 }

void RioQt::arrangeVertically ( void   )  [slot]

Tiles MDI windows vertically.

Definition at line 215 of file RioQt.cpp.

00216 {
00217     int x;
00218     int count;
00219     int widthForEach;
00220     int preferredWidth;
00221     int actWidth;
00222 
00223     windows_arrangement = VERTICAL;
00224 
00225     // primitive horizontal tiling
00226     count = workspace->windowList().count();
00227 
00228     if( count > 0 )
00229     {
00230         widthForEach = workspace->width() / count;
00231         x = 0;
00232         for( int i = 0; i < count; i++ )
00233         {
00234             QWidget *window = workspace->windowList().at( i );
00235             if( window->testWState( WState_Maximized ) )
00236             {
00237                 // prevent flicker
00238                 window->hide();
00239                 window->showNormal();
00240             }
00241             preferredWidth = window->minimumWidth()
00242                            + window->parentWidget()->baseSize().width();
00243             actWidth       = QMAX( widthForEach, preferredWidth );
00244 
00245             window->parentWidget()->setGeometry( x, 0,
00246                                                  actWidth,
00247                                                  workspace->height() );
00248             x += actWidth;
00249         }
00250     }
00251 }

void RioQt::arrangeWindows ( void   )  [private]

Arrange windows according to current state.

Definition at line 194 of file RioQt.cpp.

00195 {
00196     switch( windows_arrangement )
00197     {
00198         case VERTICAL:
00199             arrangeVertically();
00200             break;
00201 
00202         case HORIZONTAL:
00203             arrangeHorizontally();
00204             break;
00205 
00206         case CASCADE:
00207             arrangeCascade();
00208             break;
00209     }
00210 }

void RioQt::closeEvent ( QCloseEvent *  event  )  [slot]

Handle closeEvent Closes application.

Definition at line 316 of file RioQt.cpp.

00317 {
00318     bool can_close           = true;
00319 
00320     #ifdef USE_QT_GRID
00321     // Adapta��o para a Qt 3.1. A fun��o n�o possui par�metros na Qt 3.1.
00322     QWidgetList windows_list = workspace->windowList();
00323     #else
00324     QWidgetList windows_list = workspace->windowList( QWorkspace::CreationOrder );
00325     #endif
00326 
00327     // Verify if there is some pending editor for each FileWindow
00328     for( unsigned int i = 0; i < windows_list.count(); i++ )
00329     {
00330         if( hasPendingEditor( (FileWindow *)windows_list.at( i ) ) )
00331         {
00332             can_close = false;
00333 
00334             ShowMessageEvent * event = new ShowMessageEvent( ShowMessageEvent::WARNING,
00335                                                              tr( "There are files being edited in this window. Finalize these editors before closing it." ) );
00336             QApplication::postEvent( this, event );
00337 
00338             break;
00339         }
00340     }
00341 
00342     // Verify if there is some pending copy for each FileWindow
00343     for( unsigned int i = 0; i < windows_list.count(); i++ )
00344     {
00345         // As janelas DfRioWindow e MonitorWindow nao podem impedir o
00346         // fechamento do riosh, pois nao podem possuir copias pendentes
00347         if( ( windows_list.at( i )->name() != (QCString)"DfRioWindow" ) &&
00348             ( windows_list.at( i )->name() != (QCString)"MonitorWindow" ) )
00349         {
00350             FileWindow * fileWindow = (FileWindow *)windows_list.at( i );
00351             if( fileWindow->hasPendingCopies() )
00352             {
00353                 can_close = false;
00354 
00355                 ShowMessageEvent * event = new ShowMessageEvent( ShowMessageEvent::WARNING,
00356                                                                  tr( "There are copies that involves this window being performed.\nWait for these copies to finish or cancel them before closing this window." ) );
00357                 QApplication::postEvent( this, event );
00358                 break;
00359             }
00360         }
00361     }
00362 
00363     // Close only if there is no pending task
00364     if( can_close )
00365     {
00366         // Call Filewindow destructor
00367         delete workspace;
00368 
00369         event->accept();
00370     }
00371 }

void RioQt::createConfigureWindow ( void   )  [slot]

Definition at line 137 of file RioQt.cpp.

00138 {
00139     ConfigureWindow *dlg = new ConfigureWindow( this, config );
00140 
00141     if( dlg->exec() == QDialog::Accepted )
00142     {
00143         arrangeWindows();
00144 
00145         #ifdef USE_QT_GRID
00146         // Adapta��o para a Qt 3.1. A fun��o n�o possui par�metros na Qt 3.1.
00147         QWidgetList list = workspace->windowList();
00148         #else
00149         QWidgetList list = workspace->windowList( QWorkspace::CreationOrder );
00150         #endif
00151         
00152         //Atualizando arranjo atual de janelas (acionado apenas quando uma nova
00153         //janela for instanciada)
00154         windows_arrangement = getConfig()->getRioshWindowArrangement();
00155         //Atualizando o intervalo de atualizacao da monitor connection.
00156         UpIntMonConnection = getConfig()->getUpIntMonConnection();
00157         
00158         // Atualizando as FileWindow's e alterando o tempo de atualizacao das
00159         // MonitorWindow's
00160         QPtrListIterator <QWidget> it ( list );
00161         while ( it.current() != 0 )
00162         {  // for each widget...
00163             // Verifica se o QWidget e da classe FileWindow (somente esta
00164             // classe possui a funcao refreshDirectory).
00165             if( ( *it )->inherits( "FileWindow" ) ) 
00166             {
00167                 FileWindow *w = ( FileWindow * ) * it;
00168                 ++it;
00169                 w->refreshDirectory();
00170             }
00171             // Verifica se o QWidget e da classe MonitorWindow
00172             else if( ( *it )->inherits( "MonitorWindow" ) ) 
00173             {
00174                 MonitorWindow *w = ( MonitorWindow * ) * it;
00175                 ++it;
00176                 w->setUpdateInterval( UpIntMonConnection );
00177             }
00178             else if( ( *it )->inherits( "DfRioWindow" ) )
00179             {
00180                 DfRioWindow *w = ( DfRioWindow * ) * it;
00181                 ++it;
00182                 w->getDiskInfo();
00183             }
00184             else 
00185                 ++it;
00186         }
00187     }
00188 }

void RioQt::createConnectionWindow ( void   )  [slot]

Create Window to Connect.

Definition at line 121 of file RioQt.cpp.

00122 {
00123     ConnectWindow *dlg = new ConnectWindow( this, workspace );
00124 
00125     // Atualiza o intervalo de atualizacao da monitor connection.
00126     
00127     dlg->changeUpdateInterval( UpIntMonConnection );
00128     
00129     if( dlg->exec() == QDialog::Accepted )
00130     {
00131         arrangeWindows();
00132     }
00133 
00134     delete dlg;
00135 }

void RioQt::customEvent ( QCustomEvent *  event  )  [private]

Handles Custom Events.

Definition at line 385 of file RioQt.cpp.

00386 {
00387     if( event->type() == WINDOW_CLOSED_EVENT )
00388     {
00389         // Removes Window from windowList
00390         WindowClosedEvent *windowClosedEvent = (WindowClosedEvent *)event;
00391         workspace->windowList().remove( windowClosedEvent->getWindow() );
00392 
00393         delete windowClosedEvent->getWindow();
00394 
00395         // Rearrange windows
00396         arrangeWindows();
00397     }
00398     else if( event->type() == SHOW_MESSAGE_EVENT )
00399     {
00400         ShowMessageEvent *showMessageEvent = (ShowMessageEvent *)event;
00401         int result = showMessage( showMessageEvent->getType(),
00402                      showMessageEvent->getMessage(),
00403                      showMessageEvent->getTitle() );
00404         showMessageEvent->setResult( result );
00405     }
00406     else if( event->type() == WINDOW_OPENED_EVENT )
00407     {
00408         arrangeWindows();
00409     }
00410     else if( event->type() == PROGRESS_STATUS_EVENT )
00411     {
00412         ProgressStatusEvent *progressStatusEvent = (ProgressStatusEvent *)event;
00413 
00414         progressStatusEvent->updateProgress();
00415     }
00416     else if( event->type() == WINDOW_CONNECTION_LOST_EVENT )
00417     {        
00418         WindowConnectionLostEvent * connectionLostEvent =
00419                                              (WindowConnectionLostEvent *)event;
00420         FileWindow *window = (FileWindow *)connectionLostEvent->getWindow();
00421         
00422         FileItem *currentDir = window->getCurrentDir();
00423         QString currentHost = window->getUserName();
00424         CRioSession * currentSession = window->getSession();
00425         QString currentServer = (QString) currentSession->GetServerName();
00426 
00427         showMessage( ShowMessageEvent::ERROR, "Conex�o com " + currentHost + 
00428                     "@" + currentServer + " no diret�rio " +
00429                     currentDir->getFileName() + " perdida.\n" +
00430                     "A janela ser� fechada.", "ERROR" );
00431                     
00432         window->close();
00433     }
00434     else if( event->type() == SEARCH_LOGS_EVENT )
00435     {
00436         // Converte o evento generico para o tipo do evento da busca.
00437         SearchLogsEvent *SearchEvent = ( SearchLogsEvent * ) event;
00438         // Obtem o ponteiro para a janela de monitoramento.
00439         MonitorWindow *Monitor = SearchEvent->getMonitorWindow();
00440         // Processa o evento
00441         Monitor->processSearchLogsEvent( SearchEvent );
00442     }
00443 }

ConfigData * RioQt::getConfig ( void   ) 

Returns a pointer to ConfigData object.

Definition at line 489 of file RioQt.cpp.

00490 {
00491     return config;
00492 }

void RioQt::handle_SIGCHLD ( int  ,
int   
)
bool RioQt::hasPendingEditor ( FileWindow file_window  ) 

Returns true if there is some editor opened for 'file_window'.

Definition at line 563 of file RioQt.cpp.

00564 {
00565     Editor *editor;
00566 
00567     for( unsigned int i = 0; i < editorList.count(); i++ )
00568     {
00569         editor = ( (Editor *)editorList.at( i ) );
00570 
00571         if( editor->fileWindow == file_window )
00572             return true;
00573     }
00574 
00575     return false;
00576 }

void RioQt::resizeEvent ( QResizeEvent *   )  [private]

Handles resize event Rearrange MDI windows.

Definition at line 377 of file RioQt.cpp.

00378 {
00379     arrangeWindows();
00380 }

int RioQt::showMessage ( int  type,
string  message,
string  title 
)

Shows message in QMessageBox.

Definition at line 448 of file RioQt.cpp.

00449 {
00450     int status = 0;
00451 
00452     switch( type )
00453     {
00454         case ShowMessageEvent::ERROR:
00455             QMessageBox::critical( this, title, message,
00456                                   QMessageBox::Ok, QMessageBox::NoButton );
00457             break;
00458         case ShowMessageEvent::INFO:
00459             QMessageBox::information( this, title, message,
00460                                       QMessageBox::Ok, QMessageBox::NoButton );
00461             break;
00462         case ShowMessageEvent::QUESTION:
00463 
00464             #ifdef USE_QT_GRID
00465             // Adapta��o para a Qt 3.1. Este tipo de QMessageBox n�o existe no
00466             // Qt 3.1.
00467             status = QMessageBox(title, message, QMessageBox::NoIcon,
00468                                  QMessageBox::Yes, QMessageBox::No,
00469                                  QMessageBox::NoButton, this).exec();
00470             
00471             #else
00472             status = QMessageBox::question( this, title, message,
00473                                        QMessageBox::Yes, QMessageBox::No );
00474             #endif                           
00475         
00476             break;
00477         case ShowMessageEvent::WARNING:
00478             QMessageBox::warning( this, title, message,
00479                                   QMessageBox::Ok, QMessageBox::NoButton );
00480             break;
00481     }
00482 
00483     return status;
00484 }


Field Documentation

const int RioQt::CASCADE = 2 [static]

Definition at line 84 of file RioQt.h.

Definition at line 42 of file RioQt.h.

QPtrList<Editor> RioQt::editorList [private]

Definition at line 43 of file RioQt.h.

const int RioQt::HORIZONTAL = 0 [static]

Definition at line 82 of file RioQt.h.

QToolButton* RioQt::tbCascade [private]

Definition at line 48 of file RioQt.h.

QToolButton* RioQt::tbTileHorizontally [private]

Definition at line 46 of file RioQt.h.

QToolButton* RioQt::tbTileVertically [private]

Definition at line 47 of file RioQt.h.

Definition at line 52 of file RioQt.h.

const int RioQt::VERTICAL = 1 [static]

Definition at line 83 of file RioQt.h.

Definition at line 44 of file RioQt.h.

QWorkspace* RioQt::workspace [private]

Definition at line 41 of file RioQt.h.


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