-rw-r--r-- | korganizer/koagenda.cpp | 172 |
1 files changed, 80 insertions, 92 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 14f52b8..ed7a443 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -347,18 +347,9 @@ void KOAgenda::changeColumns(int columns) | |||
347 | { | 347 | { |
348 | if (columns == 0) { | 348 | if (columns == 0) { |
349 | kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; | 349 | qDebug("KOAgenda::changeColumns() called with argument 0 "); |
350 | return; | 350 | return; |
351 | } | 351 | } |
352 | 352 | clear(); | |
353 | clear(); | 353 | mColumns = columns; |
354 | |||
355 | mColumns = columns; | ||
356 | // setMinimumSize(mColumns * 10, mGridSpacingY + 1); | ||
357 | // init(); | ||
358 | // update(); | ||
359 | //qDebug("KOAgenda::changeColumns "); | ||
360 | computeSizes(); | 354 | computeSizes(); |
361 | // QResizeEvent event( size(), size() ); | ||
362 | |||
363 | //QApplication::sendEvent( this, &event ); | ||
364 | } | 355 | } |
@@ -371,4 +362,4 @@ bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | |||
371 | { | 362 | { |
372 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 363 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
373 | switch(event->type()) { | 364 | switch(event->type()) { |
374 | case QEvent::MouseButtonPress: | 365 | case QEvent::MouseButtonPress: |
@@ -377,12 +368,12 @@ bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | |||
377 | case QEvent::MouseMove: | 368 | case QEvent::MouseMove: |
378 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 369 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
379 | 370 | ||
380 | case (QEvent::Leave): | 371 | case (QEvent::Leave): |
381 | if (!mActionItem) | 372 | if (!mActionItem) |
382 | setCursor(arrowCursor); | 373 | setCursor(arrowCursor); |
383 | return true; | 374 | return true; |
384 | 375 | ||
385 | default: | 376 | default: |
386 | return QScrollView::eventFilter(object,event); | 377 | return QScrollView::eventFilter(object,event); |
387 | } | 378 | } |
388 | } | 379 | } |
@@ -1750,6 +1741,4 @@ KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int | |||
1750 | { | 1741 | { |
1751 | //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; | ||
1752 | |||
1753 | if (mAllDayMode) { | 1742 | if (mAllDayMode) { |
1754 | kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; | 1743 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); |
1755 | return 0; | 1744 | return 0; |
@@ -1762,3 +1751,2 @@ KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int | |||
1762 | if (YSize < 0) { | 1751 | if (YSize < 0) { |
1763 | kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; | ||
1764 | YSize = 1; | 1752 | YSize = 1; |
@@ -1892,58 +1880,58 @@ void KOAgenda::computeSizes() | |||
1892 | return; | 1880 | return; |
1881 | int frameOffset = frameWidth() * 2 +1; | ||
1882 | if (mAllDayMode) { | ||
1883 | mGridSpacingX = (width()-frameOffset) / mColumns; | ||
1884 | mGridSpacingY = height() - 2 * frameWidth() - 1; | ||
1885 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); | ||
1886 | // mGridSpacingY = height(); | ||
1887 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | ||
1893 | 1888 | ||
1894 | if (mAllDayMode) { | 1889 | KOAgendaItem *item; |
1895 | mGridSpacingX = (width()-3) / mColumns; | 1890 | int subCellWidth; |
1896 | mGridSpacingY = height() - 2 * frameWidth() - 1; | 1891 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1897 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); | 1892 | subCellWidth = mGridSpacingY / item->subCells(); |
1898 | // mGridSpacingY = height(); | 1893 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); |
1899 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1894 | moveChild(item,KOGlobals::self()->reverseLayout() ? |
1900 | 1895 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | |
1901 | KOAgendaItem *item; | ||
1902 | int subCellWidth; | ||
1903 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | ||
1904 | subCellWidth = mGridSpacingY / item->subCells(); | ||
1905 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); | ||
1906 | moveChild(item,KOGlobals::self()->reverseLayout() ? | ||
1907 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | ||
1908 | item->cellX() * mGridSpacingX, | 1896 | item->cellX() * mGridSpacingX, |
1909 | item->subCell() * subCellWidth); | 1897 | item->subCell() * subCellWidth); |
1910 | } | 1898 | } |
1911 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; | 1899 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; |
1912 | } else { | 1900 | } else { |
1913 | mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; | 1901 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; |
1914 | if (height() > mGridSpacingY * mRows + 1 ) { | 1902 | if (height() > mGridSpacingY * mRows + 1 ) { |
1915 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; | 1903 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; |
1916 | mGridSpacingY = KOPrefs::instance()->mHourSize ; | 1904 | mGridSpacingY = KOPrefs::instance()->mHourSize ; |
1917 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1905 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1918 | emit resizedSignal(); | 1906 | emit resizedSignal(); |
1919 | } else | 1907 | } else |
1920 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1908 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1921 | KOAgendaItem *item; | 1909 | KOAgendaItem *item; |
1922 | int subCellWidth; | 1910 | int subCellWidth; |
1923 | 1911 | ||
1924 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1912 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1925 | subCellWidth = mGridSpacingX / item->subCells(); | 1913 | subCellWidth = mGridSpacingX / item->subCells(); |
1926 | item->resize(subCellWidth,item->height()); | 1914 | item->resize(subCellWidth,item->height()); |
1927 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1915 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
1928 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1916 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1929 | item->cellX() * mGridSpacingX) + | 1917 | item->cellX() * mGridSpacingX) + |
1930 | item->subCell() * subCellWidth,childY(item)); | 1918 | item->subCell() * subCellWidth,childY(item)); |
1919 | } | ||
1920 | } | ||
1921 | int cw = contentsWidth(); | ||
1922 | int ch = contentsHeight(); | ||
1923 | if ( mAllDayMode ) { | ||
1924 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | ||
1925 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) | ||
1926 | paintPixAll->resize( cw, ch ); | ||
1927 | } else { | ||
1928 | QPixmap* paintPix = KOAgendaItem::paintPix(); | ||
1929 | if ( paintPix->width() < cw || paintPix->height() < ch ) | ||
1930 | KOAgendaItem::resizePixmap( cw , ch ); | ||
1931 | } | 1931 | } |
1932 | } | ||
1933 | int cw = contentsWidth(); | ||
1934 | int ch = contentsHeight(); | ||
1935 | if ( mAllDayMode ) { | ||
1936 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | ||
1937 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) | ||
1938 | paintPixAll->resize( cw, ch ); | ||
1939 | } else { | ||
1940 | QPixmap* paintPix = KOAgendaItem::paintPix(); | ||
1941 | if ( paintPix->width() < cw || paintPix->height() < ch ) | ||
1942 | KOAgendaItem::resizePixmap( cw , ch ); | ||
1943 | } | ||
1944 | 1932 | ||
1945 | checkScrollBoundaries(); | 1933 | checkScrollBoundaries(); |
1946 | marcus_bains(); | 1934 | marcus_bains(); |
1947 | drawContentsToPainter(); | 1935 | drawContentsToPainter(); |
1948 | viewport()->repaint(false); | 1936 | viewport()->repaint(false); |
1949 | } | 1937 | } |
@@ -1952,3 +1940,3 @@ void KOAgenda::scrollUp() | |||
1952 | { | 1940 | { |
1953 | scrollBy(0,-mScrollOffset); | 1941 | scrollBy(0,-mScrollOffset); |
1954 | } | 1942 | } |
@@ -1958,3 +1946,3 @@ void KOAgenda::scrollDown() | |||
1958 | { | 1946 | { |
1959 | scrollBy(0,mScrollOffset); | 1947 | scrollBy(0,mScrollOffset); |
1960 | } | 1948 | } |
@@ -1963,15 +1951,15 @@ void KOAgenda::popupAlarm() | |||
1963 | { | 1951 | { |
1964 | if (!mClickedItem) { | 1952 | if (!mClickedItem) { |
1965 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); | 1953 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); |
1966 | return; | 1954 | return; |
1967 | } | 1955 | } |
1968 | // TODO: deal correctly with multiple alarms | 1956 | // TODO: deal correctly with multiple alarms |
1969 | Alarm* alarm; | 1957 | Alarm* alarm; |
1970 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); | 1958 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); |
1971 | for(alarm=list.first();alarm;alarm=list.next()) { | 1959 | for(alarm=list.first();alarm;alarm=list.next()) { |
1972 | alarm->toggleAlarm(); | 1960 | alarm->toggleAlarm(); |
1973 | } | 1961 | } |
1974 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); | 1962 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); |
1975 | mClickedItem->paintMe( true ); | 1963 | mClickedItem->paintMe( true ); |
1976 | mClickedItem->repaint( false ); | 1964 | mClickedItem->repaint( false ); |
1977 | } | 1965 | } |