ginebra2/Snippets.cpp
changeset 5 0f2326c2a325
parent 0 1450b09d0cfd
child 6 1c3b8676e58c
equal deleted inserted replaced
1:b0dd75e285d2 5:0f2326c2a325
     1 /*
     1 /*
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
     4 *
     9 * Initial Contributors:
     5 * This program is free software: you can redistribute it and/or modify
    10 * Nokia Corporation - initial contribution.
     6 * it under the terms of the GNU Lesser General Public License as published by
       
     7 * the Free Software Foundation, version 2.1 of the License.
    11 *
     8 *
    12 * Contributors:
     9 * This program is distributed in the hope that it will be useful,
       
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 * GNU Lesser General Public License for more details.
    13 *
    13 *
    14 * Description: 
    14 * You should have received a copy of the GNU Lesser General Public License
       
    15 * along with this program.  If not,
       
    16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
       
    17 *
       
    18 * Description:
    15 *
    19 *
    16 */
    20 */
    17 
       
    18 
    21 
    19 #include "Snippets.h"
    22 #include "Snippets.h"
    20 #include "ChromeSnippet.h"
    23 #include "ChromeSnippet.h"
    21 #include "ChromeWidget.h"
    24 #include "ChromeWidget.h"
    22 
    25 
    41   void Snippets::addSnippet(ChromeSnippet * snippet, const QString & id)
    44   void Snippets::addSnippet(ChromeSnippet * snippet, const QString & id)
    42   {
    45   {
    43     m_snippetMap[id] = snippet;
    46     m_snippetMap[id] = snippet;
    44   }
    47   }
    45 
    48 
    46   QObjectList Snippets::getList() 
    49   QObjectList Snippets::getList()
    47   {
    50   {
    48     QObjectList result;
    51     QObjectList result;
    49     foreach(GVA::ChromeSnippet *snippet, m_snippetMap) {
    52     foreach(GVA::ChromeSnippet *snippet, m_snippetMap) {
    50       result.append(snippet);
    53       result.append(snippet);
    51     }
    54     }
    52     return result;
    55     return result;
    53   }
    56   }
    54 
    57 
    55   void Snippets::clear()
    58   void Snippets::clear()
    56   {
    59   {
    57    
    60 
    58     foreach(ChromeSnippet *snippet, m_snippetMap){
    61     foreach(ChromeSnippet *snippet, m_snippetMap){
    59       if(snippet){
    62       if (snippet){
    60         //If anchored, shrink the anchor bar
    63         //If anchored, shrink the anchor bar
    61         m_chrome->snippetHiding(snippet);
    64         m_chrome->snippetHiding(snippet);
    62         //Remove about-to-be-deleted snippet from scene
    65         //Remove about-to-be-deleted snippet from scene
    63         m_chrome->getScene()->removeItem(snippet->widget());
    66         m_chrome->getScene()->removeItem(snippet->widget());
    64         delete snippet;
    67         delete snippet;