Ver código fonte

VNoteFile: update config file after save() to update the modified time

Le Tan 7 anos atrás
pai
commit
42fbdace55
3 arquivos alterados com 25 adições e 3 exclusões
  1. 7 1
      src/vfilelist.cpp
  2. 16 2
      src/vnotefile.cpp
  3. 2 0
      src/vnotefile.h

+ 7 - 1
src/vfilelist.cpp

@@ -262,9 +262,15 @@ void VFileList::fillItem(QListWidgetItem *p_item, const VNoteFile *p_file)
 {
     qulonglong ptr = (qulonglong)p_file;
     p_item->setData(Qt::UserRole, ptr);
-    p_item->setToolTip(p_file->getName());
     p_item->setText(p_file->getName());
 
+    QString createdTime = VUtils::displayDateTime(p_file->getCreatedTimeUtc().toLocalTime());
+    QString modifiedTime = VUtils::displayDateTime(p_file->getModifiedTimeUtc().toLocalTime());
+    QString tooltip = tr("%1\n\nCreated Time: %2\nModified Time: %3")
+                        .arg(p_file->getName())
+                        .arg(createdTime)
+                        .arg(modifiedTime);
+    p_item->setToolTip(tooltip);
     V_ASSERT(sizeof(p_file) <= sizeof(ptr));
 }
 

+ 16 - 2
src/vnotefile.cpp

@@ -164,9 +164,9 @@ QJsonObject VNoteFile::toConfigJson() const
     // Attachments.
     QJsonArray attachmentJson;
     for (int i = 0; i < m_attachments.size(); ++i) {
-        const VAttachment &item = m_attachments[i];
+        const VAttachment &att = m_attachments[i];
         QJsonObject attachmentItem;
-        attachmentItem[DirConfig::c_name] = item.m_name;
+        attachmentItem[DirConfig::c_name] = att.m_name;
         attachmentJson.append(attachmentItem);
     }
 
@@ -652,3 +652,17 @@ bool VNoteFile::addTag(const QString &p_tag)
 
     return true;
 }
+
+bool VNoteFile::save()
+{
+    bool ret = VFile::save();
+    if (ret) {
+        if (!getDirectory()->updateFileConfig(this)) {
+            qWarning() << "fail to update config of file" << m_name
+                       << "in directory" << fetchBasePath();
+            ret = false;
+        }
+    }
+
+    return ret;
+}

+ 2 - 0
src/vnotefile.h

@@ -47,6 +47,8 @@ public:
 
     QString getImageFolderInLink() const Q_DECL_OVERRIDE;
 
+    bool save() Q_DECL_OVERRIDE;
+
     // Set the name of this file.
     void setName(const QString &p_name);