Slightly reorganized the menubar
Added menu action to sort the groups (Bug #2268672) git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@268 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
parent
688bfe44c7
commit
dbb6e00a4a
|
@ -167,14 +167,15 @@
|
||||||
<addaction name="FileUnLockWorkspaceAction" />
|
<addaction name="FileUnLockWorkspaceAction" />
|
||||||
<addaction name="FileExitAction" />
|
<addaction name="FileExitAction" />
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuBearbeiten" >
|
<widget class="QMenu" name="menuEntries" >
|
||||||
<property name="title" >
|
<property name="title" >
|
||||||
<string>&Edit</string>
|
<string>&Entries</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="EditNewGroupAction" />
|
<addaction name="EditNewEntryAction" />
|
||||||
<addaction name="EditNewSubgroupAction" />
|
<addaction name="EditCloneEntryAction" />
|
||||||
<addaction name="EditEditGroupAction" />
|
<addaction name="EditEditEntryAction" />
|
||||||
<addaction name="EditDeleteGroupAction" />
|
<addaction name="EditDeleteEntryAction" />
|
||||||
|
<addaction name="EditAutoTypeAction" />
|
||||||
<addaction name="separator" />
|
<addaction name="separator" />
|
||||||
<addaction name="EditUsernameToClipboardAction" />
|
<addaction name="EditUsernameToClipboardAction" />
|
||||||
<addaction name="EditPasswordToClipboardAction" />
|
<addaction name="EditPasswordToClipboardAction" />
|
||||||
|
@ -182,12 +183,6 @@
|
||||||
<addaction name="EditCopyUrlAction" />
|
<addaction name="EditCopyUrlAction" />
|
||||||
<addaction name="EditSaveAttachmentAction" />
|
<addaction name="EditSaveAttachmentAction" />
|
||||||
<addaction name="separator" />
|
<addaction name="separator" />
|
||||||
<addaction name="EditNewEntryAction" />
|
|
||||||
<addaction name="EditEditEntryAction" />
|
|
||||||
<addaction name="EditCloneEntryAction" />
|
|
||||||
<addaction name="EditDeleteEntryAction" />
|
|
||||||
<addaction name="EditAutoTypeAction" />
|
|
||||||
<addaction name="separator" />
|
|
||||||
<addaction name="EditSearchAction" />
|
<addaction name="EditSearchAction" />
|
||||||
<addaction name="EditGroupSearchAction" />
|
<addaction name="EditGroupSearchAction" />
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -240,8 +235,19 @@
|
||||||
<addaction name="separator" />
|
<addaction name="separator" />
|
||||||
<addaction name="ExtrasSettingsAction" />
|
<addaction name="ExtrasSettingsAction" />
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuGroups" >
|
||||||
|
<property name="title" >
|
||||||
|
<string>&Groups</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="EditNewGroupAction" />
|
||||||
|
<addaction name="EditNewSubgroupAction" />
|
||||||
|
<addaction name="EditEditGroupAction" />
|
||||||
|
<addaction name="EditDeleteGroupAction" />
|
||||||
|
<addaction name="EditGroupSortAction" />
|
||||||
|
</widget>
|
||||||
<addaction name="menuDatei" />
|
<addaction name="menuDatei" />
|
||||||
<addaction name="menuBearbeiten" />
|
<addaction name="menuEntries" />
|
||||||
|
<addaction name="menuGroups" />
|
||||||
<addaction name="ViewMenu" />
|
<addaction name="ViewMenu" />
|
||||||
<addaction name="menuExtras" />
|
<addaction name="menuExtras" />
|
||||||
<addaction name="menuHilfe" />
|
<addaction name="menuHilfe" />
|
||||||
|
@ -593,6 +599,16 @@
|
||||||
<string>Add New Group...</string>
|
<string>Add New Group...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="EditGroupSortAction" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Sort groups</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="EditGroupSortDesc" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Sort in descending oder</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "dialogs/EditGroupDlg.h"
|
#include "dialogs/EditGroupDlg.h"
|
||||||
|
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
|
#include <QHeaderView>
|
||||||
|
|
||||||
#define INSERT_AREA_WIDTH 4
|
#define INSERT_AREA_WIDTH 4
|
||||||
|
|
||||||
|
@ -494,11 +495,47 @@ void KeepassGroupView::mouseMoveEvent(QMouseEvent *event){
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeepassGroupView::OnItemExpanded(QTreeWidgetItem* item){
|
void KeepassGroupView::OnItemExpanded(QTreeWidgetItem* item){
|
||||||
dynamic_cast<GroupViewItem*>(item)->GroupHandle->setExpanded(true);
|
static_cast<GroupViewItem*>(item)->GroupHandle->setExpanded(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeepassGroupView::OnItemCollapsed(QTreeWidgetItem* item){
|
void KeepassGroupView::OnItemCollapsed(QTreeWidgetItem* item){
|
||||||
dynamic_cast<GroupViewItem*>(item)->GroupHandle->setExpanded(false);
|
static_cast<GroupViewItem*>(item)->GroupHandle->setExpanded(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeepassGroupView::OnSort() {
|
||||||
|
QHash<QTreeWidgetItem*,int> oldIndex;
|
||||||
|
for (int i=0; i<Items.size(); i++) {
|
||||||
|
if (Items[i]->parent())
|
||||||
|
oldIndex.insert(Items[i], Items[i]->parent()->indexOfChild(Items[i]));
|
||||||
|
else
|
||||||
|
oldIndex.insert(Items[i], invisibleRootItem()->indexOfChild(Items[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
sortItems(0, Qt::AscendingOrder);
|
||||||
|
|
||||||
|
bool modified = false;
|
||||||
|
QMutableHashIterator<QTreeWidgetItem*, int> i(oldIndex);
|
||||||
|
while (i.hasNext()) {
|
||||||
|
i.next();
|
||||||
|
int newIndex;
|
||||||
|
IGroupHandle* parent;
|
||||||
|
if (i.key()->parent()) {
|
||||||
|
newIndex = i.key()->parent()->indexOfChild(i.key());
|
||||||
|
parent = static_cast<GroupViewItem*>(i.key()->parent())->GroupHandle;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
newIndex = invisibleRootItem()->indexOfChild(i.key());
|
||||||
|
parent = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newIndex != i.value()) {
|
||||||
|
db->moveGroup(static_cast<GroupViewItem*>(i.key())->GroupHandle, parent, newIndex);
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modified)
|
||||||
|
emit fileModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -518,3 +555,21 @@ GroupViewItem::GroupViewItem(QTreeWidgetItem *parent):QTreeWidgetItem(parent){
|
||||||
GroupViewItem::GroupViewItem(QTreeWidgetItem *parent, QTreeWidgetItem *preceding):QTreeWidgetItem(parent,preceding){
|
GroupViewItem::GroupViewItem(QTreeWidgetItem *parent, QTreeWidgetItem *preceding):QTreeWidgetItem(parent,preceding){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GroupViewItem::operator<(const QTreeWidgetItem& other) const {
|
||||||
|
const GroupViewItem* otherItem = static_cast<const GroupViewItem*>(&other);
|
||||||
|
KeepassGroupView* groupView = static_cast<KeepassGroupView*>(treeWidget());
|
||||||
|
|
||||||
|
// Search result is always at the bottom
|
||||||
|
if (this == groupView->SearchResultItem)
|
||||||
|
return false;
|
||||||
|
if (otherItem == groupView->SearchResultItem)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Backup group is always at the bottom but above search results
|
||||||
|
if (!parent() && text(0).compare("Backup", Qt::CaseInsensitive) == 0)
|
||||||
|
return false;
|
||||||
|
if (!otherItem->parent() && otherItem->text(0).compare("Backup", Qt::CaseInsensitive) == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return QTreeWidgetItem::operator<(other);
|
||||||
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
* Free Software Foundation, Inc., *
|
* Free Software Foundation, Inc., *
|
||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#ifndef _GROUP_VIEW_H_
|
#ifndef _GROUP_VIEW_H_
|
||||||
#define _GROUP_VIEW_H_
|
#define _GROUP_VIEW_H_
|
||||||
|
|
||||||
|
@ -71,6 +72,7 @@ class KeepassGroupView:public QTreeWidget{
|
||||||
void OnHideSearchResults();
|
void OnHideSearchResults();
|
||||||
void OnItemExpanded(QTreeWidgetItem*);
|
void OnItemExpanded(QTreeWidgetItem*);
|
||||||
void OnItemCollapsed(QTreeWidgetItem*);
|
void OnItemCollapsed(QTreeWidgetItem*);
|
||||||
|
void OnSort();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void groupChanged(IGroupHandle* NewGroup);
|
void groupChanged(IGroupHandle* NewGroup);
|
||||||
|
@ -87,6 +89,7 @@ class GroupViewItem:public QTreeWidgetItem{
|
||||||
GroupViewItem(QTreeWidget *parent, QTreeWidgetItem * preceding);
|
GroupViewItem(QTreeWidget *parent, QTreeWidgetItem * preceding);
|
||||||
GroupViewItem(QTreeWidgetItem *parent);
|
GroupViewItem(QTreeWidgetItem *parent);
|
||||||
GroupViewItem(QTreeWidgetItem *parent, QTreeWidgetItem * preceding);
|
GroupViewItem(QTreeWidgetItem *parent, QTreeWidgetItem * preceding);
|
||||||
|
bool operator<(const QTreeWidgetItem& other) const;
|
||||||
IGroupHandle* GroupHandle;
|
IGroupHandle* GroupHandle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -152,6 +152,7 @@ void KeepassMainWindow::setupConnections(){
|
||||||
connect(EditNewSubgroupAction, SIGNAL(triggered()), GroupView, SLOT(OnNewSubgroup()));
|
connect(EditNewSubgroupAction, SIGNAL(triggered()), GroupView, SLOT(OnNewSubgroup()));
|
||||||
connect(EditEditGroupAction, SIGNAL(triggered()), GroupView, SLOT(OnEditGroup()));
|
connect(EditEditGroupAction, SIGNAL(triggered()), GroupView, SLOT(OnEditGroup()));
|
||||||
connect(EditDeleteGroupAction, SIGNAL(triggered()), GroupView, SLOT(OnDeleteGroup()));
|
connect(EditDeleteGroupAction, SIGNAL(triggered()), GroupView, SLOT(OnDeleteGroup()));
|
||||||
|
connect(EditGroupSortAction, SIGNAL(triggered()), GroupView, SLOT(OnSort()));
|
||||||
connect(EditNewEntryAction, SIGNAL(triggered()), EntryView, SLOT(OnNewEntry()));
|
connect(EditNewEntryAction, SIGNAL(triggered()), EntryView, SLOT(OnNewEntry()));
|
||||||
connect(EditEditEntryAction, SIGNAL(triggered()), EntryView, SLOT(OnEditEntry()));
|
connect(EditEditEntryAction, SIGNAL(triggered()), EntryView, SLOT(OnEditEntry()));
|
||||||
connect(EntryView, SIGNAL(requestCreateGroup(QString,quint32,GroupViewItem*)), GroupView, SLOT(createGroup(QString,quint32,GroupViewItem*)));
|
connect(EntryView, SIGNAL(requestCreateGroup(QString,quint32,GroupViewItem*)), GroupView, SLOT(createGroup(QString,quint32,GroupViewItem*)));
|
||||||
|
@ -243,6 +244,7 @@ void KeepassMainWindow::setupIcons(){
|
||||||
EditNewEntryAction->setIcon(getIcon("newentry"));
|
EditNewEntryAction->setIcon(getIcon("newentry"));
|
||||||
EditEditEntryAction->setIcon(getIcon("editentry"));
|
EditEditEntryAction->setIcon(getIcon("editentry"));
|
||||||
EditDeleteEntryAction->setIcon(getIcon("deleteentry"));
|
EditDeleteEntryAction->setIcon(getIcon("deleteentry"));
|
||||||
|
EditGroupSortAction->setIcon(getIcon("swap"));
|
||||||
EditUsernameToClipboardAction->setIcon(getIcon("copyusername"));
|
EditUsernameToClipboardAction->setIcon(getIcon("copyusername"));
|
||||||
EditPasswordToClipboardAction->setIcon(getIcon("copypwd"));
|
EditPasswordToClipboardAction->setIcon(getIcon("copypwd"));
|
||||||
EditCloneEntryAction->setIcon(getIcon("cloneentry"));
|
EditCloneEntryAction->setIcon(getIcon("cloneentry"));
|
||||||
|
@ -278,6 +280,7 @@ void KeepassMainWindow::setupMenus(){
|
||||||
GroupView->ContextMenu->addAction(EditNewSubgroupAction);
|
GroupView->ContextMenu->addAction(EditNewSubgroupAction);
|
||||||
GroupView->ContextMenu->addAction(EditEditGroupAction);
|
GroupView->ContextMenu->addAction(EditEditGroupAction);
|
||||||
GroupView->ContextMenu->addAction(EditDeleteGroupAction);
|
GroupView->ContextMenu->addAction(EditDeleteGroupAction);
|
||||||
|
GroupView->ContextMenu->addAction(EditGroupSortAction);
|
||||||
GroupView->ContextMenu->addSeparator();
|
GroupView->ContextMenu->addSeparator();
|
||||||
GroupView->ContextMenu->addAction(EditNewEntryAction);
|
GroupView->ContextMenu->addAction(EditNewEntryAction);
|
||||||
GroupView->ContextMenu->addSeparator();
|
GroupView->ContextMenu->addSeparator();
|
||||||
|
|
Loading…
Reference in New Issue