phoneuis/bubblemanager2/inc/bubblemanager2.h
changeset 21 92ab7f8d0eab
child 27 2f8f8080a020
equal deleted inserted replaced
4:c84cf270c54f 21:92ab7f8d0eab
       
     1 /*!
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     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 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  BubbleManager widget.
       
    15 *
       
    16 */
       
    17 
       
    18 // Bubble widget API
       
    19 
       
    20 #ifndef BUBBLEMANAGER2_H
       
    21 #define BUBBLEMANAGER2_H
       
    22 
       
    23 #include <QtCore>
       
    24 #include <hbwidget.h>
       
    25 #include "bubblemanagerif.h"
       
    26 
       
    27 #ifdef BUILD_BUBBLEMANAGER
       
    28 #define BUBBLEMANAGER_EXPORT Q_DECL_EXPORT
       
    29 #else
       
    30 #define BUBBLEMANAGER_EXPORT Q_DECL_IMPORT
       
    31 #endif
       
    32 
       
    33 class BubbleHeader;
       
    34 class BubbleConferenceHeader;
       
    35 class BubbleWidgetManager;
       
    36 class HbAction;
       
    37 class HbStackedLayout;
       
    38 class BubbleHandler;
       
    39 
       
    40 static const int BUBBLE_MAX_CALL_COUNT = 7;
       
    41 static const int BUBBLE_CONF_CALL_ID   = 10;
       
    42 
       
    43 class BUBBLEMANAGER_EXPORT BubbleManager : public HbWidget, public BubbleManagerIF
       
    44 {
       
    45     Q_OBJECT
       
    46 
       
    47 public:
       
    48     explicit BubbleManager( QGraphicsItem *parent = 0 );
       
    49     ~BubbleManager();
       
    50 
       
    51 public:
       
    52 
       
    53     // ====================================================
       
    54     // Must surround all the changes:
       
    55     // ====================================================
       
    56     //
       
    57 
       
    58     /**
       
    59     * Before making any changes to bubble headers, call this function
       
    60     * so that manager can prapare for them properly.
       
    61     */
       
    62     void startChanges();
       
    63 
       
    64     /**
       
    65     * After the changes to bubble headers call this function so manager
       
    66     * can prepare bubbles to right places and check the drawing order.
       
    67     * Memory for arrays has been allocated beforehand.
       
    68     */
       
    69     void endChanges();
       
    70 
       
    71 
       
    72     // ====================================================
       
    73     // For call headers and some for conference call
       
    74     // ====================================================
       
    75     //
       
    76 
       
    77     /**
       
    78     * Takes a new call header in use.
       
    79     * Returns bubble idenfication number.
       
    80     */
       
    81     int createCallHeader();
       
    82 
       
    83     /**
       
    84     * Removes call header from use
       
    85     */
       
    86     void removeCallHeader( int bubbleId );
       
    87 
       
    88     /**
       
    89     * Sets call state to header.
       
    90     */
       
    91     void setState( int bubbleId,
       
    92                    PhoneCallState state );
       
    93 
       
    94     /**
       
    95     * Sets text label to header. For conf also.
       
    96     * Text to be seen in bubble ( e.g. 'on hold' )
       
    97     */
       
    98     void setLabel(
       
    99         int bubbleId,
       
   100         const QString& text,
       
   101         Qt::TextElideMode clipDirection = Qt::ElideRight );
       
   102 
       
   103     /**
       
   104     * Sets caller's line identification ( name or number) to header.
       
   105     * For conf also. Caller's CLI ( e.g. 'Mother' )
       
   106     */
       
   107     void setCli( int bubbleId,
       
   108                  const QString& cliText,
       
   109                  Qt::TextElideMode clipDirection );
       
   110 
       
   111     /**
       
   112     * Updates caller's line identification ( name or number) to header.
       
   113     * Caller's CLI ( e.g. 'Daddy' )-
       
   114     */
       
   115     void updateCLI(
       
   116         int bubbleId,
       
   117         const QString& cliText,
       
   118         Qt::TextElideMode clipDirection );
       
   119 
       
   120     /**
       
   121     * Number or voip adress, when phonebook name takes Cli.
       
   122     */
       
   123     void setSecondaryCli(
       
   124         int bubbleId,
       
   125         const QString& cliText,
       
   126         Qt::TextElideMode clipDirection = Qt::ElideLeft );
       
   127 
       
   128 
       
   129     /**
       
   130     * Sets call time or cost text to header. For conf also.
       
   131     */
       
   132     void setCallTime(
       
   133         int bubbleId,
       
   134         const QString& callTime );
       
   135 
       
   136     /**
       
   137     * Updates call time or cost text to header.  For conf also.
       
   138     * Timer or cost text ( e.g. '00:12:34' or '£01.23' ).
       
   139     */
       
   140     void updateCallTime(
       
   141         int bubbleId,
       
   142         const QString& callTime );
       
   143 
       
   144     /**
       
   145     * Attach a call image to header.
       
   146     */
       
   147     void setCallObjectImage( int bubbleId,
       
   148                              const QString& fileName );
       
   149 
       
   150     /**
       
   151     * Attach the theme call image to header.
       
   152     */
       
   153     void setCallObjectFromTheme( int bubbleId );
       
   154 
       
   155     /**
       
   156     * Sets call flags to header.
       
   157     */
       
   158     void setCallFlags(
       
   159         int bubbleId,
       
   160         int flags );
       
   161 
       
   162     /**
       
   163     * Sets call flags to header.
       
   164     */
       
   165     void setCallFlag( int bubbleId,
       
   166                       PhoneCallFlags flag,
       
   167                       bool set );
       
   168 
       
   169     /**
       
   170     * Sets number type.
       
   171     */
       
   172     void setNumberType( int bubbleId,
       
   173                         PhoneNumberType type );
       
   174 
       
   175     // ====================================================
       
   176     // For all bubbles
       
   177     // ====================================================
       
   178     //
       
   179 
       
   180     /**
       
   181     * Sets phone muted/unmuted.
       
   182     * @param aIsMuted ETrue if phone is muted.
       
   183     */
       
   184     void setPhoneMuted( bool muted = true );
       
   185 
       
   186 
       
   187     // ====================================================
       
   188     // For conference call
       
   189     // ====================================================
       
   190     //
       
   191 
       
   192     /**
       
   193     * Creates a conference call based upon two calls. Bubbles must be
       
   194     * created first.
       
   195     */
       
   196     int createConference( int bubble1,
       
   197                           int bubble2 );
       
   198 
       
   199     /**
       
   200     * Splits conference call into invidual two calls. Call headers stays
       
   201     * in use. Headers' state will not be changed.
       
   202     */
       
   203     void removeConference();
       
   204 
       
   205     /**
       
   206     * Adds new call to conference call.
       
   207     */
       
   208     void addRowToConference( int bubbleId );
       
   209 
       
   210     /**
       
   211     * Takes specified call out of conference. Use RemoveConference if
       
   212     * conference has only two calls in it. Header's state is same as
       
   213     * before adding it to conference (if not changed inside the conf).
       
   214     */
       
   215     void removeRowFromConference( int bubbleId );
       
   216 
       
   217     /**
       
   218     * Counts calls in conference call.
       
   219     */
       
   220     int conferenceRowCount() const;
       
   221 
       
   222     /**
       
   223     * Sets highlight to specified line in conference.
       
   224     */
       
   225     void setSelectionInConference( int rowNumber );
       
   226 
       
   227     /**
       
   228     * Sets highlight to specified bubble id in conference.
       
   229     */
       
   230     void setSelectionIdInConference( int bubbleId );
       
   231 
       
   232     /**
       
   233     * Gets highlighted item in conference.
       
   234     */
       
   235     int selectionInConference() const;
       
   236 
       
   237     /**
       
   238     * Gets highlighted item in conference.
       
   239     */
       
   240     int selectionIdInConference() const;
       
   241 
       
   242     /**
       
   243     * Moves highligh one up if possible
       
   244     */
       
   245     void moveHighlightOneUpInConference();
       
   246 
       
   247     /**
       
   248     * Moves highligh one down if possible
       
   249     */
       
   250     void moveHighlightOneDownInConference();
       
   251 
       
   252     /**
       
   253     * Use this function to expand or shrink conference bubble.
       
   254     */
       
   255     void setExpandedConferenceCallHeader(
       
   256         bool expanded = true );
       
   257 
       
   258     /**
       
   259     * Query: is conference expanded?
       
   260     */
       
   261     bool isConferenceExpanded( ) const;
       
   262 
       
   263     /**
       
   264     * Number of headers shown on the screen.
       
   265     */
       
   266     int shownHeaderCount() const;
       
   267 
       
   268     /**
       
   269     * Set CLI used in participant list (text or phonenumber).
       
   270     */
       
   271     void setParticipantListCli(
       
   272         int aBubbleId,
       
   273         ParticipantListCli aParticipantCli );
       
   274 
       
   275 
       
   276     // ====================================================
       
   277     // Call bubble actions
       
   278     // ====================================================
       
   279     //
       
   280 
       
   281     /**
       
   282     * Appends new action to call bubble
       
   283     */
       
   284     void addAction ( int bubbleId, HbAction* action );
       
   285 
       
   286     /**
       
   287     * Removes all actions from call bubble
       
   288     */
       
   289     void clearActions( int bubbleId );
       
   290 
       
   291     /**
       
   292     * Gets graphics widget for action
       
   293     */
       
   294     QGraphicsWidget* graphicsWidgetForAction(
       
   295         HbAction* action ) const;
       
   296 
       
   297     /**
       
   298     * Appends new action to participant list in conference call bubble.
       
   299     */
       
   300     void addParticipantListAction(HbAction *action);
       
   301 
       
   302     /**
       
   303     * Removes participant list actions from conference call bubble.
       
   304     */
       
   305     void clearParticipantListActions();
       
   306 
       
   307 
       
   308     // ====================================================
       
   309     // Bubble state related (multicall)
       
   310     // ====================================================
       
   311     //
       
   312 
       
   313     /**
       
   314     * Bubble shown in expanded position.
       
   315     */
       
   316     int expandedBubble() const;
       
   317 
       
   318     /**
       
   319     * Sets action that is triggered when user taps collapsed
       
   320     * call bubble and it changes to expanded. Setting null
       
   321     * pointer removes expand action.
       
   322     */
       
   323     void setExpandAction(int bubbleId, HbAction* action);
       
   324 
       
   325     /**
       
   326     * Bubble state (expanded/collapsed) cannot be changed when
       
   327     * disabled is set true.
       
   328     */
       
   329     void setBubbleSelectionDisabled(bool disabled);
       
   330 
       
   331 public slots:
       
   332     void handleOrientationChange(Qt::Orientation orientation);
       
   333 
       
   334 private:
       
   335     QGraphicsWidget* selectView();
       
   336     bool addToLayout(QGraphicsWidget* widget);
       
   337     void removeFromLayout(QGraphicsWidget* widget);
       
   338     void connectSignals(QGraphicsWidget* widget);
       
   339     void setViewData(QGraphicsWidget* view);
       
   340 
       
   341     bool findActiveHeader(int bubbleId, BubbleHeader*& header);
       
   342     void findNextDrawableHeader(int& index) const;
       
   343     void polishEvent();
       
   344 
       
   345 private slots:
       
   346     void showExpanded( int bubbleId );
       
   347 
       
   348 private:
       
   349     QVector<BubbleHeader*> mCallHeaders;
       
   350     BubbleConferenceHeader* mConferenceHeader;
       
   351     QVector<BubbleHeader*> mActiveHeaders;
       
   352     QVector<BubbleHandler*> mActiveHandlers;
       
   353 
       
   354     int mIsReadyToDraw;
       
   355     int mDefaultStyleBaseId;
       
   356     bool mMuted;
       
   357     QGraphicsWidget* mMutedIcon;
       
   358     bool mSortHeaders;
       
   359     BubbleWidgetManager* mWidgetManager;
       
   360     HbStackedLayout* mMainLayout;
       
   361     bool mInitialized;
       
   362     bool mBubbleSelectionDisabled;
       
   363 };
       
   364 
       
   365 #endif /* BUBBLEMANAGER2_H */
       
   366 
       
   367 
       
   368 
       
   369 
       
   370 
       
   371 
       
   372 
       
   373 
       
   374 
       
   375 
       
   376 
       
   377 
       
   378 
       
   379 
       
   380 
       
   381 
       
   382 
       
   383 
       
   384