Synchro::Synchro(const char *token, char *folder, char *URL) : folder(folder), URL(URL) { _instance = this; this->_sysWatcher = new QFileSystemWatcher(); connect(_instance->_sysWatcher, SIGNAL(directoryChanged(QString)), _instance, SLOT(directoryUpdated(QString))); connect(_instance->_sysWatcher, SIGNAL(fileChanged(QString)), _instance, SLOT(fileUpdated(QString))); this->xtoken = token; }
void VDirectoryTree::editDirectoryInfo() { QTreeWidgetItem *curItem = currentItem(); if (!curItem) { return; } VDirectory *curDir = getVDirectory(curItem); QString curName = curDir->getName(); VDirInfoDialog dialog(tr("Folder Information"), "", curDir, curDir->getParentDirectory(), this); if (dialog.exec() == QDialog::Accepted) { QString name = dialog.getNameInput(); if (name == curName) { return; } if (!curDir->rename(name)) { VUtils::showMessage(QMessageBox::Warning, tr("Warning"), tr("Fail to rename folder <span style=\"%1\">%2</span>.") .arg(g_config->c_dataTextStyle) .arg(curName), "", QMessageBox::Ok, QMessageBox::Ok, this); return; } fillTreeItem(curItem, curDir); emit directoryUpdated(curDir, UpdateAction::InfoChanged); } }
void VDirectoryTree::pasteDirectories(VDirectory *p_destDir, const QVector<QString> &p_dirs, bool p_isCut) { if (!p_destDir || p_dirs.isEmpty()) { return; } int nrPasted = 0; for (int i = 0; i < p_dirs.size(); ++i) { VDirectory *dir = g_vnote->getInternalDirectory(p_dirs[i]); if (!dir) { qWarning() << "Copied dir is not an internal folder" << p_dirs[i]; VUtils::showMessage(QMessageBox::Warning, tr("Warning"), tr("Fail to paste folder <span style=\"%1\">%2</span>.") .arg(g_config->c_dataTextStyle) .arg(p_dirs[i]), tr("VNote could not find this folder in any notebook."), QMessageBox::Ok, QMessageBox::Ok, this); continue; } if (dir == p_destDir) { continue; } QString dirName = dir->getName(); VDirectory *paDir = dir->getParentDirectory(); if (paDir == p_destDir) { if (p_isCut) { continue; } // Copy and paste in the same folder. // Rename it to xxx_copy. dirName = VUtils::generateCopiedDirName(paDir->fetchPath(), dirName); } else { // Rename it to xxx_copy if needed. dirName = VUtils::generateCopiedDirName(p_destDir->fetchPath(), dirName); } QString msg; VDirectory *destDir = NULL; bool ret = VDirectory::copyDirectory(p_destDir, dirName, dir, p_isCut, &destDir, &msg); if (!ret) { VUtils::showMessage(QMessageBox::Warning, tr("Warning"), tr("Fail to copy folder <span style=\"%1\">%2</span>.") .arg(g_config->c_dataTextStyle) .arg(p_dirs[i]), msg, QMessageBox::Ok, QMessageBox::Ok, this); } if (destDir) { ++nrPasted; // Update QTreeWidget. bool isWidget; QTreeWidgetItem *destItem = findVDirectory(p_destDir, &isWidget); if (destItem || isWidget) { updateItemDirectChildren(destItem); } if (p_isCut) { QTreeWidgetItem *srcItem = findVDirectory(paDir, &isWidget); if (srcItem || isWidget) { updateItemDirectChildren(srcItem); } } // Broadcast this update emit directoryUpdated(destDir, p_isCut ? UpdateAction::Moved : UpdateAction::InfoChanged); } } qDebug() << "pasted" << nrPasted << "directories"; if (nrPasted > 0) { g_mainWin->showStatusMessage(tr("%1 %2 pasted") .arg(nrPasted) .arg(nrPasted > 1 ? tr("folders") : tr("folder"))); } getNewMagic(); }