void EffectsManager::removeRequested (const QString&, const QModelIndexList& indexes) { for (const auto& index : indexes) { const auto elem = Filters_.takeAt (index.row ()); if (!elem) { qWarning () << Q_FUNC_INFO << "invalid row" << index << "of" << Filters_.size (); continue; } elem->RemoveFrom (Path_); delete elem; Model_->removeRow (index.row ()); } UpdateHeaders (); SaveFilters (); ReemitEffectsList (); }
void CFilterDialog::OnApply(wxCommandEvent& event) { m_globalFilters = m_filters; m_globalFilterSets = m_filterSets; m_globalCurrentFilterSet = m_currentFilterSet; SaveFilters(); m_pMainFrame->GetState()->NotifyHandlers(STATECHANGE_APPLYFILTER); }
void CFilterDialog::OnOK(wxCommandEvent& event) { m_globalFilters = m_filters; CompileRegexes(); m_globalFilterSets = m_filterSets; m_globalCurrentFilterSet = m_currentFilterSet; SaveFilters(); EndModal(wxID_OK); }
void CFilterDialog::OnApply(wxCommandEvent& event) { m_globalFilters = m_filters; m_globalFilterSets = m_filterSets; m_globalCurrentFilterSet = m_currentFilterSet; SaveFilters(); CContextManager::Get()->NotifyAllHandlers(STATECHANGE_APPLYFILTER); }
void CFilterDialog::OnOkOrApply(wxCommandEvent& event) { m_globalFilters = m_filters; CompileRegexes(); m_globalFilterSets = m_filterSets; m_globalCurrentFilterSet = m_currentFilterSet; SaveFilters(); CContextManager::Get()->NotifyAllHandlers(STATECHANGE_APPLYFILTER); if (event.GetId() == wxID_OK) { EndModal(wxID_OK); } }
void EffectsManager::addRequested (const QString&, const QVariantList& datas) { const auto& id = datas.value (0).toByteArray (); const auto effectPos = std::find_if (RegisteredEffects_.begin (), RegisteredEffects_.end (), [&id] (const EffectInfo& info) { return info.ID_ == id; }); if (effectPos == RegisteredEffects_.end ()) { qWarning () << Q_FUNC_INFO << "effect" << id << "not found"; return; } const auto elem = RestoreFilter (effectPos, {}); if (const auto conf = elem->GetConfigurator ()) conf->OpenDialog (); UpdateHeaders (); SaveFilters (); ReemitEffectsList (); }
//---------------------------------------------------------------------------// // Save // //---------------------------------------------------------------------------// void CMGEffect::Save(CNodeFile *pFile) { // <effect fxclass="class"> pFile->WriteOpenNode("effect", "fxclass=\"" + m_FXClass + "\""); pFile->WriteNode("fxdir", "", m_FXDir); pFile->WriteNode("fxfile", "", m_FXFile); pFile->WriteNode("fxname", "", m_FXName); pFile->WriteNode("fileName", "", m_FileName); // Main vars pFile->WriteNode("adjusttobpm", "", m_CBAdjustToBPM->Checked ()); pFile->WriteNode("adjusttobpmnum", "", m_SBAdjustToBPM->GetValue()); // Vars pFile->WriteOpenNode("vars", ""); // FX Vars pFile->WriteOpenNode("effect", ""); // Speed pFile->WriteOpenNode ("speed", ""); pFile->WriteNode ("value", "", (int)(m_TBSpeed->GetPos() * 200.f)); pFile->WriteCloseNode(); // Alpha pFile->WriteOpenNode ("alpha", ""); pFile->WriteNode ("value", "", (int)(m_TBAlpha->GetPos() * 200.f)); pFile->WriteCloseNode(); // Blend pFile->WriteOpenNode ("blend", ""); pFile->WriteNode ("value", "", m_Blend); pFile->WriteCloseNode(); // Quality pFile->WriteOpenNode ("quality", ""); pFile->WriteNode ("value", "", (int)(m_CBQuality->GetSelected())); pFile->WriteCloseNode(); // Quality pFile->WriteOpenNode ("fade", ""); pFile->WriteNode ("value", "", (m_SBFade->GetValue())); pFile->WriteCloseNode(); // FXVars m_VJFXVars->Save(pFile); pFile->WriteCloseNode(); // effect // Obj Vars pFile->WriteOpenNode ("objvars", ""); for (size_t i = 0; i < m_VJScopeVars.size(); i++) { for (size_t j = 0; j < m_VJScopeVars[i].size(); j++) { char pBuffer[64]; sprintf_s(pBuffer, 64, "scope=\"%d\" obj=\"%d\"", i,j); pFile->WriteOpenNode ("objvar", pBuffer); m_VJScopeVars[i][j]->Save(pFile); pFile->WriteCloseNode(); // objvar } } pFile->WriteCloseNode(); // objvars pFile->WriteCloseNode(); // vars // filters SaveFilters(pFile); pFile->WriteCloseNode(); // effect }
bool nsEudoraFilters::RealImport() { nsresult rv; rv = Init(); if (NS_FAILED(rv)) { IMPORT_LOG0("*** Error initializing filter import process\n"); return false; } nsCOMPtr <nsIInputStream> inputStream; rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), m_pLocation); if (NS_FAILED(rv)) { IMPORT_LOG0("*** Error opening filters file for reading\n"); return false; } rv = LoadServers(); if (NS_FAILED(rv)) { IMPORT_LOG0("*** Error loading servers with filters\n"); return false; } nsCOMPtr<nsILineInputStream> lineStream(do_QueryInterface(inputStream, &rv)); NS_ENSURE_SUCCESS(rv, false); nsCString line; bool more = true; nsAutoCString header; nsAutoCString verb; nsAutoString name; // Windows Eudora filters files have a version header as a first line - just skip it #if defined(XP_WIN) rv = lineStream->ReadLine(line, &more); #endif while (more && NS_SUCCEEDED(rv)) { rv = lineStream->ReadLine(line, &more); const char* pLine = line.get(); if (NS_SUCCEEDED(rv)) { // New filters start with a "rule <name>" line if (!strncmp(pLine, "rule ", 5)) { rv = FinalizeFilter(); if (NS_SUCCEEDED(rv)) { const char* pName = pLine + 5; NS_CopyNativeToUnicode(nsCString(pName), name); rv = CreateNewFilter(pName); } } #ifdef XP_MACOSX else if (!strncmp(pLine, "id ", 3)) ;// ids have no value to us, but we don't want them to produce a warning either #endif else if (!strncmp(pLine, "conjunction ", 12)) { const char* cj = pLine + 12; if (!strcmp(cj, "and")) m_isAnd = true; else if (!strcmp(cj, "unless")) m_isUnless = true; else if (!strcmp(cj, "ignore")) m_ignoreTerm = true; } else if (!strncmp(pLine, "header ", 7)) header = (pLine + 7); else if (!strncmp(pLine, "verb ", 5)) verb = (pLine + 5); else if (!strncmp(pLine, "value ", 6)) { if (!m_ignoreTerm) { rv = AddTerm(header.get(), verb.get(), pLine + 6, (m_isAnd || m_isUnless), m_isUnless); // For now, ignoring terms that can't be represented in TB filters if (rv == NS_ERROR_INVALID_ARG) { rv = NS_OK; m_termNotGroked = true; } } } else if (!strcmp(pLine, "incoming")) m_isIncoming = true; else if (!strncmp(pLine, "transfer ", 9) || !strncmp(pLine, "copy ", 5)) { const char* pMailboxPath = strchr(pLine, ' ') + 1; bool isTransfer = (*pLine == 't'); rv = AddMailboxAction(pMailboxPath, isTransfer); if (rv == NS_ERROR_INVALID_ARG) { nsAutoString unicodeMailboxPath; NS_CopyNativeToUnicode(nsCString(pMailboxPath), unicodeMailboxPath); m_errorLog += NS_LITERAL_STRING("- "); m_errorLog += name; m_errorLog += NS_LITERAL_STRING(": "); m_errorLog += nsEudoraStringBundle::FormatString(EUDORAIMPORT_FILTERS_WARN_MAILBOX_MISSING, unicodeMailboxPath.get()); m_errorLog += NS_LITERAL_STRING("\n"); rv = NS_OK; } } // Doing strncmp() here because Win Eudora puts a space after "stop" but Mac Eudora doesn't else if (!strncmp(pLine, "stop", 4)) m_hasStop = true; else if (!strncmp(pLine, "forward ", 8)) rv = AddStringAction(nsMsgFilterAction::Forward, pLine + 8); else if (!strncmp(pLine, "reply ", 6)) rv = AddStringAction(nsMsgFilterAction::Reply, pLine + 6); else if (!strncmp(pLine, "priority ", 9)) { // Win Eudora's priority values are 0 (highest) to 4 (lowest) // Mac Eudora's priority values are 1 (highest) to 5 (lowest) // Thunderbird's priority values are 6 (highest) to 2 (lowest) int32_t TBPriority = 6 - atoi(pLine + 9); #ifdef XP_MACOSX TBPriority++; #endif rv = AddPriorityAction(TBPriority); } else if (!strncmp(pLine, "label ", 6)) { nsAutoCString tagName("$label"); tagName += pLine + 6; rv = AddStringAction(nsMsgFilterAction::AddTag, tagName.get()); } // Doing strncmp() here because Win Eudora puts a space after "junk" but Mac Eudora doesn't else if (!strncmp(pLine, "junk", 4)) rv = AddJunkAction(100); else if (!strncmp(pLine, "status ", 7)) { // Win Eudora's read status is 1, whereas Mac Eudora's read status is 2 uint32_t status = atoi(pLine + 7); #ifdef XP_MACOSX status--; #endif if (status == 1) rv = AddAction(nsMsgFilterAction::MarkRead); } else if (!strncmp(pLine, "serverOpt ", 10)) { // Win and Mac Eudora have the two bits swapped in the file uint32_t bits = atoi(pLine + 10); #if defined(XP_WIN) bool bFetch = (bits & 1); bool bDelete = (bits & 2); #endif #ifdef XP_MACOSX bool bFetch = (bits & 2); bool bDelete = (bits & 1); #endif rv = AddAction(bDelete? (nsMsgRuleActionType)nsMsgFilterAction::DeleteFromPop3Server : (nsMsgRuleActionType)nsMsgFilterAction::LeaveOnPop3Server); if (NS_SUCCEEDED(rv) && bFetch) rv = AddAction(nsMsgFilterAction::FetchBodyFromPop3Server); } else if (strcmp(pLine, "manual") == 0) ;// Just ignore manual as TB handles manual in a different way else if (strcmp(pLine, "outgoing") == 0) { m_errorLog += NS_LITERAL_STRING("- "); m_errorLog += name; m_errorLog += NS_LITERAL_STRING(": "); m_errorLog += nsEudoraStringBundle::FormatString(EUDORAIMPORT_FILTERS_WARN_OUTGOING); m_errorLog += NS_LITERAL_STRING("\n"); } else { nsAutoString unicodeLine; NS_CopyNativeToUnicode(nsCString(pLine), unicodeLine); m_errorLog += NS_LITERAL_STRING("- "); m_errorLog += name; m_errorLog += NS_LITERAL_STRING(": "); m_errorLog += nsEudoraStringBundle::FormatString(EUDORAIMPORT_FILTERS_WARN_ACTION, unicodeLine.get()); m_errorLog += NS_LITERAL_STRING("\n"); } } } // Process the last filter if (!more && NS_SUCCEEDED(rv)) rv = FinalizeFilter(); inputStream->Close(); if (more) { IMPORT_LOG0("*** Error reading the filters, didn't reach the end\n"); return false; } rv = SaveFilters(); return NS_SUCCEEDED(rv); }
bool FileFilter::FilterEdit() { if (bMenuOpen) return false; Changed = true; bMenuOpen = true; MenuItemEx ListItem; int ExitCode; bool bNeedUpdate=false; VMenu FilterList(MSG(MFilterTitle),nullptr,0,ScrY-6); FilterList.SetHelp(L"FiltersMenu"); FilterList.SetPosition(-1,-1,0,0); FilterList.SetBottomTitle(MSG(MFilterBottom)); FilterList.SetFlags(/*VMENU_SHOWAMPERSAND|*/VMENU_WRAPMODE); for (size_t i=0; i<FilterData.getCount(); i++) { ListItem.Clear(); MenuString(ListItem.strName,FilterData.getItem(i)); if (!i) ListItem.Flags|=LIF_SELECTED; int Check = GetCheck(FilterData.getItem(i)); if (Check) ListItem.SetCheck(Check); FilterList.AddItem(&ListItem); } ListItem.Clear(); if (!FilterData.getCount()) ListItem.Flags|=LIF_SELECTED; FilterList.AddItem(&ListItem); if (m_FilterType != FFT_CUSTOM) { wchar_t *ExtPtr=nullptr; int ExtCount=0; { enumFileFilterFlagsType FFFT = GetFFFT(); for (size_t i=0; i<TempFilterData.getCount(); i++) { //AY: Будем показывать только те выбранные авто фильтры //(для которых нету файлов на панели) которые выбраны в области данного меню if (!TempFilterData.getItem(i)->GetFlags(FFFT)) continue; const wchar_t *FMask; TempFilterData.getItem(i)->GetMask(&FMask); string strMask = FMask; Unquote(strMask); if (!ParseAndAddMasks(&ExtPtr,strMask,0,ExtCount,GetCheck(TempFilterData.getItem(i)))) break; } } ListItem.Clear(); ListItem.Flags|=LIF_SEPARATOR; FilterList.AddItem(&ListItem); ListItem.Clear(); FoldersFilter.SetTitle(MSG(MFolderFileType)); MenuString(ListItem.strName,&FoldersFilter,false,L'0'); int Check = GetCheck(&FoldersFilter); if (Check) ListItem.SetCheck(Check); FilterList.AddItem(&ListItem); if (GetHostPanel()->GetMode()==NORMAL_PANEL) { string strCurDir, strFileName; FAR_FIND_DATA_EX fdata; GetHostPanel()->GetCurDir(strCurDir); ScanTree ScTree(FALSE,FALSE); ScTree.SetFindPath(strCurDir,L"*"); while (ScTree.GetNextName(&fdata,strFileName)) if (!ParseAndAddMasks(&ExtPtr,fdata.strFileName,fdata.dwFileAttributes,ExtCount,0)) break; } else { string strFileName; DWORD FileAttr; for (int i=0; GetHostPanel()->GetFileName(strFileName,i,FileAttr); i++) if (!ParseAndAddMasks(&ExtPtr,strFileName,FileAttr,ExtCount,0)) break; } far_qsort((void *)ExtPtr,ExtCount,MAX_PATH*sizeof(wchar_t),ExtSort); ListItem.Clear(); for (int i=0, h=L'1'; i<ExtCount; i++, (h==L'9'?h=L'A':(h==L'Z'||h?h++:h=0))) { wchar_t *CurExtPtr=ExtPtr+i*MAX_PATH; MenuString(ListItem.strName,nullptr,false,h,true,CurExtPtr,MSG(MPanelFileType)); int Length = StrLength(CurExtPtr)+1; ListItem.SetCheck(CurExtPtr[Length]); FilterList.SetUserData(CurExtPtr, Length*sizeof(wchar_t), FilterList.AddItem(&ListItem)); } xf_free(ExtPtr); } FilterList.Show(); while (!FilterList.Done()) { int Key=FilterList.ReadInput(); if (Key==KEY_ADD) Key=L'+'; else if (Key==KEY_SUBTRACT) Key=L'-'; else if (Key==L'i') Key=L'I'; else if (Key==L'x') Key=L'X'; switch (Key) { case L'+': case L'-': case L'I': case L'X': case KEY_SPACE: case KEY_BS: { int SelPos=FilterList.GetSelectPos(); if (SelPos<0 || SelPos==(int)FilterData.getCount()) break; int Check=FilterList.GetCheck(SelPos); int NewCheck; if (Key==KEY_BS) NewCheck = 0; else if (Key==KEY_SPACE) NewCheck = Check ? 0 : L'+'; else NewCheck = (Check == Key) ? 0 : Key; FilterList.SetCheck(NewCheck,SelPos); FilterList.SetSelectPos(SelPos,1); FilterList.SetUpdateRequired(TRUE); FilterList.FastShow(); FilterList.ProcessKey(KEY_DOWN); bNeedUpdate=true; break; } case KEY_SHIFTBS: { for (int I=0; I < FilterList.GetItemCount(); I++) { FilterList.SetCheck(FALSE, I); } FilterList.SetUpdateRequired(TRUE); FilterList.FastShow(); break; } case KEY_F4: { int SelPos=FilterList.GetSelectPos(); if (SelPos<0) break; if (SelPos<(int)FilterData.getCount()) { if (FileFilterConfig(FilterData.getItem(SelPos))) { ListItem.Clear(); MenuString(ListItem.strName,FilterData.getItem(SelPos)); int Check = GetCheck(FilterData.getItem(SelPos)); if (Check) ListItem.SetCheck(Check); FilterList.DeleteItem(SelPos); FilterList.AddItem(&ListItem,SelPos); FilterList.SetSelectPos(SelPos,1); FilterList.SetUpdateRequired(TRUE); FilterList.FastShow(); bNeedUpdate=true; } } else if (SelPos>(int)FilterData.getCount()) { Message(MSG_WARNING,1,MSG(MFilterTitle),MSG(MCanEditCustomFilterOnly),MSG(MOk)); } break; } case KEY_NUMPAD0: case KEY_INS: case KEY_F5: { int pos=FilterList.GetSelectPos(); if (pos<0) break; size_t SelPos=pos; size_t SelPos2=pos+1; SelPos = Min(FilterData.getCount(), SelPos); FileFilterParams *NewFilter = FilterData.insertItem(SelPos); if (!NewFilter) break; if (Key==KEY_F5) { if (SelPos2 < FilterData.getCount()) { *NewFilter = *FilterData.getItem(SelPos2); NewFilter->SetTitle(L""); NewFilter->ClearAllFlags(); } else if (SelPos2 == FilterData.getCount()+2) { *NewFilter = FoldersFilter; NewFilter->SetTitle(L""); NewFilter->ClearAllFlags(); } else if (SelPos2 > FilterData.getCount()+2) { NewFilter->SetMask(1,static_cast<const wchar_t*>(FilterList.GetUserData(nullptr, 0, static_cast<int>(SelPos2-1)))); //Авто фильтры они только для файлов, папки не должны к ним подходить NewFilter->SetAttr(1,0,FILE_ATTRIBUTE_DIRECTORY); } else { FilterData.deleteItem(SelPos); break; } } else { //AY: Раз создаём новый фильтр то думаю будет логично если он будет только для файлов NewFilter->SetAttr(1,0,FILE_ATTRIBUTE_DIRECTORY); } if (FileFilterConfig(NewFilter)) { ListItem.Clear(); MenuString(ListItem.strName,NewFilter); FilterList.AddItem(&ListItem,static_cast<int>(SelPos)); FilterList.SetSelectPos(static_cast<int>(SelPos),1); FilterList.SetPosition(-1,-1,0,0); FilterList.Show(); bNeedUpdate=true; } else FilterData.deleteItem(SelPos); break; } case KEY_NUMDEL: case KEY_DEL: { int SelPos=FilterList.GetSelectPos(); if (SelPos<0) break; if (SelPos<(int)FilterData.getCount()) { string strQuotedTitle=FilterData.getItem(SelPos)->GetTitle(); InsertQuote(strQuotedTitle); if (!Message(0,2,MSG(MFilterTitle),MSG(MAskDeleteFilter), strQuotedTitle,MSG(MDelete),MSG(MCancel))) { FilterData.deleteItem(SelPos); FilterList.DeleteItem(SelPos); FilterList.SetSelectPos(SelPos,1); FilterList.SetPosition(-1,-1,0,0); FilterList.Show(); bNeedUpdate=true; } } else if (SelPos>(int)FilterData.getCount()) { Message(MSG_WARNING,1,MSG(MFilterTitle),MSG(MCanDeleteCustomFilterOnly),MSG(MOk)); } break; } case KEY_CTRLUP: case KEY_RCTRLUP: case KEY_CTRLDOWN: case KEY_RCTRLDOWN: { int SelPos=FilterList.GetSelectPos(); if (SelPos<0) break; if (SelPos<(int)FilterData.getCount() && !((Key==KEY_CTRLUP || Key==KEY_RCTRLUP) && !SelPos) && !((Key==KEY_CTRLDOWN || Key==KEY_RCTRLDOWN) && SelPos==(int)(FilterData.getCount()-1))) { int NewPos = SelPos + ((Key == KEY_CTRLDOWN || Key == KEY_RCTRLDOWN) ? 1 : -1); MenuItemEx CurItem = *FilterList.GetItemPtr(SelPos); MenuItemEx NextItem = *FilterList.GetItemPtr(NewPos); FilterData.swapItems(NewPos,SelPos); if (NewPos<SelPos) { FilterList.DeleteItem(NewPos,2); FilterList.AddItem(&CurItem,NewPos); FilterList.AddItem(&NextItem,SelPos); } else { FilterList.DeleteItem(SelPos,2); FilterList.AddItem(&NextItem,SelPos); FilterList.AddItem(&CurItem,NewPos); } FilterList.SetSelectPos(NewPos,1); FilterList.SetUpdateRequired(TRUE); FilterList.FastShow(); bNeedUpdate=true; } break; } default: { FilterList.ProcessInput(); //заставляем хоткеи позиционировать курсор на пункте но не закрывать меню if (Key!=KEY_NUMENTER && Key!=KEY_ENTER && Key!=KEY_ESC && Key!=KEY_F10 && (IsAlphaNum(Key) || Key&(KEY_ALT|KEY_RALT))) FilterList.ClearDone(); } } } FilterList.Hide(); ExitCode=FilterList.Modal::GetExitCode(); if (ExitCode!=-1) ProcessSelection(&FilterList); if (Opt.AutoSaveSetup) SaveFilters(); if (ExitCode!=-1 || bNeedUpdate) { if (m_FilterType == FFT_PANEL) { GetHostPanel()->Update(UPDATE_KEEP_SELECTION); GetHostPanel()->Redraw(); } } bMenuOpen = false; return (ExitCode!=-1); }