diff --git a/src/forms/MainWindow.ui b/src/forms/MainWindow.ui
index 060109d..8402d6a 100644
--- a/src/forms/MainWindow.ui
+++ b/src/forms/MainWindow.ui
@@ -115,6 +115,50 @@
29
+
+
+
- KeepassEntryView
+ KeepassGroupView
QTreeWidget
- ../../src/lib/EntryView.h
+ ../../src/lib/GroupView.h
- KeepassGroupView
+ KeepassEntryView
QTreeWidget
- ../../src/lib/GroupView.h
+ ../../src/lib/EntryView.h
diff --git a/src/lib/EntryView.cpp b/src/lib/EntryView.cpp
index bc3a2b4..9748e4a 100644
--- a/src/lib/EntryView.cpp
+++ b/src/lib/EntryView.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2005-2006 by Tarek Saidi *
+ * Copyright (C) 2005-2007 by Tarek Saidi *
* tarek.saidi@arcor.de *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -36,31 +36,71 @@
#include "lib/AutoType.h"
+// just for the lessThan funtion
+QList* pItems;
+KeepassEntryView* pEntryView;
KeepassEntryView::KeepassEntryView(QWidget* parent):QTreeWidget(parent){
- AutoResizeColumns=true;
- int sum=0;
- for(int i=0;isetResizeMode(QHeaderView::Interactive);
header()->setStretchLastSection(false);
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;ivalue("Ui/ShowColumns",DefaultColumnConfig).toStringList();
+ Columns.resize(NUM_COLUMNS);
+ if(ColumnConfig.size()value("Ui/ColumnOrder",QStringList()<<"100"<<"100"<<"100"<<"100"<<"100"<<"100"<<"100"<<"100"<<"100"<<"100"<<"100").toStringList();
+ for(int i=0;isetValue("Ui/ColumnSizes",ColumnSizesConfig);
+ QStringList ColumnConfig;
+ for(int i=0;isetValue("Ui/ShowColumns",ColumnConfig);
+ QStringList ColumnOrderConfig;
+ for(int i=0;isetValue("Ui/ColumnOrder",ColumnOrderConfig);
}
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;indexAsize();indexA++){
+ if((*pItems)[indexA]->EntryHandle==a)break;
+ }
+ for(indexB;indexBsize();indexB++){
+ if((*pItems)[indexB]->EntryHandle==b)break;
+ }
+ return pEntryView->indexOfTopLevelItem((*pItems)[indexA])indexOfTopLevelItem((*pItems)[indexB]);
+}
+
+
void KeepassEntryView::OnHeaderSectionClicked(int index){
if(header()->isSortIndicatorShown() && header()->sortIndicatorSection()==index){
header()->setSortIndicator(index,header()->sortIndicatorOrder() ? Qt::DescendingOrder : Qt::AscendingOrder);
@@ -94,9 +147,18 @@ void KeepassEntryView::OnHeaderSectionClicked(int index){
header()->setSortIndicatorShown(true);
sortItems(index,Qt::AscendingOrder);
}
-
- for(int i=0;iEntryHandle->setVisualIndexDirectly(indexOfTopLevelItem(Items[i]));
+
+ if(ViewMode==Normal){
+ for(int i=0;iEntryHandle->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){
IEntryHandle* entry = item->EntryHandle;
int j=0;
- if(config.Columns[0])item->setText(j++,entry->title());
- if(config.Columns[1]){
+ if(Columns[0]){
+ item->setText(j++,entry->title());
+ item->setIcon(0,db->icon(entry->image()));
+ }
+ if(Columns[1]){
if(config.ListView_HideUsernames)
item->setText(j++,"******");
else
item->setText(j++,entry->username());}
- if(config.Columns[2]){item->setText(j++,entry->url());}
- if(config.Columns[3]){
+ if(Columns[2]){item->setText(j++,entry->url());}
+ if(Columns[3]){
if(config.ListView_HidePasswords)
item->setText(j++,"******");
else{
@@ -147,19 +212,21 @@ void KeepassEntryView::updateEntry(EntryViewItem* item){
item->setText(j++,password.string());
}
}
- if(config.Columns[4]){
- item->setText(j++,entry->comment().section('\n',0,0));}
- if(config.Columns[5]){
- item->setText(j++,entry->expire().dateToString(Qt::LocalDate));}
- if(config.Columns[6]){
- item->setText(j++,entry->creation().dateToString(Qt::LocalDate));}
- if(config.Columns[7]){
- item->setText(j++,entry->lastMod().dateToString(Qt::LocalDate));}
- if(config.Columns[8]){
- item->setText(j++,entry->lastAccess().dateToString(Qt::LocalDate));}
- if(config.Columns[9]){
- item->setText(j++,entry->binaryDesc());}
- item->setIcon(0,db->icon(entry->image()));
+ if(Columns[4]){
+ item->setText(j++,entry->comment().section('\n',0,0));}
+ if(Columns[5]){
+ item->setText(j++,entry->expire().dateToString(Qt::LocalDate));}
+ if(Columns[6]){
+ item->setText(j++,entry->creation().dateToString(Qt::LocalDate));}
+ if(Columns[7]){
+ item->setText(j++,entry->lastMod().dateToString(Qt::LocalDate));}
+ if(Columns[8]){
+ item->setText(j++,entry->lastAccess().dateToString(Qt::LocalDate));}
+ if(Columns[9]){
+ item->setText(j++,entry->binaryDesc());}
+ if(Columns[10]){
+ item->setText(j,entry->group()->title());
+ item->setIcon(j++,db->icon(entry->group()->image()));}
}
void KeepassEntryView::editEntry(EntryViewItem* item){
@@ -272,13 +339,15 @@ void KeepassEntryView::resizeEvent(QResizeEvent* e){
void KeepassEntryView::showSearchResults(){
+ ViewMode=ShowSearchResults;
clear();
Items.clear();
- createItems(SearchResults);
+ createItems(SearchResults);
}
void KeepassEntryView::showGroup(IGroupHandle* group){
+ ViewMode=Normal;
clear();
Items.clear();
if(group==NULL)return;
@@ -294,14 +363,16 @@ void KeepassEntryView::createItems(QList& entries){
Items.push_back(item);
Items.back()->EntryHandle=entries[i];
int j=0;
- if(config.Columns[0])item->setText(j++,entries[i]->title());
- if(config.Columns[1]){
+ if(Columns[0]){
+ item->setText(j++,entries[i]->title());
+ item->setIcon(0,db->icon(entries[i]->image()));}
+ if(Columns[1]){
if(config.ListView_HideUsernames)
item->setText(j++,"******");
else
item->setText(j++,entries[i]->username());}
- if(config.Columns[2]){item->setText(j++,entries[i]->url());}
- if(config.Columns[3]){
+ if(Columns[2]){item->setText(j++,entries[i]->url());}
+ if(Columns[3]){
if(config.ListView_HidePasswords)
item->setText(j++,"******");
else{
@@ -310,20 +381,21 @@ void KeepassEntryView::createItems(QList& entries){
item->setText(j++,password.string());
}
}
- if(config.Columns[4]){
+ if(Columns[4]){
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));}
- if(config.Columns[6]){
+ if(Columns[6]){
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));}
- if(config.Columns[8]){
+ if(Columns[8]){
item->setText(j++,entries[i]->lastAccess().dateToString(Qt::LocalDate));}
- if(config.Columns[9]){
+ if(Columns[9]){
item->setText(j++,entries[i]->binaryDesc());}
- Items.back()->setIcon(0,db->icon(entries[i]->image()));
- qDebug("%s : %i",entries[i]->title().toUtf8().data(),entries[i]->visualIndex());
+ if(Columns[10]){
+ 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::refreshItems(){
-EntryViewItem *tmp=NULL;
-for(int i=0;ipEntry;
-
- 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(){
setColumnCount(0);
QStringList cols;
- if(config.Columns[0]){
+ if(Columns[0]){
cols << tr("Title");}
- if(config.Columns[1]){
+ if(Columns[1]){
cols << tr("Username");}
- if(config.Columns[2]){
+ if(Columns[2]){
cols << tr("URL");}
- if(config.Columns[3]){
+ if(Columns[3]){
cols << tr("Password");}
- if(config.Columns[4]){
+ if(Columns[4]){
cols << tr("Comments");}
- if(config.Columns[5]){
+ if(Columns[5]){
cols << tr("Expires");}
- if(config.Columns[6]){
+ if(Columns[6]){
cols << tr("Creation");}
- if(config.Columns[7]){
+ if(Columns[7]){
cols << tr("Last Change");}
- if(config.Columns[8]){
+ if(Columns[8]){
cols << tr("Last Access");}
- if(config.Columns[9]){
+ if(Columns[9]){
cols << tr("Attachment");}
+ if(Columns[10]){
+ cols << tr("Group");}
setHeaderLabels(cols);
- resizeColumns();
-}
-
-void KeepassEntryView::resizeColumns(){
-AutoResizeColumns=false;
-if(!header()->count())return;
-
-for(int i=0;iwidth();
-int wx=0; int j=0;
-
-
-for(int i=0;iresizeSection(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));
+
+ QMap Order;
+ for(int i=NUM_COLUMNS-1;i>=0;i--)
+ Order.insertMulti(ColumnOrder[i],i);
+
+ QMapIterator i(Order);
+ while (i.hasNext()) {
+ i.next();
+ int index=i.value();
+ if(!Columns[index])continue;
+ header()->moveSection(header()->visualIndex(logicalColIndex(index)),header()->count()-1);
}
-}
-
-AutoResizeColumns=true;
+ resizeColumns();
}
+void KeepassEntryView::OnColumnMoved(int LogIndex,int OldVisIndex,int NewVisIndex){
+ for(int i=0;icount();i++){
+ ColumnOrder[columnListIndex(header()->logicalIndex(i))]=i;
+ }
+}
-void KeepassEntryView::OnColumnResized(int index,int Old, int New){
-if(!AutoResizeColumns)return;
-
-int i=0; int c=-1;
-for(i;iwidth();
+ int sum=0;
+ for(int i=0;icount();i++){
+ sum+=ColumnSizes[columnListIndex(i)];
+ }
+ float stretch=((float)w)/((float)sum);
+ sum=0;
+ for(int i=0;icount();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;
}
-if(IsLastColumn){
- j=0; c=-1;
- for(j;jwidth();
-float div=(float)(New-Old)/(float)w;
-if(((ColumnSizes[j]-div)*w > 2)){
- ColumnSizes[j]-=div;
- ColumnSizes[i]+=div;
-}
-resizeColumns();
+void KeepassEntryView::OnColumnResized(int lindex,int Old, int New){
+ if(!AutoResizeColumns)return;
+ for(int i=0;icount();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)
DragStartPos = event->pos();
- //call base function
QTreeWidget::mousePressEvent(event);
}
void KeepassEntryView::mouseMoveEvent(QMouseEvent *event){
- /*
-if(IsSearchGroup)
- return;
-if (!(event->buttons() & Qt::LeftButton))
- return;
-if ((event->pos() - DragStartPos).manhattanLength() < QApplication::startDragDistance())
- return;
-
-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;ibuttons() & Qt::LeftButton))
+ return;
+ if ((event->pos() - DragStartPos).manhattanLength() < QApplication::startDragDistance())
+ return;
+
+ DragItems.clear();
+ EntryViewItem* DragStartItem=(EntryViewItem*)itemAt(DragStartPos);
+ if(!DragStartItem){
while(selectedItems().size()){
- setItemSelected(selectedItems()[0],false);
+ setItemSelected(selectedItems()[0],false);}
+ return;
+ }
+ if(selectedItems().size()==0){
+ setItemSelected(DragStartItem,true);}
+ else{
+ bool AlreadySelected=false;
+ for(int i=0;ifont(0));
-int DragPixmHeight=16;
-if(fontmet.height()>16)DragPixmHeight=fontmet.height();
-QString DragText;
-if(DragItems.size()>1)DragText=QString(tr("%1 items")).arg(DragItems.size());
-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();
- */
+
+ 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();
+
+}
+
+void KeepassEntryView::removeDragItems(){
+ for(int i=0;isortColumn();
- 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)
return true;
else
diff --git a/src/lib/EntryView.h b/src/lib/EntryView.h
index 5425ca0..1b01d7a 100644
--- a/src/lib/EntryView.h
+++ b/src/lib/EntryView.h
@@ -27,9 +27,10 @@
#include
#include
#include
+#include
#include "../StandardDatabase.h"
-#define NUM_COLUMNS 10
+#define NUM_COLUMNS 11
class EntryViewItem;
enum SelectionState{NONE,SINGLE,MULTIPLE,SEARCHGROUP};
@@ -42,26 +43,31 @@ class KeepassEntryView:public QTreeWidget{
void showSearchResults();
void showGroup(IGroupHandle* group);
void updateColumns();
- // void showSearchResults(QList& results);
IDatabase* db;
QListItems;
QList SearchResults;
QMenu *ContextMenu;
+ QVarLengthArrayColumns;
private:
void setEntry(IEntryHandle* entry);
void updateEntry(EntryViewItem*);
void editEntry(EntryViewItem*);
void createItems(QList& entries);
+ int columnListIndex(int LogicalIndex);
+ int logicalColIndex(int ListIndex);
QClipboard* Clipboard;
QTimer ClipboardTimer;
- QListColumnSizes;
void resizeColumns();
bool AutoResizeColumns;
QPoint DragStartPos;
QList DragItems;
QPixmap DragPixmap;
IGroupHandle* CurrentGroup;
+ enum EntryViewMode {Normal, ShowSearchResults};
+ EntryViewMode ViewMode;
+ QVarLengthArrayColumnSizes;
+ QVarLengthArrayColumnOrder;
virtual void contextMenuEvent(QContextMenuEvent *event);
virtual void paintEvent(QPaintEvent* event);
@@ -85,6 +91,8 @@ class KeepassEntryView:public QTreeWidget{
void OnDeleteEntry();
void OnSaveAttachment();
void OnAutoType();
+ void removeDragItems();
+ void OnColumnMoved(int LogIndex,int OldVisIndex,int NewVisIndex);
signals:
void fileModified();
void selectionChanged(SelectionState);
diff --git a/src/lib/GroupView.cpp b/src/lib/GroupView.cpp
index dc06c3d..8451fac 100644
--- a/src/lib/GroupView.cpp
+++ b/src/lib/GroupView.cpp
@@ -54,6 +54,7 @@ KeepassGroupView::KeepassGroupView(QWidget* parent):QTreeWidget(parent){
void KeepassGroupView::createItems(){
clear();
Items.clear();
+ InsLinePos=-1;
QList groups=db->groups();
for(int i=0;iparent()==NULL){
@@ -178,7 +179,14 @@ void KeepassGroupView::dragEnterEvent ( QDragEnterEvent * event ){
LastHoverItem=NULL;
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();
return;
}
@@ -199,10 +207,39 @@ void KeepassGroupView::dragLeaveEvent ( QDragLeaveEvent * event ){
}
+void KeepassGroupView::entryDropEvent( QDropEvent * event ){
+ if(LastHoverItem){
+ 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;isize();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){
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 ){
+ if(DragType==EntryDrag){
+ entryDragMoveEvent(event);
+ return;
+ }
if(DragItem){
GroupViewItem* Item=(GroupViewItem*)itemAt(event->pos());
if(!Item){
@@ -393,7 +461,7 @@ void KeepassGroupView::mouseMoveEvent(QMouseEvent *event){
QMimeData *mimeData = new QMimeData;
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);
Qt::DropAction dropAction = drag->start(Qt::MoveAction);
diff --git a/src/lib/GroupView.h b/src/lib/GroupView.h
index e3f65aa..69bfc22 100644
--- a/src/lib/GroupView.h
+++ b/src/lib/GroupView.h
@@ -40,10 +40,12 @@ class KeepassGroupView:public QTreeWidget{
void showSearchResults();
private:
- virtual void dragEnterEvent ( QDragEnterEvent * event );
- virtual void dragMoveEvent ( QDragMoveEvent * event );
+ virtual void dragEnterEvent(QDragEnterEvent* event);
+ virtual void dragMoveEvent(QDragMoveEvent* event);
+ void entryDragMoveEvent(QDragMoveEvent* event);
virtual void dragLeaveEvent ( QDragLeaveEvent * event );
virtual void dropEvent ( QDropEvent * event );
+ void entryDropEvent(QDropEvent* event);
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void paintEvent ( QPaintEvent * event );
@@ -54,6 +56,9 @@ class KeepassGroupView:public QTreeWidget{
GroupViewItem* LastHoverItem;
int InsLinePos;
int InsLineStart;
+ enum GroupViewDragType{EntryDrag,GroupDrag};
+ GroupViewDragType DragType;
+ QList* EntryDragItems;
public slots:
void OnCurrentGroupChanged(QTreeWidgetItem*,QTreeWidgetItem*);
@@ -69,6 +74,7 @@ class KeepassGroupView:public QTreeWidget{
void groupChanged(IGroupHandle* NewGroup);
void searchResultsSelected();
void fileModified();
+ void entriesDropped();
};
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 23ce186..105868d 100755
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -144,16 +144,8 @@ void KeepassMainWindow::setupConnections(){
connect(ViewShowEntryDetailsAction,SIGNAL(toggled(bool)),this,SLOT(OnViewShowEntryDetails(bool)));
connect(ViewHidePasswordsAction,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(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(menuColumns,SIGNAL(triggered(QAction*)),this,SLOT(OnColumnVisibilityChanged(QAction*)));
connect(ViewToolButtonSize16Action,SIGNAL(toggled(bool)), this, SLOT(OnViewToolbarIconSize16(bool)));
connect(ViewToolButtonSize22Action,SIGNAL(toggled(bool)), this, SLOT(OnViewToolbarIconSize22(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(GroupView,SIGNAL(searchResultsSelected()),EntryView,SLOT(OnShowSearchResults()));
connect(GroupView,SIGNAL(searchResultsSelected()),this,SLOT(OnShowSearchResults()));
+ connect(GroupView,SIGNAL(entriesDropped()),EntryView,SLOT(removeDragItems()));
connect(HideSearchResultsAction,SIGNAL(triggered()),GroupView,SLOT(OnHideSearchResults()));
connect(SysTray,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(OnSysTrayActivated(QSystemTrayIcon::ActivationReason)));
@@ -258,16 +251,17 @@ void KeepassMainWindow::setupMenus(){
ViewShowEntryDetailsAction->setChecked(config.EntryDetails);
ViewHidePasswordsAction->setChecked(config.ListView_HidePasswords);
ViewHideUsernamesAction->setChecked(config.ListView_HideUsernames);
- ViewColumnsTitleAction->setChecked(config.Columns[0]);
- ViewColumnsUsernameAction->setChecked(config.Columns[1]);
- ViewColumnsUrlAction->setChecked(config.Columns[2]);
- ViewColumnsPasswordAction->setChecked(config.Columns[3]);
- ViewColumnsCommentAction->setChecked(config.Columns[4]);
- ViewColumnsExpireAction->setChecked(config.Columns[5]);
- ViewColumnsCreationAction->setChecked(config.Columns[6]);
- ViewColumnsLastChangeAction->setChecked(config.Columns[7]);
- ViewColumnsLastAccessAction->setChecked(config.Columns[8]);
- ViewColumnsAttachmentAction->setChecked(config.Columns[9]);
+ 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]);
ViewShowStatusbarAction->setChecked(config.ShowStatusbar);
switch(config.ToolbarIconSize){
@@ -754,24 +748,25 @@ void KeepassMainWindow::OnQuickSearch(){
GroupView->showSearchResults();
}
-void KeepassMainWindow::OnColumnVisibilityChanged(bool value){
- config.Columns[0]=ViewColumnsTitleAction->isChecked();
- config.Columns[1]=ViewColumnsUsernameAction->isChecked();
- config.Columns[2]=ViewColumnsUrlAction->isChecked();
- config.Columns[3]=ViewColumnsPasswordAction->isChecked();
- config.Columns[4]=ViewColumnsCommentAction->isChecked();
- config.Columns[5]=ViewColumnsExpireAction->isChecked();
- config.Columns[6]=ViewColumnsCreationAction->isChecked();
- config.Columns[7]=ViewColumnsLastChangeAction->isChecked();
- config.Columns[8]=ViewColumnsLastAccessAction->isChecked();
- config.Columns[9]=ViewColumnsAttachmentAction->isChecked();
- //EntryView->updateColumns();
+void KeepassMainWindow::OnColumnVisibilityChanged(QAction* action){
+ 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->updateItems();
}
void KeepassMainWindow::OnUsernPasswVisibilityChanged(bool value){
-config.ListView_HidePasswords=ViewHidePasswordsAction->isChecked();
-config.ListView_HideUsernames=ViewHideUsernamesAction->isChecked();
+ config.ListView_HidePasswords=ViewHidePasswordsAction->isChecked();
+ config.ListView_HideUsernames=ViewHideUsernamesAction->isChecked();
//EntryView->refreshItems();
}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 3fb35cf..5f09370 100755
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -77,7 +77,7 @@ class KeepassMainWindow : public QMainWindow, public Ui_MainWindow{
void OnViewToolbarIconSize28(bool);
void OnGroupSelectionChanged(IGroupHandle*);
void OnQuickSearch();
- void OnColumnVisibilityChanged(bool show);
+ void OnColumnVisibilityChanged(QAction* action);
void OnUsernPasswVisibilityChanged(bool hide);
void OnFileModified();
void OnExtrasSettings();