summaryrefslogtreecommitdiff
path: root/noncore/net/mail/accountview.cpp
authoralwin <alwin>2005-03-09 14:40:43 (UTC)
committer alwin <alwin>2005-03-09 14:40:43 (UTC)
commit84f237fb3b83400a031bf7c2d3025f78c02f28a8 (patch) (side-by-side diff)
treefbe8992bea9ddda02129d4c3aa4facc4ec38e00c /noncore/net/mail/accountview.cpp
parente62e4a9111d9f5cfe4f004f1b21d377b92018b33 (diff)
downloadopie-84f237fb3b83400a031bf7c2d3025f78c02f28a8.zip
opie-84f237fb3b83400a031bf7c2d3025f78c02f28a8.tar.gz
opie-84f237fb3b83400a031bf7c2d3025f78c02f28a8.tar.bz2
cleanups/fixed potential crashers
context menus are displayed in mainmenu, too.
Diffstat (limited to 'noncore/net/mail/accountview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp52
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
@@ -20,11 +20,17 @@ using namespace Opie::Core;
AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
: QListView( parent, name, flags )
{
+ setSorting(0);
+ setSelectionMode(Single);
+ m_rightPressed = false;
+
connect( this, SIGNAL( selectionChanged(QListViewItem*) ),
- SLOT( refresh(QListViewItem*) ) );
+ SLOT( slotSelectionChanged(QListViewItem*) ) );
connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
- SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) );
- setSorting(0);
+ SLOT( slotMouseButton(int,QListViewItem*,const QPoint&,int) ) );
+ connect( this, SIGNAL(clicked(QListViewItem*) ),this,
+ SLOT( slotMouseClicked(QListViewItem*) ) );
+ m_currentItem = 0;
}
AccountView::~AccountView()
@@ -33,6 +39,18 @@ AccountView::~AccountView()
mhAccounts.clear();
}
+void AccountView::slotSelectionChanged(QListViewItem*item)
+{
+ odebug << "AccountView: Selection changed" << oendl;
+ if (!item) {
+ emit serverSelected(0);
+ return;
+ }
+ AccountViewItem *view = static_cast<AccountViewItem *>(item);
+
+ emit serverSelected(view->isServer());
+}
+
void AccountView::slotContextMenu(int id)
{
AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
@@ -40,9 +58,9 @@ void AccountView::slotContextMenu(int id)
view->contextMenuSelected(id);
}
-void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int)
+void AccountView::slotRightButton(int button, QListViewItem * item,const QPoint&,int)
{
- if (button==1) {return;}
+ m_rightPressed = true;
if (!item) return;
AccountViewItem *view = static_cast<AccountViewItem *>(item);
QPopupMenu*m = view->getContextMenu();
@@ -51,6 +69,30 @@ void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int)
m->setFocus();
m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
delete m;
+ setSelected(item,true);
+}
+
+void AccountView::slotLeftButton(int button, QListViewItem * item,const QPoint&,int)
+{
+ m_rightPressed = false;
+}
+
+void AccountView::slotMouseClicked(QListViewItem*item)
+{
+ if (m_rightPressed) return;
+ if (!item || m_currentItem == item) return;
+ /* ### ToDo check settings if on single tab it should open */
+ m_currentItem = item;
+ refresh(m_currentItem);
+}
+
+void AccountView::slotMouseButton(int button, QListViewItem * item,const QPoint&pos,int column)
+{
+ if (button==1) {
+ slotLeftButton(button,item,pos,column);
+ } else if (button==2) {
+ slotRightButton(button,item,pos,column);
+ }
}
void AccountView::populate( QList<Account> list )