summaryrefslogtreecommitdiffabout
path: root/kaddressbook/views
Side-by-side diff
Diffstat (limited to 'kaddressbook/views') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/views/contactlistview.cpp27
-rw-r--r--kaddressbook/views/contactlistview.h1
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp29
-rw-r--r--kaddressbook/views/kaddressbookcardview.h2
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp2
5 files changed, 61 insertions, 0 deletions
diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp
index 23b091c..e75810e 100644
--- a/kaddressbook/views/contactlistview.cpp
+++ b/kaddressbook/views/contactlistview.cpp
@@ -256,48 +256,75 @@ ContactListView::ContactListView(KAddressBookTableView *view,
#else //KAB_EMBEDDED
mAlternateColor = QColor(240, 240, 240);
#endif //KAB_EMBEDDED
setAlternateBackgroundEnabled(mABackground);
setAcceptDrops( true );
viewport()->setAcceptDrops( true );
setAllColumnsShowFocus( true );
setShowSortIndicator(true);
setSelectionModeExt( KListView::Extended );
setDropVisualizer(false);
// setFrameStyle(QFrame::NoFrame);
//setLineWidth ( 0 );
//setMidLineWidth ( 0 );
//setMargin ( 0 );
#ifndef KAB_EMBEDDED
connect(this, SIGNAL(dropped(QDropEvent*)),
this, SLOT(itemDropped(QDropEvent*)));
#endif //KAB_EMBEDDED
new DynamicTip( this );
}
+void ContactListView::printMe()
+{
+#ifdef DESKTOP_VERSION
+ QPrinter printer;
+ if (!printer.setup() )
+ return;
+ QPainter p;
+ p.begin ( &printer );
+ QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
+ float dx, dy;
+ int wid = (m.width() * 9)/10;
+ dx = (float) wid/(float)contentsWidth ();
+ dy = (float)(m.height()) / (float)contentsHeight ();
+ float scale;
+ // scale to fit the width or height of the paper
+ if ( dx < dy )
+ scale = dx;
+ else
+ scale = dy;
+ p.translate( m.width()/10,0 );
+ p.scale( scale, scale );
+ qDebug("scale %f ", scale);
+ drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
+ p.end();
+ qDebug("Why does it not print??? ");
+#endif
+}
void ContactListView::setAlternateColor(const QColor &m_AlternateColor)
{
mAlternateColor = m_AlternateColor;
}
void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect )
{
QBrush b = palette().brush(QPalette::Active, QColorGroup::Base);
// Get the brush, which will have the background pixmap if there is one.
if (b.pixmap())
{
p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(),
*(b.pixmap()),
rect.left() + contentsX(),
rect.top() + contentsY() );
}
else
{
// Do a normal paint
KListView::paintEmptyArea(p, rect);
}
diff --git a/kaddressbook/views/contactlistview.h b/kaddressbook/views/contactlistview.h
index fad7f38..9d1a672 100644
--- a/kaddressbook/views/contactlistview.h
+++ b/kaddressbook/views/contactlistview.h
@@ -84,46 +84,47 @@ public:
const QColor &alternateColor() const { return mAlternateColor; }
void setAlternateColor(const QColor &mAlternateColor);
/** Sets the background pixmap to <i>filename</i>. If the
* QString is empty (QString::isEmpty()), then the background
* pixmap will be disabled.
*/
void setBackgroundPixmap(const QString &filename);
protected:
/** Paints the background pixmap in the empty area. This method is needed
* since Qt::FixedPixmap will not scroll with the list view.
*/
virtual void paintEmptyArea( QPainter * p, const QRect & rect );
virtual void contentsMousePressEvent(QMouseEvent*);
void contentsMouseMoveEvent( QMouseEvent *e );
void contentsDropEvent( QDropEvent *e );
virtual bool acceptDrag(QDropEvent *e) const;
protected slots:
void itemDropped(QDropEvent *e);
public slots:
+ void printMe();
signals:
void startAddresseeDrag();
void addresseeDropped(QDropEvent *);
private:
KAddressBookTableView *pabWidget;
int oldColumn;
int column;
bool ascending;
bool mABackground;
bool mSingleLine;
bool mToolTips;
QColor mAlternateColor;
QPoint presspos;
};
#endif
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp
index 2d7ed08..107be59 100644
--- a/kaddressbook/views/kaddressbookcardview.cpp
+++ b/kaddressbook/views/kaddressbookcardview.cpp
@@ -17,48 +17,49 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include <qdragobject.h>
#include <qevent.h>
#include <qiconview.h>
#include <qlayout.h>
#include <qstringlist.h>
#include <qregexp.h>
#include <qapplication.h>
#include <kabc/addressbook.h>
#include <kabc/addressee.h>
#include <kconfig.h>
#include <kdebug.h>
#include <klocale.h>
#include "kabprefs.h"
#include "viewmanager.h"
+
#include "kaddressbookcardview.h"
#ifndef KAB_EMBEDDED
extern "C" {
void *init_libkaddrbk_cardview()
{
return ( new CardViewFactory );
}
}
#endif //KAB_EMBEDDED
////////////////////////////////
// AddresseeCardViewItem (internal class)
class AddresseeCardViewItem : public CardViewItem
{
public:
AddresseeCardViewItem(const KABC::Field::List &fields,
bool showEmptyFields,
KABC::AddressBook *doc, const KABC::Addressee &a,
CardView *parent)
: CardViewItem(parent, a.formattedName()),
mFields( fields ), mShowEmptyFields(showEmptyFields),
mDocument(doc), mAddressee(a)
{
@@ -95,96 +96,124 @@ class AddresseeCardViewItem : public CardViewItem
// We might want to make this the first field. hmm... -mpilone
setCaption( mAddressee.realName() );
}
}
private:
KABC::Field::List mFields;
bool mShowEmptyFields;
KABC::AddressBook *mDocument;
KABC::Addressee mAddressee;
};
///////////////////////////////
// AddresseeCardView
AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name)
: CardView(parent, name)
{
setAcceptDrops(true);
}
AddresseeCardView::~AddresseeCardView()
{
}
+void AddresseeCardView::printMe()
+{
+#ifdef DESKTOP_VERSION
+ QPrinter printer;
+ if (!printer.setup() )
+ return;
+ QPainter p;
+ p.begin ( &printer );
+ QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
+ float dx, dy;
+ int wid = (m.width() * 9)/10;
+ dx = (float) wid/(float)contentsWidth ();
+ dy = (float)(m.height()) / (float)contentsHeight ();
+ float scale;
+ // scale to fit the width or height of the paper
+ if ( dx < dy )
+ scale = dx;
+ else
+ scale = dy;
+ p.translate( m.width()/10,0 );
+ p.scale( scale, scale );
+ drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
+ p.end();
+ repaint();
+#endif
+}
void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e)
{
#ifndef KAB_EMBEDDED
if (QTextDrag::canDecode(e))
e->accept();
#else //KAB_EMBEDDED
qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented");
#endif //KAB_EMBEDDED
}
void AddresseeCardView::dropEvent(QDropEvent *e)
{
emit addresseeDropped(e);
}
void AddresseeCardView::startDrag()
{
emit startAddresseeDrag();
}
///////////////////////////////
// KAddressBookCardView
KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab,
QWidget *parent, const char *name )
: KAddressBookView( ab, parent, name )
{
mShowEmptyFields = false;
// Init the GUI
QVBoxLayout *layout = new QVBoxLayout(viewWidget());
mCardView = new AddresseeCardView(viewWidget(), "mCardView");
mCardView->setSelectionMode(CardView::Extended);
layout->addWidget(mCardView);
// Connect up the signals
connect(mCardView, SIGNAL(executed(CardViewItem *)),
this, SLOT(addresseeExecuted(CardViewItem *)));
connect(mCardView, SIGNAL(selectionChanged()),
this, SLOT(addresseeSelected()));
connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)),
this, SIGNAL(dropped(QDropEvent*)));
connect(mCardView, SIGNAL(startAddresseeDrag()),
this, SIGNAL(startDrag()));
+ connect(this, SIGNAL(printView()),
+ mCardView , SLOT(printMe()));
}
KAddressBookCardView::~KAddressBookCardView()
{
}
void KAddressBookCardView::setFocusAV()
{
if ( mCardView )
mCardView->setFocus();
}
void KAddressBookCardView::scrollUP()
{
QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
QApplication::postEvent( mCardView, ev );
}
void KAddressBookCardView::scrollDOWN()
{
QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
QApplication::postEvent( mCardView, ev );
}
void KAddressBookCardView::readConfig(KConfig *config)
{
diff --git a/kaddressbook/views/kaddressbookcardview.h b/kaddressbook/views/kaddressbookcardview.h
index 8f22d54..2a71f7e 100644
--- a/kaddressbook/views/kaddressbookcardview.h
+++ b/kaddressbook/views/kaddressbookcardview.h
@@ -64,48 +64,50 @@ class KAddressBookCardView : public KAddressBookView
virtual void scrollDOWN();
virtual void setFocusAV();
public slots:
void refresh(QString uid = QString::null);
void setSelected(QString uid/*US = QString::null*/, bool selected/*US = true*/);
//US added an additional method without parameter
void setSelected();
protected slots:
void addresseeExecuted(CardViewItem *item);
void addresseeSelected();
private:
AddresseeCardView *mCardView;
bool mShowEmptyFields;
};
class AddresseeCardView : public CardView
{
Q_OBJECT
public:
AddresseeCardView(QWidget *parent, const char *name = 0);
~AddresseeCardView();
+public slots:
+ void printMe();
signals:
void startAddresseeDrag();
void addresseeDropped(QDropEvent *);
protected:
virtual void dragEnterEvent(QDragEnterEvent *);
virtual void dropEvent(QDropEvent *);
virtual void startDrag();
};
class CardViewFactory : public ViewFactory
{
public:
KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name )
{
return new KAddressBookCardView( ab, parent, name );
}
QString type() const { return "Card"; }
QString description() const { return i18n( "Rolodex style cards represent contacts." ); }
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index 61703ee..ecd6f05 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -68,48 +68,50 @@ void KAddressBookTableView::scrollDOWN()
QApplication::postEvent( mListView, ev );
}
void KAddressBookTableView::reconstructListView()
{
if (mListView)
{
disconnect(mListView, SIGNAL(selectionChanged()),
this, SLOT(addresseeSelected()));
disconnect(mListView, SIGNAL(executed(QListViewItem*)),
this, SLOT(addresseeExecuted(QListViewItem*)));
disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
this, SLOT(addresseeExecuted(QListViewItem*)));
disconnect(mListView, SIGNAL(startAddresseeDrag()), this,
SIGNAL(startDrag()));
disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)),
this, SLOT(addresseeExecuted(QListViewItem*)));
disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
SIGNAL(dropped(QDropEvent*)));
delete mListView;
}
mListView = new ContactListView( this, addressBook(), viewWidget() );
+ connect(this, SIGNAL(printView()),
+ mListView , SLOT(printMe()));
//US set singleClick manually, because it is no global configparameter in embedded space
mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick);
// Add the columns
KABC::Field::List fieldList = fields();
KABC::Field::List::ConstIterator it;
int c = 0;
for( it = fieldList.begin(); it != fieldList.end(); ++it ) {
mListView->addColumn( (*it)->label() );
mListView->setColumnWidthMode(c++, QListView::Manual);
//US
// qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1());
}
connect(mListView, SIGNAL(selectionChanged()),
this, SLOT(addresseeSelected()));
connect(mListView, SIGNAL(startAddresseeDrag()), this,
SIGNAL(startDrag()));
connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
SIGNAL(dropped(QDropEvent*)));
if (KABPrefs::instance()->mHonorSingleClick) {
// qDebug("KAddressBookTableView::reconstructListView single");