completed drag&drop stuff,
moved column configuration to QSettings, improved column handling and resizing behavior, column order is now remembered after a restart, added group column. git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@127 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
parent
11b33969d8
commit
6cae658d24
|
@ -115,65 +115,6 @@
|
||||||
<height>29</height>
|
<height>29</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuBearbeiten" >
|
|
||||||
<property name="title" >
|
|
||||||
<string>&Edit</string>
|
|
||||||
</property>
|
|
||||||
<addaction name="EditNewGroupAction" />
|
|
||||||
<addaction name="EditEditGroupAction" />
|
|
||||||
<addaction name="EditDeleteGroupAction" />
|
|
||||||
<addaction name="separator" />
|
|
||||||
<addaction name="EditPasswordToClipboardAction" />
|
|
||||||
<addaction name="EditUsernameToClipboardAction" />
|
|
||||||
<addaction name="EditOpenUrlAction" />
|
|
||||||
<addaction name="EditSaveAttachmentAction" />
|
|
||||||
<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="EditGroupSearchAction" />
|
|
||||||
</widget>
|
|
||||||
<widget class="QMenu" name="ViewMenu" >
|
|
||||||
<property name="title" >
|
|
||||||
<string>&View</string>
|
|
||||||
</property>
|
|
||||||
<widget class="QMenu" name="menuSpalten" >
|
|
||||||
<property name="title" >
|
|
||||||
<string>Columns</string>
|
|
||||||
</property>
|
|
||||||
<addaction name="ViewColumnsTitleAction" />
|
|
||||||
<addaction name="ViewColumnsUsernameAction" />
|
|
||||||
<addaction name="ViewColumnsUrlAction" />
|
|
||||||
<addaction name="ViewColumnsPasswordAction" />
|
|
||||||
<addaction name="ViewColumnsCommentAction" />
|
|
||||||
<addaction name="separator" />
|
|
||||||
<addaction name="ViewColumnsExpireAction" />
|
|
||||||
<addaction name="ViewColumnsCreationAction" />
|
|
||||||
<addaction name="ViewColumnsLastChangeAction" />
|
|
||||||
<addaction name="ViewColumnsLastAccessAction" />
|
|
||||||
<addaction name="ViewColumnsAttachmentAction" />
|
|
||||||
</widget>
|
|
||||||
<widget class="QMenu" name="menuTool_Button_Sizes" >
|
|
||||||
<property name="title" >
|
|
||||||
<string>Toolbar Icon Size</string>
|
|
||||||
</property>
|
|
||||||
<addaction name="ViewToolButtonSize16Action" />
|
|
||||||
<addaction name="ViewToolButtonSize22Action" />
|
|
||||||
<addaction name="ViewToolButtonSize28Action" />
|
|
||||||
</widget>
|
|
||||||
<addaction name="ViewShowEntryDetailsAction" />
|
|
||||||
<addaction name="ViewShowStatusbarAction" />
|
|
||||||
<addaction name="separator" />
|
|
||||||
<addaction name="ViewHideUsernamesAction" />
|
|
||||||
<addaction name="ViewHidePasswordsAction" />
|
|
||||||
<addaction name="separator" />
|
|
||||||
<addaction name="menuSpalten" />
|
|
||||||
<addaction name="menuTool_Button_Sizes" />
|
|
||||||
</widget>
|
|
||||||
<widget class="QMenu" name="menuHilfe" >
|
<widget class="QMenu" name="menuHilfe" >
|
||||||
<property name="title" >
|
<property name="title" >
|
||||||
<string>&Help</string>
|
<string>&Help</string>
|
||||||
|
@ -218,6 +159,67 @@
|
||||||
<addaction name="separator" />
|
<addaction name="separator" />
|
||||||
<addaction name="FileExitAction" />
|
<addaction name="FileExitAction" />
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuBearbeiten" >
|
||||||
|
<property name="title" >
|
||||||
|
<string>&Edit</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="EditNewGroupAction" />
|
||||||
|
<addaction name="EditEditGroupAction" />
|
||||||
|
<addaction name="EditDeleteGroupAction" />
|
||||||
|
<addaction name="separator" />
|
||||||
|
<addaction name="EditPasswordToClipboardAction" />
|
||||||
|
<addaction name="EditUsernameToClipboardAction" />
|
||||||
|
<addaction name="EditOpenUrlAction" />
|
||||||
|
<addaction name="EditSaveAttachmentAction" />
|
||||||
|
<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="EditGroupSearchAction" />
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="ViewMenu" >
|
||||||
|
<property name="title" >
|
||||||
|
<string>&View</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QMenu" name="menuTool_Button_Sizes" >
|
||||||
|
<property name="title" >
|
||||||
|
<string>Toolbar Icon Size</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="ViewToolButtonSize16Action" />
|
||||||
|
<addaction name="ViewToolButtonSize22Action" />
|
||||||
|
<addaction name="ViewToolButtonSize28Action" />
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuColumns" >
|
||||||
|
<property name="title" >
|
||||||
|
<string>Columns</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="ViewColumnsGroupAction" />
|
||||||
|
<addaction name="separator" />
|
||||||
|
<addaction name="ViewColumnsTitleAction" />
|
||||||
|
<addaction name="ViewColumnsUsernameAction" />
|
||||||
|
<addaction name="ViewColumnsUrlAction" />
|
||||||
|
<addaction name="ViewColumnsPasswordAction" />
|
||||||
|
<addaction name="ViewColumnsCommentAction" />
|
||||||
|
<addaction name="separator" />
|
||||||
|
<addaction name="ViewColumnsExpireAction" />
|
||||||
|
<addaction name="ViewColumnsCreationAction" />
|
||||||
|
<addaction name="ViewColumnsLastChangeAction" />
|
||||||
|
<addaction name="ViewColumnsLastAccessAction" />
|
||||||
|
<addaction name="ViewColumnsAttachmentAction" />
|
||||||
|
</widget>
|
||||||
|
<addaction name="ViewShowEntryDetailsAction" />
|
||||||
|
<addaction name="ViewShowStatusbarAction" />
|
||||||
|
<addaction name="separator" />
|
||||||
|
<addaction name="ViewHideUsernamesAction" />
|
||||||
|
<addaction name="ViewHidePasswordsAction" />
|
||||||
|
<addaction name="separator" />
|
||||||
|
<addaction name="menuColumns" />
|
||||||
|
<addaction name="menuTool_Button_Sizes" />
|
||||||
|
</widget>
|
||||||
<addaction name="menuDatei" />
|
<addaction name="menuDatei" />
|
||||||
<addaction name="menuBearbeiten" />
|
<addaction name="menuBearbeiten" />
|
||||||
<addaction name="ViewMenu" />
|
<addaction name="ViewMenu" />
|
||||||
|
@ -505,18 +507,29 @@
|
||||||
<string>Password Generator...</string>
|
<string>Password Generator...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="ViewColumnsGroupAction" >
|
||||||
|
<property name="checkable" >
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked" >
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Group (search results only)</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
|
||||||
<class>KeepassEntryView</class>
|
|
||||||
<extends>QTreeWidget</extends>
|
|
||||||
<header>../../src/lib/EntryView.h</header>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>KeepassGroupView</class>
|
<class>KeepassGroupView</class>
|
||||||
<extends>QTreeWidget</extends>
|
<extends>QTreeWidget</extends>
|
||||||
<header>../../src/lib/GroupView.h</header>
|
<header>../../src/lib/GroupView.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>KeepassEntryView</class>
|
||||||
|
<extends>QTreeWidget</extends>
|
||||||
|
<header>../../src/lib/EntryView.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Copyright (C) 2005-2006 by Tarek Saidi *
|
* Copyright (C) 2005-2007 by Tarek Saidi *
|
||||||
* tarek.saidi@arcor.de *
|
* tarek.saidi@arcor.de *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
@ -36,31 +36,71 @@
|
||||||
#include "lib/AutoType.h"
|
#include "lib/AutoType.h"
|
||||||
|
|
||||||
|
|
||||||
|
// just for the lessThan funtion
|
||||||
|
QList<EntryViewItem*>* pItems;
|
||||||
|
KeepassEntryView* pEntryView;
|
||||||
|
|
||||||
KeepassEntryView::KeepassEntryView(QWidget* parent):QTreeWidget(parent){
|
KeepassEntryView::KeepassEntryView(QWidget* parent):QTreeWidget(parent){
|
||||||
AutoResizeColumns=true;
|
AutoResizeColumns=true;
|
||||||
int sum=0;
|
|
||||||
for(int i=0;i<NUM_COLUMNS;i++)
|
|
||||||
sum+=config.ColumnSizes[i];
|
|
||||||
for(int i=0;i<NUM_COLUMNS;i++)
|
|
||||||
ColumnSizes << (float)config.ColumnSizes[i]/(float)sum;
|
|
||||||
updateColumns();
|
|
||||||
header()->setResizeMode(QHeaderView::Interactive);
|
header()->setResizeMode(QHeaderView::Interactive);
|
||||||
header()->setStretchLastSection(false);
|
header()->setStretchLastSection(false);
|
||||||
header()->setClickable(true);
|
header()->setClickable(true);
|
||||||
|
header()->setCascadingSectionResizes(true);
|
||||||
|
ColumnSizes.resize(NUM_COLUMNS);
|
||||||
|
QStringList ColumnSizeConfig=settings->value("Ui/ColumnSizes",QStringList()<<"1"<<"1"<<"1"<<"1"<<"1"<<"1"<<"1"<<"1"<<"1"<<"1"<<"1").toStringList();
|
||||||
|
for(int i=0;i<NUM_COLUMNS;i++)
|
||||||
|
ColumnSizes[i]=(float)ColumnSizeConfig[i].toInt();
|
||||||
|
QStringList DefaultColumnConfig=QStringList()<<"1"<<"1"<<"1"<<"1"<<"1"<<"0"<<"0"<<"0"<<"0"<<"0"<<"1";
|
||||||
|
QStringList ColumnConfig=settings->value("Ui/ShowColumns",DefaultColumnConfig).toStringList();
|
||||||
|
Columns.resize(NUM_COLUMNS);
|
||||||
|
if(ColumnConfig.size()<NUM_COLUMNS)ColumnConfig=DefaultColumnConfig;
|
||||||
|
for(int i=0;i<ColumnConfig.size();i++){
|
||||||
|
Columns[i]=(bool)ColumnConfig[i].toInt();
|
||||||
|
}
|
||||||
|
ColumnOrder.resize(NUM_COLUMNS);
|
||||||
|
QStringList ColumnOrderConfig=settings->value("Ui/ColumnOrder",QStringList()<<"100"<<"100"<<"100"<<"100"<<"100"<<"100"<<"100"<<"100"<<"100"<<"100"<<"100").toStringList();
|
||||||
|
for(int i=0;i<NUM_COLUMNS;i++){
|
||||||
|
if(i<ColumnOrderConfig.size()){
|
||||||
|
ColumnOrder[i]=ColumnOrderConfig[i].toInt();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ColumnOrder[i]=100;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateColumns();
|
||||||
|
|
||||||
connect(header(),SIGNAL(sectionResized(int,int,int)),this,SLOT(OnColumnResized(int,int,int)));
|
connect(header(),SIGNAL(sectionResized(int,int,int)),this,SLOT(OnColumnResized(int,int,int)));
|
||||||
connect(this,SIGNAL(itemSelectionChanged()),this,SLOT(OnItemsChanged()));
|
connect(this,SIGNAL(itemSelectionChanged()),this,SLOT(OnItemsChanged()));
|
||||||
connect(&ClipboardTimer, SIGNAL(timeout()), this, SLOT(OnClipboardTimeOut()));
|
connect(&ClipboardTimer, SIGNAL(timeout()), this, SLOT(OnClipboardTimeOut()));
|
||||||
connect(header(),SIGNAL(sectionClicked(int)),this,SLOT(OnHeaderSectionClicked(int)));
|
connect(header(),SIGNAL(sectionClicked(int)),this,SLOT(OnHeaderSectionClicked(int)));
|
||||||
|
connect(header(),SIGNAL(sectionMoved(int,int,int)),this,SLOT(OnColumnMoved(int,int,int)));
|
||||||
Clipboard=QApplication::clipboard();
|
Clipboard=QApplication::clipboard();
|
||||||
ContextMenu=new QMenu(this);
|
ContextMenu=new QMenu(this);
|
||||||
setAlternatingRowColors(config.AlternatingRowColors);
|
setAlternatingRowColors(config.AlternatingRowColors);
|
||||||
|
|
||||||
|
pItems=&Items;
|
||||||
|
pEntryView=this;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeepassEntryView::~KeepassEntryView(){
|
KeepassEntryView::~KeepassEntryView(){
|
||||||
|
QStringList ColumnSizesConfig;
|
||||||
for(int i=0;i<ColumnSizes.size();i++){
|
for(int i=0;i<ColumnSizes.size();i++){
|
||||||
config.ColumnSizes[i]=(int)(ColumnSizes[i]*10000.0f);
|
ColumnSizesConfig<<QString::number((int)(ColumnSizes[i]));
|
||||||
}
|
}
|
||||||
|
settings->setValue("Ui/ColumnSizes",ColumnSizesConfig);
|
||||||
|
QStringList ColumnConfig;
|
||||||
|
for(int i=0;i<Columns.size();i++){
|
||||||
|
if(Columns[i])
|
||||||
|
ColumnConfig<<"1";
|
||||||
|
else
|
||||||
|
ColumnConfig<<"0";
|
||||||
|
}
|
||||||
|
settings->setValue("Ui/ShowColumns",ColumnConfig);
|
||||||
|
QStringList ColumnOrderConfig;
|
||||||
|
for(int i=0;i<NUM_COLUMNS;i++){
|
||||||
|
ColumnOrderConfig << QString::number(ColumnOrder[i]);
|
||||||
|
}
|
||||||
|
settings->setValue("Ui/ColumnOrder",ColumnOrderConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeepassEntryView::OnGroupChanged(IGroupHandle* group){
|
void KeepassEntryView::OnGroupChanged(IGroupHandle* group){
|
||||||
|
@ -84,6 +124,19 @@ void KeepassEntryView::OnItemsChanged(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool sortSearchResultsLessThan(const IEntryHandle* a, const IEntryHandle* b){
|
||||||
|
int indexA=0;
|
||||||
|
int indexB=0;
|
||||||
|
for(indexA;indexA<pItems->size();indexA++){
|
||||||
|
if((*pItems)[indexA]->EntryHandle==a)break;
|
||||||
|
}
|
||||||
|
for(indexB;indexB<pItems->size();indexB++){
|
||||||
|
if((*pItems)[indexB]->EntryHandle==b)break;
|
||||||
|
}
|
||||||
|
return pEntryView->indexOfTopLevelItem((*pItems)[indexA])<pEntryView->indexOfTopLevelItem((*pItems)[indexB]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void KeepassEntryView::OnHeaderSectionClicked(int index){
|
void KeepassEntryView::OnHeaderSectionClicked(int index){
|
||||||
if(header()->isSortIndicatorShown() && header()->sortIndicatorSection()==index){
|
if(header()->isSortIndicatorShown() && header()->sortIndicatorSection()==index){
|
||||||
header()->setSortIndicator(index,header()->sortIndicatorOrder() ? Qt::DescendingOrder : Qt::AscendingOrder);
|
header()->setSortIndicator(index,header()->sortIndicatorOrder() ? Qt::DescendingOrder : Qt::AscendingOrder);
|
||||||
|
@ -94,9 +147,18 @@ void KeepassEntryView::OnHeaderSectionClicked(int index){
|
||||||
header()->setSortIndicatorShown(true);
|
header()->setSortIndicatorShown(true);
|
||||||
sortItems(index,Qt::AscendingOrder);
|
sortItems(index,Qt::AscendingOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i=0;i<Items.size();i++){
|
if(ViewMode==Normal){
|
||||||
Items[i]->EntryHandle->setVisualIndexDirectly(indexOfTopLevelItem(Items[i]));
|
for(int i=0;i<Items.size();i++){
|
||||||
|
Items[i]->EntryHandle->setVisualIndexDirectly(indexOfTopLevelItem(Items[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(ViewMode==ShowSearchResults){
|
||||||
|
if(header()->sortIndicatorOrder()==Qt::AscendingOrder)
|
||||||
|
qSort(SearchResults.begin(),SearchResults.end(),sortSearchResultsLessThan);
|
||||||
|
else
|
||||||
|
qSort(SearchResults.end(),SearchResults.begin(),sortSearchResultsLessThan);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,14 +193,17 @@ void KeepassEntryView::OnDeleteEntry(){
|
||||||
void KeepassEntryView::updateEntry(EntryViewItem* item){
|
void KeepassEntryView::updateEntry(EntryViewItem* item){
|
||||||
IEntryHandle* entry = item->EntryHandle;
|
IEntryHandle* entry = item->EntryHandle;
|
||||||
int j=0;
|
int j=0;
|
||||||
if(config.Columns[0])item->setText(j++,entry->title());
|
if(Columns[0]){
|
||||||
if(config.Columns[1]){
|
item->setText(j++,entry->title());
|
||||||
|
item->setIcon(0,db->icon(entry->image()));
|
||||||
|
}
|
||||||
|
if(Columns[1]){
|
||||||
if(config.ListView_HideUsernames)
|
if(config.ListView_HideUsernames)
|
||||||
item->setText(j++,"******");
|
item->setText(j++,"******");
|
||||||
else
|
else
|
||||||
item->setText(j++,entry->username());}
|
item->setText(j++,entry->username());}
|
||||||
if(config.Columns[2]){item->setText(j++,entry->url());}
|
if(Columns[2]){item->setText(j++,entry->url());}
|
||||||
if(config.Columns[3]){
|
if(Columns[3]){
|
||||||
if(config.ListView_HidePasswords)
|
if(config.ListView_HidePasswords)
|
||||||
item->setText(j++,"******");
|
item->setText(j++,"******");
|
||||||
else{
|
else{
|
||||||
|
@ -147,19 +212,21 @@ void KeepassEntryView::updateEntry(EntryViewItem* item){
|
||||||
item->setText(j++,password.string());
|
item->setText(j++,password.string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(config.Columns[4]){
|
if(Columns[4]){
|
||||||
item->setText(j++,entry->comment().section('\n',0,0));}
|
item->setText(j++,entry->comment().section('\n',0,0));}
|
||||||
if(config.Columns[5]){
|
if(Columns[5]){
|
||||||
item->setText(j++,entry->expire().dateToString(Qt::LocalDate));}
|
item->setText(j++,entry->expire().dateToString(Qt::LocalDate));}
|
||||||
if(config.Columns[6]){
|
if(Columns[6]){
|
||||||
item->setText(j++,entry->creation().dateToString(Qt::LocalDate));}
|
item->setText(j++,entry->creation().dateToString(Qt::LocalDate));}
|
||||||
if(config.Columns[7]){
|
if(Columns[7]){
|
||||||
item->setText(j++,entry->lastMod().dateToString(Qt::LocalDate));}
|
item->setText(j++,entry->lastMod().dateToString(Qt::LocalDate));}
|
||||||
if(config.Columns[8]){
|
if(Columns[8]){
|
||||||
item->setText(j++,entry->lastAccess().dateToString(Qt::LocalDate));}
|
item->setText(j++,entry->lastAccess().dateToString(Qt::LocalDate));}
|
||||||
if(config.Columns[9]){
|
if(Columns[9]){
|
||||||
item->setText(j++,entry->binaryDesc());}
|
item->setText(j++,entry->binaryDesc());}
|
||||||
item->setIcon(0,db->icon(entry->image()));
|
if(Columns[10]){
|
||||||
|
item->setText(j,entry->group()->title());
|
||||||
|
item->setIcon(j++,db->icon(entry->group()->image()));}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeepassEntryView::editEntry(EntryViewItem* item){
|
void KeepassEntryView::editEntry(EntryViewItem* item){
|
||||||
|
@ -272,13 +339,15 @@ void KeepassEntryView::resizeEvent(QResizeEvent* e){
|
||||||
|
|
||||||
|
|
||||||
void KeepassEntryView::showSearchResults(){
|
void KeepassEntryView::showSearchResults(){
|
||||||
|
ViewMode=ShowSearchResults;
|
||||||
clear();
|
clear();
|
||||||
Items.clear();
|
Items.clear();
|
||||||
createItems(SearchResults);
|
createItems(SearchResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void KeepassEntryView::showGroup(IGroupHandle* group){
|
void KeepassEntryView::showGroup(IGroupHandle* group){
|
||||||
|
ViewMode=Normal;
|
||||||
clear();
|
clear();
|
||||||
Items.clear();
|
Items.clear();
|
||||||
if(group==NULL)return;
|
if(group==NULL)return;
|
||||||
|
@ -294,14 +363,16 @@ void KeepassEntryView::createItems(QList<IEntryHandle*>& entries){
|
||||||
Items.push_back(item);
|
Items.push_back(item);
|
||||||
Items.back()->EntryHandle=entries[i];
|
Items.back()->EntryHandle=entries[i];
|
||||||
int j=0;
|
int j=0;
|
||||||
if(config.Columns[0])item->setText(j++,entries[i]->title());
|
if(Columns[0]){
|
||||||
if(config.Columns[1]){
|
item->setText(j++,entries[i]->title());
|
||||||
|
item->setIcon(0,db->icon(entries[i]->image()));}
|
||||||
|
if(Columns[1]){
|
||||||
if(config.ListView_HideUsernames)
|
if(config.ListView_HideUsernames)
|
||||||
item->setText(j++,"******");
|
item->setText(j++,"******");
|
||||||
else
|
else
|
||||||
item->setText(j++,entries[i]->username());}
|
item->setText(j++,entries[i]->username());}
|
||||||
if(config.Columns[2]){item->setText(j++,entries[i]->url());}
|
if(Columns[2]){item->setText(j++,entries[i]->url());}
|
||||||
if(config.Columns[3]){
|
if(Columns[3]){
|
||||||
if(config.ListView_HidePasswords)
|
if(config.ListView_HidePasswords)
|
||||||
item->setText(j++,"******");
|
item->setText(j++,"******");
|
||||||
else{
|
else{
|
||||||
|
@ -310,20 +381,21 @@ void KeepassEntryView::createItems(QList<IEntryHandle*>& entries){
|
||||||
item->setText(j++,password.string());
|
item->setText(j++,password.string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(config.Columns[4]){
|
if(Columns[4]){
|
||||||
item->setText(j++,entries[i]->comment().section('\n',0,0));}
|
item->setText(j++,entries[i]->comment().section('\n',0,0));}
|
||||||
if(config.Columns[5]){
|
if(Columns[5]){
|
||||||
item->setText(j++,entries[i]->expire().dateToString(Qt::LocalDate));}
|
item->setText(j++,entries[i]->expire().dateToString(Qt::LocalDate));}
|
||||||
if(config.Columns[6]){
|
if(Columns[6]){
|
||||||
item->setText(j++,entries[i]->creation().dateToString(Qt::LocalDate));}
|
item->setText(j++,entries[i]->creation().dateToString(Qt::LocalDate));}
|
||||||
if(config.Columns[7]){
|
if(Columns[7]){
|
||||||
item->setText(j++,entries[i]->lastMod().dateToString(Qt::LocalDate));}
|
item->setText(j++,entries[i]->lastMod().dateToString(Qt::LocalDate));}
|
||||||
if(config.Columns[8]){
|
if(Columns[8]){
|
||||||
item->setText(j++,entries[i]->lastAccess().dateToString(Qt::LocalDate));}
|
item->setText(j++,entries[i]->lastAccess().dateToString(Qt::LocalDate));}
|
||||||
if(config.Columns[9]){
|
if(Columns[9]){
|
||||||
item->setText(j++,entries[i]->binaryDesc());}
|
item->setText(j++,entries[i]->binaryDesc());}
|
||||||
Items.back()->setIcon(0,db->icon(entries[i]->image()));
|
if(Columns[10]){
|
||||||
qDebug("%s : %i",entries[i]->title().toUtf8().data(),entries[i]->visualIndex());
|
item->setText(j,entries[i]->group()->title());
|
||||||
|
item->setIcon(j++,db->icon(entries[i]->group()->image()));}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,205 +409,163 @@ void KeepassEntryView::updateIcons(){
|
||||||
void KeepassEntryView::setEntry(IEntryHandle* entry){
|
void KeepassEntryView::setEntry(IEntryHandle* entry){
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
void KeepassEntryView::refreshItems(){
|
|
||||||
EntryViewItem *tmp=NULL;
|
|
||||||
for(int i=0;i<Items.size();i++){
|
|
||||||
tmp=Items[i];
|
|
||||||
IEntryHandle* entry=tmp->pEntry;
|
|
||||||
|
|
||||||
int j=0;
|
|
||||||
if(config.Columns[0]){
|
|
||||||
tmp->setText(j++,entry->Title);}
|
|
||||||
if(config.Columns[1]){
|
|
||||||
if(config.ListView_HideUsernames)
|
|
||||||
tmp->setText(j++,"******");
|
|
||||||
else
|
|
||||||
tmp->setText(j++,entry->UserName);}
|
|
||||||
if(config.Columns[2]){
|
|
||||||
tmp->setText(j++,entry->URL);}
|
|
||||||
if(config.Columns[3]){
|
|
||||||
if(config.ListView_HidePasswords)
|
|
||||||
tmp->setText(j++,"******");
|
|
||||||
else{
|
|
||||||
entry->Password.unlock();
|
|
||||||
tmp->setText(j++,entry->Password.string());
|
|
||||||
entry->Password.lock();}}
|
|
||||||
if(config.Columns[4]){
|
|
||||||
tmp->setText(j++,entry->Additional.section('\n',0,0));}
|
|
||||||
if(config.Columns[5]){
|
|
||||||
tmp->setText(j++,entry->Expire.dateToString(Qt::LocalDate));}
|
|
||||||
if(config.Columns[6]){
|
|
||||||
tmp->setText(j++,entry->Creation.dateToString(Qt::LocalDate));}
|
|
||||||
if(config.Columns[7]){
|
|
||||||
tmp->setText(j++,entry->LastMod.dateToString(Qt::LocalDate));}
|
|
||||||
if(config.Columns[8]){
|
|
||||||
tmp->setText(j++,entry->LastAccess.dateToString(Qt::LocalDate));}
|
|
||||||
if(config.Columns[9]){
|
|
||||||
tmp->setText(j++,entry->BinaryDesc);}
|
|
||||||
tmp->setIcon(0,db->icon(entry->ImageID));
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
void KeepassEntryView::updateColumns(){
|
void KeepassEntryView::updateColumns(){
|
||||||
setColumnCount(0);
|
setColumnCount(0);
|
||||||
QStringList cols;
|
QStringList cols;
|
||||||
if(config.Columns[0]){
|
if(Columns[0]){
|
||||||
cols << tr("Title");}
|
cols << tr("Title");}
|
||||||
if(config.Columns[1]){
|
if(Columns[1]){
|
||||||
cols << tr("Username");}
|
cols << tr("Username");}
|
||||||
if(config.Columns[2]){
|
if(Columns[2]){
|
||||||
cols << tr("URL");}
|
cols << tr("URL");}
|
||||||
if(config.Columns[3]){
|
if(Columns[3]){
|
||||||
cols << tr("Password");}
|
cols << tr("Password");}
|
||||||
if(config.Columns[4]){
|
if(Columns[4]){
|
||||||
cols << tr("Comments");}
|
cols << tr("Comments");}
|
||||||
if(config.Columns[5]){
|
if(Columns[5]){
|
||||||
cols << tr("Expires");}
|
cols << tr("Expires");}
|
||||||
if(config.Columns[6]){
|
if(Columns[6]){
|
||||||
cols << tr("Creation");}
|
cols << tr("Creation");}
|
||||||
if(config.Columns[7]){
|
if(Columns[7]){
|
||||||
cols << tr("Last Change");}
|
cols << tr("Last Change");}
|
||||||
if(config.Columns[8]){
|
if(Columns[8]){
|
||||||
cols << tr("Last Access");}
|
cols << tr("Last Access");}
|
||||||
if(config.Columns[9]){
|
if(Columns[9]){
|
||||||
cols << tr("Attachment");}
|
cols << tr("Attachment");}
|
||||||
|
if(Columns[10]){
|
||||||
|
cols << tr("Group");}
|
||||||
setHeaderLabels(cols);
|
setHeaderLabels(cols);
|
||||||
|
|
||||||
|
QMap<int,int> Order;
|
||||||
|
for(int i=NUM_COLUMNS-1;i>=0;i--)
|
||||||
|
Order.insertMulti(ColumnOrder[i],i);
|
||||||
|
|
||||||
|
QMapIterator<int, int> i(Order);
|
||||||
|
while (i.hasNext()) {
|
||||||
|
i.next();
|
||||||
|
int index=i.value();
|
||||||
|
if(!Columns[index])continue;
|
||||||
|
header()->moveSection(header()->visualIndex(logicalColIndex(index)),header()->count()-1);
|
||||||
|
}
|
||||||
|
|
||||||
resizeColumns();
|
resizeColumns();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeepassEntryView::resizeColumns(){
|
void KeepassEntryView::OnColumnMoved(int LogIndex,int OldVisIndex,int NewVisIndex){
|
||||||
AutoResizeColumns=false;
|
for(int i=0;i<header()->count();i++){
|
||||||
if(!header()->count())return;
|
ColumnOrder[columnListIndex(header()->logicalIndex(i))]=i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(int i=0;i<NUM_COLUMNS;i++)
|
int KeepassEntryView::logicalColIndex(int LstIndex){
|
||||||
if(!config.Columns[i])ColumnSizes[i]=0;
|
qDebug("%i",LstIndex);
|
||||||
|
int c=-1;
|
||||||
for(int i=0;i<NUM_COLUMNS;i++)
|
for(int i=0;i<NUM_COLUMNS;i++){
|
||||||
if(config.Columns[i] && ColumnSizes[i]==0)ColumnSizes[i]=0.1f;
|
if(Columns[i])c++;
|
||||||
|
if(i==LstIndex)return c;
|
||||||
float sum=0;
|
|
||||||
for(int i=0;i<NUM_COLUMNS;i++)
|
|
||||||
sum+=ColumnSizes[i];
|
|
||||||
|
|
||||||
for(int i=0;i<NUM_COLUMNS;i++)
|
|
||||||
ColumnSizes[i]/=sum;
|
|
||||||
|
|
||||||
int w=viewport()->width();
|
|
||||||
int wx=0; int j=0;
|
|
||||||
|
|
||||||
|
|
||||||
for(int i=0;i<NUM_COLUMNS;i++){
|
|
||||||
if(!config.Columns[i])continue;
|
|
||||||
int NewWidth=(int)(ColumnSizes[i]*(float)w);
|
|
||||||
wx+=NewWidth;
|
|
||||||
header()->resizeSection(j++,NewWidth);
|
|
||||||
//add rounding difference (w-wx) to the last column
|
|
||||||
if(j==header()->count()){
|
|
||||||
header()->resizeSection(j-1,header()->sectionSize(j-1)+(w-wx));
|
|
||||||
}
|
}
|
||||||
|
Q_ASSERT(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoResizeColumns=true;
|
void KeepassEntryView::resizeColumns(){
|
||||||
|
AutoResizeColumns=false;
|
||||||
}
|
int w=viewport()->width();
|
||||||
|
int sum=0;
|
||||||
|
for(int i=0;i<header()->count();i++){
|
||||||
void KeepassEntryView::OnColumnResized(int index,int Old, int New){
|
sum+=ColumnSizes[columnListIndex(i)];
|
||||||
if(!AutoResizeColumns)return;
|
|
||||||
|
|
||||||
int i=0; int c=-1;
|
|
||||||
for(i;i<ColumnSizes.size();i++){
|
|
||||||
if(config.Columns[i])c++;
|
|
||||||
if(c==index)break;
|
|
||||||
}
|
|
||||||
|
|
||||||
int j=0; c=-1; bool IsLastColumn=true;
|
|
||||||
for(j;j<ColumnSizes.size();j++){
|
|
||||||
if(config.Columns[j])c++;
|
|
||||||
if(c==(index+1)){IsLastColumn=false; break;}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(IsLastColumn){
|
|
||||||
j=0; c=-1;
|
|
||||||
for(j;j<ColumnSizes.size();j++){
|
|
||||||
if(config.Columns[j])c++;
|
|
||||||
if(c==(index-1))break;
|
|
||||||
}
|
}
|
||||||
|
float stretch=((float)w)/((float)sum);
|
||||||
|
sum=0;
|
||||||
|
for(int i=0;i<header()->count();i++){
|
||||||
|
int lstIndex=columnListIndex(header()->logicalIndex(i));
|
||||||
|
int NewSize=qRound(stretch*(float)ColumnSizes[lstIndex]);
|
||||||
|
sum+=NewSize;
|
||||||
|
if(i==header()->count()-1){
|
||||||
|
NewSize+=(w-sum); // add rounding difference to the last column
|
||||||
|
}
|
||||||
|
//qDebug("i=%i lstIndex=%i NewSize=%f",i,lstIndex,NewSize);
|
||||||
|
header()->resizeSection(header()->logicalIndex(i),NewSize);
|
||||||
|
ColumnSizes[lstIndex]=NewSize;
|
||||||
|
}
|
||||||
|
AutoResizeColumns=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w=viewport()->width();
|
int KeepassEntryView::columnListIndex(int LogicalIndex){
|
||||||
float div=(float)(New-Old)/(float)w;
|
int c=-1; int i=0;
|
||||||
|
for(i;i<NUM_COLUMNS;i++){
|
||||||
if(((ColumnSizes[j]-div)*w > 2)){
|
if(Columns[i])c++;
|
||||||
ColumnSizes[j]-=div;
|
if(c==LogicalIndex)break;
|
||||||
ColumnSizes[i]+=div;
|
}
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
resizeColumns();
|
|
||||||
|
|
||||||
|
void KeepassEntryView::OnColumnResized(int lindex,int Old, int New){
|
||||||
|
if(!AutoResizeColumns)return;
|
||||||
|
for(int i=0;i<header()->count();i++){
|
||||||
|
ColumnSizes[columnListIndex(i)]=header()->sectionSize(i);
|
||||||
|
}
|
||||||
|
resizeColumns();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeepassEntryView::mousePressEvent(QMouseEvent *event){
|
void KeepassEntryView::mousePressEvent(QMouseEvent *event){
|
||||||
//save event position - maybe this is the start of a drag
|
//save event position - maybe this is the start of a drag
|
||||||
if (event->button() == Qt::LeftButton)
|
if (event->button() == Qt::LeftButton)
|
||||||
DragStartPos = event->pos();
|
DragStartPos = event->pos();
|
||||||
//call base function
|
|
||||||
QTreeWidget::mousePressEvent(event);
|
QTreeWidget::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeepassEntryView::mouseMoveEvent(QMouseEvent *event){
|
void KeepassEntryView::mouseMoveEvent(QMouseEvent *event){
|
||||||
/*
|
if (!(event->buttons() & Qt::LeftButton))
|
||||||
if(IsSearchGroup)
|
return;
|
||||||
return;
|
if ((event->pos() - DragStartPos).manhattanLength() < QApplication::startDragDistance())
|
||||||
if (!(event->buttons() & Qt::LeftButton))
|
return;
|
||||||
return;
|
|
||||||
if ((event->pos() - DragStartPos).manhattanLength() < QApplication::startDragDistance())
|
DragItems.clear();
|
||||||
return;
|
EntryViewItem* DragStartItem=(EntryViewItem*)itemAt(DragStartPos);
|
||||||
|
if(!DragStartItem){
|
||||||
DragItems.clear();
|
|
||||||
EntryViewItem* DragStartItem=(EntryViewItem*)itemAt(DragStartPos);
|
|
||||||
if(!DragStartItem){
|
|
||||||
while(selectedItems().size()){
|
|
||||||
setItemSelected(selectedItems()[0],false);}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(selectedItems().size()==0){
|
|
||||||
setItemSelected(DragStartItem,true);}
|
|
||||||
else{
|
|
||||||
bool AlreadySelected=false;
|
|
||||||
for(int i=0;i<selectedItems().size();i++){
|
|
||||||
if(selectedItems()[i]==DragStartItem){AlreadySelected=true; break;}
|
|
||||||
}
|
|
||||||
if(!AlreadySelected){
|
|
||||||
while(selectedItems().size()){
|
while(selectedItems().size()){
|
||||||
setItemSelected(selectedItems()[0],false);
|
setItemSelected(selectedItems()[0],false);}
|
||||||
}
|
return;
|
||||||
setItemSelected(DragStartItem,true);
|
|
||||||
}
|
}
|
||||||
|
if(selectedItems().size()==0){
|
||||||
|
setItemSelected(DragStartItem,true);}
|
||||||
|
else{
|
||||||
|
bool AlreadySelected=false;
|
||||||
|
for(int i=0;i<selectedItems().size();i++){
|
||||||
|
if(selectedItems()[i]==DragStartItem){AlreadySelected=true; break;}
|
||||||
|
}
|
||||||
|
if(!AlreadySelected){
|
||||||
|
while(selectedItems().size()){
|
||||||
|
setItemSelected(selectedItems()[0],false);
|
||||||
|
}
|
||||||
|
setItemSelected(DragStartItem,true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DragItems=selectedItems();
|
||||||
|
QDrag *drag = new QDrag(this);
|
||||||
|
QMimeData *mimeData = new QMimeData;
|
||||||
|
void* pDragItems=&DragItems;
|
||||||
|
mimeData->setData("text/plain;charset=UTF-8",DragItems[0]->text(0).toUtf8());
|
||||||
|
mimeData->setData("application/x-keepassx-entry",QByteArray((char*)&pDragItems,sizeof(void*)));
|
||||||
|
drag->setMimeData(mimeData);
|
||||||
|
drag->setPixmap(DragPixmap);
|
||||||
|
drag->start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DragItems=selectedItems();
|
void KeepassEntryView::removeDragItems(){
|
||||||
QDrag *drag = new QDrag(this);
|
for(int i=0;i<DragItems.size();i++){
|
||||||
QFontMetrics fontmet(DragStartItem->font(0));
|
for(int j=0;j<Items.size();j++){
|
||||||
int DragPixmHeight=16;
|
if(Items[j]==DragItems[i]){
|
||||||
if(fontmet.height()>16)DragPixmHeight=fontmet.height();
|
Items.removeAt(j);
|
||||||
QString DragText;
|
j--;
|
||||||
if(DragItems.size()>1)DragText=QString(tr("%1 items")).arg(DragItems.size());
|
delete DragItems[i];
|
||||||
else DragText=((EntryViewItem*)DragItems[0])->pEntry->Title;
|
}
|
||||||
DragPixmap = QPixmap(fontmet.width(DragText)+19,DragPixmHeight);
|
}
|
||||||
DragPixmap.fill(QColor(255,255,255));
|
}
|
||||||
QPainter painter(&DragPixmap);
|
|
||||||
painter.setPen(QColor(0,0,0));
|
|
||||||
painter.setFont(DragItems[0]->font(0));
|
|
||||||
painter.drawPixmap(0,0,DragItems[0]->icon(0).pixmap(QSize(16,16)));
|
|
||||||
painter.drawText(19,DragPixmHeight-fontmet.strikeOutPos(),DragText);
|
|
||||||
QMimeData *mimeData = new QMimeData;
|
|
||||||
void* pDragItems=&DragItems;
|
|
||||||
mimeData->setData("keepass/entry",QByteArray((char*)&pDragItems,sizeof(void*)));
|
|
||||||
drag->setMimeData(mimeData);
|
|
||||||
drag->setPixmap(DragPixmap);
|
|
||||||
drag->start();
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeepassEntryView::OnAutoType(){
|
void KeepassEntryView::OnAutoType(){
|
||||||
|
@ -568,7 +598,7 @@ EntryViewItem::EntryViewItem(QTreeWidgetItem *parent, QTreeWidgetItem *preceding
|
||||||
|
|
||||||
bool EntryViewItem::operator<(const QTreeWidgetItem& other)const{
|
bool EntryViewItem::operator<(const QTreeWidgetItem& other)const{
|
||||||
int SortCol=treeWidget()->sortColumn();
|
int SortCol=treeWidget()->sortColumn();
|
||||||
if(SortCol < 5 || SortCol==9){ //columns with string values (Title, Username, Password, URL, Comment)
|
if(SortCol < 5 || SortCol==9 || SortCol==10){ //columns with string values (Title, Username, Password, URL, Comment, Group)
|
||||||
if(QString::localeAwareCompare(text(SortCol),other.text(SortCol)) < 0)
|
if(QString::localeAwareCompare(text(SortCol),other.text(SortCol)) < 0)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
|
|
|
@ -27,9 +27,10 @@
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
#include <QVarLengthArray>
|
||||||
#include "../StandardDatabase.h"
|
#include "../StandardDatabase.h"
|
||||||
|
|
||||||
#define NUM_COLUMNS 10
|
#define NUM_COLUMNS 11
|
||||||
|
|
||||||
class EntryViewItem;
|
class EntryViewItem;
|
||||||
enum SelectionState{NONE,SINGLE,MULTIPLE,SEARCHGROUP};
|
enum SelectionState{NONE,SINGLE,MULTIPLE,SEARCHGROUP};
|
||||||
|
@ -42,26 +43,31 @@ class KeepassEntryView:public QTreeWidget{
|
||||||
void showSearchResults();
|
void showSearchResults();
|
||||||
void showGroup(IGroupHandle* group);
|
void showGroup(IGroupHandle* group);
|
||||||
void updateColumns();
|
void updateColumns();
|
||||||
// void showSearchResults(QList<quint32>& results);
|
|
||||||
IDatabase* db;
|
IDatabase* db;
|
||||||
QList<EntryViewItem*>Items;
|
QList<EntryViewItem*>Items;
|
||||||
QList<IEntryHandle*> SearchResults;
|
QList<IEntryHandle*> SearchResults;
|
||||||
QMenu *ContextMenu;
|
QMenu *ContextMenu;
|
||||||
|
QVarLengthArray<bool>Columns;
|
||||||
private:
|
private:
|
||||||
void setEntry(IEntryHandle* entry);
|
void setEntry(IEntryHandle* entry);
|
||||||
void updateEntry(EntryViewItem*);
|
void updateEntry(EntryViewItem*);
|
||||||
void editEntry(EntryViewItem*);
|
void editEntry(EntryViewItem*);
|
||||||
void createItems(QList<IEntryHandle*>& entries);
|
void createItems(QList<IEntryHandle*>& entries);
|
||||||
|
int columnListIndex(int LogicalIndex);
|
||||||
|
int logicalColIndex(int ListIndex);
|
||||||
|
|
||||||
QClipboard* Clipboard;
|
QClipboard* Clipboard;
|
||||||
QTimer ClipboardTimer;
|
QTimer ClipboardTimer;
|
||||||
QList<float>ColumnSizes;
|
|
||||||
void resizeColumns();
|
void resizeColumns();
|
||||||
bool AutoResizeColumns;
|
bool AutoResizeColumns;
|
||||||
QPoint DragStartPos;
|
QPoint DragStartPos;
|
||||||
QList<QTreeWidgetItem*> DragItems;
|
QList<QTreeWidgetItem*> DragItems;
|
||||||
QPixmap DragPixmap;
|
QPixmap DragPixmap;
|
||||||
IGroupHandle* CurrentGroup;
|
IGroupHandle* CurrentGroup;
|
||||||
|
enum EntryViewMode {Normal, ShowSearchResults};
|
||||||
|
EntryViewMode ViewMode;
|
||||||
|
QVarLengthArray<float>ColumnSizes;
|
||||||
|
QVarLengthArray<int>ColumnOrder;
|
||||||
|
|
||||||
virtual void contextMenuEvent(QContextMenuEvent *event);
|
virtual void contextMenuEvent(QContextMenuEvent *event);
|
||||||
virtual void paintEvent(QPaintEvent* event);
|
virtual void paintEvent(QPaintEvent* event);
|
||||||
|
@ -85,6 +91,8 @@ class KeepassEntryView:public QTreeWidget{
|
||||||
void OnDeleteEntry();
|
void OnDeleteEntry();
|
||||||
void OnSaveAttachment();
|
void OnSaveAttachment();
|
||||||
void OnAutoType();
|
void OnAutoType();
|
||||||
|
void removeDragItems();
|
||||||
|
void OnColumnMoved(int LogIndex,int OldVisIndex,int NewVisIndex);
|
||||||
signals:
|
signals:
|
||||||
void fileModified();
|
void fileModified();
|
||||||
void selectionChanged(SelectionState);
|
void selectionChanged(SelectionState);
|
||||||
|
|
|
@ -54,6 +54,7 @@ KeepassGroupView::KeepassGroupView(QWidget* parent):QTreeWidget(parent){
|
||||||
void KeepassGroupView::createItems(){
|
void KeepassGroupView::createItems(){
|
||||||
clear();
|
clear();
|
||||||
Items.clear();
|
Items.clear();
|
||||||
|
InsLinePos=-1;
|
||||||
QList<IGroupHandle*> groups=db->groups();
|
QList<IGroupHandle*> groups=db->groups();
|
||||||
for(int i=0;i<groups.size();i++){
|
for(int i=0;i<groups.size();i++){
|
||||||
if(groups[i]->parent()==NULL){
|
if(groups[i]->parent()==NULL){
|
||||||
|
@ -178,7 +179,14 @@ void KeepassGroupView::dragEnterEvent ( QDragEnterEvent * event ){
|
||||||
LastHoverItem=NULL;
|
LastHoverItem=NULL;
|
||||||
InsLinePos=-1;
|
InsLinePos=-1;
|
||||||
|
|
||||||
if(event->mimeData()->hasFormat("application/x-keepassx")){
|
if(event->mimeData()->hasFormat("application/x-keepassx-group")){
|
||||||
|
DragType=GroupDrag;
|
||||||
|
event->accept();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(event->mimeData()->hasFormat("application/x-keepassx-entry")){
|
||||||
|
DragType=EntryDrag;
|
||||||
|
memcpy(&EntryDragItems,event->mimeData()->data("application/x-keepassx-entry").data(),sizeof(void*));
|
||||||
event->accept();
|
event->accept();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -199,10 +207,39 @@ void KeepassGroupView::dragLeaveEvent ( QDragLeaveEvent * event ){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KeepassGroupView::entryDropEvent( QDropEvent * event ){
|
||||||
void KeepassGroupView::dropEvent( QDropEvent * event ){
|
|
||||||
if(LastHoverItem){
|
if(LastHoverItem){
|
||||||
LastHoverItem->setBackgroundColor(0,QApplication::palette().color(QPalette::Base));
|
LastHoverItem->setBackgroundColor(0,QApplication::palette().color(QPalette::Base));
|
||||||
|
LastHoverItem->setForeground(0,QBrush(QApplication::palette().color(QPalette::Text)));
|
||||||
|
}
|
||||||
|
GroupViewItem* Item=(GroupViewItem*)itemAt(event->pos());
|
||||||
|
if(!Item){
|
||||||
|
event->ignore();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(Item->GroupHandle==((EntryViewItem*)(*EntryDragItems)[0])->EntryHandle->group())
|
||||||
|
return;
|
||||||
|
for(int i=0;i<EntryDragItems->size();i++){
|
||||||
|
db->moveEntry(((EntryViewItem*)(*EntryDragItems)[i])->EntryHandle,Item->GroupHandle);
|
||||||
|
}
|
||||||
|
emit entriesDropped();
|
||||||
|
emit fileModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KeepassGroupView::dropEvent( QDropEvent * event ){
|
||||||
|
|
||||||
|
if(DragType==EntryDrag){
|
||||||
|
entryDropEvent(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(LastHoverItem){
|
||||||
|
LastHoverItem->setBackgroundColor(0,QApplication::palette().color(QPalette::Base));
|
||||||
|
LastHoverItem->setForeground(0,QBrush(QApplication::palette().color(QPalette::Text)));
|
||||||
}
|
}
|
||||||
if(InsLinePos!=-1){
|
if(InsLinePos!=-1){
|
||||||
int RemoveLine=InsLinePos;
|
int RemoveLine=InsLinePos;
|
||||||
|
@ -290,7 +327,38 @@ void KeepassGroupView::dropEvent( QDropEvent * event ){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KeepassGroupView::entryDragMoveEvent( QDragMoveEvent * event ){
|
||||||
|
|
||||||
|
GroupViewItem* Item=(GroupViewItem*)itemAt(event->pos());
|
||||||
|
if(!Item){
|
||||||
|
if(LastHoverItem){
|
||||||
|
LastHoverItem->setBackgroundColor(0,QApplication::palette().color(QPalette::Base));
|
||||||
|
LastHoverItem->setForeground(0,QBrush(QApplication::palette().color(QPalette::Text)));
|
||||||
|
LastHoverItem=NULL;
|
||||||
|
}
|
||||||
|
event->ignore();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(LastHoverItem != Item){
|
||||||
|
if(LastHoverItem){
|
||||||
|
LastHoverItem->setBackgroundColor(0,QApplication::palette().color(QPalette::Base));
|
||||||
|
LastHoverItem->setForeground(0,QBrush(QApplication::palette().color(QPalette::Text)));
|
||||||
|
}
|
||||||
|
Item->setBackgroundColor(0,QApplication::palette().color(QPalette::Highlight));
|
||||||
|
Item->setForeground(0,QBrush(QApplication::palette().color(QPalette::HighlightedText)));
|
||||||
|
LastHoverItem=Item;
|
||||||
|
}
|
||||||
|
|
||||||
|
event->accept();
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void KeepassGroupView::dragMoveEvent( QDragMoveEvent * event ){
|
void KeepassGroupView::dragMoveEvent( QDragMoveEvent * event ){
|
||||||
|
if(DragType==EntryDrag){
|
||||||
|
entryDragMoveEvent(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(DragItem){
|
if(DragItem){
|
||||||
GroupViewItem* Item=(GroupViewItem*)itemAt(event->pos());
|
GroupViewItem* Item=(GroupViewItem*)itemAt(event->pos());
|
||||||
if(!Item){
|
if(!Item){
|
||||||
|
@ -393,7 +461,7 @@ void KeepassGroupView::mouseMoveEvent(QMouseEvent *event){
|
||||||
QMimeData *mimeData = new QMimeData;
|
QMimeData *mimeData = new QMimeData;
|
||||||
|
|
||||||
mimeData->setData("text/plain;charset=UTF-8",DragItem->text(0).toUtf8());
|
mimeData->setData("text/plain;charset=UTF-8",DragItem->text(0).toUtf8());
|
||||||
mimeData->setData("application/x-keepassx",QString("drag-type=group").toUtf8());
|
mimeData->setData("application/x-keepassx-group",QByteArray());
|
||||||
drag->setMimeData(mimeData);
|
drag->setMimeData(mimeData);
|
||||||
|
|
||||||
Qt::DropAction dropAction = drag->start(Qt::MoveAction);
|
Qt::DropAction dropAction = drag->start(Qt::MoveAction);
|
||||||
|
|
|
@ -40,10 +40,12 @@ class KeepassGroupView:public QTreeWidget{
|
||||||
void showSearchResults();
|
void showSearchResults();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void dragEnterEvent ( QDragEnterEvent * event );
|
virtual void dragEnterEvent(QDragEnterEvent* event);
|
||||||
virtual void dragMoveEvent ( QDragMoveEvent * event );
|
virtual void dragMoveEvent(QDragMoveEvent* event);
|
||||||
|
void entryDragMoveEvent(QDragMoveEvent* event);
|
||||||
virtual void dragLeaveEvent ( QDragLeaveEvent * event );
|
virtual void dragLeaveEvent ( QDragLeaveEvent * event );
|
||||||
virtual void dropEvent ( QDropEvent * event );
|
virtual void dropEvent ( QDropEvent * event );
|
||||||
|
void entryDropEvent(QDropEvent* event);
|
||||||
virtual void mousePressEvent(QMouseEvent *event);
|
virtual void mousePressEvent(QMouseEvent *event);
|
||||||
virtual void mouseMoveEvent(QMouseEvent *event);
|
virtual void mouseMoveEvent(QMouseEvent *event);
|
||||||
virtual void paintEvent ( QPaintEvent * event );
|
virtual void paintEvent ( QPaintEvent * event );
|
||||||
|
@ -54,6 +56,9 @@ class KeepassGroupView:public QTreeWidget{
|
||||||
GroupViewItem* LastHoverItem;
|
GroupViewItem* LastHoverItem;
|
||||||
int InsLinePos;
|
int InsLinePos;
|
||||||
int InsLineStart;
|
int InsLineStart;
|
||||||
|
enum GroupViewDragType{EntryDrag,GroupDrag};
|
||||||
|
GroupViewDragType DragType;
|
||||||
|
QList<QTreeWidgetItem*>* EntryDragItems;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*);
|
void OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*);
|
||||||
|
@ -69,6 +74,7 @@ class KeepassGroupView:public QTreeWidget{
|
||||||
void groupChanged(IGroupHandle* NewGroup);
|
void groupChanged(IGroupHandle* NewGroup);
|
||||||
void searchResultsSelected();
|
void searchResultsSelected();
|
||||||
void fileModified();
|
void fileModified();
|
||||||
|
void entriesDropped();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -144,16 +144,8 @@ void KeepassMainWindow::setupConnections(){
|
||||||
connect(ViewShowEntryDetailsAction,SIGNAL(toggled(bool)),this,SLOT(OnViewShowEntryDetails(bool)));
|
connect(ViewShowEntryDetailsAction,SIGNAL(toggled(bool)),this,SLOT(OnViewShowEntryDetails(bool)));
|
||||||
connect(ViewHidePasswordsAction,SIGNAL(toggled(bool)), this, SLOT(OnUsernPasswVisibilityChanged(bool)));
|
connect(ViewHidePasswordsAction,SIGNAL(toggled(bool)), this, SLOT(OnUsernPasswVisibilityChanged(bool)));
|
||||||
connect(ViewHideUsernamesAction,SIGNAL(toggled(bool)), this, SLOT(OnUsernPasswVisibilityChanged(bool)));
|
connect(ViewHideUsernamesAction,SIGNAL(toggled(bool)), this, SLOT(OnUsernPasswVisibilityChanged(bool)));
|
||||||
connect(ViewColumnsTitleAction,SIGNAL(toggled(bool)), this, SLOT(OnColumnVisibilityChanged(bool)));
|
|
||||||
connect(ViewColumnsUsernameAction,SIGNAL(toggled(bool)), this, SLOT(OnColumnVisibilityChanged(bool)));
|
connect(menuColumns,SIGNAL(triggered(QAction*)),this,SLOT(OnColumnVisibilityChanged(QAction*)));
|
||||||
connect(ViewColumnsUrlAction,SIGNAL(toggled(bool)), this, SLOT(OnColumnVisibilityChanged(bool)));
|
|
||||||
connect(ViewColumnsPasswordAction,SIGNAL(toggled(bool)), this, SLOT(OnColumnVisibilityChanged(bool)));
|
|
||||||
connect(ViewColumnsCommentAction,SIGNAL(toggled(bool)), this, SLOT(OnColumnVisibilityChanged(bool)));
|
|
||||||
connect(ViewColumnsExpireAction,SIGNAL(toggled(bool)), this, SLOT(OnColumnVisibilityChanged(bool)));
|
|
||||||
connect(ViewColumnsCreationAction,SIGNAL(toggled(bool)), this, SLOT(OnColumnVisibilityChanged(bool)));
|
|
||||||
connect(ViewColumnsLastChangeAction,SIGNAL(toggled(bool)), this, SLOT(OnColumnVisibilityChanged(bool)));
|
|
||||||
connect(ViewColumnsLastAccessAction,SIGNAL(toggled(bool)), this, SLOT(OnColumnVisibilityChanged(bool)));
|
|
||||||
connect(ViewColumnsAttachmentAction,SIGNAL(toggled(bool)), this, SLOT(OnColumnVisibilityChanged(bool)));
|
|
||||||
connect(ViewToolButtonSize16Action,SIGNAL(toggled(bool)), this, SLOT(OnViewToolbarIconSize16(bool)));
|
connect(ViewToolButtonSize16Action,SIGNAL(toggled(bool)), this, SLOT(OnViewToolbarIconSize16(bool)));
|
||||||
connect(ViewToolButtonSize22Action,SIGNAL(toggled(bool)), this, SLOT(OnViewToolbarIconSize22(bool)));
|
connect(ViewToolButtonSize22Action,SIGNAL(toggled(bool)), this, SLOT(OnViewToolbarIconSize22(bool)));
|
||||||
connect(ViewToolButtonSize28Action,SIGNAL(toggled(bool)), this, SLOT(OnViewToolbarIconSize28(bool)));
|
connect(ViewToolButtonSize28Action,SIGNAL(toggled(bool)), this, SLOT(OnViewToolbarIconSize28(bool)));
|
||||||
|
@ -174,6 +166,7 @@ void KeepassMainWindow::setupConnections(){
|
||||||
connect(EntryView,SIGNAL(selectionChanged(SelectionState)),this,SLOT(OnEntryChanged(SelectionState)));
|
connect(EntryView,SIGNAL(selectionChanged(SelectionState)),this,SLOT(OnEntryChanged(SelectionState)));
|
||||||
connect(GroupView,SIGNAL(searchResultsSelected()),EntryView,SLOT(OnShowSearchResults()));
|
connect(GroupView,SIGNAL(searchResultsSelected()),EntryView,SLOT(OnShowSearchResults()));
|
||||||
connect(GroupView,SIGNAL(searchResultsSelected()),this,SLOT(OnShowSearchResults()));
|
connect(GroupView,SIGNAL(searchResultsSelected()),this,SLOT(OnShowSearchResults()));
|
||||||
|
connect(GroupView,SIGNAL(entriesDropped()),EntryView,SLOT(removeDragItems()));
|
||||||
connect(HideSearchResultsAction,SIGNAL(triggered()),GroupView,SLOT(OnHideSearchResults()));
|
connect(HideSearchResultsAction,SIGNAL(triggered()),GroupView,SLOT(OnHideSearchResults()));
|
||||||
|
|
||||||
connect(SysTray,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(OnSysTrayActivated(QSystemTrayIcon::ActivationReason)));
|
connect(SysTray,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(OnSysTrayActivated(QSystemTrayIcon::ActivationReason)));
|
||||||
|
@ -258,16 +251,17 @@ void KeepassMainWindow::setupMenus(){
|
||||||
ViewShowEntryDetailsAction->setChecked(config.EntryDetails);
|
ViewShowEntryDetailsAction->setChecked(config.EntryDetails);
|
||||||
ViewHidePasswordsAction->setChecked(config.ListView_HidePasswords);
|
ViewHidePasswordsAction->setChecked(config.ListView_HidePasswords);
|
||||||
ViewHideUsernamesAction->setChecked(config.ListView_HideUsernames);
|
ViewHideUsernamesAction->setChecked(config.ListView_HideUsernames);
|
||||||
ViewColumnsTitleAction->setChecked(config.Columns[0]);
|
ViewColumnsTitleAction->setChecked(EntryView->Columns[0]);
|
||||||
ViewColumnsUsernameAction->setChecked(config.Columns[1]);
|
ViewColumnsUsernameAction->setChecked(EntryView->Columns[1]);
|
||||||
ViewColumnsUrlAction->setChecked(config.Columns[2]);
|
ViewColumnsUrlAction->setChecked(EntryView->Columns[2]);
|
||||||
ViewColumnsPasswordAction->setChecked(config.Columns[3]);
|
ViewColumnsPasswordAction->setChecked(EntryView->Columns[3]);
|
||||||
ViewColumnsCommentAction->setChecked(config.Columns[4]);
|
ViewColumnsCommentAction->setChecked(EntryView->Columns[4]);
|
||||||
ViewColumnsExpireAction->setChecked(config.Columns[5]);
|
ViewColumnsExpireAction->setChecked(EntryView->Columns[5]);
|
||||||
ViewColumnsCreationAction->setChecked(config.Columns[6]);
|
ViewColumnsCreationAction->setChecked(EntryView->Columns[6]);
|
||||||
ViewColumnsLastChangeAction->setChecked(config.Columns[7]);
|
ViewColumnsLastChangeAction->setChecked(EntryView->Columns[7]);
|
||||||
ViewColumnsLastAccessAction->setChecked(config.Columns[8]);
|
ViewColumnsLastAccessAction->setChecked(EntryView->Columns[8]);
|
||||||
ViewColumnsAttachmentAction->setChecked(config.Columns[9]);
|
ViewColumnsAttachmentAction->setChecked(EntryView->Columns[9]);
|
||||||
|
ViewColumnsGroupAction->setChecked(EntryView->Columns[10]);
|
||||||
ViewShowStatusbarAction->setChecked(config.ShowStatusbar);
|
ViewShowStatusbarAction->setChecked(config.ShowStatusbar);
|
||||||
|
|
||||||
switch(config.ToolbarIconSize){
|
switch(config.ToolbarIconSize){
|
||||||
|
@ -754,24 +748,25 @@ void KeepassMainWindow::OnQuickSearch(){
|
||||||
GroupView->showSearchResults();
|
GroupView->showSearchResults();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeepassMainWindow::OnColumnVisibilityChanged(bool value){
|
void KeepassMainWindow::OnColumnVisibilityChanged(QAction* action){
|
||||||
config.Columns[0]=ViewColumnsTitleAction->isChecked();
|
EntryView->Columns[0]=ViewColumnsTitleAction->isChecked();
|
||||||
config.Columns[1]=ViewColumnsUsernameAction->isChecked();
|
EntryView->Columns[1]=ViewColumnsUsernameAction->isChecked();
|
||||||
config.Columns[2]=ViewColumnsUrlAction->isChecked();
|
EntryView->Columns[2]=ViewColumnsUrlAction->isChecked();
|
||||||
config.Columns[3]=ViewColumnsPasswordAction->isChecked();
|
EntryView->Columns[3]=ViewColumnsPasswordAction->isChecked();
|
||||||
config.Columns[4]=ViewColumnsCommentAction->isChecked();
|
EntryView->Columns[4]=ViewColumnsCommentAction->isChecked();
|
||||||
config.Columns[5]=ViewColumnsExpireAction->isChecked();
|
EntryView->Columns[5]=ViewColumnsExpireAction->isChecked();
|
||||||
config.Columns[6]=ViewColumnsCreationAction->isChecked();
|
EntryView->Columns[6]=ViewColumnsCreationAction->isChecked();
|
||||||
config.Columns[7]=ViewColumnsLastChangeAction->isChecked();
|
EntryView->Columns[7]=ViewColumnsLastChangeAction->isChecked();
|
||||||
config.Columns[8]=ViewColumnsLastAccessAction->isChecked();
|
EntryView->Columns[8]=ViewColumnsLastAccessAction->isChecked();
|
||||||
config.Columns[9]=ViewColumnsAttachmentAction->isChecked();
|
EntryView->Columns[9]=ViewColumnsAttachmentAction->isChecked();
|
||||||
//EntryView->updateColumns();
|
EntryView->Columns[10]=ViewColumnsGroupAction->isChecked();
|
||||||
|
EntryView->updateColumns();
|
||||||
//if(FileOpen) EntryView->updateItems();
|
//if(FileOpen) EntryView->updateItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeepassMainWindow::OnUsernPasswVisibilityChanged(bool value){
|
void KeepassMainWindow::OnUsernPasswVisibilityChanged(bool value){
|
||||||
config.ListView_HidePasswords=ViewHidePasswordsAction->isChecked();
|
config.ListView_HidePasswords=ViewHidePasswordsAction->isChecked();
|
||||||
config.ListView_HideUsernames=ViewHideUsernamesAction->isChecked();
|
config.ListView_HideUsernames=ViewHideUsernamesAction->isChecked();
|
||||||
//EntryView->refreshItems();
|
//EntryView->refreshItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ class KeepassMainWindow : public QMainWindow, public Ui_MainWindow{
|
||||||
void OnViewToolbarIconSize28(bool);
|
void OnViewToolbarIconSize28(bool);
|
||||||
void OnGroupSelectionChanged(IGroupHandle*);
|
void OnGroupSelectionChanged(IGroupHandle*);
|
||||||
void OnQuickSearch();
|
void OnQuickSearch();
|
||||||
void OnColumnVisibilityChanged(bool show);
|
void OnColumnVisibilityChanged(QAction* action);
|
||||||
void OnUsernPasswVisibilityChanged(bool hide);
|
void OnUsernPasswVisibilityChanged(bool hide);
|
||||||
void OnFileModified();
|
void OnFileModified();
|
||||||
void OnExtrasSettings();
|
void OnExtrasSettings();
|
||||||
|
|
Loading…
Reference in New Issue