connectionmonitoring/connectionview/src/connectionview.cpp
changeset 20 9c97ad6591ae
parent 18 fcbbe021d614
child 27 489cf6208544
equal deleted inserted replaced
18:fcbbe021d614 20:9c97ad6591ae
    79 
    79 
    80 ConnectionView::~ConnectionView()
    80 ConnectionView::~ConnectionView()
    81 {
    81 {
    82     OstTraceFunctionEntry0( DUP1_CONNECTIONVIEW_CONNECTIONVIEW_ENTRY );
    82     OstTraceFunctionEntry0( DUP1_CONNECTIONVIEW_CONNECTIONVIEW_ENTRY );
    83     // other widgets are childs of this widget, so they will be
    83     // other widgets are childs of this widget, so they will be
    84     // deleted along with mMainView. Add infolabel and scrollarea
    84     // deleted along with mMainView. 
    85     // again under mainlayout, since one of them is only there at the time
       
    86     // this way all the ui components are deleted at once
       
    87     mInfoLabel->setParentLayoutItem(mMainLayout);
       
    88     mScrollArea->setParentLayoutItem(mMainLayout);
       
    89     delete mMainView;
    85     delete mMainView;
       
    86     delete mNoConnView;
    90     OstTraceFunctionExit0( DUP1_CONNECTIONVIEW_CONNECTIONVIEW_EXIT );
    87     OstTraceFunctionExit0( DUP1_CONNECTIONVIEW_CONNECTIONVIEW_EXIT );
    91 }
    88 }
    92 
    89 
    93 /* !
    90 /* !
    94      Quit the application when the timer is triggered
    91      Quit the application when the timer is triggered
   106 */ 
   103 */ 
   107 void ConnectionView::createView()
   104 void ConnectionView::createView()
   108 {
   105 {
   109     OstTraceFunctionEntry0( CONNECTIONVIEW_CREATEVIEW_ENTRY );
   106     OstTraceFunctionEntry0( CONNECTIONVIEW_CREATEVIEW_ENTRY );
   110     
   107     
   111     // Create the mainView and the layout for the window
   108     // Create the secondary view for displaying the "No active connections"-text
   112     mMainView = new HbView();
   109     mNoConnView = new HbView();
   113     addView(mMainView);
   110     mNoConnView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
   114     setCurrentView(mMainView);
   111     addView(mNoConnView);
       
   112     QGraphicsLinearLayout *noConnViewLayout = new QGraphicsLinearLayout(Qt::Vertical);
       
   113     noConnViewLayout->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
       
   114 
       
   115     HbLabel *infoLabel = new HbLabel;
       
   116     infoLabel->setObjectName("mInfoLabel");
       
   117     infoLabel->setPlainText(hbTrId("txt_occ_info_no_active_connections"));
       
   118     infoLabel->setAlignment(Qt::AlignCenter);
       
   119     noConnViewLayout->addItem(infoLabel);
       
   120     noConnViewLayout->setAlignment(infoLabel, Qt::AlignCenter);
       
   121     mNoConnView->setLayout(noConnViewLayout);
   115    
   122    
   116     mMainLayout = new QGraphicsLinearLayout(Qt::Vertical);
   123     mMainLayout = new QGraphicsLinearLayout(Qt::Vertical);
   117     mMainLayout->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
   124     mMainLayout->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
   118     mScrollArea = new HbScrollArea();
   125     mScrollArea = new HbScrollArea();
   119     mScrollArea->setScrollDirections(Qt::Vertical);
   126     mScrollArea->setScrollDirections(Qt::Vertical);
   120     mScrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
   127     mScrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
   121     mMainLayout->addItem(mScrollArea);
   128     mMainLayout->addItem(mScrollArea);
   122 
   129 
   123     // Create the widgets and layouts for the scroll area
   130     // Create the mainView and the layout for the window
       
   131     mMainView = new HbView();
       
   132     addView(mMainView);
   124     ScrollAreaWidget *scrollContent = new ScrollAreaWidget();
   133     ScrollAreaWidget *scrollContent = new ScrollAreaWidget();
   125     scrollContent->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
   134     scrollContent->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
   126     mScrollArea->installEventFilter(scrollContent);
   135     mScrollArea->installEventFilter(scrollContent);
   127     
   136     
   128     mBoxLayout = new QGraphicsLinearLayout(Qt::Vertical);
   137     mBoxLayout = new QGraphicsLinearLayout(Qt::Vertical);
   140             mDisconnectAction,
   149             mDisconnectAction,
   141             SIGNAL(triggered(bool)),
   150             SIGNAL(triggered(bool)),
   142             this,
   151             this,
   143             SLOT(disconnectAll()));
   152             SLOT(disconnectAll()));
   144     
   153     
   145     // label for informing the user that there are no connections
       
   146     mInfoLabel = new HbLabel;
       
   147     mInfoLabel->setObjectName("mInfoLabel");
       
   148     mInfoLabel->setPlainText(hbTrId("txt_occ_info_no_active_connections"));
       
   149     mInfoLabel->setAlignment(Qt::AlignCenter);
       
   150     
       
   151     // Create the actual groupboxes for all the active connections
   154     // Create the actual groupboxes for all the active connections
   152     createGroupBoxesForConnections();  
   155     createGroupBoxesForConnections();  
   153     show();
   156     show();
   154     
   157     
   155     OstTraceFunctionExit0( CONNECTIONVIEW_CREATEVIEW_EXIT );
   158     OstTraceFunctionExit0( CONNECTIONVIEW_CREATEVIEW_EXIT );
   178         mToolBar->show();
   181         mToolBar->show();
   179     } else {
   182     } else {
   180         mToolBar->hide();
   183         mToolBar->hide();
   181     }
   184     }
   182     
   185     
   183     // if there are connections, then the label should be removed
   186     // if there are connections, the main view with the connections is shown
   184     // and the connection boxes drawn
       
   185     if (mConnectionCount > 0) { 
   187     if (mConnectionCount > 0) { 
   186         mMainLayout->removeItem(mInfoLabel);
   188         setCurrentView(mMainView);
   187         mInfoLabel->hide();
       
   188         mMainLayout->addItem(mScrollArea);
       
   189 
   189 
   190         for (int i=0; i<mConnectionCount; i++) {
   190         for (int i=0; i<mConnectionCount; i++) {
   191             // Get the iap id and the iap name for the UI construction
   191             // Get the iap id and the iap name for the UI construction
   192             bool ok = true;
   192             bool ok = true;
   193             int iapId = activeConfigurations[i].identifier().toInt(&ok);
   193             int iapId = activeConfigurations[i].identifier().toInt(&ok);
   202             mSignalMapper, 
   202             mSignalMapper, 
   203             SIGNAL(mapped(int)), 
   203             SIGNAL(mapped(int)), 
   204             this, 
   204             this, 
   205             SLOT(disconnectSelectedIap(int)));
   205             SLOT(disconnectSelectedIap(int)));
   206         
   206         
   207         // there are no connections, inform the user with the text 
   207         // there are no connections, show the view with the "no connections" label
   208     } else {
   208     } else {
   209         mMainLayout->removeItem(mScrollArea);
   209         setCurrentView(mNoConnView);
   210         mInfoLabel->show();
       
   211         mMainLayout->addItem(mInfoLabel);
       
   212         mMainLayout->setAlignment(mInfoLabel, Qt::AlignCenter);
       
   213         // start the timer to close the application after 3 seconds
   210         // start the timer to close the application after 3 seconds
   214         if (mClosingTimer == 0) {
   211         if (mClosingTimer == 0) {
   215             mClosingTimer = startTimer(timerValue);
   212             mClosingTimer = startTimer(timerValue);
   216         }
   213         }
   217     }
   214     }
   306     groupBox->setCollapsable(true);
   303     groupBox->setCollapsable(true);
   307     
   304     
   308     // Create the disconnection button
   305     // Create the disconnection button
   309     HbPushButton* button = new HbPushButton(
   306     HbPushButton* button = new HbPushButton(
   310             hbTrId("txt_occ_button_disconnect"), mMainView);
   307             hbTrId("txt_occ_button_disconnect"), mMainView);
       
   308     button->setObjectName("disconnectButton");
   311     button->setSizePolicy(QSizePolicy::Preferred, 
   309     button->setSizePolicy(QSizePolicy::Preferred, 
   312                           QSizePolicy::Preferred, 
   310                           QSizePolicy::Preferred, 
   313                           QSizePolicy::PushButton);
   311                           QSizePolicy::PushButton);
   314     
   312     
   315     // Create the horizontal layout for the labels
   313     // Create the horizontal layout for the labels