diff -r 6727c5d0afc7 -r 458d8c8d9580 homescreenapp/hsdomainmodel/src/hspagenewwidgetlayout.cpp --- a/homescreenapp/hsdomainmodel/src/hspagenewwidgetlayout.cpp Fri Sep 17 08:27:54 2010 +0300 +++ b/homescreenapp/hsdomainmodel/src/hspagenewwidgetlayout.cpp Mon Oct 04 00:07:25 2010 +0300 @@ -45,6 +45,7 @@ QGraphicsLayoutItem *parent) : QGraphicsLayout(parent), mTouchPoint(touchPoint) + // add mWidgetRects { mSize = HsGui::instance()->layoutRect().size(); } @@ -104,15 +105,6 @@ { QGraphicsLayout::setGeometry(rect); -#ifdef HSWIDGETORGANIZER_ALGORITHM - // sort new widgets in order - if (mNewWidgets.count() > 1) { - // TODO: read from configuration? or just use height for portrait and width for landscape (currently only height is used) - sortOrder order(height); - mNewWidgets = sortWidgets(order); - } -#endif - // get rects for new widgets QList newRects; foreach (HsWidgetHost *newWidget, mNewWidgets) { @@ -123,7 +115,7 @@ then there is only one widget in the list -> set widget center point to this touch point */ - if (mTouchPoint != QPointF() && mNewWidgets.count() == 1) { + if (mTouchPoint != QPointF() && newRects.count() == 1) { QRectF widgetRect = newRects.at(0); widgetRect.moveCenter(mTouchPoint); widgetRect.moveTopLeft(HsScene::instance()->activePage()->adjustedWidgetPosition(widgetRect)); @@ -153,8 +145,8 @@ HsWidgetPositioningOnWidgetAdd::instance(); QList calculatedRects = algorithm->convert(pageRect, existingRects, newRects, QPointF()); - - for ( int i=0; ivisual()->setGeometry(calculatedRects.at(i)); mNewWidgets.at(i)->savePresentation(); } @@ -168,47 +160,3 @@ { mNewWidgets.append(item); } - -#ifdef HSWIDGETORGANIZER_ALGORITHM -// TODO: sorting should be done in algorithm class, make widget<->rect mapping here and move sortWidgets function to algorithm side -/*! - Sorts widgets in height/width order -*/ -QList HsPageNewWidgetLayout::sortWidgets(sortOrder order) -{ - QList tmpWidgets; - - for ( int i = 0; i < mNewWidgets.count(); i++) { - int index = 0; - // add first widget to sorted list - if (i == 0) { - tmpWidgets << mNewWidgets.at(i); - } else { - // go through existing widgets in the sorted list - for ( int j = 0; j < tmpWidgets.count(); j++) { - // sort widgets in height order - if (order == height) { - /* if widgets heigth is smaller on already - existing ones in the list -> increment index - */ - if (mNewWidgets.at(i)->visual()->preferredHeight() <= tmpWidgets.at(j)->visual()->preferredHeight()) { - index++; - } - // sort widgets in width order - } else { - /* if widgets width is smaller on already - existing ones in the sorted list -> increment index - */ - if (mNewWidgets.at(i)->visual()->preferredWidth() <= tmpWidgets.at(j)->visual()->preferredWidth()) { - index++; - } - } - } - // add widget to its correct index in sorted list - tmpWidgets.insert(index, mNewWidgets.at(i)); - } - } - return tmpWidgets; -} -#endif // HSWIDGETORGANIZER_ALGORITHM -