add/edit/delete group (qt4-reimplementation)
git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@11 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
parent
8642ccfe94
commit
b2ae2d1d17
|
@ -32,6 +32,8 @@ CEditGroupDialog::CEditGroupDialog(QWidget* parent, const char* name, bool modal
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
IconID=0;
|
IconID=0;
|
||||||
|
connect( ButtonOK, SIGNAL( clicked() ), this, SLOT( OnOK() ) );
|
||||||
|
connect( ButtonCancel, SIGNAL( clicked() ), this, SLOT( OnCancel() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
CEditGroupDialog::~CEditGroupDialog()
|
CEditGroupDialog::~CEditGroupDialog()
|
||||||
|
@ -51,14 +53,12 @@ void CEditGroupDialog::OnOK()
|
||||||
{
|
{
|
||||||
GroupName=EditTitle->text();
|
GroupName=EditTitle->text();
|
||||||
IconID=ComboIconPicker->currentItem();
|
IconID=ComboIconPicker->currentItem();
|
||||||
OK=true;
|
done(1);
|
||||||
close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEditGroupDialog::OnCancel()
|
void CEditGroupDialog::OnCancel()
|
||||||
{
|
{
|
||||||
OK=false;
|
done(0);
|
||||||
close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,6 @@ protected slots:
|
||||||
public:
|
public:
|
||||||
int IconID;
|
int IconID;
|
||||||
QString GroupName;
|
QString GroupName;
|
||||||
bool OK;
|
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
@ -104,6 +104,8 @@ void KeepassGroupView::mouseMoveEvent(QMouseEvent *event){
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeepassGroupView::updateItems(){
|
void KeepassGroupView::updateItems(){
|
||||||
|
clear();
|
||||||
|
Items.clear();
|
||||||
for(GroupItr i=db->Groups.begin();i!=db->Groups.end();i++){
|
for(GroupItr i=db->Groups.begin();i!=db->Groups.end();i++){
|
||||||
if((*i).Level==0){
|
if((*i).Level==0){
|
||||||
if(Items.size()) Items.push_back(new GroupViewItem(this,getLastSameLevelItem(0)));
|
if(Items.size()) Items.push_back(new GroupViewItem(this,getLastSameLevelItem(0)));
|
||||||
|
|
|
@ -78,6 +78,11 @@ void KeepassMainWindow::setupConnections(){
|
||||||
connect(FileExitAction, SIGNAL(triggered()), this, SLOT(OnFileExit()));
|
connect(FileExitAction, SIGNAL(triggered()), this, SLOT(OnFileExit()));
|
||||||
connect(FileImpPwmAction, SIGNAL(triggered()), this, SLOT(OnImportFromPwm()));
|
connect(FileImpPwmAction, SIGNAL(triggered()), this, SLOT(OnImportFromPwm()));
|
||||||
connect(FileImpKWalletXmlAction, SIGNAL(triggered()), this,SLOT(OnImportFromKWalletXml()));
|
connect(FileImpKWalletXmlAction, SIGNAL(triggered()), this,SLOT(OnImportFromKWalletXml()));
|
||||||
|
|
||||||
|
connect(EditNewGroupAction, SIGNAL(triggered()), this, SLOT(OnEditNewGroup()));
|
||||||
|
connect(EditEditGroupAction, SIGNAL(triggered()), this, SLOT(OnEditEditGroup()));
|
||||||
|
connect(EditDeleteGroupAction, SIGNAL(triggered()), this, SLOT(OnEditDeleteGroup()));
|
||||||
|
|
||||||
connect(GroupView,SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),this,
|
connect(GroupView,SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),this,
|
||||||
SLOT(OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*)));
|
SLOT(OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*)));
|
||||||
connect(EntryView,SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),this,
|
connect(EntryView,SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),this,
|
||||||
|
@ -368,4 +373,43 @@ if(GroupView->selectedItems().size()==0)
|
||||||
if(GroupView->selectedItems().size()==1)
|
if(GroupView->selectedItems().size()==1)
|
||||||
setStateGroupSelected(SINGLE);
|
setStateGroupSelected(SINGLE);
|
||||||
Q_ASSERT(GroupView->selectedItems().size()<=1);
|
Q_ASSERT(GroupView->selectedItems().size()<=1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeepassMainWindow::OnEditNewGroup(){
|
||||||
|
CGroup *pNew=NULL;
|
||||||
|
if(GroupView->selectedItems().size())
|
||||||
|
pNew=db->addGroup(static_cast<GroupViewItem*>(GroupView->selectedItems()[0])->pGroup);
|
||||||
|
else
|
||||||
|
pNew=db->addGroup(NULL);
|
||||||
|
CEditGroupDialog dlg(this,"EditGroupDlg",true);
|
||||||
|
if(!dlg.exec()){
|
||||||
|
db->deleteGroup(pNew);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pNew->Name=dlg.GroupName;
|
||||||
|
pNew->ImageID=dlg.IconID;
|
||||||
|
setStateFileModified(true);
|
||||||
|
GroupView->updateItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeepassMainWindow::OnEditEditGroup(){
|
||||||
|
Q_ASSERT(GroupView->selectedItems().size());
|
||||||
|
CGroup *pGroup=static_cast<GroupViewItem*>(GroupView->selectedItems()[0])->pGroup;
|
||||||
|
CEditGroupDialog dlg(this,"EditGroupDlg",true);
|
||||||
|
dlg.GroupName=pGroup->Name;
|
||||||
|
dlg.IconID=pGroup->ImageID;
|
||||||
|
if(!dlg.exec())return;
|
||||||
|
if((pGroup->Name != dlg.GroupName) || (pGroup->ImageID != dlg.IconID)){
|
||||||
|
setStateFileModified(true);
|
||||||
|
pGroup->Name = dlg.GroupName;
|
||||||
|
pGroup->ImageID = dlg.IconID;
|
||||||
|
GroupView->updateItems();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeepassMainWindow::OnEditDeleteGroup(){
|
||||||
|
Q_ASSERT(GroupView->selectedItems().size());
|
||||||
|
CGroup *pGroup=static_cast<GroupViewItem*>(GroupView->selectedItems()[0])->pGroup;
|
||||||
|
db->deleteGroup(pGroup);
|
||||||
|
GroupView->updateItems();
|
||||||
}
|
}
|
|
@ -61,6 +61,9 @@ private slots:
|
||||||
void OnFileExit();
|
void OnFileExit();
|
||||||
void OnImportFromPwm();
|
void OnImportFromPwm();
|
||||||
void OnImportFromKWalletXml();
|
void OnImportFromKWalletXml();
|
||||||
|
void OnEditNewGroup();
|
||||||
|
void OnEditEditGroup();
|
||||||
|
void OnEditDeleteGroup();
|
||||||
void OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*);
|
void OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*);
|
||||||
void OnEntryItemDoubleClicked(QTreeWidgetItem* item,int column);
|
void OnEntryItemDoubleClicked(QTreeWidgetItem* item,int column);
|
||||||
void OnEntrySelectionChanged();
|
void OnEntrySelectionChanged();
|
||||||
|
|
Loading…
Reference in New Issue