finished search function

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@34 b624d157-de02-0410-bad0-e51aec6abb33
master
tariq 18 years ago
parent befd8d5631
commit cdbd7e1b9c
  1. BIN
      share/keepass/icons/nuvola/32x32/actions/find.png
  2. 12
      src/PwManager.cpp
  3. 1
      src/PwManager.h
  4. 4
      src/PwmConfig.cpp
  5. 2
      src/PwmConfig.h
  6. 22
      src/dialogs/SearchDlg.cpp
  7. 26
      src/forms/SearchDlg.ui
  8. 1
      src/lib/GroupView.cpp
  9. 4
      src/main.cpp
  10. 1
      src/main.h
  11. 63
      src/mainwindow.cpp
  12. 2
      src/mainwindow.h

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

@ -52,6 +52,18 @@ Errors.clear();
return r;
}
QList<int> PwDatabase::getChildIds(CGroup* group){
if(!group)return QList<int>();
int GroupIndex=Groups.indexOf(*group);
int i;
QList<int> ids;
for(i=GroupIndex+1; i<Groups.size(); i++){
ids << Groups[i].ID;
if(Groups[i].Level <= group->Level) break;
}
return ids;
}
bool PwDatabase::loadDatabase(QString _filename, QString& err){
unsigned long total_size,crypto_size;
Q_UINT32 Signature1,Signature2,Version,NumGroups,NumEntries,Flags;

@ -62,6 +62,7 @@ public:
int getGroupIndex(CGroup* group);
int getGroupIndex(unsigned long ID);
int getNumberOfChilds(CGroup* pGroup);
QList<int> getChildIds(CGroup* pGroup);
CEntry* cloneEntry(CEntry* pEntry);
void deleteEntry(CEntry* pEntry);

@ -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);

@ -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];

@ -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;i<db->Entries.size();i++){
if(group){if(db->Entries[i].GroupID != group->ID)continue;}
bool hit=false;
if(group){
if(checkBox_Recursive->isChecked()){
QList<int> groups=db->getChildIds(group);
groups << group->ID;
bool IsInAnyGroup=false;
for(int j=0; j<groups.size();j++){
if(db->Entries[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);

@ -106,19 +106,6 @@
<bool>true</bool>
</property>
</widget>
<widget class="QCheckBox" name="checkBox" >
<property name="geometry" >
<rect>
<x>110</x>
<y>130</y>
<width>271</width>
<height>22</height>
</rect>
</property>
<property name="text" >
<string>Untergruppen einbeziehen</string>
</property>
</widget>
<widget class="Q3GroupBox" name="groupBox1" >
<property name="geometry" >
<rect>
@ -268,6 +255,19 @@
<string>Alt+C</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBox_Recursive" >
<property name="geometry" >
<rect>
<x>110</x>
<y>130</y>
<width>271</width>
<height>22</height>
</rect>
</property>
<property name="text" >
<string>Untergruppen einbeziehen</string>
</property>
</widget>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>

@ -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);
}

@ -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);
}

@ -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;

@ -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(){

@ -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;