Seperate columns/search order between normal and search results view (not yet complete)

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@324 b624d157-de02-0410-bad0-e51aec6abb33
master
sniperbeamer 16 years ago
parent 671dcc2c30
commit 049ea5e5a2
  1. 14
      src/KpxConfig.h
  2. 9
      src/forms/MainWindow.ui
  3. 455
      src/lib/EntryView.cpp
  4. 32
      src/lib/EntryView.h
  5. 5
      src/lib/GroupView.cpp
  6. 1
      src/lib/GroupView.h
  7. 1
      src/lib/random.cpp
  8. 58
      src/mainwindow.cpp
  9. 1
      src/mainwindow.h

@ -49,11 +49,8 @@ public:
QColor bannerColor2(){return stringToColor(settings.value("Options/BannerColor2","0,117,175").toString());}
QColor bannerTextColor(){return stringToColor(settings.value("Options/BannerTextColor","222,222,222").toString());}
int clipboardTimeOut(){return settings.value("Options/ClipboardTimeOut",20).toInt();}
QBitArray columns(){return stringToBitArray(settings.value("UI/Columns","11111000000").toString(),11);}
QList<int> columnOrder(){return stringToIntArray(settings.value("UI/ColumnOrder","100,100,100,100,100,100,100,100,100,100,100").toString(),11);}
QList<int> columnSizes(){return stringToIntArray(settings.value("UI/ColumnSizes","15,10,10,10,10,10,10,10,10,10,10").toString(),11);}
int columnSort(){return settings.value("UI/ColumnSort",0).toInt();}
Qt::SortOrder columnSortOrder(){return static_cast<Qt::SortOrder>(settings.value("UI/ColumnSortOrder",Qt::AscendingOrder).toInt());}
QByteArray entryView(){return settings.value("UI/EntryView").toByteArray();}
QByteArray entryViewSearch(){return settings.value("UI/EntryViewSearch").toByteArray();}
QStringList fileDlgHistory(unsigned index){return settings.value(QString("FileDlgHistory/ENTRY%1").arg(index)).toStringList();}
GrpTreeState groupTreeState(){return stringToGrpTreeState(settings.value("Options/GroupTreeState").toString());}
bool hidePasswords(){return settings.value("UI/HidePasswords",true).toBool();}
@ -115,11 +112,8 @@ public:
void setBannerColor2(const QColor& value){settings.setValue("Options/BannerColor2",colorToString(value));}
void setBannerTextColor(const QColor& value){settings.setValue("Options/BannerTextColor",colorToString(value));}
void setClipboardTimeOut(int value){settings.setValue("Options/ClipboardTimeOut",value);}
void setColumns(const QBitArray& value){settings.setValue("UI/Columns",bitArrayToString(value));}
void setColumnOrder(const QList<int>& value){settings.setValue("UI/ColumnOrder",intArrayToString(value));}
void setColumnSizes(const QList<int>& value){settings.setValue("UI/ColumnSizes",intArrayToString(value));}
void setColumnSort(int value){settings.setValue("UI/ColumnSort",value);}
void setColumnSortOrder(int value){settings.setValue("UI/ColumnSortOrder",value);}
void setEntryView(const QByteArray& value){settings.setValue("UI/EntryView",value);}
void setEntryViewSearch(const QByteArray& value){settings.setValue("UI/EntryViewSearch",value);}
void setFileDlgHistory(unsigned index,const QStringList& value){settings.setValue(QString("FileDlgHistory/ENTRY%1").arg(index), value);}
void setGroupTreeState(GrpTreeState value){settings.setValue("Options/GroupTreeState",grpTreeStateToString(value));}
void setHidePasswords(bool value){settings.setValue("UI/HidePasswords",value);}

@ -196,7 +196,6 @@
<string>&amp;Columns</string>
</property>
<addaction name="ViewColumnsGroupAction"/>
<addaction name="separator"/>
<addaction name="ViewColumnsTitleAction"/>
<addaction name="ViewColumnsUsernameAction"/>
<addaction name="ViewColumnsUrlAction"/>
@ -539,11 +538,11 @@
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Group (search results only)</string>
<string>&amp;Group</string>
</property>
<property name="visible">
<bool>false</bool>
</property>
</action>
<action name="ExtrasShowExpiredEntriesAction">

@ -20,49 +20,132 @@
#include <QHeaderView>
#include <QClipboard>
#include <QFileDialog>
#include <QProcess>
#include "lib/AutoType.h"
#include "lib/EntryView.h"
#include "dialogs/EditEntryDlg.h"
// just for the lessThan funtion
QList<EntryViewItem*>* pItems;
KeepassEntryView* pEntryView;
/*QList<EntryViewItem*>* pItems;
KeepassEntryView* pEntryView;*/
KeepassEntryView::KeepassEntryView(QWidget* parent):QTreeWidget(parent){
ViewMode=Normal;
AutoResizeColumns=true;
header()->setResizeMode(QHeaderView::Interactive);
header()->setStretchLastSection(false);
header()->setClickable(true);
header()->setCascadingSectionResizes(true);
ColumnSizes=config->columnSizes();
Columns=config->columns();
ColumnOrder=config->columnOrder();
updateColumns();
header()->setSortIndicator(config->columnSort(), config->columnSortOrder());
connect(header(),SIGNAL(sectionResized(int,int,int)),this,SLOT(OnColumnResized()));
connect(this,SIGNAL(itemSelectionChanged()),this,SLOT(OnItemsChanged()));
connect(&ClipboardTimer, SIGNAL(timeout()), this, SLOT(OnClipboardTimeOut()));
connect(header(),SIGNAL(sectionClicked(int)),this,SLOT(OnHeaderSectionClicked(int)));
connect(header(),SIGNAL(sectionMoved(int,int,int)),this,SLOT(OnColumnMoved()));
//header()->setCascadingSectionResizes(true);
retranslateColumns();
restoreHeaderView();
connect(this,SIGNAL(itemSelectionChanged()), SLOT(OnItemsChanged()));
connect(&ClipboardTimer, SIGNAL(timeout()), SLOT(OnClipboardTimeOut()));
connect(this, SIGNAL(itemActivated(QTreeWidgetItem*,int)), SLOT(OnEntryActivated(QTreeWidgetItem*,int)));
connect(this, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), SLOT(OnEntryDblClicked(QTreeWidgetItem*,int)));
Clipboard=QApplication::clipboard();
ContextMenu=new QMenu(this);
setAlternatingRowColors(config->alternatingRowColors());
pItems=&Items;
pEntryView=this;
/*pItems=&Items;
pEntryView=this;*/
}
KeepassEntryView::~KeepassEntryView(){
config->setColumnSizes(ColumnSizes);
config->setColumns(Columns);
config->setColumnOrder(ColumnOrder);
config->setColumnSort(header()->sortIndicatorSection());
config->setColumnSortOrder(header()->sortIndicatorOrder());
saveHeaderView();
}
void KeepassEntryView::retranslateColumns() {
setHeaderLabels( QStringList() << tr("Title") << tr("Username") << tr("URL") << tr("Password") << tr("Comments")
<< tr("Expires") << tr("Creation") << tr("Last Change") << tr("Last Access") << tr("Attachment") << tr("Group") );
}
bool KeepassEntryView::columnVisible(int col) {
return !header()->isSectionHidden(col);
}
void KeepassEntryView::setColumnVisible(int col, bool visible) {
header()->setSectionHidden(col, !visible);
}
void KeepassEntryView::saveHeaderView() {
if (ViewMode == Normal)
config->setEntryView( header()->saveState() );
else
config->setEntryViewSearch( header()->saveState() );
}
void KeepassEntryView::restoreHeaderView() {
if (ViewMode == Normal) {
QByteArray state = config->entryView();
if (state.isEmpty()) {
for (int i=10; i>=0; --i) {
if (i <= 3) {
setColumnVisible(i, true);
header()->moveSection(header()->visualIndex(i), 0);
}
else {
setColumnVisible(i, false);
}
}
header()->setSortIndicator(0, Qt::AscendingOrder);
header()->setSortIndicatorShown(true);
header()->resizeSection(0, (int) (header()->sectionSize(0) * 1.5));
}
else {
header()->restoreState(state);
setColumnVisible(10, false); // just to be sure
QApplication::processEvents();
//QHash<int, int> sectionSize;
QList<int> visibleSections;
for (int i=0; i<=10; ++i) {
if (columnVisible(i)) {
qDebug("%d",i);
visibleSections.append(i);
header()->hideSection(i);
}
}
QApplication::processEvents();
for (int i=0; i<visibleSections.size(); ++i) {
qDebug("%d",visibleSections[i]);
header()->showSection(visibleSections[i]);
}
/*for (int i=0; i<=10; ++i) {
if (columnVisible(i)) {
int size = header()->sectionSize(i);
header()->resizeSection(i, 1);
header()->resizeSection(i, size);
}
}*/
}
}
else {
QByteArray state = config->entryViewSearch();
if (state.isEmpty()) {
for (int i=10; i>=0; --i) {
if (i <= 3 || i == 10) {
setColumnVisible(i, true);
header()->moveSection(header()->visualIndex(i), 0);
}
else {
setColumnVisible(i, false);
}
}
header()->moveSection(header()->visualIndex(10), 0);
header()->setSortIndicator(10, Qt::AscendingOrder);
header()->setSortIndicatorShown(true);
}
else {
header()->restoreState(state);
}
}
}
void KeepassEntryView::OnGroupChanged(IGroupHandle* group){
@ -75,7 +158,6 @@ void KeepassEntryView::OnShowSearchResults(){
showSearchResults();
}
void KeepassEntryView::OnItemsChanged(){
switch(selectedItems().size()){
case 0: emit selectionChanged(NONE);
@ -86,40 +168,6 @@ void KeepassEntryView::OnItemsChanged(){
}
}
bool sortSearchResultsLessThan(const IEntryHandle* a, const IEntryHandle* b){
int indexA, indexB;
for(indexA=0;indexA<pItems->size();indexA++){
if((*pItems)[indexA]->EntryHandle==a)break;
}
for(indexB=0;indexB<pItems->size();indexB++){
if((*pItems)[indexB]->EntryHandle==b)break;
}
return pEntryView->indexOfTopLevelItem((*pItems)[indexA])<pEntryView->indexOfTopLevelItem((*pItems)[indexB]);
}
void KeepassEntryView::OnHeaderSectionClicked(int index){
if(header()->sortIndicatorSection()==index){
header()->setSortIndicator(index,header()->sortIndicatorOrder() ? Qt::DescendingOrder : Qt::AscendingOrder);
}
else{
header()->setSortIndicator(index,Qt::AscendingOrder);
}
if(ViewMode==Normal){
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);
}
}
void KeepassEntryView::OnSaveAttachment(){
if (selectedItems().size() == 0) return;
CEditEntryDlg::saveAttachment(((EntryViewItem*)selectedItems().first())->EntryHandle,this);
@ -181,45 +229,32 @@ void KeepassEntryView::OnDeleteEntry(){
void KeepassEntryView::updateEntry(EntryViewItem* item){
IEntryHandle* entry = item->EntryHandle;
int j=0;
if(Columns.at(0)){
item->setText(j++,entry->title());
item->setIcon(0,db->icon(entry->image()));
}
if (Columns.at(1)){
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());
}
}
if (Columns.at(4)){
QString comment = entry->comment();
int toPos = comment.indexOf(QRegExp("[\\r\\n]"));
if (toPos == -1)
item->setText(j++,comment);
else
item->setText(j++,comment.left(toPos));
}
if (Columns.at(5)){
item->setText(j++,entry->expire().dateToString(Qt::SystemLocaleDate));}
if (Columns.at(6)){
item->setText(j++,entry->creation().dateToString(Qt::SystemLocaleDate));}
if (Columns.at(7)){
item->setText(j++,entry->lastMod().dateToString(Qt::SystemLocaleDate));}
if (Columns.at(8)){
item->setText(j++,entry->lastAccess().dateToString(Qt::SystemLocaleDate));}
if (Columns.at(9)){
item->setText(j++,entry->binaryDesc());}
if(Columns.at(10) && ViewMode==ShowSearchResults){
item->setText(j++,entry->title());
item->setIcon(0,db->icon(entry->image()));
if(config->hideUsernames())
item->setText(j++,"******");
else
item->setText(j++,entry->username());
item->setText(j++,entry->url());
if(config->hidePasswords())
item->setText(j++,"******");
else{
SecString password=entry->password();
password.unlock();
item->setText(j++,password.string());
}
QString comment = entry->comment();
int toPos = comment.indexOf(QRegExp("[\\r\\n]"));
if (toPos == -1)
item->setText(j++,comment);
else
item->setText(j++,comment.left(toPos));
item->setText(j++,entry->expire().dateToString(Qt::SystemLocaleDate));
item->setText(j++,entry->creation().dateToString(Qt::SystemLocaleDate));
item->setText(j++,entry->lastMod().dateToString(Qt::SystemLocaleDate));
item->setText(j++,entry->lastAccess().dateToString(Qt::SystemLocaleDate));
item->setText(j++,entry->binaryDesc());
if (ViewMode == ShowSearchResults) {
item->setText(j,entry->group()->title());
item->setIcon(j++,db->icon(entry->group()->image()));
}
@ -288,10 +323,10 @@ void KeepassEntryView::OnNewEntry(){
}
void KeepassEntryView::OnEntryActivated(QTreeWidgetItem* item,int Column){
void KeepassEntryView::OnEntryActivated(QTreeWidgetItem* item, int Column){
Q_UNUSED(item);
switch (columnListIndex(Column)){
switch (Column){
case 1:
OnUsernameToClipboard();
break;
@ -304,8 +339,8 @@ void KeepassEntryView::OnEntryActivated(QTreeWidgetItem* item,int Column){
}
}
void KeepassEntryView::OnEntryDblClicked(QTreeWidgetItem* item,int Column){
if (columnListIndex(Column) == 0)
void KeepassEntryView::OnEntryDblClicked(QTreeWidgetItem* item, int Column){
if (Column == 0)
editEntry((EntryViewItem*)item);
}
@ -371,7 +406,8 @@ void KeepassEntryView::OnClipboardTimeOut(){
}
#ifdef Q_WS_X11
QProcess::startDetached("dcop klipper klipper clearClipboardHistory");
QProcess::startDetached("dbus-send --type=method_call --dest=org.kde.klipper /klipper org.kde.klipper.klipper.clearClipboardHistory");
QProcess::startDetached("dbus-send --type=method_call --dest=org.kde.klipper /klipper "
"org.kde.klipper.klipper.clearClipboardHistory");
#endif
}
@ -400,16 +436,17 @@ void KeepassEntryView::contextMenuEvent(QContextMenuEvent* e){
}
void KeepassEntryView::resizeEvent(QResizeEvent* e){
resizeColumns();
// TODO resizeColumns();
e->accept();
}
void KeepassEntryView::showSearchResults(){
if(ViewMode==Normal){
ViewMode=ShowSearchResults;
if(Columns.at(10))ColumnOrder[10]--;
updateColumns();
if(ViewMode == Normal){
saveHeaderView();
ViewMode = ShowSearchResults;
restoreHeaderView();
emit viewModeChanged(true);
}
clear();
Items.clear();
@ -418,9 +455,11 @@ void KeepassEntryView::showSearchResults(){
void KeepassEntryView::showGroup(IGroupHandle* group){
if(ViewMode==ShowSearchResults){
ViewMode=Normal;
updateColumns();
if(ViewMode == ShowSearchResults){
saveHeaderView();
ViewMode = Normal;
restoreHeaderView();
emit viewModeChanged(false);
}
clear();
Items.clear();
@ -436,45 +475,35 @@ void KeepassEntryView::createItems(QList<IEntryHandle*>& entries){
Items.push_back(item);
Items.back()->EntryHandle=entries[i];
int j=0;
if (Columns.at(0)){
item->setText(j++,entries[i]->title());
item->setIcon(0,db->icon(entries[i]->image()));}
if (Columns.at(1)){
if(config->hideUsernames())
item->setText(j++,"******");
else
item->setText(j++,entries[i]->username());}
if (Columns.at(2)){item->setText(j++,entries[i]->url());}
if (Columns.at(3)){
if(config->hidePasswords())
item->setText(j++,"******");
else{
SecString password=entries[i]->password();
password.unlock();
item->setText(j++,password.string());
}
}
if (Columns.at(4)){
QString comment = entries[i]->comment();
int toPos = comment.indexOf(QRegExp("[\\r\\n]"));
if (toPos == -1)
item->setText(j++,comment);
else
item->setText(j++,comment.left(toPos));
item->setText(j++,entries[i]->title());
item->setIcon(0,db->icon(entries[i]->image()));
if(config->hideUsernames())
item->setText(j++,"******");
else
item->setText(j++,entries[i]->username());
item->setText(j++,entries[i]->url());
if(config->hidePasswords())
item->setText(j++,"******");
else{
SecString password=entries[i]->password();
password.unlock();
item->setText(j++,password.string());
}
if (Columns.at(5)){
item->setText(j++,entries[i]->expire().dateToString(Qt::SystemLocaleDate));}
if (Columns.at(6)){
item->setText(j++,entries[i]->creation().dateToString(Qt::SystemLocaleDate));}
if (Columns.at(7)){
item->setText(j++,entries[i]->lastMod().dateToString(Qt::SystemLocaleDate));}
if (Columns.at(8)){
item->setText(j++,entries[i]->lastAccess().dateToString(Qt::SystemLocaleDate));}
if (Columns.at(9)){
item->setText(j++,entries[i]->binaryDesc());}
if(Columns.at(10) && ViewMode==ShowSearchResults){
QString comment = entries[i]->comment();
int toPos = comment.indexOf(QRegExp("[\\r\\n]"));
if (toPos == -1)
item->setText(j++,comment);
else
item->setText(j++,comment.left(toPos));
item->setText(j++,entries[i]->expire().dateToString(Qt::SystemLocaleDate));
item->setText(j++,entries[i]->creation().dateToString(Qt::SystemLocaleDate));
item->setText(j++,entries[i]->lastMod().dateToString(Qt::SystemLocaleDate));
item->setText(j++,entries[i]->lastAccess().dateToString(Qt::SystemLocaleDate));
item->setText(j++,entries[i]->binaryDesc());
if (ViewMode == ShowSearchResults) {
item->setText(j,entries[i]->group()->title());
item->setIcon(j++,db->icon(entries[i]->group()->image()));}
item->setIcon(j++,db->icon(entries[i]->group()->image()));
}
}
}
@ -484,137 +513,11 @@ void KeepassEntryView::updateIcons(){
}
}
/*void KeepassEntryView::setEntry(IEntryHandle* entry){
}*/
void KeepassEntryView::updateColumns(){
setColumnCount(0);
QStringList cols;
if (Columns.at(0)){
cols << tr("Title");}
if (Columns.at(1)){
cols << tr("Username");}
if (Columns.at(2)){
cols << tr("URL");}
if (Columns.at(3)){
cols << tr("Password");}
if (Columns.at(4)){
cols << tr("Comments");}
if (Columns.at(5)){
cols << tr("Expires");}
if (Columns.at(6)){
cols << tr("Creation");}
if (Columns.at(7)){
cols << tr("Last Change");}
if (Columns.at(8)){
cols << tr("Last Access");}
if (Columns.at(9)){
cols << tr("Attachment");}
if(Columns.at(10) && ViewMode==ShowSearchResults){
cols << tr("Group");}
setHeaderLabels(cols);
for(int i=0;i<NUM_COLUMNS;i++){
if(!Columns.at(i))
ColumnOrder[i]=100;
}
QMap<int,int> Order;
for(int i=NUM_COLUMNS-1;i>=0;i--)
Order.insertMulti(ColumnOrder.at(i),i);
QMapIterator<int, int> i(Order);
while (i.hasNext()) {
i.next();
int index=i.value();
if(!Columns.at(index))continue;
header()->moveSection(header()->visualIndex(logicalColIndex(index)),header()->count()-1);
}
resizeColumns();
}
void KeepassEntryView::refreshItems(){
for (int i=0;i<Items.size();i++)
updateEntry(Items.at(i));
}
void KeepassEntryView::OnColumnMoved(){
for(int i=0;i<header()->count();i++){
ColumnOrder[columnListIndex(header()->logicalIndex(i))]=i;
}
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
}
int KeepassEntryView::logicalColIndex(int LstIndex){
int c=-1;
for(int i=0;i<NUM_COLUMNS;i++){
if(Columns.at(i))
c++;
if(i==10 && Columns.at(10) && ViewMode!=ShowSearchResults)
c--;
if(i==LstIndex)
return c;
}
Q_ASSERT(false);
return -1;
}
void KeepassEntryView::resizeColumns(){
AutoResizeColumns=false;
int w=viewport()->width();
int sum=0;
for(int i=0;i<NUM_COLUMNS;i++){
// if(i==10) continue; //skip "Group" column
if(!Columns.at(i))
ColumnSizes[i]=0;
if(Columns.at(i) && !ColumnSizes.at(i))
ColumnSizes[i]=w/10;
}
for(int i=0;i<header()->count();i++){
sum+=ColumnSizes.at(columnListIndex(i));
}
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.at(lstIndex));
sum+=NewSize;
if(i==header()->count()-1){
NewSize+=(w-sum); // add rounding difference to the last column
}
header()->resizeSection(header()->logicalIndex(i),NewSize);
ColumnSizes[lstIndex]=NewSize;
}
AutoResizeColumns=true;
}
int KeepassEntryView::columnListIndex(int LogicalIndex){
int c=-1; int i;
for(i=0;i<NUM_COLUMNS;i++){
if(Columns.at(i))
c++;
if(i==10 && Columns.at(10) && ViewMode!=ShowSearchResults)
c--;
if(c==LogicalIndex)
break;
}
return i;
}
void KeepassEntryView::OnColumnResized(){
if(!AutoResizeColumns)return;
for(int i=0;i<header()->count();i++){
ColumnSizes[columnListIndex(i)]=header()->sectionSize(i);
}
resizeColumns();
}
void KeepassEntryView::mousePressEvent(QMouseEvent *event){
//save event position - maybe this is the start of a drag
if (event->button() == Qt::LeftButton)
@ -710,7 +613,7 @@ EntryViewItem::EntryViewItem(QTreeWidgetItem *parent, QTreeWidgetItem *preceding
bool EntryViewItem::operator<(const QTreeWidgetItem& other) const{
int SortCol = treeWidget()->header()->sortIndicatorSection();
int ListIndex = ((KeepassEntryView*)treeWidget())->columnListIndex(SortCol);
int ListIndex = ((KeepassEntryView*)treeWidget())->header()->logicalIndex(SortCol);
int comp = compare(other, SortCol, ListIndex);
if (comp!=0)
@ -720,7 +623,7 @@ bool EntryViewItem::operator<(const QTreeWidgetItem& other) const{
int ListIndexOrg = ListIndex;
for (int i=0; i<visibleCols; i++){
SortCol = treeWidget()->header()->logicalIndex(i);
ListIndex = ((KeepassEntryView*)treeWidget())->columnListIndex(SortCol);
ListIndex = ((KeepassEntryView*)treeWidget())->header()->logicalIndex(SortCol);
if (ListIndex==ListIndexOrg || ListIndex==3) // sort or password column
continue;

@ -23,8 +23,6 @@
#include "Kdb3Database.h"
#define NUM_COLUMNS 11
class EntryViewItem;
class GroupViewItem;
enum SelectionState{NONE,SINGLE,MULTIPLE,SEARCHGROUP};
@ -36,36 +34,32 @@ class KeepassEntryView:public QTreeWidget{
~KeepassEntryView();
void showSearchResults();
void showGroup(IGroupHandle* group);
void updateColumns();
void refreshItems();
int columnListIndex(int LogicalIndex);
void retranslateColumns();
IDatabase* db;
QList<EntryViewItem*>Items;
QList<IEntryHandle*> SearchResults;
QMenu *ContextMenu;
QBitArray Columns;
void setCurrentEntry(IEntryHandle* entry);
inline IGroupHandle* getCurrentGroup() { return CurrentGroup; };
bool columnVisible(int col);
void setColumnVisible(int col, bool visible);
private:
//void setEntry(IEntryHandle* entry);
void updateEntry(EntryViewItem*);
void editEntry(EntryViewItem*);
void createItems(QList<IEntryHandle*>& entries);
int logicalColIndex(int ListIndex);
QClipboard* Clipboard;
QTimer ClipboardTimer;
void resizeColumns();
bool AutoResizeColumns;
QPoint DragStartPos;
QList<QTreeWidgetItem*> DragItems;
IGroupHandle* CurrentGroup;
enum EntryViewMode {Normal, ShowSearchResults};
EntryViewMode ViewMode;
QList<int> ColumnSizes;
QList<int> ColumnOrder;
float GroupColumnSize;
void updateEntry(EntryViewItem*);
void editEntry(EntryViewItem*);
void createItems(QList<IEntryHandle*>& entries);
void saveHeaderView();
void restoreHeaderView();
void contextMenuEvent(QContextMenuEvent *event);
void paintEvent(QPaintEvent* event);
void resizeEvent(QResizeEvent* event);
@ -73,8 +67,6 @@ class KeepassEntryView:public QTreeWidget{
void mouseMoveEvent(QMouseEvent *event);
private slots:
void OnColumnResized();
void OnHeaderSectionClicked(int index);
void OnGroupChanged(IGroupHandle* group);
void OnShowSearchResults();
void OnEntryActivated(QTreeWidgetItem*,int);
@ -93,7 +85,6 @@ class KeepassEntryView:public QTreeWidget{
void OnAutoType();
#endif
void removeDragItems();
void OnColumnMoved();
void OnEditOpenUrl();
void OnEditCopyUrl();
@ -101,6 +92,7 @@ class KeepassEntryView:public QTreeWidget{
void fileModified();
void selectionChanged(SelectionState);
void requestCreateGroup(QString title, quint32 image, GroupViewItem* parent);
void viewModeChanged(bool searchResultMode);
};

@ -36,7 +36,6 @@ KeepassGroupView::KeepassGroupView(QWidget* parent):QTreeWidget(parent){
connect(this,SIGNAL(itemCollapsed(QTreeWidgetItem*)),this,SLOT(OnItemCollapsed(QTreeWidgetItem*)));
}
void KeepassGroupView::createItems(){
clear();
Items.clear();
@ -55,6 +54,10 @@ void KeepassGroupView::createItems(){
Items[i]->setExpanded(Items[i]->GroupHandle->expanded());
}
SearchResultItem=new GroupViewItem();
retranslateUi();
}
void KeepassGroupView::retranslateUi() {
SearchResultItem->setText(0,tr("Search Results"));
}

@ -38,6 +38,7 @@ class KeepassGroupView:public QTreeWidget{
void showSearchResults();
void setCurrentGroup(IGroupHandle* group);
void selectFirstGroup();
void retranslateUi();
public slots:
void createGroup(const QString& title, quint32 image, GroupViewItem* group=NULL);

@ -32,7 +32,6 @@
#include <QCryptographicHash>
#include <QCursor>
#include <QDataStream>
#include <QDateTime>
#include <QTime>
void initStdRand();

@ -49,7 +49,6 @@ Import_KWalletXml import_KWalletXml;
Export_Txt export_Txt;
Export_KeePassX_Xml export_KeePassX_Xml;
KeepassMainWindow::KeepassMainWindow(const QString& ArgFile,bool ArgMin,bool ArgLock,QWidget *parent, Qt::WFlags flags) :QMainWindow(parent,flags){
IsLocked=false;
EventOccurred=true;
@ -191,8 +190,6 @@ void KeepassMainWindow::setupConnections(){
connect(HelpHandbookAction,SIGNAL(triggered()),this,SLOT(OnHelpHandbook()));
connect(HelpAboutAction,SIGNAL(triggered()),this,SLOT(OnHelpAbout()));
connect(EntryView,SIGNAL(itemActivated(QTreeWidgetItem*,int)),EntryView,SLOT(OnEntryActivated(QTreeWidgetItem*,int)));
connect(EntryView,SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),EntryView,SLOT(OnEntryDblClicked(QTreeWidgetItem*,int)));
connect(QuickSearchEdit,SIGNAL(returnPressed()), this, SLOT(OnQuickSearch()));
connect(GroupView,SIGNAL(groupChanged(IGroupHandle*)),EntryView,SLOT(OnGroupChanged(IGroupHandle*)));
connect(GroupView,SIGNAL(groupChanged(IGroupHandle*)),this,SLOT(OnGroupSelectionChanged(IGroupHandle*)));
@ -203,6 +200,8 @@ void KeepassMainWindow::setupConnections(){
connect(GroupView,SIGNAL(searchResultsSelected()),this,SLOT(OnShowSearchResults()));
connect(GroupView,SIGNAL(entriesDropped()),EntryView,SLOT(removeDragItems()));
connect(HideSearchResultsAction,SIGNAL(triggered()),GroupView,SLOT(OnHideSearchResults()));
connect(EntryView, SIGNAL(viewModeChanged(bool)), SLOT(loadColumnVisibility()));
connect(EntryView, SIGNAL(viewModeChanged(bool)), ViewColumnsGroupAction, SLOT(setVisible(bool)));
connect(SysTray,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(OnSysTrayActivated(QSystemTrayIcon::ActivationReason)));
connect(DetailView,SIGNAL(anchorClicked(const QUrl&)),this,SLOT(OnDetailViewUrlClicked(const QUrl&)));
@ -311,17 +310,7 @@ void KeepassMainWindow::setupMenus(){
ViewShowEntryDetailsAction->setChecked(config->showEntryDetails());
ViewHidePasswordsAction->setChecked(config->hidePasswords());
ViewHideUsernamesAction->setChecked(config->hideUsernames());
ViewColumnsTitleAction->setChecked(EntryView->Columns[0]);
ViewColumnsUsernameAction->setChecked(EntryView->Columns[1]);
ViewColumnsUrlAction->setChecked(EntryView->Columns[2]);
ViewColumnsPasswordAction->setChecked(EntryView->Columns[3]);
ViewColumnsCommentAction->setChecked(EntryView->Columns[4]);
ViewColumnsExpireAction->setChecked(EntryView->Columns[5]);
ViewColumnsCreationAction->setChecked(EntryView->Columns[6]);
ViewColumnsLastChangeAction->setChecked(EntryView->Columns[7]);
ViewColumnsLastAccessAction->setChecked(EntryView->Columns[8]);
ViewColumnsAttachmentAction->setChecked(EntryView->Columns[9]);
ViewColumnsGroupAction->setChecked(EntryView->Columns[10]);
loadColumnVisibility();
ViewShowStatusbarAction->setChecked(config->showStatusbar());
switch(config->toolbarIconSize()){
@ -385,6 +374,20 @@ void KeepassMainWindow::setupMenus(){
menuBookmarks->menuAction()->setVisible(config->featureBookmarks());
}
void KeepassMainWindow::loadColumnVisibility() {
ViewColumnsTitleAction->setChecked(EntryView->columnVisible(0));
ViewColumnsUsernameAction->setChecked(EntryView->columnVisible(1));
ViewColumnsUrlAction->setChecked(EntryView->columnVisible(2));
ViewColumnsPasswordAction->setChecked(EntryView->columnVisible(3));
ViewColumnsCommentAction->setChecked(EntryView->columnVisible(4));
ViewColumnsExpireAction->setChecked(EntryView->columnVisible(5));
ViewColumnsCreationAction->setChecked(EntryView->columnVisible(6));
ViewColumnsLastChangeAction->setChecked(EntryView->columnVisible(7));
ViewColumnsLastAccessAction->setChecked(EntryView->columnVisible(8));
ViewColumnsAttachmentAction->setChecked(EntryView->columnVisible(9));
ViewColumnsGroupAction->setChecked(EntryView->columnVisible(10));
}
void KeepassMainWindow::setupDatabaseConnections(IDatabase* DB){
ICustomIcons* CustomIconsDb=dynamic_cast<ICustomIcons*>(DB);
if(CustomIconsDb){
@ -1013,19 +1016,17 @@ void KeepassMainWindow::OnQuickSearch(){
}
void KeepassMainWindow::OnColumnVisibilityChanged(){
EntryView->Columns[0]=ViewColumnsTitleAction->isChecked();
EntryView->Columns[1]=ViewColumnsUsernameAction->isChecked();
EntryView->Columns[2]=ViewColumnsUrlAction->isChecked();
EntryView->Columns[3]=ViewColumnsPasswordAction->isChecked();
EntryView->Columns[4]=ViewColumnsCommentAction->isChecked();
EntryView->Columns[5]=ViewColumnsExpireAction->isChecked();
EntryView->Columns[6]=ViewColumnsCreationAction->isChecked();
EntryView->Columns[7]=ViewColumnsLastChangeAction->isChecked();
EntryView->Columns[8]=ViewColumnsLastAccessAction->isChecked();
EntryView->Columns[9]=ViewColumnsAttachmentAction->isChecked();
EntryView->Columns[10]=ViewColumnsGroupAction->isChecked();
EntryView->updateColumns();
if(FileOpen) EntryView->refreshItems();
EntryView->setColumnVisible(0, ViewColumnsTitleAction->isChecked());
EntryView->setColumnVisible(1, ViewColumnsUsernameAction->isChecked());
EntryView->setColumnVisible(2, ViewColumnsUrlAction->isChecked());
EntryView->setColumnVisible(3, ViewColumnsPasswordAction->isChecked());
EntryView->setColumnVisible(4, ViewColumnsCommentAction->isChecked());
EntryView->setColumnVisible(5, ViewColumnsExpireAction->isChecked());
EntryView->setColumnVisible(6, ViewColumnsCreationAction->isChecked());
EntryView->setColumnVisible(7, ViewColumnsLastChangeAction->isChecked());
EntryView->setColumnVisible(8, ViewColumnsLastAccessAction->isChecked());
EntryView->setColumnVisible(9, ViewColumnsAttachmentAction->isChecked());
EntryView->setColumnVisible(10, ViewColumnsGroupAction->isVisible() && ViewColumnsGroupAction->isChecked());
}
void KeepassMainWindow::OnUsernPasswVisibilityChanged(){
@ -1102,7 +1103,8 @@ void KeepassMainWindow::OnExtrasSettings(){
retranslateUi(this);
WorkspaceLockedWidget.retranslateUi(LockedCentralWidget);
ViewShowToolbarAction->setText(tr("Show &Toolbar"));
EntryView->updateColumns();
EntryView->retranslateColumns();
GroupView->retranslateUi();
if (FileOpen) {
if (db->file())
setWindowTitle(QString("%1[*] - KeePassX").arg(db->file()->fileName()));

@ -86,6 +86,7 @@ class KeepassMainWindow : public QMainWindow, private Ui_MainWindow{
void OnLockClose();
void OnInactivityTimer();
void OnShutdown(QSessionManager& manager);
void loadColumnVisibility();
private:
void closeEvent(QCloseEvent* event);