void VariablesListView::addVariable(DebuggerVariable* variable) { if(!variable) { kdDebug(24002) << k_funcinfo << " Tried to show NULL variable!" << endl; return; } // Find the old variable in the tree if it is there for(DebuggerVariable* v = m_variablesList.first(); v; v = m_variablesList.next()) { if(v->name() == variable->name()) { replaceVariable(v, variable); return; } } // Insert the new variable DebuggerVariable *newvar = new DebuggerVariable(variable); m_variablesList.append(newvar); KListViewItem * item = new KListViewItem(this); insertItem(item); newvar->setItem(item); replaceVariable(newvar, variable); }
// Procedure function for the message history location page in the wizard BOOL CALLBACK wlmDBProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) { BOOL result = FALSE; switch(message) { // Message to initialize dialog case WM_INITDIALOG: TranslateDialogDefault(hdlg); { TCHAR *defaultPath; #ifdef _DEBUG defaultPath = replaceVariable(_T("C:\\Documents and Settings\\Very Crazy Dog\\My Documents\\我已接收的檔案\\Very Crazy Dog's Message History")); #else defaultPath = replaceVariable(_T("%USERPROFILE%\\My Received Files")); #endif SetDlgItemText(hdlg, IDC_FOLDERNAME, defaultPath); mir_free(defaultPath); } result = TRUE; break; // Message when a button is pressed case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_BROWSER: { BROWSEINFO binfo; LPITEMIDLIST pidl; ZeroMemory(&binfo, sizeof(binfo)); binfo.hwndOwner = hdlg; binfo.ulFlags = BIF_USENEWUI | BIF_NONEWFOLDERBUTTON | BIF_RETURNONLYFSDIRS; binfo.lpszTitle = TranslateT("Please select the Windows Live Messenger message history directory:"); pidl = SHBrowseForFolder(&binfo); if(pidl != NULL) { // Get the name of the folder TCHAR path[MAX_PATH]; if (SHGetPathFromIDList(pidl, path)) { SetDlgItemText(hdlg, IDC_FOLDERNAME, path); } GlobalFree(pidl); } } break; case IDC_BACK: PostMessage(GetParent(hdlg), WIZM_GOTOPAGE, IDD_IMPORTACC, (LPARAM)importAccountPageProc); break; case IDOK: { TCHAR path[MAX_PATH]; UINT pathLen; TCHAR *realPath; pathLen = GetDlgItemText(hdlg, IDC_FOLDERNAME, path, SIZEOF(path)); _tcscat_s(path, MAX_PATH, _T("\\MessageLog.xsl")); realPath = replaceVariable(path); if(_taccess_s(realPath, 4)) { MessageBox(hdlg, TranslateT("File 'MessageLog.xsl' is missing.\r\nIs this a Windows Live Messenger message history folder?"), TranslateT("WLM History Importer"), MB_OK | MB_ICONINFORMATION); } else { // Remove the appended file name if(pathLen <= MAX_PATH) { path[pathLen] = '\0'; } mir_free(realPath); realPath = replaceVariable(path); _tcscpy_s(importFolderPath, MAX_PATH, realPath); _tcscat_s(importFolderPath, MAX_PATH, _T("\\")); PostMessage(GetParent(hdlg), WIZM_GOTOPAGE, IDD_OPTIONS, (LPARAM)wlmOptionsPageProc); } mir_free(realPath); } break; case IDCANCEL: PostMessage(GetParent(hdlg), WM_CLOSE, 0, 0); break; } break; } return result; }
std::string Configuration::get(const string &key) { std:string value = getValueAsString(key); if("" == value)return value; return replaceVariable(value); }
void VariablesListView::replaceVariable(DebuggerVariable* oldvar, DebuggerVariable* newvar) { KListViewItem * item; // Remove children that doesen't exist anymore QPtrList<DebuggerVariable> oldlist = oldvar->values(); for(DebuggerVariable* oldchild = oldlist.last(); oldchild; oldchild = oldlist.prev()) { bool found = false; QPtrList<DebuggerVariable> newlist = newvar->values(); for(DebuggerVariable* newchild = newlist.last(); newchild; newchild = newlist.prev()) { if(newchild->name() == oldchild->name()) { found = true; break; } } if(!found) oldvar->deleteChild(oldchild); } // Update and add children QPtrList<DebuggerVariable> newlist = newvar->values(); for(DebuggerVariable* newchild = newlist.last(); newchild; newchild = newlist.prev()) { bool found = false; QPtrList<DebuggerVariable> oldlist = oldvar->values(); for(DebuggerVariable* oldchild = oldlist.last(); oldchild; oldchild = oldlist.prev()) { if(newchild->name() == oldchild->name()) { found = true; replaceVariable( oldchild, newchild); break; } } if(!found) { DebuggerVariable* child = new DebuggerVariable(); item = new KListViewItem(oldvar->item()); child->setItem(item); replaceVariable( child, newchild); oldvar->append(child); } } item = oldvar->item(); if(oldvar->value() != newvar->value()) item->setPixmap(VariablesListViewColumns::Status, SmallIcon("ok")); else item->setPixmap(VariablesListViewColumns::Status, KPixmap()); oldvar->copy(newvar, false); item->setText(VariablesListViewColumns::Name, oldvar->name()); item->setText(VariablesListViewColumns::Type, oldvar->typeName()); item->setText(VariablesListViewColumns::Size, oldvar->sizeName()); item->setText(VariablesListViewColumns::Value, (newvar->isScalar() ? oldvar->value() : QString())); }