void TreeWidgetEditor::fillContentsFromTreeWidget(QTreeWidget *treeWidget) { m_updating = true; copyContents(treeWidget, ui.treeWidget); ui.listWidget->clear(); QTreeWidgetItem *headerItem = ui.treeWidget->headerItem(); int colCount = ui.treeWidget->columnCount(); for (int col = 0; col < colCount; col++) { QListWidgetItem *item = new QListWidgetItem(ui.listWidget); item->setFlags(item->flags() | Qt::ItemIsEditable); item->setText(headerItem->text(col)); item->setIcon(headerItem->icon(col)); item->setData(QAbstractFormBuilder::resourceRole(), headerItem->data(col, QAbstractFormBuilder::resourceRole())); } if (colCount > 0) { ui.listWidget->setCurrentRow(0); if (ui.treeWidget->topLevelItemCount() > 0) ui.treeWidget->setCurrentItem(ui.treeWidget->topLevelItem(0)); } m_updating = false; updateEditor(); }
TCObject *TCSortedStringArray::copy(void) const { TCStringArray *newSortedStringArray = new TCSortedStringArray(count, caseSensitive); copyContents(newSortedStringArray); return newSortedStringArray; }
/** * OPERATORS */ CategoryMap& CategoryMap::operator =(const CategoryMap& rhs) { if (this != &rhs) { delete[] subCategories; delete[] categories; copyContents(rhs); } return *this; }
void JurisdictionMap::copyContents(const JurisdictionMap& other) { copyContents(other._rootOctalCode, other._endNodes); }
// Copy constructor JurisdictionMap::JurisdictionMap(const JurisdictionMap& other) : _rootOctalCode(NULL) { copyContents(other); }
// standard assignment // copy assignment JurisdictionMap& JurisdictionMap::operator=(const JurisdictionMap& other) { copyContents(other); return *this; }
// move assignment NetworkPacket& NetworkPacket::operator=(NetworkPacket&& other) { copyContents(other.getNode(), other.getByteArray()); return *this; }
// move, same as copy, but other packet won't be used further NetworkPacket::NetworkPacket(NetworkPacket && packet) { copyContents(packet.getNode(), packet.getByteArray()); }
NetworkPacket::NetworkPacket(const SharedNodePointer& node, const QByteArray& packet) { copyContents(node, packet); };
static int traverseDirs(const shared_ptr<EncFS_Root> &rootInfo, std::string volumeDir, std::string destDir, const std::set<std::string>& toWrite ) { bool fake = toWrite.empty(); if(!endsWith(volumeDir, '/')) volumeDir.append("/"); if(!endsWith(destDir, '/')) destDir.append("/"); std::string test_string = volumeDir; if (endsWith(test_string, '/') && test_string.length() != 1) { test_string = test_string.substr(0, test_string.length()-1); } /* Abort if we're in export mode and this directory * doesn't need to be written */ if (!toWrite.empty() && toWrite.find(test_string) == toWrite.end()) { return EXIT_SUCCESS; } // Lookup directory node so we can create a destination directory // with the same permissions { struct stat st; shared_ptr<FileNode> dirNode = rootInfo->root->lookupNode( volumeDir.c_str(), "encfsctl" ); if(dirNode->getAttr(&st)) return EXIT_FAILURE; // In fake mode, we always create rw: mode_t srcmode = st.st_mode; if (fake) srcmode = S_IRWXU; if (mkdir(destDir.c_str(), srcmode) == -1) { if (errno == EACCES /* sic! */ || errno == EROFS || errno == ENOSPC) { std::ostringstream out; out << "Not creating " << destDir << ": " << strerror(errno); LOGE(out.str().c_str()); return EXIT_FAILURE; } } } // show files in directory DirTraverse dt = rootInfo->root->openDir(volumeDir.c_str()); if(dt.valid()) { for(std::string name = dt.nextPlaintextName(); !name.empty(); name = dt.nextPlaintextName()) { bool skip = !toWrite.empty() && toWrite.find(volumeDir+name) == toWrite.end(); // Recurse to subdirectories if(name != "." && name != ".." && !skip) { std::string plainPath = volumeDir + name; std::string cpath = rootInfo->root->cipherPath(plainPath.c_str()); std::string destName = destDir + name; /*std::ostringstream out; out << "Decoding " << cpath << " to " << plainPath << " in " << destName; LOGI(out.str().c_str()); */ int r = EXIT_SUCCESS; struct stat stBuf; if( !lstat( cpath.c_str(), &stBuf )) { if( S_ISDIR( stBuf.st_mode ) ) { r = traverseDirs(rootInfo, (plainPath + '/').c_str(), destName + '/', toWrite); } else if( S_ISLNK( stBuf.st_mode )) { r = copyLink( stBuf, rootInfo, cpath, destName ); } else { r = copyContents(rootInfo, plainPath.c_str(), destName.c_str(), fake); } } else { r = EXIT_FAILURE; } if(r != EXIT_SUCCESS) return r; } } } return EXIT_SUCCESS; }
CategoryMap::CategoryMap(const CategoryMap& rhs) { copyContents(rhs); }