Implemented backup feature
Disabled desktop integration plugins Disabled "Features" tab in SettingsDlg Removed useless files git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@231 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
@@ -170,17 +170,18 @@ void KeepassEntryView::updateEntry(EntryViewItem* item){
|
||||
if(config->hideUsernames())
|
||||
item->setText(j++,"******");
|
||||
else
|
||||
item->setText(j++,entry->username());}
|
||||
if (Columns.at(2)){item->setText(j++,entry->url());}
|
||||
if (Columns.at(3)){
|
||||
if(config->hidePasswords())
|
||||
item->setText(j++,"******");
|
||||
else{
|
||||
SecString password=entry->password();
|
||||
password.unlock();
|
||||
item->setText(j++,password.string());
|
||||
}
|
||||
item->setText(j++,entry->username());
|
||||
}
|
||||
if (Columns.at(2)){item->setText(j++,entry->url());}
|
||||
if (Columns.at(3)){
|
||||
if(config->hidePasswords())
|
||||
item->setText(j++,"******");
|
||||
else{
|
||||
SecString password=entry->password();
|
||||
password.unlock();
|
||||
item->setText(j++,password.string());
|
||||
}
|
||||
}
|
||||
if (Columns.at(4)){
|
||||
item->setText(j++,entry->comment().section('\n',0,0));}
|
||||
if (Columns.at(5)){
|
||||
@@ -195,25 +196,40 @@ void KeepassEntryView::updateEntry(EntryViewItem* item){
|
||||
item->setText(j++,entry->binaryDesc());}
|
||||
if(Columns.at(10) && ViewMode==ShowSearchResults){
|
||||
item->setText(j,entry->group()->title());
|
||||
item->setIcon(j++,db->icon(entry->group()->image()));}
|
||||
item->setIcon(j++,db->icon(entry->group()->image()));
|
||||
}
|
||||
}
|
||||
|
||||
void KeepassEntryView::editEntry(EntryViewItem* item){
|
||||
CEntry old = item->EntryHandle->data();
|
||||
|
||||
CEditEntryDlg dlg(db,item->EntryHandle,this,true);
|
||||
switch(dlg.exec()){
|
||||
int result = dlg.exec();
|
||||
switch(result){
|
||||
case 0: //canceled or no changes
|
||||
break;
|
||||
case 1: //modifications but same group
|
||||
updateEntry(item);
|
||||
emit fileModified();
|
||||
break;
|
||||
case 2: //entry moved to another group
|
||||
//entry moved to another group
|
||||
case 2: //modified
|
||||
case 3: //not modified
|
||||
delete item;
|
||||
Items.removeAt(Items.indexOf(item));
|
||||
emit fileModified();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ((result==1 || result==2) && config->backup()){
|
||||
old.LastAccess = QDateTime::currentDateTime();
|
||||
old.LastMod = QDateTime::currentDateTime();
|
||||
IGroupHandle* bGroup = db->backupGroup();
|
||||
if (bGroup==NULL)
|
||||
emit requestCreateGroup("Backup", 4, NULL);
|
||||
if ((bGroup = db->backupGroup())!=NULL)
|
||||
db->addEntry(&old, bGroup);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#define NUM_COLUMNS 11
|
||||
|
||||
class EntryViewItem;
|
||||
class GroupViewItem;
|
||||
enum SelectionState{NONE,SINGLE,MULTIPLE,SEARCHGROUP};
|
||||
|
||||
class KeepassEntryView:public QTreeWidget{
|
||||
@@ -44,6 +45,7 @@ class KeepassEntryView:public QTreeWidget{
|
||||
QMenu *ContextMenu;
|
||||
QBitArray Columns;
|
||||
void setCurrentEntry(IEntryHandle* entry);
|
||||
inline IGroupHandle* getCurrentGroup() { return CurrentGroup; };
|
||||
private:
|
||||
void setEntry(IEntryHandle* entry);
|
||||
void updateEntry(EntryViewItem*);
|
||||
@@ -97,6 +99,7 @@ class KeepassEntryView:public QTreeWidget{
|
||||
signals:
|
||||
void fileModified();
|
||||
void selectionChanged(SelectionState);
|
||||
void requestCreateGroup(QString title, quint32 image, GroupViewItem* parent);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ void KeepassGroupView::createItems(){
|
||||
Items.append(new GroupViewItem(this));
|
||||
Items.back()->setText(0,groups[i]->title());
|
||||
Items.back()->GroupHandle=groups[i];
|
||||
addChilds(Items.back());
|
||||
addChildren(Items.back());
|
||||
}
|
||||
}
|
||||
for(int i=0;i<Items.size();i++){
|
||||
@@ -71,15 +71,15 @@ void KeepassGroupView::showSearchResults(){
|
||||
emit searchResultsSelected();
|
||||
}
|
||||
|
||||
void KeepassGroupView::addChilds(GroupViewItem* item){
|
||||
QList<IGroupHandle*>childs=item->GroupHandle->childs();
|
||||
if(!childs.size())
|
||||
void KeepassGroupView::addChildren(GroupViewItem* item){
|
||||
QList<IGroupHandle*>children=item->GroupHandle->children();
|
||||
if(!children.size())
|
||||
return;
|
||||
for(int i=0; i<childs.size(); i++){
|
||||
for(int i=0; i<children.size(); i++){
|
||||
Items.push_back(new GroupViewItem(item));
|
||||
Items.back()->setText(0,childs[i]->title());
|
||||
Items.back()->GroupHandle=childs[i];
|
||||
addChilds(Items.back());
|
||||
Items.back()->setText(0,children[i]->title());
|
||||
Items.back()->GroupHandle=children[i];
|
||||
addChildren(Items.back());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,50 +106,39 @@ void KeepassGroupView::OnNewGroup(){
|
||||
GroupViewItem* parent=(GroupViewItem*)currentItem();
|
||||
CGroup NewGroup;
|
||||
CEditGroupDialog dlg(db,&NewGroup,parentWidget(),true);
|
||||
if(dlg.exec()){
|
||||
IGroupHandle* group;
|
||||
if(parent){
|
||||
group=db->addGroup(&NewGroup,parent->GroupHandle);
|
||||
Items.append(new GroupViewItem(parent));
|
||||
}
|
||||
else{
|
||||
if(topLevelItemCount()){
|
||||
if(topLevelItem(topLevelItemCount()-1)==SearchResultItem)
|
||||
Items.append(new GroupViewItem(this,topLevelItem(topLevelItemCount()-2)));
|
||||
else
|
||||
Items.append(new GroupViewItem(this,topLevelItem(topLevelItemCount()-1)));
|
||||
}
|
||||
else
|
||||
Items.append(new GroupViewItem(this));
|
||||
group=db->addGroup(&NewGroup,NULL);
|
||||
}
|
||||
Items.back()->GroupHandle=group;
|
||||
Items.back()->setText(0,group->title());
|
||||
Items.back()->setIcon(0,db->icon(group->image()));
|
||||
}
|
||||
emit fileModified();
|
||||
if(dlg.exec())
|
||||
createGroup(NewGroup.Title, NewGroup.Image, parent);
|
||||
}
|
||||
|
||||
void KeepassGroupView::createGroup(const QString& title, quint32 image){
|
||||
void KeepassGroupView::createGroup(const QString& title, quint32 image, GroupViewItem* parent){
|
||||
CGroup NewGroup;
|
||||
NewGroup.Title = title;
|
||||
NewGroup.Image = image;
|
||||
|
||||
IGroupHandle* group;
|
||||
if(topLevelItemCount()){
|
||||
if(topLevelItem(topLevelItemCount()-1)==SearchResultItem)
|
||||
Items.append(new GroupViewItem(this,topLevelItem(topLevelItemCount()-2)));
|
||||
else
|
||||
Items.append(new GroupViewItem(this,topLevelItem(topLevelItemCount()-1)));
|
||||
if(parent){
|
||||
group=db->addGroup(&NewGroup,parent->GroupHandle);
|
||||
Items.append(new GroupViewItem(parent));
|
||||
}
|
||||
else{
|
||||
if(topLevelItemCount()){
|
||||
int i=1;
|
||||
if(topLevelItem(topLevelItemCount()-i)==SearchResultItem)
|
||||
i++;
|
||||
if(title!="Backup" && topLevelItem(topLevelItemCount()-i)->text(0)=="Backup")
|
||||
i++;
|
||||
Items.append(new GroupViewItem(this,topLevelItem(topLevelItemCount()-i)));
|
||||
}
|
||||
else
|
||||
Items.append(new GroupViewItem(this));
|
||||
|
||||
group = db->addGroup(&NewGroup,NULL);
|
||||
}
|
||||
else
|
||||
Items.append(new GroupViewItem(this));
|
||||
|
||||
group = db->addGroup(&NewGroup,NULL);
|
||||
|
||||
Items.back()->GroupHandle = group;
|
||||
Items.back()->setText(0, group->title());
|
||||
Items.back()->setIcon(0, db->icon(group->image()));
|
||||
emit fileModified();
|
||||
}
|
||||
|
||||
void KeepassGroupView::OnEditGroup(){
|
||||
|
||||
@@ -36,7 +36,9 @@ class KeepassGroupView:public QTreeWidget{
|
||||
void createItems();
|
||||
void showSearchResults();
|
||||
void setCurrentGroup(IGroupHandle* group);
|
||||
void createGroup(const QString& title, quint32 image);
|
||||
|
||||
public slots:
|
||||
void createGroup(const QString& title, quint32 image, GroupViewItem* group=NULL);
|
||||
|
||||
private:
|
||||
virtual void dragEnterEvent(QDragEnterEvent* event);
|
||||
@@ -49,7 +51,7 @@ class KeepassGroupView:public QTreeWidget{
|
||||
virtual void mouseMoveEvent(QMouseEvent *event);
|
||||
virtual void paintEvent ( QPaintEvent * event );
|
||||
virtual void contextMenuEvent(QContextMenuEvent *event);
|
||||
void addChilds(GroupViewItem* item);
|
||||
void addChildren(GroupViewItem* item);
|
||||
QPoint DragStartPos;
|
||||
GroupViewItem* DragItem;
|
||||
GroupViewItem* LastHoverItem;
|
||||
|
||||
Reference in New Issue
Block a user