-rw-r--r-- | korganizer/kolistview.cpp | 82 | ||||
-rw-r--r-- | korganizer/kolistview.h | 3 |
2 files changed, 85 insertions, 0 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index bc52281..7022e02 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp @@ -31,12 +31,14 @@ #include <qmessagebox.h> #include <qdialog.h> #include <qtextstream.h> #include <qdir.h> #include <qwhatsthis.h> #include <qregexp.h> +#include <qpainter.h> +#include <qpaintdevicemetrics.h> #include <klocale.h> #include <kdebug.h> #include <kiconloader.h> #include <kglobal.h> @@ -60,12 +62,13 @@ #endif #include "koglobals.h" #include "koprefs.h" #include "kfiledialog.h" #include "kolistview.h" +#include "koeventviewer.h" class KOListViewWhatsThis :public QWhatsThis { @@ -277,13 +280,24 @@ KOListView::KOListView(Calendar *calendar, QWidget *parent, mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("Deselect all"),this, SLOT(clearSelection()),true); mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("Delete all selected"),this, SLOT(deleteAll()),true); +#ifdef DESKTOP_VERSION + mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), + i18n("Hide all selected"),this, + SLOT(hideAll()),true); +#endif + mPopupMenu->insertSeparator(); +#ifdef DESKTOP_VERSION + mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), + i18n("Print complete list"),this, + SLOT(printList()),true); mPopupMenu->insertSeparator(); +#endif QPopupMenu * exportPO = new QPopupMenu ( this ); mPopupMenu->insertItem( i18n("Export selected"), exportPO ); exportPO->insertItem( i18n("As iCal (ics) file..."),this, SLOT(saveToFile())); exportPO->insertItem( i18n("As vCal (vcs) file..."),this, SLOT(saveToFileVCS())); @@ -719,12 +733,33 @@ void KOListView::writeToFile( bool iCal ) KOPrefs::instance()->mLastSaveFile = fn; topLevelWidget()->setCaption(mes); } } QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); } +void KOListView::hideAll() +{ + QPtrList<QListViewItem> delSel ; + QListViewItem *item = mListView->firstChild (); + while ( item ) { + if ( item->isSelected() ) { + delSel.append(item); + } + item = item->nextSibling(); + } + item = delSel.first() ; + while ( item ) { + QListViewItem * del = item; + item = delSel.next(); + delete del; + } +} +void KOListView::printList() +{ + mListView->printList(); +} void KOListView::deleteAll() { int icount = 0; QPtrList<Incidence> delSel ; QListViewItem *item = mListView->firstChild (); while ( item ) { @@ -1284,6 +1319,53 @@ void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) mEventPos = contentsToViewport(e->pos()); mEventGlobalPos = e->globalPos(); } KListView::contentsMouseMoveEvent(e); } +#define protected public +#include <qheader.h> +#undef protected +void KOListViewListView::printList() +{ +#ifdef DESKTOP_VERSION + KOPrintPrefs pp ( this ); + if (!pp.exec() ) + return; + int scaleval = pp.printMode() ; + + QPrinter printer; + if (!printer.setup() ) + return; + clearSelection (); + 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,m.width()/10 ); + if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { + p.scale( scale, scale ); + } + + int cou = header()->count(); + int iii; + QRect rect ( 0,0,0, header()->height()); + for ( iii = 0; iii < cou; ++iii ) { + rect.setLeft ( header()->sectionPos( iii ) ); + rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii)); + header()->paintSection ( & p, header()->mapToIndex (iii), rect ); + } + p.translate( 0, header()->height()); + drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () ); + p.end(); +#endif +} diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h index f4d6879..c25592d 100644 --- a/korganizer/kolistview.h +++ b/korganizer/kolistview.h @@ -213,12 +213,13 @@ class KOListView; class KOListViewListView : public KListView { Q_OBJECT public: KOListViewListView(KOListView * lv ); bool hasMultiSelection(QListViewItem*); + void printList(); signals: void newEvent(); void showIncidence( Incidence* ); public slots: void popupMenu(); private: @@ -263,12 +264,14 @@ class KOListView : public KOEventView QString getWhatsThisText(QPoint p); signals: void signalNewEvent(); void beamIncidenceList(QPtrList<Incidence>); public slots: + void hideAll(); + void printList(); void resetFocus(); virtual void updateView(); virtual void showDates(const QDate &start, const QDate &end); virtual void showEvents(QPtrList<Event> eventList); void clearSelection(); void allSelection(); |