void OptionsCtrlImpl::DateTime::onSelect() { if (!m_bEnabled || m_hDateTimeWnd) { return; } m_pCtrl->setNodeText(m_hItem, m_strLabel.c_str()); HFONT hTreeFront = reinterpret_cast<HFONT>(SendMessage(m_pCtrl->m_hTree, WM_GETFONT, 0, 0)); RECT r; if (m_pCtrl->getItemFreeRect(m_hItem, r)) { r.top -= 2; r.bottom += 2; if (r.left + 50 > r.right) { r.left = r.right - 50; } HWND hTempWnd; DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_TABSTOP | (m_bAllowNone ? DTS_SHOWNONE : 0); if (hTempWnd = CreateWindowEx( WS_EX_CLIENTEDGE, DATETIMEPICK_CLASS, L"", dwStyle, r.left, r.top, r.right - r.left, r.bottom - r.top, m_pCtrl->m_hTree, reinterpret_cast<HMENU>(ccDateTime), g_plugin.getInst(), nullptr)) { // restrict to dates a timestamp can hold (with 1 day less to avoid timezone issues) SYSTEMTIME stMinMax[2] = { toSystemTime(0x00000000 + 24 * 60 * 60), toSystemTime(0x7FFFFFFF - 24 * 60 * 60) }; SendMessage(hTempWnd, DTM_SETRANGE, GDTR_MIN | GDTR_MAX, reinterpret_cast<LPARAM>(stMinMax)); // set format string SendMessage(hTempWnd, DTM_SETFORMAT, 0, reinterpret_cast<LPARAM>(m_strFormatDT.c_str())); // set timestamp if (m_bAllowNone && m_bNone) { SendMessage(hTempWnd, DTM_SETSYSTEMTIME, GDT_NONE, 0); } else { SYSTEMTIME st = toSystemTime(m_timestamp); SendMessage(hTempWnd, DTM_SETSYSTEMTIME, GDT_VALID, reinterpret_cast<LPARAM>(&st)); } SendMessage(hTempWnd, WM_SETFONT, reinterpret_cast<WPARAM>(hTreeFront), MAKELPARAM(TRUE, 0)); m_hDateTimeWnd = hTempWnd; } } }
double LogManager::calcDuration(int from, int to) { if(from >= events.size()-1) return 0; string fromtime = events[from].timestamp; int temp = to + 1; if(temp >= events.size()) { temp = to; } string totime = events[temp].timestamp; return GetTimeDifference(toSystemTime(fromtime),toSystemTime(totime)); }
void OptionsCtrlImpl::DateTime::setTimestamp(time_t timestamp) { m_bNone = false; m_timestamp = timestamp; if (m_hDateTimeWnd) { SYSTEMTIME st = toSystemTime(timestamp); SendMessage(m_hDateTimeWnd, DTM_SETSYSTEMTIME, GDT_VALID, reinterpret_cast<LPARAM>(&st)); } else { m_pCtrl->setNodeText(m_hItem, getCombinedText().c_str()); } // enable childs? enableChildsDateTime(); }
void LogManager::calcStatistic() { int len = events.size(); totaltime = GetTimeDifference(toSystemTime(events[0].timestamp),toSystemTime(events[len-1].timestamp)); EventProcess p(events[0].processName); p.from = 0; vector<LogEvent> keys; bool hasPushCtrl = false; for(int i=0; i<len-1; i++) { //LogEvent e = events[i]; events[i].duration = GetTimeDifference(toSystemTime(events[i].timestamp),toSystemTime(events[i+1].timestamp)); if(events[i].isHasAcc) { accui_events.push_back(i); string acc_name = events[i].acc.name; std::transform(acc_name.begin(), acc_name.end(), acc_name.begin(), ::tolower); int acc_index = acc_name.find("paste"); if(acc_index>=0 && events[i].acc.type == "menu item") { PasteEvent pe; pe.timestamp = events[i].timestamp; pe.windowName = events[i].windowName; pe.processName = events[i].processName; pe.parentWindowName = events[i].parentWindowName; pe.method = "Menu -> Paste"; paste_events.push_back(pe); } } if(events[i].isHasSrceenshot) { screenshot_events.push_back(i); } process_set.insert(events[i].processName); window_set.insert(events[i].windowName); //events_map[events[i].timestamp] = i; if(events[i].eventType == "keyinput") { if(hasPushCtrl) { keys.push_back(events[i]); if(events[i].name != "Ctrl" && events[i].name != "Shift" && events[i].name != "Alt") { hasPushCtrl = false; keyEvents.push_back(keys); string keystr = this->keysToString(keys); if(keystr == "Ctrl+V") { PasteEvent pe; pe.timestamp = keys[0].timestamp; pe.windowName = keys[0].windowName; pe.processName = keys[0].processName; pe.parentWindowName = keys[0].parentWindowName; pe.method = keystr; paste_events.push_back(pe); } keys = vector<LogEvent>(); } } else { if(events[i].name == "Ctrl") { hasPushCtrl = true; keys.push_back(events[i]); } else if(events[i].name.size()>1 && events[i].name.substr(0,1) == "F") { keys.push_back(events[i]); keyEvents.push_back(keys); keys = vector<LogEvent>(); } else { if(keys.size()>0) { keyEvents.push_back(keys); keys = vector<LogEvent>(); } } } } if(i>0) { if(events[i].processName != p.name) { p.to = i - 1; if(process_stat.find(p.name) != process_stat.end()) { process_stat[p.name] += calcDuration(p.from, p.to); } else { process_stat[p.name] = calcDuration(p.from, p.to); } processes.push_back(p); p = EventProcess(events[i].processName); p.from = i; } } } p.to = len - 1; processes.push_back(p); }
void LogDetailWidget::copyPaste() { QAbstractItemModel *model = new QStandardItemModel(0, 7, this); ui.cpView->setModel(model); int k = 0; model->setHeaderData(k++, Qt::Horizontal, tr("Timestamp")); model->setHeaderData(k++, Qt::Horizontal, tr("Copy")); model->setHeaderData(k++, Qt::Horizontal, tr("Window Name")); model->setHeaderData(k++, Qt::Horizontal, tr("Process Name")); model->setHeaderData(k++, Qt::Horizontal, tr("Paste")); model->setHeaderData(k++, Qt::Horizontal, tr("Window Name")); model->setHeaderData(k++, Qt::Horizontal, tr("Process Name")); int i, j; i = j = 0; int num = 0; while(i<logMan.copy_events.size() || j < logMan.paste_events.size()) { string type = ""; string timestamp = ""; string copyText = ""; string cwindow = ""; string cprocess = ""; string pasteText = ""; string pwindow = ""; string pprocess = ""; if(i>=logMan.copy_events.size()) { timestamp = logMan.paste_events[j].timestamp; pasteText = logMan.paste_events[j].method; pwindow = logMan.paste_events[j].windowName; pprocess= logMan.paste_events[j].processName; j++; } else if(j>=logMan.paste_events.size()) { timestamp = logMan.copy_events[i].timestamp; copyText = logMan.copy_events[i].text; cwindow = logMan.copy_events[i].windowName; cprocess= logMan.copy_events[i].processName; i++; } else { string t1 = logMan.copy_events[i].timestamp; string t2 = logMan.paste_events[j].timestamp; double interval = GetTimeDifference(toSystemTime(t1), toSystemTime(t2)); if(interval<0) { timestamp = logMan.paste_events[j].timestamp; pasteText = logMan.paste_events[j].method; pwindow = logMan.paste_events[j].windowName; pprocess= logMan.paste_events[j].processName; j++; } else { timestamp = logMan.copy_events[i].timestamp; copyText = logMan.copy_events[i].text; cwindow = logMan.copy_events[i].windowName; cprocess= logMan.copy_events[i].processName; i++; } } k=0; model->insertRow(num); model->setData(model->index(num,k++), QString::fromStdString(timestamp)); model->setData(model->index(num,k++), QString::fromStdString(copyText)); model->setData(model->index(num,k++), QString::fromStdString(cwindow)); model->setData(model->index(num,k++), QString::fromStdString(cprocess)); model->setData(model->index(num,k++), QString::fromStdString(pasteText)); model->setData(model->index(num,k++), QString::fromStdString(pwindow)); model->setData(model->index(num,k++), QString::fromStdString(pprocess)); num++; } }