Diffstat (limited to 'noncore/net/mail/accountview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/accountview.cpp | 52 |
1 files changed, 47 insertions, 5 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index c747a8b..d01d6bb 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -21,9 +21,15 @@ AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | |||
21 | : QListView( parent, name, flags ) | 21 | : QListView( parent, name, flags ) |
22 | { | 22 | { |
23 | setSorting(0); | ||
24 | setSelectionMode(Single); | ||
25 | m_rightPressed = false; | ||
26 | |||
23 | connect( this, SIGNAL( selectionChanged(QListViewItem*) ), | 27 | connect( this, SIGNAL( selectionChanged(QListViewItem*) ), |
24 | SLOT( refresh(QListViewItem*) ) ); | 28 | SLOT( slotSelectionChanged(QListViewItem*) ) ); |
25 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, | 29 | connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, |
26 | SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); | 30 | SLOT( slotMouseButton(int,QListViewItem*,const QPoint&,int) ) ); |
27 | setSorting(0); | 31 | connect( this, SIGNAL(clicked(QListViewItem*) ),this, |
32 | SLOT( slotMouseClicked(QListViewItem*) ) ); | ||
33 | m_currentItem = 0; | ||
28 | } | 34 | } |
29 | 35 | ||
@@ -34,4 +40,16 @@ AccountView::~AccountView() | |||
34 | } | 40 | } |
35 | 41 | ||
42 | void AccountView::slotSelectionChanged(QListViewItem*item) | ||
43 | { | ||
44 | odebug << "AccountView: Selection changed" << oendl; | ||
45 | if (!item) { | ||
46 | emit serverSelected(0); | ||
47 | return; | ||
48 | } | ||
49 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | ||
50 | |||
51 | emit serverSelected(view->isServer()); | ||
52 | } | ||
53 | |||
36 | void AccountView::slotContextMenu(int id) | 54 | void AccountView::slotContextMenu(int id) |
37 | { | 55 | { |
@@ -41,7 +59,7 @@ void AccountView::slotContextMenu(int id) | |||
41 | } | 59 | } |
42 | 60 | ||
43 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) | 61 | void AccountView::slotRightButton(int button, QListViewItem * item,const QPoint&,int) |
44 | { | 62 | { |
45 | if (button==1) {return;} | 63 | m_rightPressed = true; |
46 | if (!item) return; | 64 | if (!item) return; |
47 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 65 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
@@ -52,4 +70,28 @@ void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) | |||
52 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 70 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
53 | delete m; | 71 | delete m; |
72 | setSelected(item,true); | ||
73 | } | ||
74 | |||
75 | void AccountView::slotLeftButton(int button, QListViewItem * item,const QPoint&,int) | ||
76 | { | ||
77 | m_rightPressed = false; | ||
78 | } | ||
79 | |||
80 | void AccountView::slotMouseClicked(QListViewItem*item) | ||
81 | { | ||
82 | if (m_rightPressed) return; | ||
83 | if (!item || m_currentItem == item) return; | ||
84 | /* ### ToDo check settings if on single tab it should open */ | ||
85 | m_currentItem = item; | ||
86 | refresh(m_currentItem); | ||
87 | } | ||
88 | |||
89 | void AccountView::slotMouseButton(int button, QListViewItem * item,const QPoint&pos,int column) | ||
90 | { | ||
91 | if (button==1) { | ||
92 | slotLeftButton(button,item,pos,column); | ||
93 | } else if (button==2) { | ||
94 | slotRightButton(button,item,pos,column); | ||
95 | } | ||
54 | } | 96 | } |
55 | 97 | ||