some work on the search function

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@32 b624d157-de02-0410-bad0-e51aec6abb33
master
tariq 19 years ago
parent ca554494d2
commit 7a343cc30b
  1. 10
      src/lib/EntryView.cpp
  2. 17
      src/lib/GroupView.cpp
  3. 3
      src/lib/GroupView.h
  4. 4
      src/mainwindow.cpp

@ -80,13 +80,17 @@ void KeepassEntryView::setCurrentGroup(uint id){
CurrentGroup=id;
for(int i=0; i<Items.size();i++){
setItemHidden(Items[i],(Items[i]->pEntry->GroupID != id));
}
}
void KeepassEntryView::showSearchResults(QList<Q_UINT32>& results){
setCurrentGroup(0);
for(int j=0; j<results.size(); j++){
for(int i=0; i<Items.size();i++){
if(Items[i]->pEntry->sID == results[j])
setItemHidden(Items[i],false);
}
}
}
void KeepassEntryView::refreshVisibleItems(){

@ -41,7 +41,12 @@ InsertionMarker=QLine();
db=NULL;
LastHoverItem=NULL;
setHeaderLabels(QStringList()<<tr("Gruppen"));
ShowSearchGroup=true;
ShowSearchGroup=false;
}
void KeepassGroupView::selectSearchGroup(){
Q_ASSERT(ShowSearchGroup);
setItemSelected(Items.back(),true);
}
void KeepassGroupView:: dragEnterEvent ( QDragEnterEvent * event ){
@ -61,8 +66,9 @@ if(LastHoverItem){
}
InsertionMarker=QLine();
if(item){
if(isSearchResultGroup(item))
event->setAccepted(false);
else if(item){
QRect ItemRect=visualItemRect(item);
if(!db->isParentGroup(item->pGroup,DragItem->pGroup) && DragItem!=item){
if((ItemRect.height()+ItemRect.y())-event->pos().y() > INSERT_AREA_WIDTH && event->pos().y() > INSERT_AREA_WIDTH){
@ -148,6 +154,8 @@ void KeepassGroupView::mouseMoveEvent(QMouseEvent *event){
if ((event->pos() - DragStartPos).manhattanLength() < QApplication::startDragDistance())
return;
DragItem=(GroupViewItem*)itemAt(DragStartPos);
if (isSearchResultGroup(DragItem))
return;
if(!DragItem)return;
QDrag *drag = new QDrag(this);
QFontMetrics fontmet(DragItem->font(0));
@ -203,6 +211,9 @@ if(ShowSearchGroup){
Items.push_back(new GroupViewItem(this));
Items.back()->setText(0,trUtf8("Suchergebnisse"));
Items.back()->pGroup=NULL;
QFont f=Items.back()->font(0);
f.setItalic(true);
Items.back()->setFont(0,f);
}
}

@ -31,7 +31,9 @@ public:
KeepassGroupView(QWidget* parent=0);
void updateItems();
bool isSearchResultGroup(GroupViewItem* item);
void selectSearchGroup();
PwDatabase *db;
bool ShowSearchGroup; //needs a "updateItems()" after a change!
vector<GroupViewItem*>Items;
protected:
virtual void dragEnterEvent ( QDragEnterEvent * event );
@ -50,7 +52,6 @@ private:
QPixmap DragPixmap;
GroupViewItem* DragItem;
GroupViewItem* LastHoverItem;
bool ShowSearchGroup; //needs a "updateItems()" after a change!
GroupViewItem* getLastSameLevelItem(int level);
};

@ -512,6 +512,10 @@ void KeepassMainWindow::search(CGroup* group){
CSearchDlg dlg(db,group,this,"SearchDialog",false);
if(dlg.exec()){
SearchResults=dlg.Hits;
GroupView->ShowSearchGroup=true;
GroupView->updateItems();
GroupView->selectSearchGroup();
EntryView->showSearchResults(SearchResults);
}
else
{