Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

linklistbox.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *   linklistbox.cpp                                                               *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   Read the file COPYING for details.                                    *
00011  *                                                                         *
00012  *   copyright: (C) 2003 by Jan Mueller                                    *
00013  *   email: janmueller7@hotmail.com                                        *
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 }

Generated on Sat Mar 27 19:20:39 2004 for Literature by doxygen 1.3.6-20040222