本文整理汇总了C++中ArchiveTreeNode::entryIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ ArchiveTreeNode::entryIndex方法的具体用法?C++ ArchiveTreeNode::entryIndex怎么用?C++ ArchiveTreeNode::entryIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArchiveTreeNode
的用法示例。
在下文中一共展示了ArchiveTreeNode::entryIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeEntry
/* Archive::removeEntry
* Removes [entry] from the archive. If [delete_entry] is true, the
* entry will also be deleted. Returns true if the removal succeeded
*******************************************************************/
bool Archive::removeEntry(ArchiveEntry* entry, bool delete_entry)
{
// Abort if read only
if (read_only)
return false;
// Check entry
if (!checkEntry(entry))
return false;
// Check if entry is locked
if (entry->isLocked())
return false;
// Get its directory
ArchiveTreeNode* dir = entry->getParentDir();
// Error if entry has no parent directory
if (!dir)
return false;
// Create undo step
if (UndoRedo::currentlyRecording())
UndoRedo::currentManager()->recordUndoStep(new EntryCreateDeleteUS(false, entry));
// Get the entry index
int index = dir->entryIndex(entry);
// Announce (before actually removing in case entry is still needed)
MemChunk mc;
wxUIntPtr ptr = wxPtrToUInt(entry);
mc.write(&index, sizeof(int));
mc.write(&ptr, sizeof(wxUIntPtr));
announce("entry_removing", mc);
// Remove it from its directory
bool ok = dir->removeEntry(index);
// If it was removed ok
if (ok)
{
// Announce removed
announce("entry_removed", mc);
// Delete if necessary
if (delete_entry)
delete entry;
// Update variables etc
setModified(true);
}
return ok;
}
示例2: swapEntries
/* Archive::swapEntries
* Swaps [entry1] and [entry2]. Returns false if either entry is
* invalid or if both entries are not in the same directory, true
* otherwise
*******************************************************************/
bool Archive::swapEntries(ArchiveEntry* entry1, ArchiveEntry* entry2)
{
// Abort if read only
if (read_only)
return false;
// Check both entries
if (!checkEntry(entry1) || !checkEntry(entry2))
return false;
// Check neither entry is locked
if (entry1->isLocked() || entry2->isLocked())
return false;
// Get their directory
ArchiveTreeNode* dir = entry1->getParentDir();
// Error if no dir
if (!dir)
return false;
// Check they are both in the same directory
if (entry2->getParentDir() != dir)
{
wxLogMessage("Error: Can't swap two entries in different directories");
return false;
}
// Get entry indices
int i1 = dir->entryIndex(entry1);
int i2 = dir->entryIndex(entry2);
// Check indices
if (i1 < 0 || i2 < 0)
return false;
// Create undo step
if (UndoRedo::currentlyRecording())
UndoRedo::currentManager()->recordUndoStep(new EntrySwapUS(dir, i1, i2));
// Swap entries
dir->swapEntries(i1, i2);
// Announce the swap
announce("entries_swapped");
// Set modified
setModified(true);
// Return success
return true;
}