some work on the search function
git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@32 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
parent
ca554494d2
commit
7a343cc30b
|
@ -80,13 +80,17 @@ void KeepassEntryView::setCurrentGroup(uint id){
|
||||||
CurrentGroup=id;
|
CurrentGroup=id;
|
||||||
for(int i=0; i<Items.size();i++){
|
for(int i=0; i<Items.size();i++){
|
||||||
setItemHidden(Items[i],(Items[i]->pEntry->GroupID != id));
|
setItemHidden(Items[i],(Items[i]->pEntry->GroupID != id));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeepassEntryView::showSearchResults(QList<Q_UINT32>& results){
|
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(){
|
void KeepassEntryView::refreshVisibleItems(){
|
||||||
|
|
|
@ -41,7 +41,12 @@ InsertionMarker=QLine();
|
||||||
db=NULL;
|
db=NULL;
|
||||||
LastHoverItem=NULL;
|
LastHoverItem=NULL;
|
||||||
setHeaderLabels(QStringList()<<tr("Gruppen"));
|
setHeaderLabels(QStringList()<<tr("Gruppen"));
|
||||||
ShowSearchGroup=true;
|
ShowSearchGroup=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeepassGroupView::selectSearchGroup(){
|
||||||
|
Q_ASSERT(ShowSearchGroup);
|
||||||
|
setItemSelected(Items.back(),true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeepassGroupView:: dragEnterEvent ( QDragEnterEvent * event ){
|
void KeepassGroupView:: dragEnterEvent ( QDragEnterEvent * event ){
|
||||||
|
@ -61,8 +66,9 @@ if(LastHoverItem){
|
||||||
}
|
}
|
||||||
|
|
||||||
InsertionMarker=QLine();
|
InsertionMarker=QLine();
|
||||||
|
if(isSearchResultGroup(item))
|
||||||
if(item){
|
event->setAccepted(false);
|
||||||
|
else if(item){
|
||||||
QRect ItemRect=visualItemRect(item);
|
QRect ItemRect=visualItemRect(item);
|
||||||
if(!db->isParentGroup(item->pGroup,DragItem->pGroup) && DragItem!=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){
|
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())
|
if ((event->pos() - DragStartPos).manhattanLength() < QApplication::startDragDistance())
|
||||||
return;
|
return;
|
||||||
DragItem=(GroupViewItem*)itemAt(DragStartPos);
|
DragItem=(GroupViewItem*)itemAt(DragStartPos);
|
||||||
|
if (isSearchResultGroup(DragItem))
|
||||||
|
return;
|
||||||
if(!DragItem)return;
|
if(!DragItem)return;
|
||||||
QDrag *drag = new QDrag(this);
|
QDrag *drag = new QDrag(this);
|
||||||
QFontMetrics fontmet(DragItem->font(0));
|
QFontMetrics fontmet(DragItem->font(0));
|
||||||
|
@ -203,6 +211,9 @@ if(ShowSearchGroup){
|
||||||
Items.push_back(new GroupViewItem(this));
|
Items.push_back(new GroupViewItem(this));
|
||||||
Items.back()->setText(0,trUtf8("Suchergebnisse"));
|
Items.back()->setText(0,trUtf8("Suchergebnisse"));
|
||||||
Items.back()->pGroup=NULL;
|
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);
|
KeepassGroupView(QWidget* parent=0);
|
||||||
void updateItems();
|
void updateItems();
|
||||||
bool isSearchResultGroup(GroupViewItem* item);
|
bool isSearchResultGroup(GroupViewItem* item);
|
||||||
|
void selectSearchGroup();
|
||||||
PwDatabase *db;
|
PwDatabase *db;
|
||||||
|
bool ShowSearchGroup; //needs a "updateItems()" after a change!
|
||||||
vector<GroupViewItem*>Items;
|
vector<GroupViewItem*>Items;
|
||||||
protected:
|
protected:
|
||||||
virtual void dragEnterEvent ( QDragEnterEvent * event );
|
virtual void dragEnterEvent ( QDragEnterEvent * event );
|
||||||
|
@ -50,7 +52,6 @@ private:
|
||||||
QPixmap DragPixmap;
|
QPixmap DragPixmap;
|
||||||
GroupViewItem* DragItem;
|
GroupViewItem* DragItem;
|
||||||
GroupViewItem* LastHoverItem;
|
GroupViewItem* LastHoverItem;
|
||||||
bool ShowSearchGroup; //needs a "updateItems()" after a change!
|
|
||||||
|
|
||||||
GroupViewItem* getLastSameLevelItem(int level);
|
GroupViewItem* getLastSameLevelItem(int level);
|
||||||
};
|
};
|
||||||
|
|
|
@ -512,6 +512,10 @@ void KeepassMainWindow::search(CGroup* group){
|
||||||
CSearchDlg dlg(db,group,this,"SearchDialog",false);
|
CSearchDlg dlg(db,group,this,"SearchDialog",false);
|
||||||
if(dlg.exec()){
|
if(dlg.exec()){
|
||||||
SearchResults=dlg.Hits;
|
SearchResults=dlg.Hits;
|
||||||
|
GroupView->ShowSearchGroup=true;
|
||||||
|
GroupView->updateItems();
|
||||||
|
GroupView->selectSearchGroup();
|
||||||
|
EntryView->showSearchResults(SearchResults);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue