417 d.uri = uri; |
396 d.uri = uri; |
418 d.pageId = query.value(1).toInt(); |
397 d.pageId = query.value(1).toInt(); |
419 data.append(d); |
398 data.append(d); |
420 } |
399 } |
421 return true; |
400 return true; |
|
401 } |
|
402 } |
|
403 |
|
404 return false; |
|
405 } |
|
406 |
|
407 /*! |
|
408 |
|
409 */ |
|
410 bool HsDatabase::widgets(const QString &uri, const QVariantHash &preferences, int &count) |
|
411 { |
|
412 if (!checkConnection()) { |
|
413 return false; |
|
414 } |
|
415 QSqlQuery query(QSqlDatabase::database(mConnectionName)); |
|
416 if ( preferences.size() == 0 ) { |
|
417 // return widget count of the given uri |
|
418 QString statement = |
|
419 "SELECT COUNT(id) " |
|
420 "FROM Widgets " |
|
421 "WHERE uri = ?"; |
|
422 |
|
423 if (query.prepare(statement)) { |
|
424 query.addBindValue(uri); |
|
425 if (query.exec() && query.next()) { |
|
426 count = query.value(0).toInt(); |
|
427 return true; |
|
428 } |
|
429 } |
|
430 } else { |
|
431 |
|
432 QString statement = |
|
433 "SELECT key, value, widgetId " |
|
434 "FROM widgetPreferences " |
|
435 "WHERE widgetId IN" |
|
436 "(SELECT id FROM widgets WHERE uri = ?)"; |
|
437 |
|
438 if (query.prepare(statement)) { |
|
439 query.addBindValue(uri); |
|
440 if (query.exec()) { |
|
441 count = 0; |
|
442 QMultiMap<QString, QString> foundPreferences; |
|
443 while (query.next()) { |
|
444 foundPreferences.insert(query.value(0).toString(), query.value(1).toString()); |
|
445 } |
|
446 if ( matchWidgetPreferences(preferences, foundPreferences) ) { |
|
447 ++count; |
|
448 } |
|
449 return true; |
|
450 } |
422 } |
451 } |
423 } |
452 } |
424 |
453 |
425 return false; |
454 return false; |
426 } |
455 } |
758 } |
787 } |
759 |
788 |
760 return true; |
789 return true; |
761 } |
790 } |
762 |
791 |
763 /*! |
792 bool HsDatabase::configuration(QVariantHash &configuration) |
764 |
793 { |
765 */ |
794 if (!checkConnection()) { |
766 bool HsDatabase::generalConfiguration(HsGeneralConfiguration &data) |
795 return false; |
767 { |
796 } |
768 if (!checkConnection()) { |
797 |
769 return false; |
798 QSqlQuery query(QSqlDatabase::database(mConnectionName)); |
770 } |
799 |
771 |
800 QString statement = |
772 QSqlQuery query(QSqlDatabase::database(mConnectionName)); |
801 "SELECT key, value " |
773 |
802 "FROM Configuration"; |
774 QString statement = |
803 |
775 "SELECT bounceEffect, tapAndHoldDistance, widgetTapAndHoldTimeout, sceneTapAndHoldTimeout, " |
804 if (query.prepare(statement) && query.exec()) { |
776 "pageChangeZoneWidth, " |
805 configuration.clear(); |
777 "pageIndicatorSpacing, pageChangeAnimationDuration, pageChangeZoneAnimationDuration, " |
806 while (query.next()) { |
778 "pageChangeZoneReverseAnimationDuration, " |
807 configuration.insert(query.value(0).toString(), |
779 "pageRemovedAnimationDuration, newPageAddedAnimationDuration, widgetDragEffectDuration, " |
808 query.value(1)); |
780 "widgetDropEffectDuration, boundaryFeedbackEffectDistance, " |
809 } |
781 "defaultPageId, maximumPageCount, maximumWidgetHeight, maximumWidgetWidth, " |
|
782 "minimumWidgetHeight, minimumWidgetWidth, shortcutLabelsVisible, " |
|
783 "pageChangePanDistance " |
|
784 "FROM GeneralConfiguration"; |
|
785 |
|
786 if (query.prepare(statement) && query.exec() && query.next()) { |
|
787 data.bounceEffect = query.value(0).toInt(); |
|
788 data.tapAndHoldDistance = query.value(1).toReal(); |
|
789 data.widgetTapAndHoldTimeout = query.value(2).toInt(); |
|
790 data.sceneTapAndHoldTimeout = query.value(3).toInt(); |
|
791 data.pageChangeZoneWidth = query.value(4).toReal(); |
|
792 data.pageIndicatorSpacing = query.value(5).toReal(); |
|
793 data.pageChangeAnimationDuration = query.value(6).toInt(); |
|
794 data.pageChangeZoneAnimationDuration = query.value(7).toInt(); |
|
795 data.pageChangeZoneReverseAnimationDuration = query.value(8).toInt(); |
|
796 data.pageRemovedAnimationDuration = query.value(9).toInt(); |
|
797 data.newPageAddedAnimationDuration = query.value(10).toInt(); |
|
798 data.widgetDragEffectDuration = query.value(11).toInt(); |
|
799 data.widgetDropEffectDuration = query.value(12).toInt(); |
|
800 data.boundaryFeedbackEffectDistance = query.value(13).toInt(); |
|
801 data.defaultPageId = query.value(14).toInt(); |
|
802 data.maximumPageCount = query.value(15).toInt(); |
|
803 data.maximumWidgetHeight = query.value(16).toReal(); |
|
804 data.maximumWidgetWidth = query.value(17).toReal(); |
|
805 data.minimumWidgetHeight = query.value(18).toReal(); |
|
806 data.minimumWidgetWidth = query.value(19).toReal(); |
|
807 data.shortcutLabelsVisible = query.value(20).toBool(); |
|
808 data.pageChangePanDistance = query.value(21).toReal(); |
|
809 return true; |
810 return true; |
810 } |
811 } |
811 |
812 |
812 return false; |
|
813 } |
|
814 |
|
815 /*! |
|
816 |
|
817 */ |
|
818 bool HsDatabase::feedbackConfiguration(HsFeedbackConfiguration &data) |
|
819 { |
|
820 if (!checkConnection()) { |
|
821 return false; |
|
822 } |
|
823 |
|
824 QSqlQuery query(QSqlDatabase::database(mConnectionName)); |
|
825 |
|
826 QString statement = |
|
827 "SELECT pageChangeFeedbackType, widgetPickFeedbackType, widgetDropFeedbackType, " |
|
828 "widgetRepositionFeedbackType, widgetOverTrashbinFeedbackType, widgetDropToTrashbinFeedbackType, " |
|
829 "shortcutWidgetTapFeedbackType, widgetMoveBlockedFeedbackType, clockWidgetTapFeedbackType, " |
|
830 "widgetSnappingFeedbackType " |
|
831 "FROM FeedbackConfiguration"; |
|
832 |
|
833 if (query.prepare(statement) && query.exec() && query.next()) { |
|
834 data.pageChangeFeedbackType = data.feedbackFromString(query.value(0).toString()); |
|
835 data.widgetPickFeedbackType = data.feedbackFromString(query.value(1).toString()); |
|
836 data.widgetDropFeedbackType = data.feedbackFromString(query.value(2).toString()); |
|
837 data.widgetRepositionFeedbackType = data.feedbackFromString(query.value(3).toString()); |
|
838 data.widgetOverTrashbinFeedbackType = data.feedbackFromString(query.value(4).toString()); |
|
839 data.widgetDropToTrashbinFeedbackType = data.feedbackFromString(query.value(5).toString()); |
|
840 data.shortcutWidgetTapFeedbackType = data.feedbackFromString(query.value(6).toString()); |
|
841 data.widgetMoveBlockedFeedbackType = data.feedbackFromString(query.value(7).toString()); |
|
842 data.clockWidgetTapFeedbackType = data.feedbackFromString(query.value(8).toString()); |
|
843 data.widgetSnappingFeedbackType = data.feedbackFromString(query.value(9).toString()); |
|
844 return true; |
|
845 } |
|
846 |
|
847 return false; |
|
848 } |
|
849 |
|
850 bool HsDatabase::snapConfiguration(HsSnapConfiguration &data) |
|
851 { |
|
852 if (!checkConnection()) { |
|
853 return false; |
|
854 } |
|
855 |
|
856 QSqlQuery query(QSqlDatabase::database(mConnectionName)); |
|
857 |
|
858 QString statement = |
|
859 "SELECT snappingEnabled, snapForce, snapGap, borderGap, timeout " |
|
860 "FROM SnapConfiguration"; |
|
861 |
|
862 if (query.prepare(statement) && query.exec() && query.next()) { |
|
863 data.snappingEnabled = query.value(0).toBool(); |
|
864 data.snapForce = query.value(1).toReal(); |
|
865 data.snapGap = query.value(2).toReal(); |
|
866 data.borderGap = query.value(3).toReal(); |
|
867 data.timeout = query.value(4).toInt(); |
|
868 return true; |
|
869 } |
|
870 return false; |
813 return false; |
871 } |
814 } |
872 |
815 |
873 /*! |
816 /*! |
874 Sets the database instance. The existing instance |
817 Sets the database instance. The existing instance |