00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "linklistbox.h"
00018 #include "linklistboxitem.h"
00019 #include <qcursor.h>
00020 #include <qapplication.h>
00021 #include "liturl.h"
00022 #include "urlevent.h"
00023
00024 LinkListBox::LinkListBox(QWidget *parent, const char *name ) :
00025 QListView(parent,name) {
00026 setFocusPolicy( QWidget::StrongFocus );
00027 setBackgroundMode( QWidget::PaletteBase );
00028 addColumn("");
00029
00030 pop.insertItem("Open", this, SLOT(slotOpen()));
00031 pop.insertItem("Open in new Window", this, SLOT(slotNewWindow()));
00032
00033 connect(this, SIGNAL(rightButtonPressed(QListViewItem*, const QPoint &,int)),
00034 this, SLOT(slotPopupMenu(QListViewItem *, const QPoint &,int)));
00035
00036 connect(this, SIGNAL(doubleClicked(QListViewItem*)),
00037 this, SLOT(slotSelected(QListViewItem*)));
00038
00039 }
00040
00041 void LinkListBox::open(bool newwin) {
00042 LinkListBoxItem *i=dynamic_cast<LinkListBoxItem*>(currentItem());
00043 ASSERT(i);
00044 qApp->postEvent(topLevelWidget(), new UrlEvent(i->url(), newwin));
00045 }
00046
00047 void LinkListBox::slotSelected(QListViewItem *item) {
00048 open(false);
00049 }
00050
00051 void LinkListBox::slotOpen() {
00052 open(false);
00053 }
00054
00055
00056 void LinkListBox::slotNewWindow() {
00057 open(true);
00058 }
00059
00060
00061 void LinkListBox::slotPopupMenu(QListViewItem *item, const QPoint& p, int c) {
00062 if(item) {
00063 setCurrentItem(item);
00064 pop.popup(QCursor::pos());
00065 }
00066 }
00067
00068 LinkListBox::~LinkListBox(){
00069 }
00070
00071 LitUrl LinkListBox::url() {
00072 LinkListBoxItem *i=dynamic_cast<LinkListBoxItem *>(currentItem());
00073 if(i)
00074 return i->url();
00075 else
00076 return LitUrl();
00077 }