-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 @@ | |||
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qdialog.h> | 32 | #include <qdialog.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | #include <qdir.h> | 34 | #include <qdir.h> |
35 | #include <qwhatsthis.h> | 35 | #include <qwhatsthis.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | #include <qpainter.h> | ||
38 | #include <qpaintdevicemetrics.h> | ||
37 | 39 | ||
38 | #include <klocale.h> | 40 | #include <klocale.h> |
39 | #include <kdebug.h> | 41 | #include <kdebug.h> |
40 | #include <kiconloader.h> | 42 | #include <kiconloader.h> |
41 | #include <kglobal.h> | 43 | #include <kglobal.h> |
42 | 44 | ||
@@ -60,12 +62,13 @@ | |||
60 | #endif | 62 | #endif |
61 | #include "koglobals.h" | 63 | #include "koglobals.h" |
62 | #include "koprefs.h" | 64 | #include "koprefs.h" |
63 | #include "kfiledialog.h" | 65 | #include "kfiledialog.h" |
64 | 66 | ||
65 | #include "kolistview.h" | 67 | #include "kolistview.h" |
68 | #include "koeventviewer.h" | ||
66 | 69 | ||
67 | 70 | ||
68 | 71 | ||
69 | 72 | ||
70 | class KOListViewWhatsThis :public QWhatsThis | 73 | class KOListViewWhatsThis :public QWhatsThis |
71 | { | 74 | { |
@@ -277,13 +280,24 @@ KOListView::KOListView(Calendar *calendar, QWidget *parent, | |||
277 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 280 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
278 | i18n("Deselect all"),this, | 281 | i18n("Deselect all"),this, |
279 | SLOT(clearSelection()),true); | 282 | SLOT(clearSelection()),true); |
280 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 283 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
281 | i18n("Delete all selected"),this, | 284 | i18n("Delete all selected"),this, |
282 | SLOT(deleteAll()),true); | 285 | SLOT(deleteAll()),true); |
286 | #ifdef DESKTOP_VERSION | ||
287 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | ||
288 | i18n("Hide all selected"),this, | ||
289 | SLOT(hideAll()),true); | ||
290 | #endif | ||
291 | mPopupMenu->insertSeparator(); | ||
292 | #ifdef DESKTOP_VERSION | ||
293 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | ||
294 | i18n("Print complete list"),this, | ||
295 | SLOT(printList()),true); | ||
283 | mPopupMenu->insertSeparator(); | 296 | mPopupMenu->insertSeparator(); |
297 | #endif | ||
284 | QPopupMenu * exportPO = new QPopupMenu ( this ); | 298 | QPopupMenu * exportPO = new QPopupMenu ( this ); |
285 | mPopupMenu->insertItem( i18n("Export selected"), exportPO ); | 299 | mPopupMenu->insertItem( i18n("Export selected"), exportPO ); |
286 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, | 300 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, |
287 | SLOT(saveToFile())); | 301 | SLOT(saveToFile())); |
288 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, | 302 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, |
289 | SLOT(saveToFileVCS())); | 303 | SLOT(saveToFileVCS())); |
@@ -719,12 +733,33 @@ void KOListView::writeToFile( bool iCal ) | |||
719 | KOPrefs::instance()->mLastSaveFile = fn; | 733 | KOPrefs::instance()->mLastSaveFile = fn; |
720 | topLevelWidget()->setCaption(mes); | 734 | topLevelWidget()->setCaption(mes); |
721 | } | 735 | } |
722 | } | 736 | } |
723 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 737 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
724 | } | 738 | } |
739 | void KOListView::hideAll() | ||
740 | { | ||
741 | QPtrList<QListViewItem> delSel ; | ||
742 | QListViewItem *item = mListView->firstChild (); | ||
743 | while ( item ) { | ||
744 | if ( item->isSelected() ) { | ||
745 | delSel.append(item); | ||
746 | } | ||
747 | item = item->nextSibling(); | ||
748 | } | ||
749 | item = delSel.first() ; | ||
750 | while ( item ) { | ||
751 | QListViewItem * del = item; | ||
752 | item = delSel.next(); | ||
753 | delete del; | ||
754 | } | ||
755 | } | ||
756 | void KOListView::printList() | ||
757 | { | ||
758 | mListView->printList(); | ||
759 | } | ||
725 | void KOListView::deleteAll() | 760 | void KOListView::deleteAll() |
726 | { | 761 | { |
727 | int icount = 0; | 762 | int icount = 0; |
728 | QPtrList<Incidence> delSel ; | 763 | QPtrList<Incidence> delSel ; |
729 | QListViewItem *item = mListView->firstChild (); | 764 | QListViewItem *item = mListView->firstChild (); |
730 | while ( item ) { | 765 | while ( item ) { |
@@ -1284,6 +1319,53 @@ void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) | |||
1284 | mEventPos = contentsToViewport(e->pos()); | 1319 | mEventPos = contentsToViewport(e->pos()); |
1285 | mEventGlobalPos = e->globalPos(); | 1320 | mEventGlobalPos = e->globalPos(); |
1286 | } | 1321 | } |
1287 | KListView::contentsMouseMoveEvent(e); | 1322 | KListView::contentsMouseMoveEvent(e); |
1288 | } | 1323 | } |
1289 | 1324 | ||
1325 | #define protected public | ||
1326 | #include <qheader.h> | ||
1327 | #undef protected | ||
1328 | void KOListViewListView::printList() | ||
1329 | { | ||
1330 | #ifdef DESKTOP_VERSION | ||
1331 | KOPrintPrefs pp ( this ); | ||
1332 | if (!pp.exec() ) | ||
1333 | return; | ||
1334 | int scaleval = pp.printMode() ; | ||
1335 | |||
1336 | QPrinter printer; | ||
1337 | if (!printer.setup() ) | ||
1338 | return; | ||
1339 | clearSelection (); | ||
1340 | QPainter p; | ||
1341 | p.begin ( &printer ); | ||
1342 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | ||
1343 | float dx, dy; | ||
1344 | int wid = (m.width() * 9)/10; | ||
1345 | dx = (float) wid/(float)contentsWidth (); | ||
1346 | dy = (float)(m.height()) / (float)contentsHeight (); | ||
1347 | float scale; | ||
1348 | // scale to fit the width or height of the paper | ||
1349 | if ( dx < dy ) | ||
1350 | scale = dx; | ||
1351 | else | ||
1352 | scale = dy; | ||
1353 | |||
1354 | p.translate( m.width()/10,m.width()/10 ); | ||
1355 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { | ||
1356 | p.scale( scale, scale ); | ||
1357 | } | ||
1358 | |||
1359 | int cou = header()->count(); | ||
1360 | int iii; | ||
1361 | QRect rect ( 0,0,0, header()->height()); | ||
1362 | for ( iii = 0; iii < cou; ++iii ) { | ||
1363 | rect.setLeft ( header()->sectionPos( iii ) ); | ||
1364 | rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii)); | ||
1365 | header()->paintSection ( & p, header()->mapToIndex (iii), rect ); | ||
1366 | } | ||
1367 | p.translate( 0, header()->height()); | ||
1368 | drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () ); | ||
1369 | p.end(); | ||
1370 | #endif | ||
1371 | } | ||
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; | |||
213 | class KOListViewListView : public KListView | 213 | class KOListViewListView : public KListView |
214 | { | 214 | { |
215 | Q_OBJECT | 215 | Q_OBJECT |
216 | public: | 216 | public: |
217 | KOListViewListView(KOListView * lv ); | 217 | KOListViewListView(KOListView * lv ); |
218 | bool hasMultiSelection(QListViewItem*); | 218 | bool hasMultiSelection(QListViewItem*); |
219 | void printList(); | ||
219 | signals: | 220 | signals: |
220 | void newEvent(); | 221 | void newEvent(); |
221 | void showIncidence( Incidence* ); | 222 | void showIncidence( Incidence* ); |
222 | public slots: | 223 | public slots: |
223 | void popupMenu(); | 224 | void popupMenu(); |
224 | private: | 225 | private: |
@@ -263,12 +264,14 @@ class KOListView : public KOEventView | |||
263 | QString getWhatsThisText(QPoint p); | 264 | QString getWhatsThisText(QPoint p); |
264 | signals: | 265 | signals: |
265 | void signalNewEvent(); | 266 | void signalNewEvent(); |
266 | void beamIncidenceList(QPtrList<Incidence>); | 267 | void beamIncidenceList(QPtrList<Incidence>); |
267 | 268 | ||
268 | public slots: | 269 | public slots: |
270 | void hideAll(); | ||
271 | void printList(); | ||
269 | void resetFocus(); | 272 | void resetFocus(); |
270 | virtual void updateView(); | 273 | virtual void updateView(); |
271 | virtual void showDates(const QDate &start, const QDate &end); | 274 | virtual void showDates(const QDate &start, const QDate &end); |
272 | virtual void showEvents(QPtrList<Event> eventList); | 275 | virtual void showEvents(QPtrList<Event> eventList); |
273 | void clearSelection(); | 276 | void clearSelection(); |
274 | void allSelection(); | 277 | void allSelection(); |