43 //Build theme list |
44 //Build theme list |
44 mThemeList = CpThemeUtil::buildThemeList(); |
45 mThemeList = CpThemeUtil::buildThemeList(); |
45 |
46 |
46 //Look into theme paths and add a file watcher for it |
47 //Look into theme paths and add a file watcher for it |
47 //to get notified when themes are added. |
48 //to get notified when themes are added. |
48 QStringList themesPathList = CpThemeUtil::themePathList(); |
49 QStringList themePaths = CpThemeUtil::themeDirectories(mThemeList); |
49 foreach (const QString &path, themesPathList) { |
50 if(!themePaths.empty()) { |
50 QDir themeDir; |
51 mFileWatcher->addPaths(themePaths); |
51 themeDir.setPath( path ) ; |
|
52 QStringList list = themeDir.entryList(QDir::AllDirs|QDir::NoDotAndDotDot,QDir::Name); |
|
53 if(list.contains("themes", Qt::CaseSensitive )) { |
|
54 mFileWatcher->addPath(themeDir.path() + "/themes/"); |
|
55 } |
|
56 } |
52 } |
57 connect(mFileWatcher, SIGNAL(directoryChanged(const QString&)), |
53 |
|
54 connect(mFileWatcher, SIGNAL(directoryChanged(QString)), |
58 this, SLOT(themeListChanged())); |
55 this, SLOT(themeListChanged())); |
59 |
56 |
60 // data for the list which appears after the themes: |
57 // data for the list which appears after the themes: |
61 CpThemeInfo fetchFromStore; |
58 CpThemeInfo fetchFromStore; |
62 fetchFromStore.setName(hbTrId("txt_cp_list_get_more_tones")); |
59 fetchFromStore.setName(hbTrId("txt_cp_list_get_more_tones")); |
63 fetchFromStore.setItemType(CpThemeInfo::ThemeListItemType_URL); |
60 fetchFromStore.setItemType(CpThemeInfo::ThemeListItemType_URL); |
64 fetchFromStore.setItemData(QString("http://lr.ovi.mobi/store/themes")); |
61 fetchFromStore.setItemData(QString("http://lr.ovi.mobi/store/themes")); |
114 if (list) { |
111 if (list) { |
115 switch (role) { |
112 switch (role) { |
116 case Qt::DisplayRole: |
113 case Qt::DisplayRole: |
117 retVal = list->at(row).name(); |
114 retVal = list->at(row).name(); |
118 break; |
115 break; |
119 |
116 #ifdef CP_THEME_PREVIEW_DEFINED |
120 case Qt::DecorationRole: |
117 case Qt::DecorationRole: |
121 retVal = list->at(row).icon(); |
118 retVal = list->at(row).icon(); |
122 break; |
|
123 |
|
124 case Qt::SizeHintRole: |
|
125 retVal = list->at(row).icon().size(); |
|
126 break; |
119 break; |
127 |
120 |
128 case PortraitPreviewRole: |
121 case PortraitPreviewRole: |
129 retVal = list->at(row).portraitPreviewIcon(); |
122 retVal = list->at(row).portraitPreviewIcon(); |
130 break; |
123 break; |
131 |
124 |
132 case LandscapePreviewRole: |
125 case LandscapePreviewRole: |
133 retVal = list->at(row).landscapePreviewIcon(); |
126 retVal = list->at(row).landscapePreviewIcon(); |
134 break; |
127 break; |
135 |
128 #endif |
|
129 case Qt::SizeHintRole: |
|
130 retVal = list->at(row).icon().size(); |
|
131 break; |
|
132 |
136 case ItemDataRole: |
133 case ItemDataRole: |
137 retVal = list->at(row).itemData(); |
134 retVal = list->at(row).itemData(); |
138 break; |
135 break; |
139 |
136 |
140 case ItemTypeRole: |
137 case ItemTypeRole: |