return new ViewPropertySettings(KSharedConfig::openConfig(settingsFile, KConfig::SimpleConfig));
}
- auto createTempFile = []() -> QTemporaryFile * {
- QTemporaryFile *tempFile = new QTemporaryFile;
- tempFile->setAutoRemove(false);
- if (!tempFile->open()) {
- qCWarning(DolphinDebug) << "Could not open temp file";
- return nullptr;
- }
- return tempFile;
- };
-
+ std::unique_ptr<QTemporaryFile> tempFile(new QTemporaryFile());
+ tempFile->setAutoRemove(false);
+ if (!tempFile->open()) {
+ qCWarning(DolphinDebug) << "Could not open temp file";
+ return nullptr;
+ }
if (QFile::exists(settingsFile)) {
// copy settings to tempfile to load them separately
- const QTemporaryFile *tempFile = createTempFile();
- if (!tempFile) {
- return nullptr;
- }
QFile::remove(tempFile->fileName());
QFile::copy(settingsFile, tempFile->fileName());
return nullptr;
}
// load view properties from xattr to temp file then loads into ViewPropertySettings
- // clear the temp file
- const QTemporaryFile *tempFile = createTempFile();
- if (!tempFile) {
- return nullptr;
- }
QFile outputFile(tempFile->fileName());
outputFile.open(QIODevice::WriteOnly);
outputFile.write(viewPropertiesString.toUtf8());
return m_node->sortHiddenLast();
}
+void ViewProperties::setDynamicViewPassed(bool dynamicViewPassed)
+{
+ if (m_node->dynamicViewPassed() != dynamicViewPassed) {
+ m_node->setDynamicViewPassed(dynamicViewPassed);
+ update();
+ }
+}
+
+bool ViewProperties::dynamicViewPassed() const
+{
+ return m_node->dynamicViewPassed();
+}
+
void ViewProperties::setVisibleRoles(const QList<QByteArray> &roles)
{
if (roles == visibleRoles()) {
const auto metaDataKey = QStringLiteral("kde.fm.viewproperties#1");
const auto items = m_node->items();
- const bool allDefault = std::all_of(items.cbegin(), items.cend(), [this](const KConfigSkeletonItem *item) {
- return item->name() == "Timestamp" || (item->name() == "Version" && m_node->version() == CurrentViewPropertiesVersion) || item->isDefault();
- });
+ const auto defaultConfig = defaultProperties();
+ bool allDefault = true;
+ for (const auto item : items) {
+ if (item->name() == "Timestamp") {
+ continue;
+ }
+ if (item->name() == "Version") {
+ if (m_node->version() != CurrentViewPropertiesVersion) {
+ allDefault = false;
+ break;
+ } else {
+ continue;
+ }
+ }
+ auto defaultItem = defaultConfig->findItem(item->name());
+ if (!defaultItem || defaultItem->property() != item->property()) {
+ allDefault = false;
+ break;
+ }
+ }
+
if (allDefault) {
if (metaData.hasAttribute(metaDataKey)) {
qCDebug(DolphinDebug) << "clearing extended attributes for " << m_filePath;