diff --git a/share/keepass/icons/nuvola/32x32/actions/find.png b/share/keepass/icons/nuvola/32x32/actions/find.png new file mode 100644 index 0000000..f1ad60c Binary files /dev/null and b/share/keepass/icons/nuvola/32x32/actions/find.png differ diff --git a/src/PwManager.cpp b/src/PwManager.cpp index dc45c92..4d18461 100755 --- a/src/PwManager.cpp +++ b/src/PwManager.cpp @@ -52,6 +52,18 @@ Errors.clear(); return r; } +QList PwDatabase::getChildIds(CGroup* group){ +if(!group)return QList(); +int GroupIndex=Groups.indexOf(*group); +int i; +QList ids; +for(i=GroupIndex+1; iLevel) break; +} +return ids; +} + bool PwDatabase::loadDatabase(QString _filename, QString& err){ unsigned long total_size,crypto_size; Q_UINT32 Signature1,Signature2,Version,NumGroups,NumEntries,Flags; diff --git a/src/PwManager.h b/src/PwManager.h index b2a726b..87c2347 100755 --- a/src/PwManager.h +++ b/src/PwManager.h @@ -62,6 +62,7 @@ public: int getGroupIndex(CGroup* group); int getGroupIndex(unsigned long ID); int getNumberOfChilds(CGroup* pGroup); + QList getChildIds(CGroup* pGroup); CEntry* cloneEntry(CEntry* pEntry); void deleteEntry(CEntry* pEntry); diff --git a/src/PwmConfig.cpp b/src/PwmConfig.cpp index 03c48c3..bd5dbe1 100755 --- a/src/PwmConfig.cpp +++ b/src/PwmConfig.cpp @@ -39,7 +39,7 @@ BannerTextColor=ParseColorString(ini.GetValue("Options","BannerTextColor","4,0,8 ShowPasswords=ini.GetValueB("Options","ShowPasswords",false); OpenUrlCommand=ini.GetValue("Options","UrlCmd","kfmclient openURL %1").c_str(); Language=ini.GetValue("Options","LangFile","").c_str(); -ParseBoolString(ini.GetValue("Options","SearchOptions","00110111").c_str(),SearchOptions,8); +ParseBoolString(ini.GetValue("Options","SearchOptions","001101111").c_str(),SearchOptions,9); ListView_HidePasswords=ini.GetValueB("UI","HidePasswords",true); ListView_HideUsernames=ini.GetValueB("UI","HideUsernames",false); ParseBoolString(ini.GetValue("Options","PwGenOptions","1111100001").c_str(),PwGenOptions,10); @@ -65,7 +65,7 @@ ini.SetValue("Options","BannerTextColor",(const char*)CreateColorString(BannerTe ini.SetValueB("Options","ShowPasswords",ShowPasswords,true); ini.SetValue("Options","UrlCmd",(const char*)OpenUrlCommand,true); ini.SetValue("Options","LangFile",(const char*)Language,true); -ini.SetValue("Options","SearchOptions",(const char*)CreateBoolString(SearchOptions,8),true); +ini.SetValue("Options","SearchOptions",(const char*)CreateBoolString(SearchOptions,9),true); ini.SetValueB("UI","HidePasswords",ListView_HidePasswords); ini.SetValueB("UI","HideUsernames",ListView_HideUsernames); ini.SetValue("Options","PwGenOptions",(const char*)CreateBoolString(PwGenOptions,10),true); diff --git a/src/PwmConfig.h b/src/PwmConfig.h index f6444ac..bf6f61f 100755 --- a/src/PwmConfig.h +++ b/src/PwmConfig.h @@ -38,7 +38,7 @@ public: bool ShowPasswords; QString OpenUrlCommand; QString Language; - bool SearchOptions[8]; + bool SearchOptions[9]; bool ListView_HidePasswords; bool ListView_HideUsernames; bool PwGenOptions[10]; diff --git a/src/dialogs/SearchDlg.cpp b/src/dialogs/SearchDlg.cpp index afd9e83..cff5cec 100755 --- a/src/dialogs/SearchDlg.cpp +++ b/src/dialogs/SearchDlg.cpp @@ -42,6 +42,11 @@ checkBox_Password->setChecked(config.SearchOptions[4]); checkBox_Comment->setChecked(config.SearchOptions[5]); checkBox_URL->setChecked(config.SearchOptions[6]); checkBox_Attachment->setChecked(config.SearchOptions[7]); +if(pGroup) + checkBox_Recursive->setChecked(config.SearchOptions[8]); +else{ + checkBox_Recursive->setChecked(false); + checkBox_Recursive->setEnabled(false);} db=_db; group=pGroup; @@ -57,6 +62,7 @@ config.SearchOptions[4]=checkBox_Password->isChecked(); config.SearchOptions[5]=checkBox_Comment->isChecked(); config.SearchOptions[6]=checkBox_URL->isChecked(); config.SearchOptions[7]=checkBox_Attachment->isChecked(); +if(group) config.SearchOptions[8]=checkBox_Recursive->isChecked(); } void CSearchDlg::OnButtonClose() @@ -74,8 +80,20 @@ QMessageBox::information(this,trUtf8("Hinweis"),trUtf8("Bitte geben Sie einen Su return;} for(int i=0;iEntries.size();i++){ - if(group){if(db->Entries[i].GroupID != group->ID)continue;} - bool hit=false; + if(group){ + if(checkBox_Recursive->isChecked()){ + QList groups=db->getChildIds(group); + groups << group->ID; + bool IsInAnyGroup=false; + for(int j=0; jEntries[i].GroupID == groups[j]){IsInAnyGroup=true; break;}} + if(!IsInAnyGroup)continue; + } + else + if(db->Entries[i].GroupID != group->ID)continue; + } + +bool hit=false; if(checkBox_Title->isChecked()) hit=hit||search(db->Entries[i].Title); if(checkBox_Username->isChecked()) hit=hit||search(db->Entries[i].UserName); if(checkBox_URL->isChecked()) hit=hit||search(db->Entries[i].URL); diff --git a/src/forms/SearchDlg.ui b/src/forms/SearchDlg.ui index b1bf091..ae57a07 100644 --- a/src/forms/SearchDlg.ui +++ b/src/forms/SearchDlg.ui @@ -106,19 +106,6 @@ true - - - - 110 - 130 - 271 - 22 - - - - Untergruppen einbeziehen - - @@ -268,6 +255,19 @@ Alt+C + + + + 110 + 130 + 271 + 22 + + + + Untergruppen einbeziehen + + diff --git a/src/lib/GroupView.cpp b/src/lib/GroupView.cpp index c512f3c..29e51a5 100644 --- a/src/lib/GroupView.cpp +++ b/src/lib/GroupView.cpp @@ -213,6 +213,7 @@ if(ShowSearchGroup){ Items.back()->pGroup=NULL; QFont f=Items.back()->font(0); f.setItalic(true); + f.setBold(true); Items.back()->setFont(0,f); } diff --git a/src/main.cpp b/src/main.cpp index 8eed099..f5dd4db 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -58,6 +58,7 @@ QIcon *Icon_EditUsernameToCb; QIcon *Icon_EditPasswordToCb; QIcon *Icon_EditClone; QIcon *Icon_EditOpenUrl; +QIcon *Icon_EditSearch; QString DateTimeFormat("no-format-string"); @@ -271,6 +272,9 @@ Icon_EditClone=new QIcon(tmpImg); //-------------------------- loadImg(ThemeDir+"/actions/run.png",tmpImg); Icon_EditOpenUrl=new QIcon(tmpImg); +//-------------------------- +loadImg(ThemeDir+"/actions/find.png",tmpImg); +Icon_EditSearch=new QIcon(tmpImg); } diff --git a/src/main.h b/src/main.h index 10e5ad3..7cf801b 100644 --- a/src/main.h +++ b/src/main.h @@ -58,6 +58,7 @@ extern QIcon *Icon_EditUsernameToCb; extern QIcon *Icon_EditPasswordToCb; extern QIcon *Icon_EditClone; extern QIcon *Icon_EditOpenUrl; +extern QIcon *Icon_EditSearch; extern QString DateTimeFormat; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d010830..566bb36 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -134,6 +134,8 @@ EditSaveAttachmentAction->setIcon(*Icon_FileSave); EditNewGroupAction->setIcon(*Icon_EditAdd); EditEditGroupAction->setIcon(*Icon_EditEdit); EditDeleteGroupAction->setIcon(*Icon_EditDelete); +EditSearchAction->setIcon(*Icon_EditSearch); +EditGroupSearchAction->setIcon(*Icon_EditSearch); } @@ -191,6 +193,8 @@ EntryView->Items.clear(); GroupView->db=NULL; GroupView->clear(); GroupView->Items.clear(); +SearchResults.clear(); +GroupView->ShowSearchGroup=false; setStateFileOpen(false); setCaption("Keepass Passwort-Manager"); return true; @@ -289,12 +293,22 @@ switch(GroupSelection){ EditGroupSearchAction->setEnabled(true); EditNewEntryAction->setEnabled(true); break; + case SEARCHGROUP: + EditNewGroupAction->setEnabled(false); + EditEditGroupAction->setEnabled(false); + EditDeleteGroupAction->setEnabled(false); + EditGroupSearchAction->setEnabled(false); + EditNewEntryAction->setEnabled(false); + break; + + default: Q_ASSERT(false); } } void KeepassMainWindow::setStateEntrySelected(SelectionState s){ EntrySelection=s; +if(GroupSelection == NONE || GroupSelection == SINGLE) switch(EntrySelection){ case NONE: EditPasswordToClipboardAction->setEnabled(false); @@ -331,6 +345,44 @@ switch(EntrySelection){ break; default: Q_ASSERT(false); } +else if(GroupSelection == SEARCHGROUP) +switch(EntrySelection){ + case NONE: + EditPasswordToClipboardAction->setEnabled(false); + EditUsernameToClipboardAction->setEnabled(false); + EditOpenUrlAction->setEnabled(false); + EditSaveAttachmentAction->setEnabled(false); + EditEditEntryAction->setEnabled(false); + EditCloneEntryAction->setEnabled(false); + EditCloneEntryAction->setText(trUtf8("Eintrag duplizieren")); + EditDeleteEntryAction->setEnabled(false); + EditDeleteEntryAction->setText(trUtf8("Eintrag löschen")); + break; + case SINGLE: + EditPasswordToClipboardAction->setEnabled(true); + EditUsernameToClipboardAction->setEnabled(true); + EditOpenUrlAction->setEnabled(true); + EditSaveAttachmentAction->setEnabled(true); + EditEditEntryAction->setEnabled(true); + EditCloneEntryAction->setEnabled(false); + EditCloneEntryAction->setText(trUtf8("Eintrag duplizieren")); + EditDeleteEntryAction->setEnabled(true); + EditDeleteEntryAction->setText(trUtf8("Eintrag löschen")); + break; + case MULTIPLE: + EditPasswordToClipboardAction->setEnabled(false); + EditUsernameToClipboardAction->setEnabled(false); + EditOpenUrlAction->setEnabled(false); + EditSaveAttachmentAction->setEnabled(false); + EditEditEntryAction->setEnabled(false); + EditCloneEntryAction->setEnabled(false); + EditCloneEntryAction->setText(trUtf8("Einträge duplizieren")); + EditDeleteEntryAction->setEnabled(true); + EditDeleteEntryAction->setText(trUtf8("Einträge löschen")); + break; + default: Q_ASSERT(false); +} +else Q_ASSERT(false); } bool KeepassMainWindow::OnFileSave(){ @@ -400,11 +452,15 @@ if(EntryView->selectedItems().size()>1) } void KeepassMainWindow::OnGroupSelectionChanged(){ +Q_ASSERT(GroupView->selectedItems().size()<=1); if(GroupView->selectedItems().size()==0) setStateGroupSelected(NONE); -if(GroupView->selectedItems().size()==1) - setStateGroupSelected(SINGLE); -Q_ASSERT(GroupView->selectedItems().size()<=1); +if(GroupView->selectedItems().size()==1){ + if(GroupView->isSearchResultGroup((GroupViewItem*)GroupView->selectedItems()[0])) + setStateGroupSelected(SEARCHGROUP); + else + setStateGroupSelected(SINGLE); +} } void KeepassMainWindow::OnEditNewGroup(){ @@ -509,7 +565,6 @@ currentEntry()->Password.delRef(); void KeepassMainWindow::OnClipboardTimeOut(){ Clipboard->clear(QClipboard::Clipboard); -qDebug("Clipper cleared."); } void KeepassMainWindow::OnEditSaveAttachment(){ diff --git a/src/mainwindow.h b/src/mainwindow.h index dda8a45..9c0bd93 100755 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -82,7 +82,7 @@ private slots: void OnClipboardTimeOut(); private: - enum SelectionState{NONE,SINGLE,MULTIPLE}; + enum SelectionState{NONE,SINGLE,MULTIPLE,SEARCHGROUP}; SelectionState GroupSelection, EntrySelection; bool FileOpen; bool ModFlag;