diff --git a/share/keepass/icons/restore.png b/share/keepass/icons/restore.png new file mode 100644 index 0000000..fe16aa7 Binary files /dev/null and b/share/keepass/icons/restore.png differ diff --git a/share/keepass/icons/trashcan.png b/share/keepass/icons/trashcan.png new file mode 100644 index 0000000..f19899d Binary files /dev/null and b/share/keepass/icons/trashcan.png differ diff --git a/src/dialogs/TrashCanDlg.cpp b/src/dialogs/TrashCanDlg.cpp new file mode 100644 index 0000000..4c1f5db --- /dev/null +++ b/src/dialogs/TrashCanDlg.cpp @@ -0,0 +1,92 @@ +/*************************************************************************** + * Copyright (C) 2007 by Tarek Saidi * + * tarek.saidi@arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +#include +#include +#include +#include "main.h" +#include "TrashCanDlg.h" + +TrashCanDialog::TrashCanDialog(QWidget* parent,IDatabase* database,const QList& TrashItems):QDialog(parent){ + setupUi(this); + Entries=TrashItems; + for(int i=0;isetData(0,Qt::UserRole,i); + item->setText(0,Entries[i]->group()->title()); + item->setText(1,Entries[i]->title()); + item->setText(2,Entries[i]->username()); + item->setText(3,Entries[i]->expire().dateToString(Qt::LocalDate)); + item->setIcon(0,database->icon(Entries[i]->group()->image())); + item->setIcon(1,database->icon(Entries[i]->image())); + + } + connect(treeWidget,SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),this,SLOT(OnItemDoubleClicked(QTreeWidgetItem*,int))); + connect(treeWidget,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(OnContextMenu(const QPoint&))); + ContextMenu=new QMenu(this); + ContextMenu->addAction(getIcon("restore"),"Restore"); + ContextMenu->addAction(getIcon("deleteentry"),"Delete"); +} + + +void TrashCanDialog::paintEvent(QPaintEvent* event){ + QDialog::paintEvent(event); + QPainter painter(this); + painter.setClipRegion(event->region()); + painter.drawPixmap(QPoint(0,0),BannerPixmap); +} + +void TrashCanDialog::resizeEvent(QResizeEvent* event){ + createBanner(&BannerPixmap,getPixmap("trashcan"),tr("Recycle Bin"),width()); + QDialog::resizeEvent(event); +} + +void TrashCanDialog::OnItemDoubleClicked(QTreeWidgetItem* item, int column){ + SelectedEntry=Entries[item->data(0,Qt::UserRole).toInt()]; + accept(); +} + +void TrashCanDialog::OnContextMenu(const QPoint& pos){ + if(treeWidget->itemAt(pos)){ + QTreeWidgetItem* item=treeWidget->itemAt(pos); + if(treeWidget->selectedItems().size()==0){ + treeWidget->setItemSelected(item,true); + } + else{ + if(!treeWidget->isItemSelected(item)){ + while(treeWidget->selectedItems().size()){ + treeWidget->setItemSelected(treeWidget->selectedItems()[0],false); + } + treeWidget->setItemSelected(item,true); + } + } + } + else + { + while(treeWidget->selectedItems().size()) + treeWidget->setItemSelected(treeWidget->selectedItems()[0],false); + } + ContextMenu->popup(treeWidget->viewport()->mapToGlobal(pos)); +} + + + +///TODO 0.2.3 locale aware string/date compare for correct sorting diff --git a/src/dialogs/TrashCanDlg.h b/src/dialogs/TrashCanDlg.h new file mode 100644 index 0000000..8fbb70c --- /dev/null +++ b/src/dialogs/TrashCanDlg.h @@ -0,0 +1,51 @@ +/*************************************************************************** + * Copyright (C) 2007 by Tarek Saidi * + * tarek.saidi@arcor.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _TRASH_CAN_DLG_ +#define _TRASH_CAN_DLG_ + +#include +#include +#include +#include +#include "ui_TrashCanDlg.h" +#include "Database.h" + +class TrashCanDialog:public QDialog, public Ui_TrashCanDialog{ + Q_OBJECT + public: + TrashCanDialog(QWidget* parent,IDatabase* database,const QList& Entries); + IEntryHandle* SelectedEntry; + private: + QList Entries; + QPixmap BannerPixmap; + QMenu* ContextMenu; + virtual void paintEvent(QPaintEvent*); + virtual void resizeEvent(QResizeEvent *); + + private slots: + void OnItemDoubleClicked(QTreeWidgetItem*,int); + void OnContextMenu(const QPoint&); + + +}; + + +#endif diff --git a/src/forms/TrashCanDlg.ui b/src/forms/TrashCanDlg.ui new file mode 100644 index 0000000..b1e1eef --- /dev/null +++ b/src/forms/TrashCanDlg.ui @@ -0,0 +1,128 @@ + + TrashCanDialog + + + + 0 + 0 + 588 + 408 + + + + + 9 + + + 6 + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 50 + + + + + + + + Double click on an entry to restore it. + + + + + + + Qt::CustomContextMenu + + + QAbstractItemView::ExtendedSelection + + + false + + + true + + + false + + + true + + + true + + + + Group + + + + + Title + + + + + Username + + + + + Expired + + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Empty Recycle Bin + + + + + + + Close + + + + + + + + + +