BOOL CPreferencesShortcutsPage::CopyItem(HTREEITEM hti, CString& sOutput) { if (!hti) return FALSE; // copy self if (hti != TVI_ROOT) { if (!m_tcCommands.ItemHasChildren(hti)) { // ignore Reserved menu commands if (IsMiscCommandID(m_tcCommands.GetItemData(hti))) return FALSE; CString sItem = m_tcCommands.GetItemText(hti); ASSERT(!sItem.IsEmpty()); if (!sItem.IsEmpty()) { // build path by recursing up the parent chain HTREEITEM htiParent = m_tcCommands.GetParentItem(hti); while (htiParent) { CString sParent = m_tcCommands.GetItemText(htiParent); ASSERT(!sParent.IsEmpty()); if (!sParent.IsEmpty()) sItem = sParent + _T(" > ") + sItem; // parent's parent htiParent = m_tcCommands.GetParentItem(htiParent); } sOutput += sItem; sOutput += _T("\r\n"); } } } // then children CopyItem(m_tcCommands.GetChildItem(hti), sOutput); // then siblings if (hti != TVI_ROOT) { // add a spacer between top-level items if (m_tcCommands.GetParentItem(hti) == NULL) sOutput += _T("\r\n"); CopyItem(m_tcCommands.GetNextItem(hti, TVGN_NEXT), sOutput); } return (!sOutput.IsEmpty()); }
bool CRecentImp<T, S>::AppendItem( ReceiveType pItemData ) { int i; if( !IsAvailable() ) return false; if( !pItemData ) return false; if( false == ValidateReceiveType(pItemData) ) return false; //登録済みか調べる。 int nIndex = FindItem( pItemData ); if( nIndex >= 0 ) { CopyItem( GetItemPointer(nIndex), pItemData ); //先頭に持ってくる。 MoveItem( nIndex, 0 ); goto reconfigure; } //いっぱいのときは最古の通常アイテムを削除する。 if( m_nArrayCount <= *m_pnUserItemCount ) { nIndex = GetOldestItem( *m_pnUserItemCount - 1, false ); if( -1 == nIndex ) { return false; } DeleteItem( nIndex ); } for( i = *m_pnUserItemCount; i > 0; i-- ) { CopyItem( i - 1, i ); } CopyItem( GetItemPointer(0), pItemData ); //(void)SetFavorite( 0, true ); //内部処理しないとだめ。 if( m_pbUserItemFavorite ) m_pbUserItemFavorite[0] = false; *m_pnUserItemCount += 1; reconfigure: //お気に入りを表示内に移動する。 if( m_pnUserViewCount ) { ChangeViewCount( *m_pnUserViewCount ); } return true; }
bool C4Record::AddFile(const char *szLocalFilename, const char *szAddAs, bool fDelete) { if (!fRecording) return false; // Streaming? if (fStreaming) { // Special stripping for streaming StdCopyStrBuf szFile(szLocalFilename); if (SEqualNoCase(GetExtension(szAddAs), "c4p")) { // Create a copy MakeTempFilename(&szFile); if (!CopyItem(szLocalFilename, szFile.getData())) return false; // Strip it if (!C4Player::Strip(szFile.getData(), true)) return false; } // Add to stream if (!StreamFile(szFile.getData(), szAddAs)) return false; // Remove temporary file if (szFile != szLocalFilename) EraseItem(szFile.getData()); } // Add to record group if (fDelete) { if (!RecordGrp.Move(szLocalFilename, szAddAs)) return false; } else { if (!RecordGrp.Add(szLocalFilename, szAddAs)) return false; } return true; }
void DeploymentHandler::initQtDeploy(QMakeProject *project, DeploymentList &deploymentList, const QString &testPath) { QString targetPath = project->values("deploy.path").join(" "); if (targetPath.isEmpty()) targetPath = testPath; if (targetPath.endsWith("/") || targetPath.endsWith("\\")) targetPath = targetPath.mid(0,targetPath.size()-1); // Only deploy Qt libs for shared build if (!project->values("QMAKE_QT_DLL").isEmpty() && !project->values("QMAKE_LIBDIR").isEmpty()) { QStringList libs = project->values("LIBS"); QStringList qtLibs; foreach (QString item, libs) { if (item.startsWith("-lQt")) { qtLibs += project->values("QMAKE_LIBDIR").at(0) + QDir::separator() + item.mid(2) + QLatin1String("4.dll"); } else { QFileInfo info(item); if (info.exists() && info.isAbsolute() && info.fileName().startsWith(QLatin1String("Qt"))) qtLibs += info.dir().absoluteFilePath(info.fileName().replace(QLatin1String(".lib"), QLatin1String(".dll"))); } } for (QStringList::ConstIterator it = qtLibs.constBegin(); it != qtLibs.constEnd(); ++it) { QString dllName = *it; QFileInfo info(dllName); if (!info.exists()) continue; deploymentList.append(CopyItem(Option::fixPathToLocalOS(info.absoluteFilePath()) , Option::fixPathToLocalOS(targetPath + "/" + info.fileName()))); } }
bool CRecentCmd::TextToDataType( CCmdString* dst, LPCTSTR pszText ) const { if( false == ValidateReceiveType(pszText) ){ return false; } CopyItem(dst, pszText); return true; }
void CPreferencesShortcutsPage::OnCopyall() { CString sOutput; if (CopyItem(TVI_ROOT, sOutput)) { VERIFY(Misc::CopyTexttoClipboard(sOutput, *this)); } }
void EXTreeCtrl::Moveup() { // Get Item HTREEITEM hItem = GetDropHilightItem(); if(hItem) SelectItem(hItem); else hItem = GetSelectedItem(); // Get previous item HTREEITEM hSibling = GetNextItem(hItem,TVGN_PREVIOUS); if(hSibling != NULL) { // Get previous to previous item HTREEITEM hNewItem=NULL; HTREEITEM hItemBefore = GetNextItem(hSibling,TVGN_PREVIOUS); if(hItemBefore != NULL) { // Insert before item hNewItem = CopyItem(hItem,GetParentItem(hItem),hItemBefore); // Don't delete item data SetItemData(hItem, NULL); DeleteItem(hItem); SelectItem(hNewItem); } else { // Insert at start hNewItem = CopyItem(hItem,GetParentItem(hItem),TVI_FIRST); // Don't delete item data SetItemData(hItem, NULL); DeleteItem(hItem); SelectItem(hNewItem); } if(hNewItem) RefreshSubItems(hNewItem); } }
HTREEITEM CTreeFileCtrl::CopyBranch(HTREEITEM htiBranch, HTREEITEM htiNewParent, HTREEITEM htiAfter) { HTREEITEM hNewItem = CopyItem(htiBranch, htiNewParent, htiAfter); HTREEITEM hChild = GetChildItem(htiBranch); while (hChild != NULL) { //recursively transfer all the items CopyBranch(hChild, hNewItem); hChild = GetNextSiblingItem(hChild); } return hNewItem; }
bool CRecentImp<T, S>::MoveItem( int nSrcIndex, int nDstIndex ) { int i; bool bFavorite; if( ! IsAvailable() ) return false; if( nSrcIndex < 0 || nSrcIndex >= *m_pnUserItemCount ) return false; if( nDstIndex < 0 || nDstIndex >= *m_pnUserItemCount ) return false; if( nSrcIndex == nDstIndex ) return true; DataType pri; //移動する情報を退避 memcpy_raw( &pri, GetItemPointer( nSrcIndex ), sizeof(pri) ); bFavorite = IsFavorite( nSrcIndex ); if( nSrcIndex < nDstIndex ) { for( i = nSrcIndex; i < nDstIndex; i++ ) { CopyItem( i + 1, i ); } } else { for( i = nSrcIndex; i > nDstIndex; i-- ) { CopyItem( i - 1, i ); } } //新しい位置に格納 memcpy_raw( GetItemPointer( nDstIndex ), &pri, sizeof(pri) ); SetFavorite( nDstIndex, bFavorite ); return true; }
HTREEITEM CTreeCtrlEx::CopyBranch(HTREEITEM htiBranch, HTREEITEM htiNewParent, HTREEITEM htiAfter) { HTREEITEM hChild; HTREEITEM hNewItem = CopyItem( htiBranch,htiNewParent,htiAfter ); hChild = GetChildItem( htiBranch ); while( hChild != NULL ) { CopyBranch( hChild,hNewItem,htiAfter ); hChild = GetNextSiblingItem( hChild ); } return hNewItem; }
void EXTreeCtrl::Movedown() { // Get Item HTREEITEM hItem = GetDropHilightItem(); if(hItem) SelectItem(hItem); else hItem = GetSelectedItem(); // Get next item HTREEITEM hNewItem=NULL; HTREEITEM hSibling = GetNextItem(hItem,TVGN_NEXT); if(hSibling != NULL) { // Insert before item hNewItem = CopyItem(hItem,GetParentItem(hItem),hSibling); // Don't delete item data SetItemData(hItem, NULL); DeleteItem(hItem); SelectItem(hNewItem); } else { // Insert at start hNewItem = CopyItem(hItem,GetParentItem(hItem),TVI_LAST); // Don't delete item data SetItemData(hItem, NULL); DeleteItem(hItem); SelectItem(hNewItem); } if(hNewItem) RefreshSubItems(hNewItem); }
void CEditTreeCtrl::DragMoveItem(HTREEITEM hDrag, HTREEITEM hDrop, EDropHint eHint, bool bCopy) { if(eHint == DROP_NODROP) return; if(IsAncestor(hDrag, hDrop) || !CanDropItem(hDrag, hDrop, eHint)) return; ASSERT(hDrag != 0); ASSERT(hDrop != 0 || eHint == DROP_BELOW); if(!hDrop && eHint == DROP_BELOW) for(hDrop = GetRootItem(); GetNextSiblingItem(hDrop) != 0; hDrop = GetNextSiblingItem(hDrop)); // Setup insertion parameters HTREEITEM hInsertAfter = 0; HTREEITEM hParent = 0; switch(eHint) { case DROP_BELOW: hInsertAfter = hDrop; hParent = GetParentItem(hDrop); break; case DROP_ABOVE: hInsertAfter = GetPrevSiblingItem(hDrop); if(!hInsertAfter) hInsertAfter = TVI_FIRST; hParent = GetParentItem(hDrop); break; case DROP_CHILD: hInsertAfter = TVI_LAST; hParent = hDrop; break; default: ASSERT(false); break; } HTREEITEM hNew = CopyItem(hDrag, hParent, hInsertAfter); SelectItem(hNew); // If the control-key ist down, we copy the data, otherwise we move // it, thus we have to delete the dragged item. if(!bCopy) DeleteItem(hDrag); }
bool CRecentImp<T, S>::DeleteItem( int nIndex ) { if( ! IsAvailable() ) return false; if( nIndex < 0 || nIndex >= *m_pnUserItemCount ) return false; ZeroItem( nIndex ); //以降のアイテムを前に詰める。 int i; for( i = nIndex; i < *m_pnUserItemCount - 1; i++ ) { CopyItem( i + 1, i ); } ZeroItem( i ); *m_pnUserItemCount -= 1; return true; }
bool CRecentImp<T, S>::EditItemText( int nIndex, LPCTSTR pText ) { DataType data; ReceiveType receiveData; memcpy_raw( &data, GetItemPointer( nIndex ), sizeof(data) ); if( !TextToDataType( &data, pText ) ){ return false; } if( !DataToReceiveType( &receiveData, &data ) ){ return false; } int findIndex = FindItem( receiveData ); if( -1 != findIndex && nIndex != findIndex ){ // 重複不可。ただし同じ場合は大文字小文字の変更かもしれないのでOK return false; } CopyItem( GetItemPointer(nIndex), receiveData ); return true; }
// CopyBranch - Copies all items in a branch to a new location // Returns - The new branch node // htiBranch - The node that starts the branch // htiNewParent - Handle of the parent for new branch // htiAfter - Item after which the new branch should be created HTREEITEM EXTreeCtrl::CopyBranch( HTREEITEM htiBranch, HTREEITEM htiNewParent, HTREEITEM htiAfter /*= TVI_LAST*/ ) { HTREEITEM hChild; HTREEITEM hNewItem = CopyItem( htiBranch, htiNewParent, htiAfter ); hChild = GetChildItem(htiBranch); while( hChild != NULL) { // recursively transfer all the items CopyBranch(hChild, hNewItem,TVI_FIRST); hChild = GetNextSiblingItem( hChild ); } // Don't delete item data only treeitem.. SetItemData(htiBranch, NULL); DeleteItem(htiBranch); return hNewItem; }
HTREEITEM CEditTreeCtrl::CopyItem(HTREEITEM hOrig, HTREEITEM hParent, HTREEITEM hInsertAfter) { // Get item information TVITEMEX item; memset(&item, 0, sizeof(item)); item.mask = TVIF_HANDLE|TVIF_IMAGE|TVIF_PARAM|TVIF_SELECTEDIMAGE|TVIF_STATE|TVIF_INTEGRAL ; item.stateMask = TVIS_OVERLAYMASK|TVIS_STATEIMAGEMASK; item.hItem = hOrig; VERIFY(GetItem((TVITEM*)&item)); CString strText = GetItemText(hOrig); // Insert new item and copy data HTREEITEM hNew = InsertItem(strText, hParent, hInsertAfter); ASSERT(hNew != 0); item.hItem = hNew; VERIFY(SetItem((TVITEM*)&item)); // copy entire subtree, too if(ItemHasChildren(hOrig)) for(HTREEITEM hChild = GetChildItem(hOrig); hChild != 0; hChild = GetNextSiblingItem(hChild)) CopyItem(hChild, hNew, TVI_LAST); return hNew; }
void ContextMenu::populate() { ContextMenuItem OpenLinkItem(ActionType, ContextMenuItemTagOpenLink, contextMenuItemTagOpenLink()); ContextMenuItem OpenLinkInNewWindowItem(ActionType, ContextMenuItemTagOpenLinkInNewWindow, contextMenuItemTagOpenLinkInNewWindow()); ContextMenuItem DownloadFileItem(ActionType, ContextMenuItemTagDownloadLinkToDisk, contextMenuItemTagDownloadLinkToDisk()); ContextMenuItem CopyLinkItem(ActionType, ContextMenuItemTagCopyLinkToClipboard, contextMenuItemTagCopyLinkToClipboard()); ContextMenuItem OpenImageInNewWindowItem(ActionType, ContextMenuItemTagOpenImageInNewWindow, contextMenuItemTagOpenImageInNewWindow()); ContextMenuItem DownloadImageItem(ActionType, ContextMenuItemTagDownloadImageToDisk, contextMenuItemTagDownloadImageToDisk()); ContextMenuItem CopyImageItem(ActionType, ContextMenuItemTagCopyImageToClipboard, contextMenuItemTagCopyImageToClipboard()); #if PLATFORM(MAC) ContextMenuItem SearchSpotlightItem(ActionType, ContextMenuItemTagSearchInSpotlight, contextMenuItemTagSearchInSpotlight()); ContextMenuItem LookInDictionaryItem(ActionType, ContextMenuItemTagLookUpInDictionary, contextMenuItemTagLookUpInDictionary()); #endif ContextMenuItem SearchWebItem(ActionType, ContextMenuItemTagSearchWeb, contextMenuItemTagSearchWeb()); ContextMenuItem CopyItem(ActionType, ContextMenuItemTagCopy, contextMenuItemTagCopy()); ContextMenuItem BackItem(ActionType, ContextMenuItemTagGoBack, contextMenuItemTagGoBack()); ContextMenuItem ForwardItem(ActionType, ContextMenuItemTagGoForward, contextMenuItemTagGoForward()); ContextMenuItem StopItem(ActionType, ContextMenuItemTagStop, contextMenuItemTagStop()); ContextMenuItem ReloadItem(ActionType, ContextMenuItemTagReload, contextMenuItemTagReload()); ContextMenuItem OpenFrameItem(ActionType, ContextMenuItemTagOpenFrameInNewWindow, contextMenuItemTagOpenFrameInNewWindow()); ContextMenuItem NoGuessesItem(ActionType, ContextMenuItemTagNoGuessesFound, contextMenuItemTagNoGuessesFound()); ContextMenuItem IgnoreSpellingItem(ActionType, ContextMenuItemTagIgnoreSpelling, contextMenuItemTagIgnoreSpelling()); ContextMenuItem LearnSpellingItem(ActionType, ContextMenuItemTagLearnSpelling, contextMenuItemTagLearnSpelling()); ContextMenuItem IgnoreGrammarItem(ActionType, ContextMenuItemTagIgnoreGrammar, contextMenuItemTagIgnoreGrammar()); ContextMenuItem CutItem(ActionType, ContextMenuItemTagCut, contextMenuItemTagCut()); ContextMenuItem PasteItem(ActionType, ContextMenuItemTagPaste, contextMenuItemTagPaste()); #if PLATFORM(GTK) ContextMenuItem DeleteItem(ActionType, ContextMenuItemTagDelete, contextMenuItemTagDelete()); ContextMenuItem SelectAllItem(ActionType, ContextMenuItemTagSelectAll, contextMenuItemTagSelectAll()); #endif HitTestResult result = hitTestResult(); Node* node = m_hitTestResult.innerNonSharedNode(); if (!node) return; #if PLATFORM(GTK) if (!result.isContentEditable() && node->isControl()) return; #endif Frame* frame = node->document()->frame(); if (!frame) return; if (!result.isContentEditable()) { FrameLoader* loader = frame->loader(); KURL linkURL = result.absoluteLinkURL(); if (!linkURL.isEmpty()) { if (loader->canHandleRequest(ResourceRequest(linkURL))) { appendItem(OpenLinkItem); appendItem(OpenLinkInNewWindowItem); appendItem(DownloadFileItem); } appendItem(CopyLinkItem); } KURL imageURL = result.absoluteImageURL(); if (!imageURL.isEmpty()) { if (!linkURL.isEmpty()) appendItem(*separatorItem()); appendItem(OpenImageInNewWindowItem); appendItem(DownloadImageItem); if (imageURL.isLocalFile() || m_hitTestResult.image()) appendItem(CopyImageItem); } if (imageURL.isEmpty() && linkURL.isEmpty()) { if (result.isSelected()) { if (selectionContainsPossibleWord(frame)) { #if PLATFORM(MAC) appendItem(SearchSpotlightItem); #endif appendItem(SearchWebItem); appendItem(*separatorItem()); #if PLATFORM(MAC) appendItem(LookInDictionaryItem); appendItem(*separatorItem()); #endif } appendItem(CopyItem); } else { #if PLATFORM(GTK) appendItem(BackItem); appendItem(ForwardItem); appendItem(StopItem); appendItem(ReloadItem); #else if (loader->canGoBackOrForward(-1)) appendItem(BackItem); if (loader->canGoBackOrForward(1)) appendItem(ForwardItem); // use isLoadingInAPISense rather than isLoading because Stop/Reload are // intended to match WebKit's API, not WebCore's internal notion of loading status if (loader->documentLoader()->isLoadingInAPISense()) appendItem(StopItem); else appendItem(ReloadItem); #endif if (frame->page() && frame != frame->page()->mainFrame()) appendItem(OpenFrameItem); } } } else { // Make an editing context menu SelectionController* selection = frame->selection(); bool inPasswordField = selection->isInPasswordField(); if (!inPasswordField) { // Consider adding spelling-related or grammar-related context menu items (never both, since a single selected range // is never considered a misspelling and bad grammar at the same time) bool misspelling = frame->editor()->isSelectionMisspelled(); bool badGrammar = !misspelling && (frame->editor()->isGrammarCheckingEnabled() && frame->editor()->isSelectionUngrammatical()); if (misspelling || badGrammar) { Vector<String> guesses = misspelling ? frame->editor()->guessesForMisspelledSelection() : frame->editor()->guessesForUngrammaticalSelection(); size_t size = guesses.size(); if (size == 0) { // If there's bad grammar but no suggestions (e.g., repeated word), just leave off the suggestions // list and trailing separator rather than adding a "No Guesses Found" item (matches AppKit) if (misspelling) { appendItem(NoGuessesItem); appendItem(*separatorItem()); } } else { for (unsigned i = 0; i < size; i++) { const String &guess = guesses[i]; if (!guess.isEmpty()) { ContextMenuItem item(ActionType, ContextMenuItemTagSpellingGuess, guess); appendItem(item); } } appendItem(*separatorItem()); } if (misspelling) { appendItem(IgnoreSpellingItem); appendItem(LearnSpellingItem); } else appendItem(IgnoreGrammarItem); appendItem(*separatorItem()); } } FrameLoader* loader = frame->loader(); KURL linkURL = result.absoluteLinkURL(); if (!linkURL.isEmpty()) { if (loader->canHandleRequest(ResourceRequest(linkURL))) { appendItem(OpenLinkItem); appendItem(OpenLinkInNewWindowItem); appendItem(DownloadFileItem); } appendItem(CopyLinkItem); appendItem(*separatorItem()); } if (result.isSelected() && !inPasswordField && selectionContainsPossibleWord(frame)) { #if PLATFORM(MAC) appendItem(SearchSpotlightItem); #endif appendItem(SearchWebItem); appendItem(*separatorItem()); #if PLATFORM(MAC) appendItem(LookInDictionaryItem); appendItem(*separatorItem()); #endif } appendItem(CutItem); appendItem(CopyItem); appendItem(PasteItem); #if PLATFORM(GTK) appendItem(DeleteItem); appendItem(*separatorItem()); appendItem(SelectAllItem); #endif if (!inPasswordField) { appendItem(*separatorItem()); #ifndef BUILDING_ON_TIGER ContextMenuItem SpellingAndGrammarMenuItem(SubmenuType, ContextMenuItemTagSpellingMenu, contextMenuItemTagSpellingMenu()); createAndAppendSpellingAndGrammarSubMenu(m_hitTestResult, SpellingAndGrammarMenuItem); appendItem(SpellingAndGrammarMenuItem); #else ContextMenuItem SpellingMenuItem(SubmenuType, ContextMenuItemTagSpellingMenu, contextMenuItemTagSpellingMenu()); createAndAppendSpellingSubMenu(m_hitTestResult, SpellingMenuItem); appendItem(SpellingMenuItem); #endif ContextMenuItem FontMenuItem(SubmenuType, ContextMenuItemTagFontMenu, contextMenuItemTagFontMenu()); createAndAppendFontSubMenu(m_hitTestResult, FontMenuItem); appendItem(FontMenuItem); #if PLATFORM(MAC) ContextMenuItem SpeechMenuItem(SubmenuType, ContextMenuItemTagSpeechMenu, contextMenuItemTagSpeechMenu()); createAndAppendSpeechSubMenu(m_hitTestResult, SpeechMenuItem); appendItem(SpeechMenuItem); #endif #if !PLATFORM(GTK) ContextMenuItem WritingDirectionMenuItem(SubmenuType, ContextMenuItemTagWritingDirectionMenu, contextMenuItemTagWritingDirectionMenu()); createAndAppendWritingDirectionSubMenu(m_hitTestResult, WritingDirectionMenuItem); appendItem(WritingDirectionMenuItem); if (Page* page = frame->page()) { if (Settings* settings = page->settings()) { bool includeTextDirectionSubmenu = settings->textDirectionSubmenuInclusionBehavior() == TextDirectionSubmenuAlwaysIncluded || settings->textDirectionSubmenuInclusionBehavior() == TextDirectionSubmenuAutomaticallyIncluded && frame->editor()->hasBidiSelection(); if (includeTextDirectionSubmenu) { ContextMenuItem TextDirectionMenuItem(SubmenuType, ContextMenuItemTagTextDirectionMenu, contextMenuItemTagTextDirectionMenu()); createAndAppendTextDirectionSubMenu(m_hitTestResult, TextDirectionMenuItem); appendItem(TextDirectionMenuItem); } } } #endif } } }
bool CRecentCurDir::TextToDataType( CCurDirString* dst, LPCTSTR pszText ) const { CopyItem(dst, pszText); return true; }
bool CRecentTagjumpKeyword::TextToDataType( CTagjumpKeywordString* dst, LPCTSTR pszText ) const { CopyItem(dst, to_wchar(pszText)); return true; }