Fixed: Predefined expire times don't work (closes #2109987)
Fixed: Sorting isn't consistent (closes #2108655) git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@221 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
@@ -493,6 +493,7 @@ void KeepassEntryView::OnColumnMoved(int LogIndex,int OldVisIndex,int NewVisInde
|
||||
for(int i=0;i<header()->count();i++){
|
||||
ColumnOrder[columnListIndex(header()->logicalIndex(i))]=i;
|
||||
}
|
||||
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
|
||||
}
|
||||
|
||||
int KeepassEntryView::logicalColIndex(int LstIndex){
|
||||
@@ -645,34 +646,67 @@ EntryViewItem::EntryViewItem(QTreeWidgetItem *parent, QTreeWidgetItem *preceding
|
||||
}
|
||||
|
||||
|
||||
bool EntryViewItem::operator<(const QTreeWidgetItem& other)const{
|
||||
int SortCol=treeWidget()->header()->sortIndicatorSection();
|
||||
int ListIndex=((KeepassEntryView*)treeWidget())->columnListIndex(SortCol);
|
||||
if(ListIndex < 5 || ListIndex > 8){ //columns with string values (Title, Username, Password, URL, Comment, Group)
|
||||
return (QString::localeAwareCompare(text(SortCol),other.text(SortCol)) < 0);
|
||||
bool EntryViewItem::operator<(const QTreeWidgetItem& other) const{
|
||||
int SortCol = treeWidget()->header()->sortIndicatorSection();
|
||||
int ListIndex = ((KeepassEntryView*)treeWidget())->columnListIndex(SortCol);
|
||||
|
||||
int comp = compare(other, SortCol, ListIndex);
|
||||
if (comp!=0)
|
||||
return (comp<0);
|
||||
else {
|
||||
int visibleCols = treeWidget()->header()->count() - treeWidget()->header()->hiddenSectionCount();
|
||||
int ListIndexOrg = ListIndex;
|
||||
for (int i=0; i<visibleCols; i++){
|
||||
SortCol = treeWidget()->header()->logicalIndex(i);
|
||||
ListIndex = ((KeepassEntryView*)treeWidget())->columnListIndex(SortCol);
|
||||
if (ListIndex==ListIndexOrg || ListIndex==3) // sort or password column
|
||||
continue;
|
||||
|
||||
comp = compare(other, SortCol, ListIndex);
|
||||
if (comp!=0)
|
||||
return (comp<0);
|
||||
}
|
||||
return true; // entries are equal
|
||||
}
|
||||
}
|
||||
|
||||
int EntryViewItem::compare(const QTreeWidgetItem& other, int col, int index) const{
|
||||
if (index < 5 || index > 8){ //columns with string values (Title, Username, Password, URL, Comment, Group)
|
||||
return QString::localeAwareCompare(text(col),other.text(col));
|
||||
}
|
||||
|
||||
KpxDateTime DateThis;
|
||||
KpxDateTime DateOther;
|
||||
|
||||
switch (ListIndex){
|
||||
case 5: DateThis=EntryHandle->expire();
|
||||
DateOther=((EntryViewItem&)other).EntryHandle->expire();
|
||||
break;
|
||||
case 6: DateThis=EntryHandle->creation();
|
||||
DateOther=((EntryViewItem&)other).EntryHandle->creation();
|
||||
break;
|
||||
case 7: DateThis=EntryHandle->lastMod();
|
||||
DateOther=((EntryViewItem&)other).EntryHandle->lastMod();
|
||||
break;
|
||||
case 8: DateThis=EntryHandle->lastAccess();
|
||||
DateOther=((EntryViewItem&)other).EntryHandle->lastAccess();
|
||||
break;
|
||||
default:Q_ASSERT(false);
|
||||
switch (index){
|
||||
case 5:
|
||||
DateThis=EntryHandle->expire();
|
||||
DateOther=((EntryViewItem&)other).EntryHandle->expire();
|
||||
break;
|
||||
case 6:
|
||||
DateThis=EntryHandle->creation();
|
||||
DateOther=((EntryViewItem&)other).EntryHandle->creation();
|
||||
break;
|
||||
case 7:
|
||||
DateThis=EntryHandle->lastMod();
|
||||
DateOther=((EntryViewItem&)other).EntryHandle->lastMod();
|
||||
break;
|
||||
case 8:
|
||||
DateThis=EntryHandle->lastAccess();
|
||||
DateOther=((EntryViewItem&)other).EntryHandle->lastAccess();
|
||||
break;
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
return DateThis < DateOther;
|
||||
|
||||
if (DateThis==DateOther)
|
||||
return 0;
|
||||
else if (DateThis < DateOther)
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void KeepassEntryView::setCurrentEntry(IEntryHandle* entry){
|
||||
bool found=false;
|
||||
int i;
|
||||
|
||||
@@ -64,11 +64,11 @@ class KeepassEntryView:public QTreeWidget{
|
||||
QList<int> ColumnOrder;
|
||||
float GroupColumnSize;
|
||||
|
||||
virtual void contextMenuEvent(QContextMenuEvent *event);
|
||||
virtual void paintEvent(QPaintEvent* event);
|
||||
virtual void resizeEvent(QResizeEvent* event);
|
||||
virtual void mousePressEvent(QMouseEvent *event);
|
||||
virtual void mouseMoveEvent(QMouseEvent *event);
|
||||
void contextMenuEvent(QContextMenuEvent *event);
|
||||
void paintEvent(QPaintEvent* event);
|
||||
void resizeEvent(QResizeEvent* event);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
|
||||
private slots:
|
||||
void OnColumnResized(int index,int OldSize, int NewSize);
|
||||
@@ -107,7 +107,9 @@ class EntryViewItem:public QTreeWidgetItem{
|
||||
EntryViewItem(QTreeWidgetItem *parent);
|
||||
EntryViewItem(QTreeWidgetItem *parent, QTreeWidgetItem * preceding);
|
||||
IEntryHandle* EntryHandle;
|
||||
virtual bool operator<(const QTreeWidgetItem& other)const;
|
||||
bool operator<(const QTreeWidgetItem& other) const;
|
||||
private:
|
||||
int compare(const QTreeWidgetItem& other, int col, int index) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user