Logo Search packages:      
Sourcecode: valknut version File versions  Download package

bool DCGuiApp::eventFilter ( QObject *  object,
QEvent *  event 
) [protected, virtual]

event filter to catch close events for MDI child windows and is installed in createClient() on every child window. Closing a window calls the eventFilter first which removes the view from the connected documents' view list. If the last view is going to be closed, the eventFilter() tests if the document is modified; if yes, it asks the user to save the document. If the document title contains "Untitled", slotFileSaveAs() gets called to get a save name and path.

Definition at line 1010 of file dcgui.cpp.

References m_bTransferViewDockVisible, m_pTrayIcon, TrayIcon::setToolTip(), slotFileQuit(), statusDMLabel, statusFMLabel, and statusTRLabel.

{
      QString s;

      if((event->type() == QEvent::Close)&&((DCGuiApp*)object!=this))
      {
            // QCloseEvent* e=(QCloseEvent*)event;

            if ( ((DCTransferView*)object == g_pTransferView) && (g_pTransferView != 0) )
            {
                  ((DCTransferView*)object)->hide();
                  ((DCTransferView*)object)->setEnabled(FALSE);
                  m_bTransferViewDockVisible = FALSE;
            }
            else if ( ((DCHubListManager*)object == g_pHubListManager) && (g_pHubListManager != 0) )
            {
                  g_pHubListManager->hide();
                  g_pHubListManager->setEnabled(FALSE);
            }
            else if ( ((DCHubSearch*)object == g_pHubSearch) && (g_pHubSearch != 0) )
            {
                  g_pHubSearch->hide();
                  g_pHubSearch->setEnabled(FALSE);
            }
            else if ( ((DCSpy*)object == g_pSpy) && (g_pSpy != 0) )
            {
                  g_pSpy->hide();
                  g_pSpy->setEnabled(FALSE);
            }
            else if ( ((DCUsersList*)object == g_pUsersList) && (g_pUsersList != 0) )
            {
                  g_pUsersList->hide();
                  g_pUsersList->setEnabled(FALSE);
            }
            else if ( ((DCUpdateManager*)object == g_pUpdateManager) && (g_pUpdateManager != 0) )
            {
                  g_pUpdateManager->hide();
                  g_pUpdateManager->setEnabled(FALSE);
            }
      }
      else if((event->type() == QEvent::Close)&&((DCGuiApp*)object==this))
      {
            QCloseEvent* e=(QCloseEvent*)event;

            if ( slotFileQuit() == FALSE ) {
                  e->ignore();
                  return TRUE;
            }
      }
      else if( (event->type() == EVENT_UPDATE_DM_STATUSBAR) && ((DCGuiApp*)object!=this) )
      {
            DC_DownloadManagerEvent * e = (DC_DownloadManagerEvent*)event;

            s  = "SL: "+QString().setNum(e->m_pDownloadManagerInfo->slot_use_settings)+QString("/")+QString().setNum(e->m_pDownloadManagerInfo->slot_max) + " ";
            s += QString().setNum(e->m_pDownloadManagerInfo->slot_use_operator)+QString("/")+
                 QString().setNum(e->m_pDownloadManagerInfo->slot_use_user)+QString("/")+
                 QString().setNum(e->m_pDownloadManagerInfo->slot_use_special);

            s += QString(" UL: ")+CUtils::GetTransferString(e->m_pDownloadManagerInfo->Rate()).Data()+\
                  QString(" DL: ")+\
                  CUtils::GetTransferString(e->m_pDownloadManagerInfo->rate_dl).Data();

            statusDMLabel->setText(s);

            // set trayicon tooltip
            if ( m_pTrayIcon )
                  m_pTrayIcon->setToolTip(s + "\n" + statusTRLabel->text() );
      }
      else if( (event->type() == EVENT_UPDATE_FM_STATUSBAR) && ((DCGuiApp*)object!=this) )
      {
            DC_FileManagerEvent * e = (DC_FileManagerEvent*)event;

            switch(e->m_pFileManagerInfo->m_eFileManagerStatus)
            {
                  case efmsCREATESHARELIST:
                        s = "L ";
                        break;
                  case efmsCREATESEARCHINDEX:
                        s = "S ";
                        break;
                  case efmsCREATEHASHLIST:
                        s = "H ";
                        break;
                  default:
                        s = "";
                        break;
            }
            
            if ( s != "" )
            {
                  s += QString().setNum(e->m_pFileManagerInfo->m_nProgress,'f',2) + "%";
            }

            if ( CFileManager::Instance()->IsCreateShareListRunning() == FALSE )
            {
                  statusFMLabel->hide();
                  statusBar()->message(tr("Refresh share finished."));
            }
            else if ( !statusFMLabel->isVisible() )
            {
                  statusFMLabel->show();
            }

            statusFMLabel->setText(s);
      }
      else if( (event->type() == EVENT_UPDATE_TR_STATUSBAR) && ((DCGuiApp*)object!=this) )
      {
            DC_TrafficInfoEvent * e = (DC_TrafficInfoEvent*)event;

            s = ( "RX: " + CUtils::GetSizeString(e->m_pTrafficInfo->m_nRx,g_pConfig->GetUnit()) + " TX: " +
                CUtils::GetSizeString(e->m_pTrafficInfo->m_nTx,g_pConfig->GetUnit()) ).Data();

            statusTRLabel->setText(s);

            // set trayicon tooltip
            if ( m_pTrayIcon )
                  m_pTrayIcon->setToolTip( statusDMLabel->text() + "\n" + s );
      }
      else if ( (event->type() == QEvent::MouseButtonPress) && ((QLabel*)object == statusTRLabel) )
      {
            QMouseEvent * e = (QMouseEvent*)event;

            if ( e->button() == Qt::RightButton )
            {
                  int id;
                  QPopupMenu *m;

                  m = new QPopupMenu(this);

                  DCMenuHandler::InsertMenu( m, emiRESET );

                  id = m->exec(QCursor::pos());

                  delete m;

                  if ( id == emiRESET )
                  {
                        CSocket::m_Traffic.ResetTraffic();
                        statusTRLabel->setText("");
                  }
            }
      }

      return QWidget::eventFilter( object, event );    // standard event processing
}


Generated by  Doxygen 1.6.0   Back to index