Changeset View
Changeset View
Standalone View
Standalone View
src/filemetadataconfigwidget.cpp
Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Line(s) | 103 | while (hiddenProperties[i] != nullptr) { | |||
---|---|---|---|---|---|
104 | if (key == QLatin1String(hiddenProperties[i])) { | 104 | if (key == QLatin1String(hiddenProperties[i])) { | ||
105 | // the item is hidden | 105 | // the item is hidden | ||
106 | return; | 106 | return; | ||
107 | } | 107 | } | ||
108 | ++i; | 108 | ++i; | ||
109 | } | 109 | } | ||
110 | 110 | | |||
111 | // the item is not hidden, add it to the list | 111 | // the item is not hidden, add it to the list | ||
112 | KConfig config("baloofileinformationrc", KConfig::NoGlobals); | 112 | KConfig config(QStringLiteral("baloofileinformationrc"), KConfig::NoGlobals); | ||
113 | KConfigGroup settings = config.group("Show"); | 113 | KConfigGroup settings = config.group("Show"); | ||
114 | 114 | | |||
115 | const QString label = m_provider->label(key); | 115 | const QString label = m_provider->label(key); | ||
116 | 116 | | |||
117 | QListWidgetItem* item = new QListWidgetItem(label, m_metaDataList); | 117 | QListWidgetItem* item = new QListWidgetItem(label, m_metaDataList); | ||
118 | item->setData(Qt::UserRole, key); | 118 | item->setData(Qt::UserRole, key); | ||
119 | const bool show = settings.readEntry(key, true); | 119 | const bool show = settings.readEntry(key, true); | ||
120 | item->setCheckState(show ? Qt::Checked : Qt::Unchecked); | 120 | item->setCheckState(show ? Qt::Checked : Qt::Unchecked); | ||
121 | } | 121 | } | ||
122 | 122 | | |||
123 | void FileMetaDataConfigWidget::Private::slotLoadingFinished() | 123 | void FileMetaDataConfigWidget::Private::slotLoadingFinished() | ||
124 | { | 124 | { | ||
125 | // Get all meta information labels that are available for | 125 | // Get all meta information labels that are available for | ||
126 | // the currently shown file item and add them to the list. | 126 | // the currently shown file item and add them to the list. | ||
127 | Q_ASSERT(m_provider != nullptr); | 127 | Q_ASSERT(m_provider != nullptr); | ||
128 | 128 | | |||
129 | m_metaDataList->clear(); | 129 | m_metaDataList->clear(); | ||
130 | 130 | | |||
131 | QVariantMap data = m_provider->data(); | 131 | QVariantMap data = m_provider->data(); | ||
132 | // Always show these 3 | 132 | // Always show these 3 | ||
133 | data.remove("rating"); | 133 | data.remove(QStringLiteral("rating")); | ||
134 | data.remove("tags"); | 134 | data.remove(QStringLiteral("tags")); | ||
135 | data.remove("userComment"); | 135 | data.remove(QStringLiteral("userComment")); | ||
136 | 136 | | |||
137 | QVariantMap::const_iterator it = data.constBegin(); | 137 | QVariantMap::const_iterator it = data.constBegin(); | ||
138 | while (it != data.constEnd()) { | 138 | while (it != data.constEnd()) { | ||
139 | addItem(it.key()); | 139 | addItem(it.key()); | ||
140 | ++it; | 140 | ++it; | ||
141 | } | 141 | } | ||
142 | 142 | | |||
143 | addItem("rating"); | 143 | addItem(QStringLiteral("rating")); | ||
144 | addItem("tags"); | 144 | addItem(QStringLiteral("tags")); | ||
145 | addItem("userComment"); | 145 | addItem(QStringLiteral("userComment")); | ||
146 | } | 146 | } | ||
147 | 147 | | |||
148 | FileMetaDataConfigWidget::FileMetaDataConfigWidget(QWidget* parent) : | 148 | FileMetaDataConfigWidget::FileMetaDataConfigWidget(QWidget* parent) : | ||
149 | QWidget(parent), | 149 | QWidget(parent), | ||
150 | d(new Private(this)) | 150 | d(new Private(this)) | ||
151 | { | 151 | { | ||
152 | } | 152 | } | ||
153 | 153 | | |||
Show All 10 Lines | |||||
164 | 164 | | |||
165 | KFileItemList FileMetaDataConfigWidget::items() const | 165 | KFileItemList FileMetaDataConfigWidget::items() const | ||
166 | { | 166 | { | ||
167 | return d->m_fileItems; | 167 | return d->m_fileItems; | ||
168 | } | 168 | } | ||
169 | 169 | | |||
170 | void FileMetaDataConfigWidget::save() | 170 | void FileMetaDataConfigWidget::save() | ||
171 | { | 171 | { | ||
172 | KConfig config("baloofileinformationrc", KConfig::NoGlobals); | 172 | KConfig config(QStringLiteral("baloofileinformationrc"), KConfig::NoGlobals); | ||
173 | KConfigGroup showGroup = config.group("Show"); | 173 | KConfigGroup showGroup = config.group("Show"); | ||
174 | 174 | | |||
175 | const int count = d->m_metaDataList->count(); | 175 | const int count = d->m_metaDataList->count(); | ||
176 | for (int i = 0; i < count; ++i) { | 176 | for (int i = 0; i < count; ++i) { | ||
177 | QListWidgetItem* item = d->m_metaDataList->item(i); | 177 | QListWidgetItem* item = d->m_metaDataList->item(i); | ||
178 | const bool show = (item->checkState() == Qt::Checked); | 178 | const bool show = (item->checkState() == Qt::Checked); | ||
179 | const QString key = item->data(Qt::UserRole).toString(); | 179 | const QString key = item->data(Qt::UserRole).toString(); | ||
180 | showGroup.writeEntry(key, show); | 180 | showGroup.writeEntry(key, show); | ||
Show All 22 Lines |