# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1278414996 -10800 # Node ID 64a47b97e1e1ff6131a804bc163c089347e005f0 # Parent b04270301d3bfc45f52d58842c9cd2342ac91d1e Revision: 201025 Kit: 2010127 diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/inc/logsbaseview.h --- a/logsui/logsapp/inc/logsbaseview.h Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/inc/logsbaseview.h Tue Jul 06 14:16:36 2010 +0300 @@ -47,7 +47,7 @@ friend class UT_LogsBaseView; public: - + virtual ~LogsBaseView(); public: @@ -74,7 +74,6 @@ virtual void handleExit(); virtual void callKeyPressed(); - void closeEmptyMenu(); signals: @@ -139,7 +138,7 @@ /** * Loads appropriate section from *.docml to resize list widget */ - void updateListSize(); + void updateListSize( HbListView& list ); protected: @@ -190,6 +189,11 @@ void updateDialpadCallAndMessagingActions(); bool tryMatchesViewTransition(); bool isDialpadInput() const; + void ensureListPositioning( HbListView& list ); + void scrollToTopItem( HbListView* list ); + + void updateMenuVisibility(); + void setMenuVisible(bool visible); protected: @@ -214,6 +218,7 @@ QString mLayoutSectionName; QStringList mActivities; + HbMenu* mOptionsMenu; }; diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/inc/logscomponentrepository.h --- a/logsui/logsapp/inc/logscomponentrepository.h Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/inc/logscomponentrepository.h Tue Jul 06 14:16:36 2010 +0300 @@ -31,8 +31,10 @@ /** * */ -class LogsComponentRepository : public HbDocumentLoader +class LogsComponentRepository : public QObject, public HbDocumentLoader { + Q_OBJECT + friend class UT_LogsComponentRepository; friend class UT_LogsViewManager; @@ -43,9 +45,9 @@ public: - LogsRecentCallsView* recentCallsView(); - LogsDetailsView* detailsView(); - LogsMatchesView* matchesView(); + LogsRecentCallsView* recentCallsView(bool onlyInit = false); + LogsDetailsView* detailsView(bool onlyInit = false); + LogsMatchesView* matchesView(bool onlyInit = false); /** * Returns dialpad. Must be always a valid pointer. @@ -63,6 +65,10 @@ void setObjectTreeToView( LogsAppViewId viewId ); bool loadSection( LogsAppViewId viewId, const QString& sectionName ); + +private slots: + + void lazyInit(); private: @@ -71,6 +77,10 @@ void addToolbarToObjectList( QObjectList& list ); + QGraphicsWidget* doLoadView( + const QString &fileName, const QString &viewName, + QObjectList &viewComponents, LogsAppViewId viewId, bool onlyInit ); + private: LogsAbstractViewManager& mViewManager; @@ -84,6 +94,7 @@ Dialpad* mDialpad; DialpadKeyHandler* mDialpadKeyHandler; LogsModel* mModel; + QObjectList* mCurrentObjectTree; }; #endif // LOGSCOMPONENTREPOSITORY_H diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/inc/logsdefs.h --- a/logsui/logsapp/inc/logsdefs.h Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/inc/logsdefs.h Tue Jul 06 14:16:36 2010 +0300 @@ -39,6 +39,7 @@ const char logsToolbarId[] = "logs_toolbar"; const char logsButtonAddToContactsId[] = "logs_button_addtocontacts"; const char logsPageIndicatorId[] = "logs_page_indicator"; +const char logsContentId[] = "logs_content"; //action ids const char logsCommonVideoCallMenuActionId[] = "logs_act_video_call"; @@ -101,6 +102,7 @@ const char logsActivityParamShowDialpad[] = "show_dialpad"; // val type bool const char logsActivityParamDialpadText[] = "dialpad_text"; // val type string +const char logsActivityParamInternalViewId[] = "view_id"; // val type int #endif // LOGSDEFS_H diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/inc/logseffecthandler.h --- a/logsui/logsapp/inc/logseffecthandler.h Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/inc/logseffecthandler.h Tue Jul 06 14:16:36 2010 +0300 @@ -41,13 +41,15 @@ void startDissappearAppearByFadingEffect(QObject& effectTarget); void startDissappearAppearByMovingEffect( - QObject& effectTarget, QObject& secondaryEffectTarget, bool dissappearToLeft, int origX); + QObject& effectTarget, QObject& secondaryEffectTarget, bool dissappearToLeft, + int origX, int secondaryOrigX); void startMoveNotPossibleEffect(QObject& effectTarget, bool moveLeft, int origX); signals: void dissappearByMovingComplete(); void dissappearByFadingComplete(); + void appearByMovingComplete(); private slots: diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/inc/logsmatchesview.h --- a/logsui/logsapp/inc/logsmatchesview.h Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/inc/logsmatchesview.h Tue Jul 06 14:16:36 2010 +0300 @@ -74,6 +74,7 @@ HbListView* mListView; //not owned LogsMatchesModel* mModel; //owned HbPushButton* mAddToContactsButton; // not owned + bool mAddToContactsButtonDisabled; }; #endif // LOGSMATCHESVIEW_H diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/inc/logsrecentcallsview.h --- a/logsui/logsapp/inc/logsrecentcallsview.h Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/inc/logsrecentcallsview.h Tue Jul 06 14:16:36 2010 +0300 @@ -19,6 +19,7 @@ #include "logsfilter.h" #include "logsbaseview.h" +#include class HbListView; class HbLabel; @@ -79,8 +80,8 @@ void rightFlick(); void dissappearByFadingComplete(); void dissappearByMovingComplete(); + void appearByMovingComplete(); bool markMissedCallsSeen(); - void scrollToTopItem(); private: // from LogsBaseView @@ -124,11 +125,14 @@ bool mMoveLeftInList; LogsEffectHandler* mEffectHandler; int mListViewX; + int mEmptyListLabelX; LogsMatchesModel* mMatchesModel; bool mMarkingMissedAsSeen; LogsPageIndicator* mPageIndicator; bool mFirstActivation; + HbScrollArea::ScrollBarPolicy mListScrollBarPolicy; + }; #endif // LOGSRECENTCALLSVIEW_H diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/inc/logsservicehandler.h --- a/logsui/logsapp/inc/logsservicehandler.h Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/inc/logsservicehandler.h Tue Jul 06 14:16:36 2010 +0300 @@ -36,7 +36,7 @@ signals: - void activateView(LogsServices::LogsView activatedView, bool showDialpad); + void activateView(LogsServices::LogsView activatedView, bool showDialpad, QString dialpadText); void activateView(QString dialpadText); public: diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/inc/logsservicehandlerold.h --- a/logsui/logsapp/inc/logsservicehandlerold.h Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/inc/logsservicehandlerold.h Tue Jul 06 14:16:36 2010 +0300 @@ -35,7 +35,7 @@ signals: - void activateView(LogsServices::LogsView activatedView, bool showDialpad); + void activateView(LogsServices::LogsView activatedView, bool showDialpad, QString dialpadText); void activateView(QString dialpadText); public: diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/inc/logsviewmanager.h --- a/logsui/logsapp/inc/logsviewmanager.h Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/inc/logsviewmanager.h Tue Jul 06 14:16:36 2010 +0300 @@ -55,8 +55,10 @@ public slots: + void changeRecentViewViaService( + LogsServices::LogsView view, bool showDialpad, QString dialpadText); + void changeMatchesViewViaService(QString dialpadText); void changeRecentView(LogsServices::LogsView view, bool showDialpad); - void changeMatchesView(QString dialpadText); public: // From LogsAbstractViewManager @@ -75,13 +77,13 @@ private: - void initViews(); bool doActivateView(LogsAppViewId viewId, bool showDialpad, QVariant args, const QString& dialpadText = QString()); bool loadActivity(); LogsAppViewId checkMatchesViewTransition( LogsAppViewId viewId, const QString& dialpadText); void handleFirstActivation(); + LogsBaseView* createView(LogsAppViewId viewId); private: //data diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/logsapp.pro --- a/logsui/logsapp/logsapp.pro Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/logsapp.pro Tue Jul 06 14:16:36 2010 +0300 @@ -43,6 +43,7 @@ HEADERS += inc/logseffecthandler.h HEADERS += inc/logspageindicator.h HEADERS += inc/logspageindicatoritem.h +HEADERS += inc/logscomponentrepository.h SOURCES += src/main.cpp SOURCES += src/logsmainwindow.cpp diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/resources/matchesView.docml --- a/logsui/logsapp/resources/matchesView.docml Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/resources/matchesView.docml Tue Jul 06 14:16:36 2010 +0300 @@ -46,6 +46,7 @@ + diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/resources/recentCallsView.docml --- a/logsui/logsapp/resources/recentCallsView.docml Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/resources/recentCallsView.docml Tue Jul 06 14:16:36 2010 +0300 @@ -57,7 +57,6 @@ - diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/src/logsbaseview.cpp --- a/logsui/logsapp/src/logsbaseview.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/src/logsbaseview.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -43,7 +43,8 @@ #include #include #include - +#include +#include Q_DECLARE_METATYPE(LogsCall*) Q_DECLARE_METATYPE(LogsMessage*) @@ -70,7 +71,8 @@ mMessage(0), mContact(0), mDetailsModel(0), - mCallTypeMapper(0) + mCallTypeMapper(0), + mOptionsMenu(0) { LOGS_QDEBUG( "logs [UI] -> LogsBaseView::LogsBaseView()" ); @@ -96,6 +98,7 @@ delete mContact; delete mDetailsModel; delete mCallTypeMapper; + delete mOptionsMenu; LOGS_QDEBUG( "logs [UI] <- LogsBaseView::~LogsBaseView()" ); } @@ -278,8 +281,6 @@ mInitialized = true; initFilterMenu(); addActionNamesToMap(); - connect(menu(), SIGNAL(aboutToShow()), this, - SLOT(closeEmptyMenu()), Qt::QueuedConnection); } // ----------------------------------------------------------------------------- @@ -336,7 +337,7 @@ listView()->scrollTo( topIndex ); listView()->setCurrentIndex( topIndex, QItemSelectionModel::Select ); initiateCallback(topIndex); - } + } LOGS_QDEBUG( "logs [UI] <- LogsBaseView::callKeyPressed()" ); } @@ -366,32 +367,17 @@ } // ----------------------------------------------------------------------------- -// LogsBaseView::closeEmptyMenu() -// ----------------------------------------------------------------------------- -// -void LogsBaseView::closeEmptyMenu() -{ - bool visibleActionsExist = false; - foreach (QAction* action, menu()->actions()) { - if (action->isVisible()) { - visibleActionsExist = true ; - } - } - - if (!visibleActionsExist) { - menu()->close(); - } -} -// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // void LogsBaseView::openDialpad() { LOGS_QDEBUG( "logs [UI] -> LogsBaseView::openDialpad()" ); + updateCallButton(); setDialpadPosition(); mDialpad->openDialpad(); + LOGS_QDEBUG( "logs [UI] <- LogsBaseView::openDialpad()" ); } @@ -402,16 +388,12 @@ void LogsBaseView::openContactsApp() { LOGS_QDEBUG( "logs [UI] -> LogsBaseView::openContactsApp()" ); - - // Need to do request in async manner, otherwise new phonebook ui process - // will be started due bug(?) in highway. - XQServiceRequest snd("com.nokia.services.phonebookappservices.Launch","launch()", false); + XQServiceRequest snd("com.nokia.services.phonebookappservices.Launch","launch()"); XQRequestInfo info; info.setForeground(true); snd.setInfo(info); int retValue; snd.send(retValue); - LOGS_QDEBUG( "logs [UI] <- LogsBaseView::openContactsApp()" ); } @@ -1034,7 +1016,7 @@ // Loads appropriate section from *.docml to resize list widget // ----------------------------------------------------------------------------- // -void LogsBaseView::updateListSize() +void LogsBaseView::updateListSize( HbListView& list ) { LOGS_QDEBUG( "logs [UI] -> LogsBaseView::updateListSize()" ); QString newSection( logsViewDefaultSection ); @@ -1050,10 +1032,13 @@ newSection = QString( logsViewDefaultSection ); } - if (newSection != mLayoutSectionName) { - mLayoutSectionName = newSection; - LOGS_QDEBUG_2( "logs [UI] loading new section: ", newSection ); - mRepository.loadSection( viewId(), newSection ); + bool sectionChanged( mLayoutSectionName != newSection ); + mLayoutSectionName = newSection; + LOGS_QDEBUG_2( "logs [UI] loading new section: ", newSection ); + mRepository.loadSection( viewId(), newSection ); + + if ( sectionChanged ){ + ensureListPositioning( list ); } LOGS_QDEBUG( "logs [UI] <- LogsBaseView::updateListSize()" ); @@ -1202,3 +1187,87 @@ return ( mDialpad->isOpen() && !mDialpad->editor().text().isEmpty() ); } +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void LogsBaseView::ensureListPositioning( HbListView& list ) +{ + LOGS_QDEBUG( "logs [UI] -> LogsBaseView::ensureListPositioning()" ); + + HbWidget* content = + qobject_cast( mRepository.findWidget( logsContentId ) ); + QList visibleItems = list.visibleItems(); + if ( content && visibleItems.count() > 0 ){ + LOGS_QDEBUG_2( "logs [UI] contentsRect:", content->contentsRect() ); + QRectF rect = content->contentsRect(); + rect.adjust( 0, list.pos().y(), 0, -list.pos().y() ); + LOGS_QDEBUG_2( "logs [UI] listRect:", rect ); + list.setGeometry(rect); + + HbScrollArea::ScrollBarPolicy prevPolicy = list.verticalScrollBarPolicy(); + list.setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff); + list.setVerticalScrollBarPolicy(prevPolicy); + + qreal itemHeight = visibleItems.at(0)->size().height(); + HbModelIterator* modelIt = list.modelIterator(); + if ( modelIt && itemHeight > 0 ) { + int maxVisibleItems = rect.height() / itemHeight; + LOGS_QDEBUG_2( "logs [UI] max visible items:", maxVisibleItems ); + if ( modelIt->indexCount() <= maxVisibleItems ){ + // All items can fit the rect reserved for the list, force them to fit + list.ensureVisible(QPointF(0,0)); + } else if ( visibleItems.count() < maxVisibleItems ) { + // All items cannot fit the rect reserved, force to reserve whole + // area so that current index is tried to be centered + list.scrollTo(list.currentIndex(), HbAbstractItemView::PositionAtCenter); + } + } + } + LOGS_QDEBUG( "logs [UI] <- LogsBaseView::ensureListPositioning()" ); +} + +// ----------------------------------------------------------------------------- +// LogsBaseView::scrollToTopItem +// ----------------------------------------------------------------------------- +// +void LogsBaseView::scrollToTopItem( HbListView* list ) +{ + LOGS_QDEBUG( "logs [UI] -> LogsBaseView::scrollToTopItem()" ); + + if ( list && list->verticalScrollBar() ){ + list->verticalScrollBar()->setValue(0.0); + } + + LOGS_QDEBUG( "logs [UI] <- LogsBaseView::scrollToTopItem()" ); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void LogsBaseView::updateMenuVisibility() +{ + bool visibleActionsExist = false; + HbMenu* optionsMenu = mOptionsMenu ? mOptionsMenu : menu(); + foreach (QAction* action, optionsMenu->actions()) { + if (action->isVisible()) { + visibleActionsExist = true; + } + } + setMenuVisible(visibleActionsExist); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void LogsBaseView::setMenuVisible(bool visible) +{ + if (!visible && !mOptionsMenu) { + mOptionsMenu = takeMenu(); + } else if (visible && mOptionsMenu) { + setMenu(mOptionsMenu); + mOptionsMenu = 0; + } +} diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/src/logscomponentrepository.cpp --- a/logsui/logsapp/src/logscomponentrepository.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/src/logscomponentrepository.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -29,21 +29,28 @@ #include #include #include +#include +#include + +const int logsRepositoryLazyInitTimerMsec = 3000; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // LogsComponentRepository::LogsComponentRepository(LogsAbstractViewManager& viewManager) - : HbDocumentLoader(), + : QObject(), + HbDocumentLoader(), mViewManager(viewManager), mRecentCallsView(0), mDetailsView(0), mMatchesView(0), mDialpad(0), - mDialpadKeyHandler(0) + mDialpadKeyHandler(0), + mCurrentObjectTree(0) { - mModel = new LogsModel(LogsModel::LogsRecentModel); + mModel = new LogsModel(LogsModel::LogsRecentModel, ETrue); + QTimer::singleShot(logsRepositoryLazyInitTimerMsec, this, SLOT(lazyInit())); } // ----------------------------------------------------------------------------- @@ -85,22 +92,16 @@ // // ----------------------------------------------------------------------------- // -LogsRecentCallsView* LogsComponentRepository::recentCallsView() +LogsRecentCallsView* LogsComponentRepository::recentCallsView(bool onlyInit) { LOGS_QDEBUG( "logs [UI] -> LogsComponentRepository::recentCallsView()" ); - setObjectTreeToView( LogsRecentViewId ); if ( !mRecentCallsView ) { - bool ok = false; - mRecentViewComponents = load( logsRecentCallsViewFile, &ok ); - if ( ok ) { - mRecentCallsView = qobject_cast - ( findWidget(logsRecentCallsViewId) ); - - addToolbarToObjectList(mRecentViewComponents); - } else { - LOGS_QCRITICAL( "logs [UI] XML loading failed..." ); - } + mRecentCallsView = qobject_cast(doLoadView( + logsRecentCallsViewFile, logsRecentCallsViewId, + mRecentViewComponents, LogsRecentViewId, onlyInit)); + } else if ( !onlyInit ){ + setObjectTreeToView( LogsRecentViewId ); } LOGS_QDEBUG( "logs [UI] <- LogsComponentRepository::recentCallsView()" ); @@ -111,23 +112,18 @@ // // ----------------------------------------------------------------------------- // -LogsDetailsView* LogsComponentRepository::detailsView() +LogsDetailsView* LogsComponentRepository::detailsView(bool onlyInit) { - LOGS_QDEBUG( "logs [UI] -> LogsComponentRepository::detailsView()" ); - setObjectTreeToView( LogsDetailsViewId ); - + LOGS_QDEBUG( "logs [UI] -> LogsComponentRepository::detailsView()" ); + if ( !mDetailsView ) { - bool ok = false; - mDetailsViewComponents = load( logsDetailsViewFile, &ok ); - if ( ok ) { - mDetailsView = qobject_cast - ( findWidget(logsDetailsViewId) ); - - addToolbarToObjectList(mDetailsViewComponents); - } else { - LOGS_QCRITICAL( "logs [UI] XML loading failed..." ); - } + mDetailsView = qobject_cast(doLoadView( + logsDetailsViewFile, logsDetailsViewId, + mDetailsViewComponents, LogsDetailsViewId, onlyInit)); + } else if ( !onlyInit ){ + setObjectTreeToView( LogsDetailsViewId ); } + LOGS_QDEBUG( "logs [UI] -> LogsComponentRepository::detailsView()" ); return mDetailsView; } @@ -136,22 +132,16 @@ // // ----------------------------------------------------------------------------- // -LogsMatchesView* LogsComponentRepository::matchesView() +LogsMatchesView* LogsComponentRepository::matchesView(bool onlyInit) { LOGS_QDEBUG( "logs [UI] -> LogsComponentRepository::matchedCallsView()" ); - setObjectTreeToView( LogsMatchesViewId ); if ( !mMatchesView ) { - bool ok = false; - mMatchesViewComponents = load( logsMatchedCallsViewFile, &ok ); - if ( ok ) { - mMatchesView = qobject_cast - ( findWidget(logsMatchesViewId) ); - - addToolbarToObjectList(mMatchesViewComponents); - } else { - LOGS_QCRITICAL( "logs [UI] XML loading failed..." ); - } + mMatchesView = qobject_cast(doLoadView( + logsMatchedCallsViewFile, logsMatchesViewId, + mMatchesViewComponents, LogsMatchesViewId, onlyInit)); + } else if ( !onlyInit ){ + setObjectTreeToView( LogsMatchesViewId ); } LOGS_QDEBUG( "logs [UI] <- LogsComponentRepository::matchedCallsView()" ); @@ -188,12 +178,17 @@ void LogsComponentRepository::setObjectTreeToView( LogsAppViewId viewId ) { reset(); + QObjectList* objTree = 0; if ( viewId == LogsRecentViewId ) { - setObjectTree( mRecentViewComponents ); + objTree = &mRecentViewComponents; } else if ( viewId == LogsDetailsViewId ) { - setObjectTree( mDetailsViewComponents ); + objTree = &mDetailsViewComponents; } else if ( viewId == LogsMatchesViewId ) { - setObjectTree( mMatchesViewComponents ); + objTree = &mMatchesViewComponents; + } + if ( objTree ){ + setObjectTree( *objTree ); + mCurrentObjectTree = objTree; } } @@ -259,3 +254,43 @@ return ok; } +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void LogsComponentRepository::lazyInit() +{ + mModel->refreshData(); + recentCallsView(true); + detailsView(true); + matchesView(true); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +QGraphicsWidget* LogsComponentRepository::doLoadView( + const QString &fileName, const QString &viewName, + QObjectList& viewComponents, LogsAppViewId viewId, bool onlyInit) +{ + QObjectList* prevObjectTree = mCurrentObjectTree; + setObjectTreeToView( viewId ); + + QGraphicsWidget* view = 0; + bool ok = false; + viewComponents = load( fileName, &ok ); + if ( ok ) { + view = findWidget(viewName); + addToolbarToObjectList(viewComponents); + } else { + LOGS_QCRITICAL( "logs [UI] XML loading failed..." ); + } + + if ( onlyInit && prevObjectTree ){ + LOGS_QDEBUG( "logs [UI] set back previous object tree" ) + mCurrentObjectTree = prevObjectTree; + setObjectTree( *mCurrentObjectTree ); + } + return view; +} diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/src/logsdetailsview.cpp --- a/logsui/logsapp/src/logsdetailsview.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/src/logsdetailsview.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -97,6 +97,8 @@ updateMenu(); + scrollToTopItem(mListView); + LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::activated()" ); } @@ -390,7 +392,7 @@ if ( mListView ) { updateMenu(); updateListLayoutName(*mListView, true); - updateListSize(); + updateListSize(*mListView); } LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::updateWidgetsSizeAndLayout()" ); } diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/src/logseffecthandler.cpp --- a/logsui/logsapp/src/logseffecthandler.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/src/logseffecthandler.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -31,6 +31,7 @@ const int logsMoveNotPossibleAmount = 30; const int logsDissappearByMovingIndex = 0; +const int logsPauseBetweenDissappearAndAppearIndex = 1; const int logsAppearByMovingIndex = 2; // ----------------------------------------------------------------------------- @@ -72,6 +73,7 @@ connect(mMoveGroup, SIGNAL(currentAnimationChanged(QAbstractAnimation *)), this, SLOT( moveAnimationChanged(QAbstractAnimation *))); + connect(mMoveGroup, SIGNAL(finished()), this, SIGNAL(appearByMovingComplete()) ); connect(mFadeGroup, SIGNAL(currentAnimationChanged(QAbstractAnimation *)), this, SLOT( fadeAnimationChanged(QAbstractAnimation *))); @@ -101,7 +103,8 @@ // void LogsEffectHandler::moveAnimationChanged(QAbstractAnimation *currentAnimation) { - if ( mMoveGroup->indexOfAnimation(currentAnimation) == 1 ) { + int indexOfAnimation = mMoveGroup->indexOfAnimation(currentAnimation); + if (indexOfAnimation == logsPauseBetweenDissappearAndAppearIndex ) { emit dissappearByMovingComplete(); } } @@ -112,7 +115,8 @@ // void LogsEffectHandler::fadeAnimationChanged(QAbstractAnimation *currentAnimation) { - if ( mFadeGroup->indexOfAnimation(currentAnimation) == 1 ) { + int indexOfAnimation = mFadeGroup->indexOfAnimation(currentAnimation); + if ( indexOfAnimation == logsPauseBetweenDissappearAndAppearIndex ) { emit dissappearByFadingComplete(); } } @@ -137,12 +141,13 @@ // void LogsEffectHandler::startDissappearAppearByMovingEffect( QObject& effectTarget, QObject& secondaryEffectTarget, - bool dissappearToLeft, int origX) + bool dissappearToLeft, int origX, int secondaryOrigX) { doStartDissappearAppearByMovingEffect( *mMoveGroup, effectTarget, dissappearToLeft, origX); + doStartDissappearAppearByMovingEffect( - *mMoveGroup2, secondaryEffectTarget, dissappearToLeft, origX); + *mMoveGroup2, secondaryEffectTarget, dissappearToLeft, secondaryOrigX); } // ----------------------------------------------------------------------------- diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/src/logsmainwindow.cpp --- a/logsui/logsapp/src/logsmainwindow.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/src/logsmainwindow.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -26,9 +26,6 @@ // LogsMainWindow::LogsMainWindow() : HbMainWindow(), mForeground(false) { - if ( viewport() ){ - viewport()->grabGesture(Qt::SwipeGesture); - } } // ----------------------------------------------------------------------------- @@ -37,9 +34,6 @@ // LogsMainWindow::~LogsMainWindow() { - if ( viewport() ){ - viewport()->ungrabGesture(Qt::SwipeGesture); - } } // ----------------------------------------------------------------------------- diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/src/logsmatchesview.cpp --- a/logsui/logsapp/src/logsmatchesview.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/src/logsmatchesview.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -45,7 +45,8 @@ : LogsBaseView(LogsMatchesViewId, repository, viewManager), mListView(0), mModel(0), - mAddToContactsButton(0) + mAddToContactsButton(0), + mAddToContactsButtonDisabled(false) { LOGS_QDEBUG( "logs [UI] <-> LogsMatchesView::LogsMatchesView()" ); @@ -69,7 +70,10 @@ // void LogsMatchesView::activated(bool showDialer, QVariant args) { - //base class handling first + // Disable add to contacts button handling while view is activated + // to avoid unnecessary quick appear/dissappear of it. + mAddToContactsButtonDisabled = true; + LogsBaseView::activated(showDialer, args); LogsMatchesModel* model = qVariantValue(args); @@ -77,6 +81,10 @@ dialpadEditorTextChanged(); activateEmptyListIndicator(mModel); + + scrollToTopItem(mListView); + + mAddToContactsButtonDisabled = false; } // ----------------------------------------------------------------------------- @@ -190,8 +198,9 @@ void LogsMatchesView::handleBackSoftkey() { LOGS_QDEBUG( "logs [UI] -> LogsMatchesView::::handleBackSoftkey()" ); - + mDialpad->editor().blockSignals(true); mDialpad->editor().setText(QString()); + mDialpad->editor().blockSignals(false); if (mDialpad->isOpen()){ LOGS_QDEBUG( "logs [UI] -> LogsMatchesView::::handleBackSoftkey() closeDialpad" ); @@ -201,7 +210,7 @@ mDialpad->closeDialpad(); mDialpad->blockSignals(false); } - + LogsBaseView::handleBackSoftkey(); LOGS_QDEBUG( "logs [UI] <- LogsMatchesView::::handleBackSoftkey()" ); @@ -213,6 +222,7 @@ // void LogsMatchesView::dialpadEditorTextChanged() { + LOGS_QDEBUG( "logs [UI] -> LogsMatchesView::::dialpadEditorTextChanged()" ); updateCallButton(); updateMenu(); @@ -223,6 +233,7 @@ } else if ( mModel ) { mModel->logsMatches( pattern ); } + LOGS_QDEBUG_2( "logs [UI] <- LogsMatchesView::::dialpadEditorTextChanged(), text: ", pattern ); } // ----------------------------------------------------------------------------- @@ -257,7 +268,7 @@ if ( mListView ) { updateMenu(); updateListLayoutName(*mListView); - updateListSize(); + updateListSize(*mListView); } LOGS_QDEBUG( "logs [UI] <- LogsMatchesView::updateWidgetsSizeAndLayout()" ); } @@ -295,9 +306,9 @@ { LOGS_QDEBUG( "logs [UI] -> LogsMatchesView::updateMenu()" ); - updateDialpadCallAndMessagingActions(); - + updateDialpadCallAndMessagingActions(); updateContactSearchAction(); + updateMenuVisibility(); LOGS_QDEBUG( "logs [UI] <- LogsMatchesView::updateMenu()" ); } @@ -311,6 +322,7 @@ if (mAddToContactsButton) { LOGS_QDEBUG( "logs [UI] <-> LogsMatchesView::updateAddContactButton()" ); bool matchesFound(model() && (model()->rowCount() > 0)); - mAddToContactsButton->setVisible(!matchesFound && isDialpadInput()); + mAddToContactsButton->setVisible( + !mAddToContactsButtonDisabled && !matchesFound && isDialpadInput() ); } } diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/src/logsrecentcallsview.cpp --- a/logsui/logsapp/src/logsrecentcallsview.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/src/logsrecentcallsview.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -65,10 +65,12 @@ mMoveLeftInList(false), mEffectHandler(0), mListViewX(0), + mEmptyListLabelX(0), mMatchesModel(0), mMarkingMissedAsSeen(false), mPageIndicator(0), - mFirstActivation(true) + mFirstActivation(true), + mListScrollBarPolicy(HbScrollArea::ScrollBarAutoHide) { LOGS_QDEBUG( "logs [UI] <-> LogsRecentCallsView::LogsRecentCallsView()" ); mModel = mRepository.model(); @@ -130,6 +132,10 @@ mFirstActivation = false; + if (mEmptyListLabel) { + mEmptyListLabelX = mEmptyListLabel->pos().x(); + } + LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::activated()" ); } @@ -213,7 +219,8 @@ this, SLOT(dissappearByMovingComplete())); connect(mEffectHandler, SIGNAL(dissappearByFadingComplete()), this, SLOT(dissappearByFadingComplete())); - + connect(mEffectHandler, SIGNAL(appearByMovingComplete()), + this, SLOT(appearByMovingComplete())); mPageIndicator = qobject_cast (mRepository.findWidget(logsPageIndicatorId)); @@ -440,6 +447,8 @@ mListViewX = mListView->pos().x(); grabGesture(Qt::SwipeGesture); + + mListScrollBarPolicy = mListView->verticalScrollBarPolicy(); LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::initListWidget() " ); } @@ -464,7 +473,7 @@ mListView->setModel( mFilter );//ownership not transferred - scrollToTopItem(); + scrollToTopItem(mListView); activateEmptyListIndicator(mFilter); @@ -569,7 +578,8 @@ if (model() && model()->rowCount() > 0) { mEffectHandler->startMoveNotPossibleEffect(*mListView, false, mListViewX); } else { - mEffectHandler->startMoveNotPossibleEffect(*mEmptyListLabel, false, mListViewX); + mEffectHandler->startMoveNotPossibleEffect(*mEmptyListLabel, + false, mEmptyListLabelX); } } LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::leftFlick()" ); @@ -590,7 +600,8 @@ if (model() && model()->rowCount() > 0) { mEffectHandler->startMoveNotPossibleEffect(*mListView, true, mListViewX); } else { - mEffectHandler->startMoveNotPossibleEffect(*mEmptyListLabel, true, mListViewX); + mEffectHandler->startMoveNotPossibleEffect(*mEmptyListLabel, + true, mEmptyListLabelX); } } LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::rightFlick()" ); @@ -613,11 +624,13 @@ } mMoveLeftInList = mConversionMap.value(view) < mConversionMap.value(mCurrentView); - mAppearingView = view; + // Disable scrollbar while moving the list for more nice looks + mListView->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff); mEffectHandler->startDissappearAppearByFadingEffect(*mViewName); mEffectHandler->startDissappearAppearByMovingEffect( - *mListView, *mEmptyListLabel, !mMoveLeftInList, mListViewX); + *mListView, *mEmptyListLabel, !mMoveLeftInList, + mListViewX, mEmptyListLabelX); mPageIndicator->setActiveItemIndex(mConversionMap.value(mAppearingView)); @@ -647,11 +660,26 @@ { LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::dissappearByMovingComplete()" ) - updateView( mAppearingView ); + updateView( mAppearingView ); LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::dissappearByMovingComplete()" ) } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void LogsRecentCallsView::appearByMovingComplete() +{ + LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::appearByMovingComplete()" ) + + // Restore scrollbar which was hidden when animation started + mListView->setVerticalScrollBarPolicy(mListScrollBarPolicy); + + LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::appearByMovingComplete()" ) +} + // ----------------------------------------------------------------------------- // LogsRecentCallsView::updateMenu // ----------------------------------------------------------------------------- @@ -673,6 +701,8 @@ updateDialpadCallAndMessagingActions(); updateContactSearchAction(); + updateMenuVisibility(); + LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::updateMenu()" ); } @@ -697,7 +727,7 @@ if ( mListView ) { updateMenu(); updateListLayoutName(*mListView); - updateListSize(); + updateListSize(*mListView); LogsConfigurationParams param; param.setListItemTextWidth( getListItemTextWidth() ); mModel->updateConfiguration(param); @@ -785,18 +815,3 @@ } return mMarkingMissedAsSeen; } - -// ----------------------------------------------------------------------------- -// LogsRecentCallsView::scrollToTopItem -// ----------------------------------------------------------------------------- -// -void LogsRecentCallsView::scrollToTopItem() -{ - LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::scrollToTopItem()" ); - disconnect( mFilter, SIGNAL(rowsInserted(const QModelIndex&,int,int)), - this, SLOT(scrollToTopItem())); - if ( mFilter && mFilter->hasIndex(0,0) ) { - mListView->scrollTo( mFilter->index(0,0) ); - } - LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::scrollToTopItem()" ); -} diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/src/logsservicehandler.cpp --- a/logsui/logsapp/src/logsservicehandler.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/src/logsservicehandler.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -82,7 +82,7 @@ if (!dialpadText.isEmpty()) { emit activateView(dialpadText); } else { - emit activateView((LogsServices::LogsView)activatedView, showDialpad); + emit activateView((LogsServices::LogsView)activatedView, showDialpad, dialpadText); } LOGS_QDEBUG( "logs [UI] <- LogsServiceHandler::show()" ) return 0; diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/src/logsservicehandlerold.cpp --- a/logsui/logsapp/src/logsservicehandlerold.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/src/logsservicehandlerold.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -69,7 +69,7 @@ LOGS_QDEBUG( "logs [UI] Bring app to foreground" ) mMainWindow.bringAppToForeground(); - emit activateView((LogsServices::LogsView)activatedView, showDialpad); + emit activateView((LogsServices::LogsView)activatedView, showDialpad, QString()); LOGS_QDEBUG( "logs [UI] <- LogsServiceHandlerOld::start()" ) return 0; diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/src/logsviewmanager.cpp --- a/logsui/logsapp/src/logsviewmanager.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/src/logsviewmanager.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -56,19 +56,18 @@ this, SLOT(handleOrientationChanged()) ); mComponentsRepository = new LogsComponentRepository(*this); - initViews(); - connect( &mService, SIGNAL( activateView(LogsServices::LogsView, bool) ), - this, SLOT( changeRecentView(LogsServices::LogsView, bool) ) ); + connect( &mService, SIGNAL( activateView(LogsServices::LogsView, bool, QString) ), + this, SLOT( changeRecentViewViaService(LogsServices::LogsView, bool, QString) ) ); connect( &mService, SIGNAL( activateView(QString) ), - this, SLOT( changeMatchesView(QString) )); + this, SLOT( changeMatchesViewViaService(QString) )); - connect( &mServiceOld, SIGNAL( activateView(LogsServices::LogsView, bool) ), - this, SLOT( changeRecentView(LogsServices::LogsView, bool) ) ); + connect( &mServiceOld, SIGNAL( activateView(LogsServices::LogsView, bool, QString) ), + this, SLOT( changeRecentViewViaService(LogsServices::LogsView, bool, QString) ) ); connect( &mServiceOld, SIGNAL( activateView(QString) ), - this, SLOT( changeMatchesView(QString) )); + this, SLOT( changeMatchesViewViaService(QString) )); QObject::connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(saveActivity())); @@ -92,55 +91,40 @@ } // ----------------------------------------------------------------------------- -// LogsViewManager::initViews +// LogsViewManager::changeRecentViewViaService // ----------------------------------------------------------------------------- // -void LogsViewManager::initViews() +void LogsViewManager::changeRecentViewViaService( + LogsServices::LogsView view, bool showDialpad, QString dialpadText) { - LOGS_QDEBUG( "logs [UI] -> LogsViewManager::initViews()" ); - - // Don't activate any view, app focus gaining or service request - // will cause view activation - // - LogsRecentCallsView* view = mComponentsRepository->recentCallsView(); - Q_ASSERT_X(view != 0, "logs [UI] ", "recentCallsView not found!"); - LOGS_QDEBUG( "logs [UI] adding view" ); - mViewStack.append(view); - mMainWindow.addView(view); - - LogsDetailsView* detailsView = mComponentsRepository->detailsView(); - mViewStack.append(detailsView); - mMainWindow.addView(detailsView); - - LogsMatchesView* matchesView = mComponentsRepository->matchesView(); - mViewStack.append(matchesView); - mMainWindow.addView(matchesView); + mComponentsRepository->dialpad()->editor().setText(dialpadText); + changeRecentView(view, showDialpad); +} - LOGS_QDEBUG( "logs [UI] <- LogsViewManager::initViews()" ); +// ----------------------------------------------------------------------------- +// LogsViewManager::changeMatchesViewViaService +// ----------------------------------------------------------------------------- +// +void LogsViewManager::changeMatchesViewViaService(QString dialpadText) +{ + LOGS_QDEBUG( "logs [UI] -> LogsViewManager::changeMatchesView()" ); + mComponentsRepository->dialpad()->editor().setText(dialpadText); + doActivateView(LogsMatchesViewId, true, QVariant()); + LOGS_QDEBUG( "logs [UI] <- LogsViewManager::changeMatchesView()" ); } // ----------------------------------------------------------------------------- // LogsViewManager::changeRecentView // ----------------------------------------------------------------------------- // -void LogsViewManager::changeRecentView(LogsServices::LogsView view, bool showDialpad) +void LogsViewManager::changeRecentView( + LogsServices::LogsView view, bool showDialpad) { QVariant args(view); doActivateView(LogsRecentViewId, showDialpad, args); } // ----------------------------------------------------------------------------- -// LogsViewManager::changeMatchesView -// ----------------------------------------------------------------------------- -// -void LogsViewManager::changeMatchesView(QString dialpadText) -{ - LOGS_QDEBUG( "logs [UI] -> LogsViewManager::changeMatchesView()" ); - doActivateView(LogsMatchesViewId, true, QVariant(), dialpadText); - LOGS_QDEBUG( "logs [UI] <- LogsViewManager::changeMatchesView()" ); -} - -// ----------------------------------------------------------------------------- // LogsViewManager::proceedExit // ----------------------------------------------------------------------------- // @@ -148,11 +132,6 @@ { LOGS_QDEBUG( "logs [UI] -> LogsViewManager::proceedExit()" ); - // Instead of compressing data, exit the application for real because - // of bug in wk16 platform which prevents bg/fg switching of the app. - // - - //mComponentsRepository->model()->compressData(); qApp->quit(); LOGS_QDEBUG( "logs [UI] <- LogsViewManager::proceedExit()" ); @@ -225,10 +204,9 @@ // bool LogsViewManager::activatePreviousView() { - if ( mViewStack.count() < 2 ){ - return false; - } - return doActivateView(mViewStack.at(1)->viewId(), false, QVariant()); + LogsAppViewId viewId = ( mViewStack.count() > 1 ) ? + mViewStack.at(1)->viewId() : LogsRecentViewId; + return doActivateView(viewId, false, QVariant()); } // ----------------------------------------------------------------------------- @@ -255,6 +233,10 @@ } } + if ( !newView ){ + newView = createView(viewId); + } + if ( oldView && newView && oldView != newView ){ oldView->deactivated(); disconnect( &mMainWindow, SIGNAL( callKeyPressed() ), oldView, 0 ); @@ -263,6 +245,9 @@ if ( newView ){ mViewStack.insert(0, newView); mMainWindow.setCurrentView(newView); + //Setting mainwindow interactive to enable user input during + //view switching animation. + mMainWindow.setInteractive(true); mViewActivationArgs = args; mViewActivationShowDialpad = showDialpad; completeViewActivation(); @@ -326,12 +311,23 @@ } QVariantHash metaData; - metaData.insert("screenshot", QPixmap::grabWidget(&mMainWindow, mMainWindow.rect())); + + LOGS_QDEBUG( "logs [UI] Start taking screenshot" ); + QImage* img = new QImage(mMainWindow.rect().size(), QImage::Format_ARGB32_Premultiplied); + QPainter p( img ); + // Use render instead of QPixmap::grabWidget as otherwise screenshot + // may become empty. + mMainWindow.render( &p, mMainWindow.rect(), mMainWindow.rect() ); + metaData.insert("screenshot", QPixmap::fromImage(*img)); + delete img; + LOGS_QDEBUG( "logs [UI] End taking screenshot" ); QByteArray serializedActivity; QDataStream stream(&serializedActivity, QIODevice::WriteOnly | QIODevice::Append); metaData.insert( + logsActivityParamInternalViewId, mViewStack.at(0)->viewId() ); + metaData.insert( logsActivityParamShowDialpad, mComponentsRepository->dialpad()->isOpen() ); metaData.insert( logsActivityParamDialpadText, mComponentsRepository->dialpad()->editor().text() ); @@ -368,6 +364,16 @@ } } + QList allParams = hbApp->activityManager()->activities(); + QVariantHash params = allParams.isEmpty() ? QVariantHash() : allParams.at(0); + LOGS_QDEBUG_2( "logs [UI] Activity params", params ); + + if ( !matchingView ){ + // Try if creating such view is possible + int viewId = params.value(logsActivityParamInternalViewId).toInt(); + matchingView = createView(static_cast(viewId)); + } + if ( matchingView ){ // Should have only one param hash in the list, use first always QList allParams = hbApp->activityManager()->activities(); @@ -394,8 +400,7 @@ LogsAppViewId viewId, const QString& dialpadText) { if ( !dialpadText.isEmpty() ){ - Dialpad* dialpad = mComponentsRepository->dialpad(); - dialpad->editor().setText(dialpadText); + mComponentsRepository->dialpad()->editor().setText(dialpadText); } if ( viewId == LogsMatchesViewId ){ @@ -435,3 +440,23 @@ } LOGS_QDEBUG( "logs [UI] <- LogsViewManager::handleFirstActivation()" ); } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +LogsBaseView* LogsViewManager::createView(LogsAppViewId viewId) +{ + LogsBaseView* newView = 0; + if ( viewId == LogsRecentViewId ){ + newView = mComponentsRepository->recentCallsView(); + mMainWindow.addView(newView); + } else if ( viewId == LogsMatchesViewId ) { + newView = mComponentsRepository->matchesView(); + mMainWindow.addView(newView); + } else if ( viewId == LogsDetailsViewId ) { + newView = mComponentsRepository->detailsView(); + mMainWindow.addView(newView); + } + return newView; +} diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/tsrc/ut_logsapp/inc/ut_logsbaseview.h --- a/logsui/logsapp/tsrc/ut_logsapp/inc/ut_logsbaseview.h Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/tsrc/ut_logsapp/inc/ut_logsbaseview.h Tue Jul 06 14:16:36 2010 +0300 @@ -67,7 +67,8 @@ void testInitiateCallback(); void testShowListItemMenu(); void testPopulateListItemMenu(); - void testCloseEmptyMenu(); + void testUpdateMenuVisibility(); + void testSetMenuVisible(); void testSaveContact(); void testUpdateCall(); void testUpdateMessage(); @@ -89,6 +90,7 @@ void testSaveActivity(); void testLoadActivity(); void testClearActivity(); + void testEnsureListPositioning(); private: diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/tsrc/ut_logsapp/inc/ut_logscomponentrepository.h --- a/logsui/logsapp/tsrc/ut_logsapp/inc/ut_logscomponentrepository.h Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/tsrc/ut_logsapp/inc/ut_logscomponentrepository.h Tue Jul 06 14:16:36 2010 +0300 @@ -56,6 +56,7 @@ void testDialpad(); void testLoadSection(); void testAddToolbarToObjectList(); + void testLazyInit(); private: diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/tsrc/ut_logsapp/inc/ut_logsviewmanager.h --- a/logsui/logsapp/tsrc/ut_logsapp/inc/ut_logsviewmanager.h Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/tsrc/ut_logsapp/inc/ut_logsviewmanager.h Tue Jul 06 14:16:36 2010 +0300 @@ -53,6 +53,7 @@ void testConstructorDestructor(); void testActivateView(); void testchangeMatchesView(); + void testchangeRecentView(); void testExitApplication(); void testStartingWithService(); void testHandleOrientationChanged(); diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/tsrc/ut_logsapp/src/ut_logsbaseview.cpp --- a/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsbaseview.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsbaseview.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -80,6 +80,7 @@ QVERIFY( !mBaseView->mMessage ); QVERIFY( !mBaseView->mContact ); QVERIFY( !mBaseView->mCallTypeMapper ); + QVERIFY( !mBaseView->mOptionsMenu ); } void UT_LogsBaseView::testActivated() @@ -273,30 +274,71 @@ QVERIFY( HbStubHelper::widgetActionsCount() == 5 ); } - - -void UT_LogsBaseView::testCloseEmptyMenu() +void UT_LogsBaseView::testUpdateMenuVisibility() { - LogsRecentCallsView* view = mRepository->recentCallsView(); - - //visible actions exist - QVERIFY( view->menu()->actions().count() > 0 ); - HbStubHelper::setWidgetOpen(true); - view->closeEmptyMenu(); - QVERIFY(HbStubHelper::isWidgetOpen()); + HbMenu* menu = new HbMenu; + HbAction* action = menu->addAction("action1"); + mBaseView->setMenu(menu); - //no visible actions - foreach (QAction* action, view->menu()->actions()) { - action->setVisible(false); - } - view->closeEmptyMenu(); - QVERIFY(!HbStubHelper::isWidgetOpen()); + // No visible actions in menu => menu is replaced by empty one + QVERIFY(!mBaseView->mOptionsMenu); + QVERIFY(!mBaseView->menu()->isEmpty()); + action->setVisible(false); + mBaseView->updateMenuVisibility(); + QVERIFY(mBaseView->menu()->isEmpty()); + QVERIFY(mBaseView->mOptionsMenu == menu); + QVERIFY(mBaseView->menu() != menu); + + // Visible action exists => restoring the menu + action->setVisible(true); + QVERIFY(mBaseView->mOptionsMenu); + mBaseView->updateMenuVisibility(); + QVERIFY(!mBaseView->menu()->isEmpty()); + QVERIFY(!mBaseView->mOptionsMenu); + QVERIFY(mBaseView->menu() == menu); + + // Menu has no actions => menu is replaced by empty one + mBaseView->setMenu(0); + menu = mBaseView->menu(); + QVERIFY(!mBaseView->mOptionsMenu); + QVERIFY(mBaseView->menu()->isEmpty()); + mBaseView->updateMenuVisibility(); + QVERIFY(mBaseView->menu()->isEmpty()); + QVERIFY(mBaseView->mOptionsMenu == menu); + QVERIFY(mBaseView->menu() != menu); +} + +void UT_LogsBaseView::testSetMenuVisible() +{ + HbMenu* menu = new HbMenu; + menu->addAction("action1"); + mBaseView->setMenu(menu); - //no actions - HbStubHelper::setWidgetOpen(true); - view->menu()->actions().clear(); - view->closeEmptyMenu(); - QVERIFY(!HbStubHelper::isWidgetOpen()); + // Hiding menu, view menu is replaced by empty menu + QVERIFY(!mBaseView->mOptionsMenu); + QVERIFY(!mBaseView->menu()->isEmpty()); + mBaseView->setMenuVisible(false); + QVERIFY(mBaseView->menu()->isEmpty()); + QVERIFY(mBaseView->mOptionsMenu == menu); + QVERIFY(mBaseView->menu() != menu); + + // Trying to hide again, nothing happens + mBaseView->setMenuVisible(false); + QVERIFY(mBaseView->menu()->isEmpty()); + QVERIFY(mBaseView->mOptionsMenu == menu); + QVERIFY(mBaseView->menu() != menu); + + // Showing menu, original menu is restored + mBaseView->setMenuVisible(true); + QVERIFY(!mBaseView->menu()->isEmpty()); + QVERIFY(!mBaseView->mOptionsMenu); + QVERIFY(mBaseView->menu() == menu); + + // Showing again, nothing happen + mBaseView->setMenuVisible(true); + QVERIFY(!mBaseView->menu()->isEmpty()); + QVERIFY(!mBaseView->mOptionsMenu); + QVERIFY(mBaseView->menu() == menu); } void UT_LogsBaseView::testSaveContact() @@ -409,23 +451,24 @@ mBaseView->mLayoutSectionName = "dummy"; //default section is loaded + HbListView view; mBaseView->mViewManager.mainWindow().setOrientation( Qt::Vertical ); mBaseView->mDialpad->closeDialpad(); - mBaseView->updateListSize(); + mBaseView->updateListSize(view); QVERIFY( mBaseView->mLayoutSectionName == logsViewDefaultSection ); //same section again, not loaded - mBaseView->updateListSize(); + mBaseView->updateListSize(view); QVERIFY( mBaseView->mLayoutSectionName == logsViewDefaultSection ); //portrait with dialpad mBaseView->mDialpad->openDialpad(); - mBaseView->updateListSize(); + mBaseView->updateListSize(view); QVERIFY( mBaseView->mLayoutSectionName == logsViewPortraitDialpadSection ); //landscape with dialpad mBaseView->mViewManager.mainWindow().setOrientation( Qt::Horizontal ); - mBaseView->updateListSize(); + mBaseView->updateListSize(view); QVERIFY( mBaseView->mLayoutSectionName == logsViewLandscapeDialpadSection ); } @@ -571,3 +614,75 @@ mBaseView->clearActivity(*manager); QCOMPARE( manager->activities().count(), 0 ); } + +void UT_LogsBaseView::testEnsureListPositioning() +{ + HbStubHelper::reset(); + HbListView list; + QStringList itemTexts; + itemTexts.append( "foo1" ); + itemTexts.append( "foo2" ); + QStringListModel model; + model.setStringList(itemTexts); + + itemTexts.append( "foo3" ); + itemTexts.append( "foo4" ); + QStringListModel model2; + model2.setStringList(itemTexts); + + list.setModel(&model); + + // No content found, nop + mBaseView->ensureListPositioning(list); + QVERIFY( !HbStubHelper::listEnsureVisibleCalled() ); + QVERIFY( !HbStubHelper::listScrollToCalled() ); + + // Content found, no visible items, nop + mRepository->recentCallsView(); + mBaseView->activated(false, QVariant()); + mBaseView->ensureListPositioning(list); + QVERIFY( !HbStubHelper::listEnsureVisibleCalled() ); + QVERIFY( !HbStubHelper::listScrollToCalled() ); + + // Content found and visible items which can fit the screen, height of item zero, nop + HbWidget* content = + qobject_cast( mRepository->findWidget( logsContentId ) ); + content->setContentsMargins(0,0,0,0); + content->setGeometry( QRectF(0,0,100,200) ); + + HbListViewItem* item = new HbListViewItem; + HbStubHelper::listItems().append(item); + HbListViewItem* item2 = new HbListViewItem; + HbStubHelper::listItems().append(item2); + mBaseView->ensureListPositioning(list); + QVERIFY( !HbStubHelper::listEnsureVisibleCalled() ); + QVERIFY( !HbStubHelper::listScrollToCalled() ); + + // Screen is already filled with items, nop + list.setModel(&model2); + HbListViewItem* item3 = new HbListViewItem; + HbStubHelper::listItems().append(item3); + item->setGeometry(QRectF(0,0,100,100)); + item2->setGeometry(QRectF(0,0,100,100)); + item3->setGeometry(QRectF(0,0,100,100)); + mBaseView->ensureListPositioning(list); + QVERIFY( !HbStubHelper::listEnsureVisibleCalled() ); + QVERIFY( !HbStubHelper::listScrollToCalled() ); + + // Content found and visible items which can fit the screen, all items ensured visible + list.setModel(&model); + delete HbStubHelper::listItems().takeLast(); + mBaseView->ensureListPositioning(list); + QVERIFY( HbStubHelper::listEnsureVisibleCalled() ); + QVERIFY( !HbStubHelper::listScrollToCalled() ); + + // Content found and more visible items which can fit the screen and currently screen + // is not full of items, ensure that area is filled by scrolling + list.setModel(&model2); + list.setCurrentIndex(model2.index(0,0)); + delete HbStubHelper::listItems().takeLast(); + mBaseView->ensureListPositioning(list); + QVERIFY( HbStubHelper::listEnsureVisibleCalled() ); + QVERIFY( HbStubHelper::listScrollToCalled() ); + +} diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/tsrc/ut_logsapp/src/ut_logscomponentrepository.cpp --- a/logsui/logsapp/tsrc/ut_logsapp/src/ut_logscomponentrepository.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/tsrc/ut_logsapp/src/ut_logscomponentrepository.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -151,3 +151,19 @@ QVERIFY( mRepository->mRecentViewComponents.at(0)->objectName() == logsToolbarId ); delete view; } + +void UT_LogsComponentRepository::testLazyInit() +{ + QObjectList dummyObjList; + mRepository->mCurrentObjectTree = &dummyObjList; + QVERIFY( !mRepository->mRecentCallsView ); + QVERIFY( !mRepository->mDetailsView ); + QVERIFY( !mRepository->mMatchesView ); + QVERIFY( !mRepository->model()->mRefreshCalled ); + mRepository->lazyInit(); + QVERIFY( mRepository->mRecentCallsView ); + QVERIFY( mRepository->mDetailsView ); + QVERIFY( mRepository->mMatchesView ); + QVERIFY( mRepository->model()->mRefreshCalled ); + QVERIFY( mRepository->mCurrentObjectTree == &dummyObjList ); +} diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/tsrc/ut_logsapp/src/ut_logseffecthandler.cpp --- a/logsui/logsapp/tsrc/ut_logsapp/src/ut_logseffecthandler.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/tsrc/ut_logsapp/src/ut_logseffecthandler.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -77,7 +77,7 @@ void UT_LogsEffectHandler::testStartDissappearAppearByMovingEffect() { QVERIFY( mEffect->mMoveGroup->state() == QAbstractAnimation::Stopped ); - mEffect->startDissappearAppearByMovingEffect(*mLabel, *mLabel2, false, 0); + mEffect->startDissappearAppearByMovingEffect(*mLabel, *mLabel2, false, 0, 0); QVERIFY( mEffect->mMoveGroup->state() == QAbstractAnimation::Running ); QVERIFY( mEffect->mMoveGroup2->state() == QAbstractAnimation::Running ); @@ -90,7 +90,7 @@ QVERIFY(spy.count() == 1 ); // When effect is running and new effect is requested, previous effect is stopped - mEffect->startDissappearAppearByMovingEffect(*mLabel, *mLabel2, true, 0); + mEffect->startDissappearAppearByMovingEffect(*mLabel, *mLabel2, true, 0, 0); } void UT_LogsEffectHandler::testStartMoveNotPossibleEffect() diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/tsrc/ut_logsapp/src/ut_logsmatchesview.cpp --- a/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsmatchesview.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsmatchesview.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -90,6 +90,7 @@ QVERIFY( mMatchesView->mListView->layoutName() == logsListDefaultLayout ); QVERIFY( mMatchesView->mLayoutSectionName == logsViewDefaultSection ); QVERIFY( mMatchesView->mAddToContactsButton ); + QVERIFY( !mMatchesView->mAddToContactsButton->isVisible() ); //activate once again, model recreated mMatchesView->mViewManager.mainWindow().setOrientation( Qt::Horizontal ); @@ -101,6 +102,7 @@ QVERIFY( mMatchesView->mActionMap.count() == 4 ); QVERIFY( mMatchesView->mListView->layoutName() == logsListLandscapeDialpadLayout ); QVERIFY( mMatchesView->mLayoutSectionName == logsViewLandscapeDialpadSection ); + QVERIFY( !mMatchesView->mAddToContactsButton->isVisible() ); //Pass model as input arg LogsDbConnector* dbConnector = 0; @@ -119,6 +121,7 @@ QVERIFY( mMatchesView->mListView ); QVERIFY( mMatchesView->mModel == model2 ); QVERIFY( mMatchesView->mModel->mLastCall.isEmpty() ); + QVERIFY( !mMatchesView->mAddToContactsButton->isVisible() ); // After passing model as input arg, do not pass model mMatchesView->activated( true,QVariant() ); @@ -366,6 +369,12 @@ QVERIFY( mMatchesView->mEmptyListLabel->isVisible() ); QVERIFY( mMatchesView->mAddToContactsButton->isVisible() ); + + mMatchesView->mAddToContactsButtonDisabled = true; + mMatchesView->updateEmptyListWidgetsVisibility(); + QVERIFY( mMatchesView->mEmptyListLabel->isVisible() ); + QVERIFY( !mMatchesView->mAddToContactsButton->isVisible() ); + delete mMatchesView->mEmptyListLabel; mMatchesView->mEmptyListLabel = 0; delete mMatchesView->mAddToContactsButton; diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/tsrc/ut_logsapp/src/ut_logsrecentcallsview.cpp --- a/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsrecentcallsview.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsrecentcallsview.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -251,11 +251,15 @@ HbAction* action = new HbAction(); action->setObjectName(logsShowFilterMissedMenuActionId); mRecentCallsView->changeFilter(action); + // Scrollbar is disbaled while changing the list and is restored when appearByMoving slot is called + QVERIFY( mRecentCallsView->mListView->verticalScrollBarPolicy() == HbScrollArea::ScrollBarAlwaysOff ); // Because of effects, filter is not changed immediately, simulate effect completion QVERIFY( mRecentCallsView->mAppearingView == LogsServices::ViewMissed ); mRecentCallsView->dissappearByMovingComplete(); - QVERIFY( mRecentCallsView->mFilter->filterType() == LogsFilter::Missed ); + QVERIFY( mRecentCallsView->mFilter->filterType() == LogsFilter::Missed ); + mRecentCallsView->appearByMovingComplete(); + QVERIFY( mRecentCallsView->mListView->verticalScrollBarPolicy() != HbScrollArea::ScrollBarAlwaysOff ); delete action; delete mRecentCallsView->mListView; diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/tsrc/ut_logsapp/src/ut_logsservicehandler.cpp --- a/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsservicehandler.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsservicehandler.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -89,7 +89,7 @@ void UT_LogsServiceHandler::testStart() { qRegisterMetaType< LogsServices::LogsView >("LogsServices::LogsView"); - QSignalSpy spy(mServiceOld, SIGNAL(activateView(LogsServices::LogsView, bool))); + QSignalSpy spy(mServiceOld, SIGNAL(activateView(LogsServices::LogsView, bool, QString))); // Wrong view QVERIFY( mServiceOld->start( 9999, true ) != 0 ); @@ -121,7 +121,7 @@ void UT_LogsServiceHandler::testShow() { qRegisterMetaType< LogsServices::LogsView >("LogsServices::LogsView"); - QSignalSpy spy(mService, SIGNAL(activateView(LogsServices::LogsView, bool))); + QSignalSpy spy(mService, SIGNAL(activateView(LogsServices::LogsView, bool, QString))); QSignalSpy spy2(mService, SIGNAL(activateView(QString))); QVariantMap map; diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/tsrc/ut_logsapp/src/ut_logsviewmanager.cpp --- a/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsviewmanager.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsviewmanager.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -68,37 +68,39 @@ { QVERIFY( mLogsViewManager ); QVERIFY( mLogsViewManager->mComponentsRepository ); - QVERIFY( mLogsViewManager->mMainWindow.views().count() == 3 ); + QVERIFY( mLogsViewManager->mMainWindow.views().count() == 1 ); QVERIFY( mLogsViewManager->mMainWindow.currentView() != 0 ); QVERIFY( static_cast( mLogsViewManager->mMainWindow.currentView() )->viewId() == LogsRecentViewId ); - QVERIFY( mLogsViewManager->mViewStack.count() == 3 ); + QVERIFY( mLogsViewManager->mViewStack.count() == 1 ); delete mLogsViewManager; mLogsViewManager = 0; // Contructor when activity restoring started the app + delete mMainWindow; + mMainWindow = 0; + mMainWindow = new LogsMainWindow(); HbStubHelper::setActivityReason(Hb::ActivationReasonActivity); mLogsViewManager = new LogsViewManager(*mMainWindow, *mService, *mServiceOld); QVERIFY( mLogsViewManager->mComponentsRepository ); - QVERIFY( mLogsViewManager->mMainWindow.currentView() != 0 ); - QVERIFY( static_cast( mLogsViewManager->mMainWindow.currentView() )->viewId() == LogsMatchesViewId ); - QVERIFY( mLogsViewManager->mViewStack.count() == 3 ); + QVERIFY( static_cast( mLogsViewManager->mMainWindow.currentView() )->viewId() == LogsRecentViewId ); + QVERIFY( mLogsViewManager->mViewStack.count() == 1 ); HbStubHelper::reset(); +} -} void UT_LogsViewManager::testActivateView() { // Activate already active view QVERIFY( mLogsViewManager->activateView(LogsRecentViewId) ); QVERIFY( mLogsViewManager->activateView(LogsRecentViewId) ); - QCOMPARE( mLogsViewManager->mMainWindow.views().count(), 3 ); + QCOMPARE( mLogsViewManager->mMainWindow.views().count(), 1 ); QVERIFY( mLogsViewManager->mMainWindow.currentView() == mLogsViewManager->mComponentsRepository->recentCallsView() ); // Activate other view QVERIFY( mLogsViewManager->activateView(LogsDetailsViewId) ); - QVERIFY( mLogsViewManager->mMainWindow.views().count() == 3 ); + QVERIFY( mLogsViewManager->mMainWindow.views().count() == 2 ); QVERIFY( mLogsViewManager->mMainWindow.currentView() == mLogsViewManager->mComponentsRepository->detailsView() ); QVERIFY( mLogsViewManager->mViewStack.at(0) == @@ -106,7 +108,7 @@ // Try to activate unknown view QVERIFY( !mLogsViewManager->activateView(LogsUnknownViewId) ); - QVERIFY( mLogsViewManager->mMainWindow.views().count() == 3 ); + QVERIFY( mLogsViewManager->mMainWindow.views().count() == 2 ); QVERIFY( mLogsViewManager->mMainWindow.currentView() == mLogsViewManager->mComponentsRepository->detailsView() ); QVERIFY( mLogsViewManager->mViewStack.at(0) == @@ -114,7 +116,7 @@ // Go back to previous view QVERIFY( mLogsViewManager->activatePreviousView() ); - QVERIFY( mLogsViewManager->mMainWindow.views().count() == 3 ); + QVERIFY( mLogsViewManager->mMainWindow.views().count() == 2 ); QVERIFY( mLogsViewManager->mMainWindow.currentView() == mLogsViewManager->mComponentsRepository->recentCallsView() ); QVERIFY( mLogsViewManager->mViewStack.at(0) == @@ -124,15 +126,32 @@ void UT_LogsViewManager::testchangeMatchesView() { //Open Matches view, dialpad visible with predefined number - mLogsViewManager->changeMatchesView(QString("+123456")); + mLogsViewManager->changeMatchesViewViaService(QString("+123456")); QVERIFY( mLogsViewManager->mMainWindow.currentView() == mLogsViewManager->mComponentsRepository->matchesView() ); // Contact search disabled, go to recent calls view instead mLogsViewManager->mComponentsRepository->mModel->mPredectiveSearchStatus = 0; - mLogsViewManager->changeMatchesView(QString("+123456777")); + QString dialString("+123456777"); + mLogsViewManager->changeMatchesViewViaService(dialString); QVERIFY( mLogsViewManager->mMainWindow.currentView() == mLogsViewManager->mComponentsRepository->recentCallsView() ); + QVERIFY( mLogsViewManager->mComponentsRepository->mDialpad->mLineEdit->text() == dialString ); +} + +void UT_LogsViewManager::testchangeRecentView() +{ + QString dialString("+123456777"); + mLogsViewManager->changeRecentViewViaService(LogsServices::ViewCalled, false, dialString); + QVERIFY( mLogsViewManager->mMainWindow.currentView() == + mLogsViewManager->mComponentsRepository->recentCallsView() ); + QVERIFY( mLogsViewManager->mComponentsRepository->mDialpad->mLineEdit->text() == dialString ); + + // Empty string clears dialpad input + mLogsViewManager->changeRecentViewViaService(LogsServices::ViewCalled, false, ""); + QVERIFY( mLogsViewManager->mMainWindow.currentView() == + mLogsViewManager->mComponentsRepository->recentCallsView() ); + QVERIFY( mLogsViewManager->mComponentsRepository->mDialpad->mLineEdit->text().isEmpty() ); } void UT_LogsViewManager::testExitApplication() @@ -171,9 +190,9 @@ service.mIsAppStartedUsingService = true; LogsViewManager vm(window, service, serviceOld); QVERIFY( vm.mComponentsRepository ); - QVERIFY( vm.mMainWindow.views().count() == 3 ); + QVERIFY( vm.mMainWindow.views().count() == 0 ); QVERIFY( vm.mMainWindow.currentView() == 0 ); - QVERIFY( vm.mViewStack.count() == 3 ); + QVERIFY( vm.mViewStack.count() == 0 ); } void UT_LogsViewManager::testHandleOrientationChanged() @@ -196,6 +215,7 @@ void UT_LogsViewManager::testSaveActivity() { + mLogsViewManager->activateView(LogsRecentViewId, false, QVariant()); HbStubHelper::setActivityReason(Hb::ActivationReasonActivity); HbApplication* hbApp = static_cast(qApp); HbActivityManager* manager = hbApp->activityManager(); @@ -204,6 +224,7 @@ QCOMPARE( manager->activities().count(), 1 ); QVERIFY( !manager->activities().at(0).value(logsActivityParamShowDialpad).toBool() ); QVERIFY( manager->activities().at(0).value(logsActivityParamDialpadText).toString().isEmpty() ); + QCOMPARE( manager->activities().at(0).value(logsActivityParamInternalViewId).toInt(), (int)LogsRecentViewId ); // Make sure that only one activity is reported mLogsViewManager->mComponentsRepository->dialpad()->mIsOpen = true; @@ -212,6 +233,7 @@ QCOMPARE( manager->activities().count(), 1 ); QVERIFY( manager->activities().at(0).value(logsActivityParamShowDialpad).toBool() ); QCOMPARE( manager->activities().at(0).value(logsActivityParamDialpadText).toString(), QString("12345") ); + QCOMPARE( manager->activities().at(0).value(logsActivityParamInternalViewId).toInt(), (int)LogsMatchesViewId ); // No views, nothing to save mLogsViewManager->mViewStack.clear(); @@ -233,6 +255,7 @@ QVariantHash params; params.insert(logsActivityParamShowDialpad, false); params.insert(logsActivityParamDialpadText, QString("")); + params.insert(logsActivityParamInternalViewId, LogsRecentViewId); manager->addActivity(QString(), QVariant(), params); QVERIFY( mLogsViewManager->loadActivity() ); QVERIFY( static_cast( mLogsViewManager->mMainWindow.currentView() )->viewId() == LogsRecentViewId ); @@ -245,6 +268,7 @@ QVariantHash params2; params2.insert(logsActivityParamShowDialpad, true); params2.insert(logsActivityParamDialpadText, QString("33333")); + params.insert(logsActivityParamInternalViewId, LogsMatchesViewId); manager->addActivity(QString(), QVariant(), params2); QVERIFY( mLogsViewManager->loadActivity() ); QVERIFY( static_cast( mLogsViewManager->mMainWindow.currentView() )->viewId() == LogsMatchesViewId ); diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/tsrc/ut_logsapp/stubs/hbstubs.cpp --- a/logsui/logsapp/tsrc/ut_logsapp/stubs/hbstubs.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/tsrc/ut_logsapp/stubs/hbstubs.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -29,6 +29,8 @@ #include #include #include +#include +#include int actionCount = 0; Qt::Orientation windowOrientation = Qt::Vertical; @@ -50,6 +52,9 @@ HbActivityManager testActivityManager; Hb::ActivationReason testActivationReason = Hb::ActivationReasonNormal; QString testActivityId = "LogsViewMatches"; +QList testViewItems; +bool testEnsureVisibleCalled = false; +bool testScrollToCalled = false; void HbStubHelper::reset() { @@ -63,10 +68,12 @@ testActivationReason = Hb::ActivationReasonNormal; testActivityId = "LogsViewMatches"; testActivities.clear(); + qDeleteAll(testViewItems); + testViewItems.clear(); + testScrollToCalled = false; + testEnsureVisibleCalled = false; } - - int HbStubHelper::widgetActionsCount() { return actionCount; @@ -135,6 +142,21 @@ testActivityId = activityId; } +QList& HbStubHelper::listItems() +{ + return testViewItems; +} + +bool HbStubHelper::listScrollToCalled() +{ + return testScrollToCalled; +} + +bool HbStubHelper::listEnsureVisibleCalled() +{ + return testEnsureVisibleCalled; +} + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -331,7 +353,6 @@ void HbMainWindow::setCurrentView(HbView *view, bool animate, Hb::ViewSwitchFlags flags) { - Q_UNUSED(animate) Q_UNUSED(flags) testView = view; } @@ -404,3 +425,39 @@ Q_UNUSED(colorRole); return testColor; } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void HbListView::scrollTo(const QModelIndex &index, ScrollHint hint) +{ + Q_UNUSED(index); + Q_UNUSED(hint); + testScrollToCalled = true; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +QList HbAbstractItemView::visibleItems() const +{ + QList visible; + foreach ( HbListViewItem* item, testViewItems ){ + visible.append( item ); + } + return visible; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void HbScrollArea::ensureVisible(const QPointF &position, qreal xMargin, qreal yMargin) +{ + Q_UNUSED(position); + Q_UNUSED(xMargin); + Q_UNUSED(yMargin); + testEnsureVisibleCalled = true; +} diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/tsrc/ut_logsapp/stubs/hbstubs_helper.h --- a/logsui/logsapp/tsrc/ut_logsapp/stubs/hbstubs_helper.h Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/tsrc/ut_logsapp/stubs/hbstubs_helper.h Tue Jul 06 14:16:36 2010 +0300 @@ -17,6 +17,9 @@ #ifndef HBSTUB_HELPER_H #define HBSTUB_HELPER_H + +class HbListViewItem; + /** * Helper class to control logsdbconnector stub behavior * @@ -37,6 +40,9 @@ static void setColorScheme(QColor col); static void setActivityReason(Hb::ActivationReason reason); static void setActivityId(QString activityId); + static QList& listItems(); + static bool listScrollToCalled(); + static bool listEnsureVisibleCalled(); }; #endif diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsapp/tsrc/ut_logsapp/ut_logsapp.pro --- a/logsui/logsapp/tsrc/ut_logsapp/ut_logsapp.pro Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsapp/tsrc/ut_logsapp/ut_logsapp.pro Tue Jul 06 14:16:36 2010 +0300 @@ -51,6 +51,7 @@ HEADERS += inc/ut_logsservicehandler.h HEADERS += ../../inc/logsmainwindow.h HEADERS += ../../inc/logsviewmanager.h +HEADERS += ../../inc/logscomponentrepository.h HEADERS += ../../inc/logsrecentcallsview.h HEADERS += ../../inc/logsbaseview.h HEADERS += ../../inc/logsdetailsview.h diff -r b04270301d3b -r 64a47b97e1e1 logsui/logscntfinder/src/logscntfinder.cpp --- a/logsui/logscntfinder/src/logscntfinder.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logscntfinder/src/logscntfinder.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -1,4 +1,4 @@ -/* + /* * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available diff -r b04270301d3b -r 64a47b97e1e1 logsui/logscntfinder/src/logspredictivetranslator.cpp --- a/logsui/logscntfinder/src/logspredictivetranslator.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logscntfinder/src/logspredictivetranslator.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -143,7 +143,8 @@ } else { delete mNameTranslator; mNameTranslator = new LogsPredictiveLatin12KeyTranslator(); - if( mNameTranslator->encodes( name ) ) { + if( mNameTranslator->mKeyMap && + mNameTranslator->encodes( name ) ) { nameTranslator = mNameTranslator; LOGS_QDEBUG( "logs [FINDER] <- LogsPredictiveTranslator::\ nameTranslator() - use latin" ) @@ -151,7 +152,8 @@ } delete mNameTranslator; mNameTranslator = new LogsPredictiveThai12KeyTranslator(); - if( mNameTranslator->encodes( name ) ) { + if( mNameTranslator->mKeyMap && + mNameTranslator->encodes( name ) ) { nameTranslator = mNameTranslator; LOGS_QDEBUG( "logs [FINDER] <- LogsPredictiveTranslator::\ nameTranslator() - use thai" ) diff -r b04270301d3b -r 64a47b97e1e1 logsui/logscntfinder/tsrc/pt_logscntfinder/src/main.cpp --- a/logsui/logscntfinder/tsrc/pt_logscntfinder/src/main.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logscntfinder/tsrc/pt_logscntfinder/src/main.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -42,9 +42,9 @@ PT_LogsCntFinderQwerty pt_LogsCntFinderQwerty( samples ); resultFileName = "c:/data/others/pt_logscntfinderqwerty.txt"; - QStringList args_logsCntFinderQwertry( "PT_LogsCntFinderQwerty"); - args_logsCntFinder << "-o" << resultFileName; - QTest::qExec(&pt_LogsCntFinderQwerty, args_logsCntFinderQwertry); + QStringList args_logsCntFinderQwerty( "PT_LogsCntFinderQwerty"); + args_logsCntFinderQwerty << "-o" << resultFileName; + QTest::qExec(&pt_LogsCntFinderQwerty, args_logsCntFinderQwerty); return 0; } diff -r b04270301d3b -r 64a47b97e1e1 logsui/logscntfinder/tsrc/pt_logscntfinder/src/pt_logscntfinder.cpp --- a/logsui/logscntfinder/tsrc/pt_logscntfinder/src/pt_logscntfinder.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logscntfinder/tsrc/pt_logscntfinder/src/pt_logscntfinder.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -145,17 +145,33 @@ //open symbian database m_manager = new QContactManager("symbian"); + /* //qDebug() << "PT_LogsCntFinder::init remove old contacts"; // Remove all contacts from the database + QList firstnamelist; + QList Lastnamelist; + firstnamelist<<"Micheal"<<"Evans"<<"Kacris"<<"Xiao"; + Lastnamelist<<"Ribecca"<<"Tina"<<"Bob"<<"George"<<"Anna"; + + for( int z = 0;z<30;z++) { + //for( int z = 0;z<10;z++) { + for(int i =0; i < firstnamelist.count(); i++) { + for(int k =0; k < Lastnamelist.count(); k++) { + //emailaddress = firstnamelist[i].Lastnamelist[k] + createContact_one_Contact(firstnamelist[i], Lastnamelist[k], QString("03432")); + } + } + } + */ + QList cnt_ids = m_manager->contactIds(); qDebug() << "contacts now in db" << cnt_ids.count(); - if ( cnt_ids.count() == 600 ) { + if ( cnt_ids.count() < 600 ) { QString f("Jack"); QString l("Whatever"); createContact_one_Contact( f,l, QString("03432")); } - cnt_ids = m_manager->contactIds(); qDebug() << "contacts now " << cnt_ids.count(); @@ -175,6 +191,7 @@ +//void PT_LogsCntFinder::createContact_one_Contact(QString& firstname, QString& Lastname, QString phnumber, QString& emailaddress) void PT_LogsCntFinder::createContact_one_Contact(QString& firstname, QString& Lastname, QString phnumber) { //Currenlty we can only fetch firstname,lastname,companyname and sip/email/phone from the databse @@ -193,6 +210,11 @@ number.setNumber(phnumber); phonecontact.saveDetail(&number); + QContactEmailAddress email; + QString emailaddress = firstname + "." + Lastname + "@ovi.com"; + email.setEmailAddress(emailaddress); + phonecontact.saveDetail(&email); + m_manager->saveContact(&phonecontact); } @@ -298,9 +320,12 @@ QList tests; tests.append( PtTest("5") ); + tests.append( PtTest("05") ); tests.append( PtTest("52") ); tests.append( PtTest("522") ); tests.append( PtTest("5220") ); + tests.append( PtTest("05220") ); + tests.append( PtTest("052207") ); tests.append( PtTest("522000000000007") ); tests.append( PtTest("205") ); tests.append( PtTest("34096") ); diff -r b04270301d3b -r 64a47b97e1e1 logsui/logscntfinder/tsrc/pt_logscntfinder/src/pt_logscntfinderqwerty.cpp --- a/logsui/logscntfinder/tsrc/pt_logscntfinder/src/pt_logscntfinderqwerty.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logscntfinder/tsrc/pt_logscntfinder/src/pt_logscntfinderqwerty.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -80,7 +80,8 @@ tests.append( PtTest("a") ); tests.append( PtTest("5") ); tests.append( PtTest("Paul") ); - tests.append( PtTest("Paul Mes") ); + tests.append( PtTest("Paul sw") ); + tests.append( PtTest("P S") ); t.start(); diff -r b04270301d3b -r 64a47b97e1e1 logsui/logscntfinder/tsrc/st_logscntfinder/inc/st_logscntfinder.h --- a/logsui/logscntfinder/tsrc/st_logscntfinder/inc/st_logscntfinder.h Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logscntfinder/tsrc/st_logscntfinder/inc/st_logscntfinder.h Tue Jul 06 14:16:36 2010 +0300 @@ -67,7 +67,8 @@ void testPredictiveSearchQueryFullyCached(); void testPredictiveSearchQueryPartialCachedNoResults(); void testPredictiveSearchQueryFullyCachedNoResults(); - void testPredictiveSearchQueryCachedZeroCase(); + void testPredictiveSearchQueryPartialCachedZeroCase(); + void testPredictiveSearchQueryFullyCachedZerosCase(); void testPredictiveSearchQueryLogs(); void testPredictiveSearchQueryLogsZeroCase(); void testPredictiveSearchQueryLogsContactsPartialCached(); @@ -76,6 +77,7 @@ void testPredictiveSearchQueryLogsContactsPhoneNumberMatch(); void testPredictiveSearchQueryLimit(); void testQueryOrder(); + void testContactWithNonMappedChars(); private: @@ -89,6 +91,7 @@ void createContacts(); void createContactsForQueryOrder(); void createContactsForQueryZero(); + void createContactsWithNonMappedChars(); void createHistoryEvents(); void createLogEvent( QString firstname, diff -r b04270301d3b -r 64a47b97e1e1 logsui/logscntfinder/tsrc/st_logscntfinder/src/st_logscntfinder.cpp --- a/logsui/logscntfinder/tsrc/st_logscntfinder/src/st_logscntfinder.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logscntfinder/tsrc/st_logscntfinder/src/st_logscntfinder.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -127,17 +127,23 @@ void ST_LogsCntFinder::createContactsForQueryZero() { createContacts(); - createOneContact( QString("Dlice 00202"), QString("Qwerty"), QString("45789348") ); + createOneContact( QString("Dlice 0202"), QString("Qwerty"), QString("45789348") ); createOneContact( QString("#Paula 2003"), QString("Augustin Ci"), QString("0078945617") ); createOneContact( QString("Paula 02010"), QString("Ezerty Adam"), QString("78945617") ); - createOneContact( QString("Ced"), QString("Y,g"), QString("+78945617") ); + createOneContact( QString("Ced"), QString(",Yg"), QString("+78945617") ); createOneContact( QString("Jari-Pekka"), QString(" "), QString("78945617") ); int contactsCount = m_manager->contactIds().count(); QCOMPARE(contactsCount, 18); } - +void ST_LogsCntFinder::createContactsWithNonMappedChars() +{ + + createOneContact( QString("Hannu%"), QString(""), QString("932472398") ); + createOneContact( QString("%Hannu"), QString(""), QString("932472398") ); + +} void ST_LogsCntFinder::createHistoryEvents() { @@ -307,7 +313,7 @@ { createContactsForQueryZero(); - m_finder->predictiveSearchQuery( QString("00202") ); + m_finder->predictiveSearchQuery( QString("0202") ); QCOMPARE( m_finder->resultsCount(), 2 ); } @@ -316,7 +322,7 @@ createContactsForQueryZero(); m_finder->predictiveSearchQuery( QString("02010") ); - QCOMPARE( m_finder->resultsCount(), 1 ); + QCOMPARE( m_finder->resultsCount(), 2 ); } void ST_LogsCntFinder::testPredictiveSearchQueryZeroMiddle() @@ -464,33 +470,67 @@ } -// 6 -> 69 (no match) -> 692 (no match) -> 69 (no match) -> 6 (all cached) -void ST_LogsCntFinder::testPredictiveSearchQueryCachedZeroCase() +// +void ST_LogsCntFinder::testPredictiveSearchQueryPartialCachedZeroCase() { createContacts(); - m_finder->predictiveSearchQuery( QString("2") ); + m_finder->predictiveSearchQuery( QString("2") );//db QCOMPARE( m_finder->resultsCount(), 3 ); CHECK_RESULTS( 2, "Levis", "Augustin" );//Augustin Zi - m_finder->predictiveSearchQuery( QString("20") ); + m_finder->predictiveSearchQuery( QString("20") );//db QCOMPARE( m_finder->resultsCount(), 3 ); CHECK_RESULTS( 2, "Levis", "Augustin" );//Augustin Zi - m_finder->predictiveSearchQuery( QString("209") ); + m_finder->predictiveSearchQuery( QString("209") );//db QCOMPARE( m_finder->resultsCount(), 1 ); CHECK_RESULTS( 1, "Levis", "Augustin" ); //Augustin Zi - m_finder->predictiveSearchQuery( QString("20") ); + m_finder->predictiveSearchQuery( QString("20") );//db QCOMPARE( m_finder->resultsCount(), 3 ); CHECK_RESULTS( 2, "Levis", "Augustin" );//Augustin Zi - m_finder->predictiveSearchQuery( QString("2") ); + m_finder->predictiveSearchQuery( QString("2") );//db QCOMPARE( m_finder->resultsCount(), 3 ); CHECK_RESULTS( 2, "Levis", "Augustin" );//Augustin Zi } +// +void ST_LogsCntFinder::testPredictiveSearchQueryFullyCachedZerosCase() +{ + createContacts(); + + m_finder->predictiveSearchQuery( QString("2") ); //db + QCOMPARE( m_finder->resultsCount(), 3 ); + CHECK_RESULTS( 3, "Levis", "Augustin" );//Augustin Zi + + m_finder->predictiveSearchQuery( QString("20") );//cache + QCOMPARE( m_finder->resultsCount(), 3 ); + CHECK_RESULTS( 3, "Levis", "Augustin" );//Augustin Zi + + m_finder->predictiveSearchQuery( QString("200") );//cache + QCOMPARE( m_finder->resultsCount(), 3 ); + CHECK_RESULTS( 3, "Levis", "Augustin" );//Augustin Zi + + m_finder->predictiveSearchQuery( QString("2009") );//cache + QCOMPARE( m_finder->resultsCount(), 1 ); + CHECK_RESULTS( 1, "Levis", "Augustin" ); //Augustin Zi + + m_finder->predictiveSearchQuery( QString("200") );//db + QCOMPARE( m_finder->resultsCount(), 3 ); + CHECK_RESULTS( 3, "Levis", "Augustin" );//Augustin Zi + + m_finder->predictiveSearchQuery( QString("20") );//db + QCOMPARE( m_finder->resultsCount(), 3 ); + CHECK_RESULTS( 3, "Levis", "Augustin" );//Augustin Zi + + m_finder->predictiveSearchQuery( QString("2") );//db + QCOMPARE( m_finder->resultsCount(), 3 ); + CHECK_RESULTS( 3, "Levis", "Augustin" );//Augustin Zi + +} //There is recent call in logs, no contacts DB void ST_LogsCntFinder::testPredictiveSearchQueryLogs() @@ -710,3 +750,24 @@ QCOMPARE(m_finder->resultAt(7).lastName().at(0).text(), QString("Yadira")); } +void ST_LogsCntFinder::testContactWithNonMappedChars() +{ + //Hannu% + //%Hannu + createContactsWithNonMappedChars(); + + m_finder->predictiveSearchQuery( QString("4") ); + QCOMPARE( m_finder->resultsCount(), 1 );//Hannu% + QCOMPARE(m_finder->resultAt(0).firstName().at(0).text(), QString("Hannu%")); + + m_finder->predictiveSearchQuery( QString("42") );//all cached + QCOMPARE( m_finder->resultsCount(), 1 );//Hannu% + QCOMPARE(m_finder->resultAt(0).firstName().at(0).text(), QString("Hannu%")); + + m_finder->predictiveSearchQuery( QString("") );//empty cache + m_finder->predictiveSearchQuery( QString("42") ); + QCOMPARE( m_finder->resultsCount(), 1 );//Hannu% + QCOMPARE(m_finder->resultAt(0).firstName().at(0).text(), QString("Hannu%")); + +} + diff -r b04270301d3b -r 64a47b97e1e1 logsui/logscntfinder/tsrc/stubs/qtcontacts_stubs.cpp --- a/logsui/logscntfinder/tsrc/stubs/qtcontacts_stubs.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logscntfinder/tsrc/stubs/qtcontacts_stubs.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -170,9 +170,10 @@ return list; } + QContact QContactManager::contact( - const QContactLocalId& contactId, - const QStringList& /*definitionRestrictions*/ ) const + const QContactLocalId& contactId, + const QContactFetchHint& /*fetchHint*/) const { QContact contact; QContactId id; @@ -182,6 +183,7 @@ return contact; } + // ---------------------------------------------------------------------------- // QContactDetailFilter // ---------------------------------------------------------------------------- diff -r b04270301d3b -r 64a47b97e1e1 logsui/logscntfinder/tsrc/ut_logscntfinder/src/ut_logspredictivethai12keytranslator.cpp --- a/logsui/logscntfinder/tsrc/ut_logscntfinder/src/ut_logspredictivethai12keytranslator.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logscntfinder/tsrc/ut_logscntfinder/src/ut_logspredictivethai12keytranslator.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -56,6 +56,7 @@ void UT_LogsPredictiveThai12KeyTranslator::testTranslateText() { + QEXPECT_FAIL("", "No proper Thai keymap yet", Abort ); QCOMPARE( mTranslator->translateText( QString( "0123456789" ) ), QString( "0123456789" ) ); //finds name latin name translator QCOMPARE( mTranslator->translateText( QString( "Nokia" ) ), QString( "66542" ) ); @@ -81,6 +82,7 @@ void UT_LogsPredictiveThai12KeyTranslator::testTranslateChar() { + QEXPECT_FAIL("", "No proper Thai keymap yet", Abort ); bool ok; QCOMPARE( mTranslator->translateChar( QChar('0'), ok ), QChar('0') ); @@ -113,12 +115,6 @@ void UT_LogsPredictiveThai12KeyTranslator::testEncodes() { - //thai - const int ucsize = 9; - const QChar thaiName2[] = {0x0E01,0x0E06,0x0E2F,0x0E0E,0x0E14,0x0E19,0x0E30,0x0E23,0x0E2A }; - - QVERIFY( mTranslator->encodes( QString( thaiName2,ucsize ) ) ); - //china QString uni1; uni1.append(QChar(0x4E0E)); @@ -126,7 +122,14 @@ QVERIFY( !mTranslator->encodes( uni1) ); QVERIFY( !mTranslator->encodes( QString( "Zulu" ) ) ); - + + QEXPECT_FAIL("", "No proper Thai keymap yet", Abort ); + //thai + const int ucsize = 9; + const QChar thaiName2[] = {0x0E01,0x0E06,0x0E2F,0x0E0E,0x0E14,0x0E19,0x0E30,0x0E23,0x0E2A }; + + QVERIFY( mTranslator->encodes( QString( thaiName2,ucsize ) ) ); + } diff -r b04270301d3b -r 64a47b97e1e1 logsui/logscntfinder/tsrc/ut_logscntfinder/src/ut_logspredictivetranslator.cpp --- a/logsui/logscntfinder/tsrc/ut_logscntfinder/src/ut_logspredictivetranslator.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logscntfinder/tsrc/ut_logscntfinder/src/ut_logspredictivetranslator.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -87,6 +87,10 @@ 2 ); QVERIFY( ok ); + QString test2( "Hannu%"); + QCOMPARE( mTranslator->LogsPredictiveTranslator::translate( test2, &ok ).length(),test2.length() -1 ); + QVERIFY( !ok ); + } void UT_LogsPredictiveTranslator::testTranslatePattern() @@ -105,11 +109,16 @@ QCOMPARE( mTranslator->translateText( test1 ).length(), test1.length() ); + QString test2( "Hannu%"); + QCOMPARE( mTranslator->translateText( test2 ).length(), test2.length() - 1 ); + + QEXPECT_FAIL("", "No proper Thai keymap yet", Abort ); //text is thai, input lang latin const int ucsize = 9; // 1 2 3 4 5 6 7 8 9 const QChar thaiName1[] = {0x0E01,0x0E06,0x0E0A,0x0E0E,0x0E14,0x0E19,0x0E1E,0x0E23,0x0E2A }; QCOMPARE( mTranslator->translateText( QString( thaiName1,ucsize ) ), QString( "123456789" ) ); + } @@ -120,6 +129,22 @@ QVERIFY( !mTranslator->mNameTranslator ); QCOMPARE( mTranslator->nameTranslator( test1 ).mib(), MIBenumLatin ); QVERIFY( mTranslator->mNameTranslator ); + + //china + QString uni; + uni.append(QChar(0x0219)); + uni.append(QChar(0x4E0F)); + QCOMPARE( mTranslator->nameTranslator( uni ).mib(), MIBenumLatin ); + QVERIFY( !mTranslator->mNameTranslator ); + QCOMPARE( mTranslator->mib(), MIBenumLatin ); + + //unmapped + QString test2( "Hannu%"); + QCOMPARE( mTranslator->nameTranslator( test2 ).mib(), MIBenumLatin ); + QVERIFY( !mTranslator->mNameTranslator ); + QCOMPARE( mTranslator->mib(), MIBenumLatin ); + + QEXPECT_FAIL("", "No proper Thai keymap yet", Abort ); //text is thai, input lang latin const int ucsize = 9; @@ -135,16 +160,6 @@ QCOMPARE( mTranslator->mNameTranslator->mib(), MIBenumThai ); QCOMPARE( mTranslator->mib(), MIBenumLatin ); - - //china - QString uni; - uni.append(QChar(0x0219)); - uni.append(QChar(0x4E0F)); - QCOMPARE( mTranslator->nameTranslator( uni ).mib(), MIBenumLatin ); - QVERIFY( !mTranslator->mNameTranslator ); - QCOMPARE( mTranslator->mib(), MIBenumLatin ); - - } diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsengine/inc/logsengdefs.h --- a/logsui/logsengine/inc/logsengdefs.h Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsengine/inc/logsengdefs.h Tue Jul 06 14:16:36 2010 +0300 @@ -56,18 +56,13 @@ const int logsEventALS = 0x4; const int logsDeleteCountInit = -1; -const int logsReadSizeCompressEnabled = 20; +const int logsReadSizeCompressEnabled = 10; const int logsReadSizeUndefined = -1; // MACROS #define DESC_TO_QSTRING( desc )\ QString::fromUtf16( desc.Ptr(), desc.Length() ); -#define LOGSENG_PANIC() User::Invariant() - -#define LOGSENG_ASSERT( cond )\ -if ( !(cond) ) LOGSENG_PANIC; - // DATA TYPES class LogsEventStrings diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsengine/inc/logsmatchesmodel.h --- a/logsui/logsengine/inc/logsmatchesmodel.h Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsengine/inc/logsmatchesmodel.h Tue Jul 06 14:16:36 2010 +0300 @@ -75,6 +75,7 @@ void eventsUpdated(const QModelIndex& first, const QModelIndex& last); void eventsAdded(const QModelIndex& parent, int first, int last); void eventsRemoved(const QModelIndex& parent, int first, int last); + void eventsResetted(); void doSearchQuery(); void doModelReset(); @@ -90,6 +91,7 @@ void getLogsMatches( const QString& pattern, bool async = false, bool force = false ); void updateSearchEntry(LogsCntEntry& entry, LogsEvent& event); QString stripPhoneNumber(const QString& phoneNumber) const; + void addEventForSearching(int index, LogsEvent& event); private: //data @@ -126,6 +128,7 @@ unsigned int contact() const; QString number() const; QString contactName() const; + QString contactNameSimple() const; bool isNull() const; bool isEventMatch() const; QStringList texts(); @@ -137,8 +140,10 @@ QString getFormattedCallerId(const LogsCntEntry& entry) const; void getFormattedContactInfo( - const LogsCntEntry& entry, QString& contactName, QString& contactNumber ) const; - void getFormattedName(QString& formattedName, + const LogsCntEntry& entry, QString& contactName, + QString& contactNameSimple, QString& contactNumber ) const; + void getFormattedName(QString& formattedName, const QList& list) const; + void getFormattedName(QString& formattedName, QString& formattedNameSimple, const QList& list) const; private: @@ -146,6 +151,7 @@ LogsAbstractModel& mParentModel; unsigned int mContactId; QString mContactName; + QString mContactNameSimple; QString mContactNumber; QString mAvatarPath; QString mFormattedCallerId; diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsengine/inc/logsmessage.h --- a/logsui/logsengine/inc/logsmessage.h Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsengine/inc/logsmessage.h Tue Jul 06 14:16:36 2010 +0300 @@ -69,6 +69,7 @@ XQServiceRequest* mService; private: friend class UT_LogsMessage; + friend class UT_LogsMatchesModel; }; diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsengine/logssymbianos/src/logsdbconnector.cpp --- a/logsui/logsengine/logssymbianos/src/logsdbconnector.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsengine/logssymbianos/src/logsdbconnector.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -509,10 +509,6 @@ } deleteRemoved(readCount); - - if ( mCompressionEnabled ){ - mReader->stop(); - } LOGS_QDEBUG( "logs [ENG] <- LogsDbConnector::readCompleted()" ) } diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsengine/logssymbianos/tsrc/ut_logssymbianos/src/ut_logsdbconnector.cpp --- a/logsui/logsengine/logssymbianos/tsrc/ut_logssymbianos/src/ut_logsdbconnector.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsengine/logssymbianos/tsrc/ut_logssymbianos/src/ut_logsdbconnector.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -287,13 +287,13 @@ QVERIFY( mDbConnector->mEvents.count() == 1 ); QVERIFY( mEvents.count() == 1 ); - // Read completed when compression is enabled, reader is stopped + // Read completed when compression is enabled, reader is not stopped QVERIFY( mDbConnector->init() == 0 ); QVERIFY( mDbConnector->start() == 0 ); QVERIFY( mDbConnector->mReader->mLogViewRecent != 0 ); mDbConnector->mCompressionEnabled = true; mDbConnector->readCompleted(0); - QVERIFY( mDbConnector->mReader->mLogViewRecent == 0 ); + QVERIFY( mDbConnector->mReader->mLogViewRecent != 0 ); } void UT_LogsDbConnector::testErrorOccurred() diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsengine/src/logscontact.cpp --- a/logsui/logsengine/src/logscontact.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsengine/src/logscontact.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -200,7 +200,10 @@ SLOT(handleRequestCompleted(QVariant))); mService->setArguments(arguments); - + XQRequestInfo info; + info.setForeground(true); + mService->setInfo(info); + QVariant retValue; return mService->send(retValue); } diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsengine/src/logsmatchesmodel.cpp --- a/logsui/logsengine/src/logsmatchesmodel.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsengine/src/logsmatchesmodel.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -165,7 +165,8 @@ } const LogsMatchesModelItemContainer& matchItem = static_cast( item ); - LogsMessage* logsMessage = new LogsMessage(matchItem.contact(), matchItem.number(),matchItem.contactName()); + LogsMessage* logsMessage = new LogsMessage( + matchItem.contact(), matchItem.number(),matchItem.contactNameSimple()); if (!logsMessage->isMessagingAllowed()) { delete logsMessage; logsMessage = 0; @@ -298,6 +299,39 @@ } // ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void LogsMatchesModel::eventsResetted() +{ + LOGS_QDEBUG( "logs [ENG] -> LogsMatchesModel::eventsResetted()" ); + + QMap unusedEvents = mSearchEvents; + for ( int i = 0; i < mParentModel.rowCount(); ++i ){ + LogsEvent* event = qVariantValue( + mParentModel.data( mParentModel.index(i, 0), LogsModel::RoleFullEvent ) ); + if ( event ){ + QObject* key = mSearchEvents.key(event); + if ( key ){ + unusedEvents.remove(key); + } else { + addEventForSearching(i, *event); + } + } + } + + QMap::iterator unusedIt; + for (unusedIt = unusedEvents.begin(); unusedIt != unusedEvents.end(); ++unusedIt){ + mLogsCntFinder->deleteEntry(*unusedIt.key()); + mSearchEvents.remove(unusedIt.key()); + } + + forceSearchQuery(); + + LOGS_QDEBUG( "logs [ENG] <- LogsMatchesModel::eventsResetted()" ); +} + +// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // @@ -315,7 +349,7 @@ this, SLOT(eventsAdded(const QModelIndex&,int,int))); connect( &mParentModel, SIGNAL(rowsRemoved(const QModelIndex&,int,int)), this, SLOT(eventsRemoved(const QModelIndex&,int,int))); - connect( &mParentModel, SIGNAL(modelReset()), this, SLOT(doModelReset())); + connect( &mParentModel, SIGNAL(modelReset()), this, SLOT(eventsResetted())); readEvents(0, mParentModel.rowCount()); mIconManager = new LogsThumbIconManager(); connect(mIconManager, SIGNAL(contactIconReady(int)), @@ -373,11 +407,7 @@ LogsEvent* event = qVariantValue( mParentModel.data( mParentModel.index(i, 0), LogsModel::RoleFullEvent ) ); if ( event ){ - QObject* entryHandle = new QObject(this); - LogsCntEntry* entry = new LogsCntEntry(*entryHandle, 0); - updateSearchEntry(*entry, *event); - mLogsCntFinder->insertEntry(i, entry); - mSearchEvents.insert(entryHandle, event); + addEventForSearching(i, *event); } } } @@ -447,10 +477,12 @@ // void LogsMatchesModel::doModelReset() { + LOGS_QDEBUG( "logs [ENG] -> LogsMatchesModel::doModelReset()" ); qDeleteAll(mMatches); mMatches.clear(); mResultCount = 0; reset(); + LOGS_QDEBUG( "logs [ENG] <- LogsMatchesModel::doModelReset()" ); } // ----------------------------------------------------------------------------- @@ -512,6 +544,19 @@ // // ----------------------------------------------------------------------------- // +void LogsMatchesModel::addEventForSearching(int index, LogsEvent& event) +{ + QObject* entryHandle = new QObject(this); + LogsCntEntry* entry = new LogsCntEntry(*entryHandle, 0); + updateSearchEntry(*entry, event); + mLogsCntFinder->insertEntry(index, entry); + mSearchEvents.insert(entryHandle, &event); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// LogsMatchesModelItemContainer::LogsMatchesModelItemContainer( LogsAbstractModel& parentModel, LogsThumbIconManager& thumbIconManager, @@ -594,6 +639,15 @@ // // ----------------------------------------------------------------------------- // +QString LogsMatchesModelItemContainer::contactNameSimple() const +{ + return mContactNameSimple; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// bool LogsMatchesModelItemContainer::isNull() const { return ( !mEvent && !mContactId ); @@ -651,7 +705,7 @@ if ( mEvent ){ mFormattedCallerId = getFormattedCallerId(entry); } else if ( mContactId > 0 ){ - getFormattedContactInfo(entry, mContactName, mContactNumber); + getFormattedContactInfo(entry, mContactName, mContactNameSimple, mContactNumber); mAvatarPath.clear(); mAvatarPath = entry.avatarPath(); } @@ -690,15 +744,17 @@ // void LogsMatchesModelItemContainer::getFormattedContactInfo( const LogsCntEntry& entry, - QString& contactName, + QString& contactName, + QString& contactNameSimple, QString& contactNumber ) const { contactName.clear(); - getFormattedName(contactName, entry.firstName()); - getFormattedName(contactName, entry.lastName()); + getFormattedName(contactName, contactNameSimple, entry.firstName()); + getFormattedName(contactName, contactNameSimple, entry.lastName()); contactName = contactName.trimmed(); + contactNameSimple = contactNameSimple.trimmed(); contactNumber = entry.phoneNumber().text(); } @@ -706,13 +762,31 @@ // // ----------------------------------------------------------------------------- // -void LogsMatchesModelItemContainer::getFormattedName(QString& formattedName, - const QList& list) const +void LogsMatchesModelItemContainer::getFormattedName( + QString& formattedName, const QList& list) const { foreach( LogsCntText name, list ) { if ( name.text().length() > 0 ) { - formattedName.append(name.richText()); + formattedName.append(name.richText()); formattedName.append(" "); } } } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +void LogsMatchesModelItemContainer::getFormattedName( + QString& formattedName, QString& formattedNameSimple, + const QList& list) const +{ + foreach( LogsCntText name, list ) { + if ( name.text().length() > 0 ) { + formattedName.append(name.richText()); + formattedName.append(" "); + formattedNameSimple.append(name.text()); + formattedNameSimple.append(" "); + } + } +} diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsengine/src/logsmessage.cpp --- a/logsui/logsengine/src/logsmessage.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsengine/src/logsmessage.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -146,6 +146,9 @@ arguments.append(QVariant(contactId)); arguments.append(QVariant(displayName)); request.setArguments(arguments); + XQRequestInfo info; + info.setForeground(true); + request.setInfo(info); QVariant retValue; bool ret = request.send(retValue); LOGS_QDEBUG_2( "logs [ENG] <- LogsMessage::doSendMessageToNumber()", ret ) diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsengine/tsrc/stubs/logscntfinder.h --- a/logsui/logsengine/tsrc/stubs/logscntfinder.h Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsengine/tsrc/stubs/logscntfinder.h Tue Jul 06 14:16:36 2010 +0300 @@ -35,7 +35,7 @@ inline LogsCntText() : mHighlights(0){} inline const QString& text() const {return mText;} - inline int highlights() const {return mHighlights;} + int highlights() const; QString richText( QString startTag = QString(""), QString endTag = QString("")) const; @@ -48,6 +48,7 @@ friend class LogsCntEntry; friend class UT_LogsCntEntry; friend class UT_LogsCntFinder; + friend class UT_LogsMatchesModel; }; typedef QList LogsCntTextList; @@ -100,6 +101,7 @@ friend class UT_LogsCntEntry; friend class UT_LogsCntFinder; + friend class UT_LogsMatchesModel; }; typedef QList LogsCntEntryList; diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsengine/tsrc/stubs/logscntfinder_stub.cpp --- a/logsui/logsengine/tsrc/stubs/logscntfinder_stub.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsengine/tsrc/stubs/logscntfinder_stub.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -24,6 +24,8 @@ #include #include +QString testHighlights; + // ----------------------------------------------------------------------------- // LogsCntEntry::richText() // ----------------------------------------------------------------------------- @@ -42,6 +44,15 @@ } // ----------------------------------------------------------------------------- +// LogsCntEntry::highlights() +// ----------------------------------------------------------------------------- +// +int LogsCntText::highlights() const +{ + return testHighlights.length() ; +} + +// ----------------------------------------------------------------------------- // LogsCntEntry::LogsCntEntry() // ----------------------------------------------------------------------------- // @@ -204,6 +215,7 @@ // void LogsCntEntry::setHighlights( const QString& pattern ) { + testHighlights = pattern; } // ----------------------------------------------------------------------------- diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsengine/tsrc/stubs/qthighway_stub.cpp --- a/logsui/logsengine/tsrc/stubs/qthighway_stub.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsengine/tsrc/stubs/qthighway_stub.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -106,3 +106,9 @@ { return qtHighwayStubRequestBg; } + + +void XQRequestInfo::setForeground(bool on) +{ + Q_UNUSED(on) +} diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsengine/tsrc/ut_logsengine/inc/ut_logsmatchesmodel.h --- a/logsui/logsengine/tsrc/ut_logsengine/inc/ut_logsmatchesmodel.h Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsengine/tsrc/ut_logsengine/inc/ut_logsmatchesmodel.h Tue Jul 06 14:16:36 2010 +0300 @@ -52,6 +52,7 @@ void testDataAdded(); void testDataUpdated(); void testDataRemoved(); + void testDataResetted(); void testLogsMatches(); void testCreateContactWithNumber(); void testCreateCall(); diff -r b04270301d3b -r 64a47b97e1e1 logsui/logsengine/tsrc/ut_logsengine/src/ut_logsmatchesmodel.cpp --- a/logsui/logsengine/tsrc/ut_logsengine/src/ut_logsmatchesmodel.cpp Wed Jun 23 18:13:05 2010 +0300 +++ b/logsui/logsengine/tsrc/ut_logsengine/src/ut_logsmatchesmodel.cpp Tue Jul 06 14:16:36 2010 +0300 @@ -331,6 +331,55 @@ // // ----------------------------------------------------------------------------- // +void UT_LogsMatchesModel::testDataResetted() +{ + // Have few events and then get reset where one event is removed and + // one new event is added + // + LogsEvent* event = new LogsEvent(); + QString event1Name("event1"); + event->setRemoteParty(event1Name); + LogsEvent* event2 = new LogsEvent(); + QString event2Name("event2"); + event2->setRemoteParty(event2Name); + LogsEvent* event3 = new LogsEvent(); + QString event3Name("event3"); + event3->setRemoteParty(event3Name); + mModel->mEvents.append(event); + mModel->mEvents.append(event2); + mModel->mEvents.append(event3); + mMatchesModel->eventsAdded(QModelIndex(), 0, 2); + QCOMPARE( mMatchesModel->mSearchEvents.count(), 3 ); + QCOMPARE( mMatchesModel->mLogsCntFinder->mHistoryEvents.count(), 3 ); + QCOMPARE( mMatchesModel->mLogsCntFinder->mHistoryEvents.at(0)->firstName().at(0).text(), event1Name ); + QCOMPARE( mMatchesModel->mLogsCntFinder->mHistoryEvents.at(1)->firstName().at(0).text(), event2Name ); + QCOMPARE( mMatchesModel->mLogsCntFinder->mHistoryEvents.at(2)->firstName().at(0).text(), event3Name ); + + mModel->mEvents.clear(); + + LogsEvent* event4 = new LogsEvent(); + QString event4Name("event4"); + event4->setRemoteParty(event4Name); + mModel->mEvents.append(event4); + + mModel->mEvents.append(event); + mModel->mEvents.append(event3); + + QSignalSpy spy(mMatchesModel, SIGNAL(modelReset())); + mMatchesModel->eventsResetted(); + QCOMPARE( mMatchesModel->mSearchEvents.count(), 3 ); + QCOMPARE( mMatchesModel->mLogsCntFinder->mHistoryEvents.count(), 3 ); + QCOMPARE( mMatchesModel->mLogsCntFinder->mHistoryEvents.at(0)->firstName().at(0).text(), event4Name ); + QCOMPARE( mMatchesModel->mLogsCntFinder->mHistoryEvents.at(1)->firstName().at(0).text(), event1Name ); + QCOMPARE( mMatchesModel->mLogsCntFinder->mHistoryEvents.at(2)->firstName().at(0).text(), event3Name ); + QCOMPARE( spy.count(), 1 ); + delete event2; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// void UT_LogsMatchesModel::testLogsMatches() { QVERIFY( mMatchesModel->mLogsCntFinder ); @@ -487,9 +536,12 @@ // With contact, messaging supported LogsMatchesModelItemContainer item3(*mModel, *mMatchesModel->mIconManager, 2); item3.setContact(2); + item3.mContactName = "somename"; + item3.mContactNameSimple = "somename"; var = mMatchesModel->createMessage(item3); message = qVariantValue( var ); QVERIFY( message ); + QVERIFY( message->mDisplayName == "somename" ); delete message; } @@ -605,22 +657,26 @@ void UT_LogsMatchesModel::testGetFormattedContactInfo() { QString name; + QString nameSimple; QString number; QVERIFY( mMatchesModel->mIconManager ); // Entry is not initialized, name and number are empty LogsCntEntry entry(0); LogsMatchesModelItemContainer item(*mModel, *mMatchesModel->mIconManager, 0); - item.getFormattedContactInfo(entry, name, number); - QVERIFY( name.length() == 0 && number.length() == 0 ); + item.getFormattedContactInfo(entry, name, nameSimple, number); + QVERIFY( name.length() == 0 && nameSimple.length() == 0 && number.length() == 0 ); // Entry is initialized, name and number are not empty entry.setFirstName("long firstname"); entry.setLastName("long lastname"); entry.setPhoneNumber("number"); - item.getFormattedContactInfo(entry, name, number); - QVERIFY( name == "long firstname long lastname" ); - QVERIFY( number == "number" ); + entry.setHighlights("lo"); + item.getFormattedContactInfo(entry, name, nameSimple, number); + QCOMPARE( nameSimple, QString("long firstname long lastname") ); + QVERIFY( nameSimple.length() < name.length() ); + QCOMPARE( number, QString("number") ); + entry.setHighlights(""); } // -----------------------------------------------------------------------------