-rw-r--r-- | korganizer/komonthview.cpp | 124 |
1 files changed, 95 insertions, 29 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 2289977..53bbe28 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1495,65 +1495,66 @@ DateList KOMonthView::selectedDates() | |||
1495 | 1495 | ||
1496 | return selected; | 1496 | return selected; |
1497 | } | 1497 | } |
1498 | #if 0 | 1498 | #if 0 |
1499 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1499 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1500 | const QDate &td) | 1500 | const QDate &td) |
1501 | { | 1501 | { |
1502 | #ifndef KORG_NOPRINTER | 1502 | #ifndef KORG_NOPRINTER |
1503 | calPrinter->preview(CalPrinter::Month, fd, td); | 1503 | calPrinter->preview(CalPrinter::Month, fd, td); |
1504 | #endif | 1504 | #endif |
1505 | } | 1505 | } |
1506 | #endif | 1506 | #endif |
1507 | void KOMonthView::updateConfig() | 1507 | void KOMonthView::updateConfig() |
1508 | { | 1508 | { |
1509 | 1509 | ||
1510 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1510 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1511 | 1511 | ||
1512 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1512 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1513 | mWeekStartsMonday = true; | 1513 | mWeekStartsMonday = true; |
1514 | } | 1514 | } |
1515 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1515 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1516 | mWidthLongDayLabel = 0; | 1516 | mWidthLongDayLabel = 0; |
1517 | 1517 | ||
1518 | for (int i = 0; i < 7; i++) { | 1518 | for (int i = 0; i < 7; i++) { |
1519 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1519 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1520 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1520 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1521 | } | 1521 | } |
1522 | bool temp = mShowSatSunComp ; | 1522 | bool temp = mShowSatSunComp ; |
1523 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1523 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1524 | if ( ! mShowWeekView ) { | 1524 | if ( ! mShowWeekView ) { |
1525 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 1525 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
1526 | computeLayout(); | 1526 | computeLayout(); |
1527 | } | 1527 | } else |
1528 | doComputeLayoutWeek(); | ||
1528 | updateDayLabels(); | 1529 | updateDayLabels(); |
1529 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1530 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1530 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1531 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1531 | //resizeEvent( 0 ); | 1532 | //resizeEvent( 0 ); |
1532 | for (uint i = 0; i < mCells.count(); ++i) { | 1533 | for (uint i = 0; i < mCells.count(); ++i) { |
1533 | mCells[i]->updateConfig(); | 1534 | mCells[i]->updateConfig(); |
1534 | } | 1535 | } |
1535 | 1536 | ||
1536 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1537 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1537 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1538 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1538 | } | 1539 | } |
1539 | #ifdef DESKTOP_VERSION | 1540 | #ifdef DESKTOP_VERSION |
1540 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1541 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1541 | #endif | 1542 | #endif |
1542 | updateView(); | 1543 | updateView(); |
1543 | } | 1544 | } |
1544 | 1545 | ||
1545 | void KOMonthView::updateDayLabels() | 1546 | void KOMonthView::updateDayLabels() |
1546 | { | 1547 | { |
1547 | 1548 | ||
1548 | QPtrVector<QLabel> *mDayLabelsT; | 1549 | QPtrVector<QLabel> *mDayLabelsT; |
1549 | 1550 | ||
1550 | mDayLabelsT = &mDayLabelsW; | 1551 | mDayLabelsT = &mDayLabelsW; |
1551 | for (int i = 0; i < 7; i++) { | 1552 | for (int i = 0; i < 7; i++) { |
1552 | { | 1553 | { |
1553 | bool show = mShortDayLabelsW; | 1554 | bool show = mShortDayLabelsW; |
1554 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1555 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1555 | show = true; | 1556 | show = true; |
1556 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1557 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1557 | } | 1558 | } |
1558 | } | 1559 | } |
1559 | mDayLabelsT = &mDayLabels; | 1560 | mDayLabelsT = &mDayLabels; |
@@ -1786,212 +1787,277 @@ void KOMonthView::updateView() | |||
1786 | 1787 | ||
1787 | void KOMonthView::setKeyBoardFocus() | 1788 | void KOMonthView::setKeyBoardFocus() |
1788 | { | 1789 | { |
1789 | //qDebug("KOMonthView::setKeyBoardFocus() "); | 1790 | //qDebug("KOMonthView::setKeyBoardFocus() "); |
1790 | bool shootAgain = false; | 1791 | bool shootAgain = false; |
1791 | if ( mShowWeekView ) { | 1792 | if ( mShowWeekView ) { |
1792 | shootAgain = !mWeekLabelsW[1]->hasFocus(); | 1793 | shootAgain = !mWeekLabelsW[1]->hasFocus(); |
1793 | mWeekLabelsW[1]->setFocus(); | 1794 | mWeekLabelsW[1]->setFocus(); |
1794 | } | 1795 | } |
1795 | else { | 1796 | else { |
1796 | shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); | 1797 | shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); |
1797 | mWeekLabels[mNumWeeks]->setFocus(); | 1798 | mWeekLabels[mNumWeeks]->setFocus(); |
1798 | } | 1799 | } |
1799 | --mKBFcounter; | 1800 | --mKBFcounter; |
1800 | if ( shootAgain && mKBFcounter > 0 ) { | 1801 | if ( shootAgain && mKBFcounter > 0 ) { |
1801 | QTimer::singleShot( 50, this, SLOT ( setKeyBoardFocus() ) ); | 1802 | QTimer::singleShot( 50, this, SLOT ( setKeyBoardFocus() ) ); |
1802 | } | 1803 | } |
1803 | } | 1804 | } |
1804 | void KOMonthView::setKeyBFocus() | 1805 | void KOMonthView::setKeyBFocus() |
1805 | { | 1806 | { |
1806 | //qDebug("KOMonthView::setKeyBFocus() "); | 1807 | //qDebug("KOMonthView::setKeyBFocus() "); |
1807 | mKBFcounter = 10; | 1808 | mKBFcounter = 10; |
1808 | QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); | 1809 | QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); |
1809 | } | 1810 | } |
1810 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1811 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1811 | { | 1812 | { |
1812 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); | 1813 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); |
1813 | if ( isVisible() ) { | 1814 | if ( isVisible() ) { |
1814 | //qDebug("KOMonthView::isVisible "); | 1815 | //qDebug("KOMonthView::isVisible "); |
1815 | slotComputeLayout(); | 1816 | slotComputeLayout(); |
1816 | } else | 1817 | } else |
1817 | mComputeLayoutTimer->start( 100 ); | 1818 | mComputeLayoutTimer->start( 100 ); |
1818 | KOEventView::resizeEvent( e ); | 1819 | if ( e ) |
1820 | KOEventView::resizeEvent( e ); | ||
1819 | } | 1821 | } |
1820 | 1822 | ||
1821 | void KOMonthView::slotComputeLayout() | 1823 | void KOMonthView::slotComputeLayout() |
1822 | { | 1824 | { |
1823 | mComputeLayoutTimer->stop(); | 1825 | mComputeLayoutTimer->stop(); |
1824 | //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); | 1826 | //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); |
1825 | computeLayout(); | 1827 | computeLayout(); |
1826 | clPending = true; | 1828 | clPending = true; |
1827 | setKeyBFocus(); | 1829 | setKeyBFocus(); |
1828 | } | 1830 | } |
1829 | void KOMonthView::computeLayoutWeek() | 1831 | |
1832 | void KOMonthView::doComputeLayoutWeek() | ||
1830 | { | 1833 | { |
1831 | static int lastWid = 0; | 1834 | |
1832 | static int lastHei = 0; | ||
1833 | int daysToShow; | 1835 | int daysToShow; |
1834 | bool combinedSatSun = false; | 1836 | bool combinedSatSun = false; |
1835 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1837 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1836 | daysToShow = 6; | 1838 | daysToShow = 6; |
1837 | combinedSatSun = true; | 1839 | combinedSatSun = true; |
1838 | } | 1840 | } |
1839 | int tWid = topLevelWidget()->size().width(); | ||
1840 | int tHei = topLevelWidget()->size().height(); | ||
1841 | |||
1842 | int wid = width();//e | 1841 | int wid = width();//e |
1843 | int hei = height()-1-mNavigatorBar->height(); | 1842 | int hei = height()-1-mNavigatorBar->height(); |
1844 | 1843 | if ( !KOPrefs::instance()->mMonthViewWeekRowlayout ) { | |
1845 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | ||
1846 | return; | ||
1847 | |||
1848 | if ( lastWid == width() && lastHei == height() ) { | ||
1849 | //qDebug("KOListWeekView::No compute layout needed "); | ||
1850 | return; | ||
1851 | } | ||
1852 | lastWid = width(); | ||
1853 | lastHei = height(); | ||
1854 | |||
1855 | |||
1856 | if ( wid < hei ) | ||
1857 | daysToShow = 2; | 1844 | daysToShow = 2; |
1858 | else | 1845 | } else { |
1859 | daysToShow = 3; | 1846 | if ( wid < hei ) |
1847 | daysToShow = 2; | ||
1848 | else | ||
1849 | daysToShow = 3; | ||
1850 | } | ||
1851 | bool landscape = (daysToShow == 3); | ||
1860 | mShowSatSunComp = true; | 1852 | mShowSatSunComp = true; |
1861 | combinedSatSun = true; | 1853 | combinedSatSun = true; |
1862 | 1854 | ||
1863 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); | 1855 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); |
1864 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1856 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1865 | int weeklabelwid = fm.width( "888" ); | 1857 | int weeklabelwid = fm.width( "888" ); |
1866 | wid -= weeklabelwid; | 1858 | wid -= weeklabelwid; |
1867 | 1859 | ||
1868 | int colWid = wid / daysToShow; | 1860 | int colWid = wid / daysToShow; |
1869 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); | 1861 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); |
1870 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1862 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1871 | int colModulo = wid % daysToShow; | 1863 | int colModulo = wid % daysToShow; |
1872 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1864 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1873 | //qDebug("rowmod %d ", rowModulo); | 1865 | //qDebug("rowmod %d ", rowModulo); |
1874 | int i; | 1866 | int i; |
1875 | int x,y,w,h; | 1867 | int x,y,w,h; |
1876 | x= 0; | 1868 | x= 0; |
1877 | y= 0; | 1869 | y= 0; |
1878 | w = colWid; | 1870 | w = colWid; |
1879 | h = dayLabelHei ; | 1871 | h = dayLabelHei ; |
1880 | for ( i = 0; i < 7; i++) { | 1872 | for ( i = 0; i < 7; i++) { |
1881 | if ( i && !( i % daysToShow) && i < 6) { | 1873 | if ( i && !( i % daysToShow) && i < 6) { |
1882 | y += hei/(5-daysToShow); | 1874 | y += hei/(5-daysToShow); |
1883 | x = 0; | 1875 | x = 0; |
1884 | w = colWid; | 1876 | w = colWid; |
1885 | } | 1877 | } |
1886 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1878 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1887 | ++w; | 1879 | ++w; |
1888 | } | 1880 | } |
1881 | int xC,yC,wC,hC; | ||
1889 | if ( i >= 5 ) { | 1882 | if ( i >= 5 ) { |
1890 | int wi = width() - x - weeklabelwid; | 1883 | int wi = width() - x - weeklabelwid; |
1891 | if ( i == 5 ) { | 1884 | if ( i == 5 ) { |
1892 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h); | 1885 | xC = x+weeklabelwid; |
1886 | yC = y; | ||
1887 | wC = wi/2+wi%2; | ||
1888 | hC = h; | ||
1893 | } else { | 1889 | } else { |
1894 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); | 1890 | xC = x+weeklabelwid; |
1891 | yC = y; | ||
1892 | wC = wi; | ||
1893 | hC = h; | ||
1895 | } | 1894 | } |
1896 | x = x - w + wi - (wi/2 ); | 1895 | x = x - w + wi - (wi/2 ); |
1897 | } | 1896 | } |
1898 | else { | 1897 | else { |
1899 | int wi = w; | 1898 | int wi = w; |
1900 | if ( !(( i+1) % daysToShow)) { | 1899 | if ( !(( i+1) % daysToShow)) { |
1901 | wi = width() - x - weeklabelwid; | 1900 | wi = width() - x - weeklabelwid; |
1902 | } | 1901 | } |
1903 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); | 1902 | xC = x+weeklabelwid; |
1903 | yC = y; | ||
1904 | wC = wi; | ||
1905 | hC = h; | ||
1904 | } | 1906 | } |
1907 | mDayLabelsW[mapWeekLayout(i,landscape)]->setGeometry( xC,yC,wC,hC); | ||
1908 | |||
1909 | |||
1905 | x += w; | 1910 | x += w; |
1906 | } | 1911 | } |
1907 | x= 0; | 1912 | x= 0; |
1908 | y= dayLabelHei; | 1913 | y= dayLabelHei; |
1909 | w = colWid; | 1914 | w = colWid; |
1910 | h = cellHei; | 1915 | h = cellHei; |
1911 | int max = 0; | 1916 | int max = 0; |
1912 | int w_count = mCellsW.count(); | 1917 | int w_count = mCellsW.count(); |
1913 | for ( i = 0; i < w_count; ++i) { | 1918 | for ( i = 0; i < w_count; ++i) { |
1914 | if ( i > 6 ) { | 1919 | if ( i > 6 ) { |
1915 | mCellsW[i]->hide(); | 1920 | mCellsW[i]->hide(); |
1916 | continue; | 1921 | continue; |
1917 | } | 1922 | } |
1918 | 1923 | ||
1919 | w = colWid; | 1924 | w = colWid; |
1920 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1925 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1921 | ++w; | 1926 | ++w; |
1922 | } | 1927 | } |
1923 | if ( i == (daysToShow-1-rowModulo)*7) | 1928 | if ( i == (daysToShow-1-rowModulo)*7) |
1924 | ++h; | 1929 | ++h; |
1925 | 1930 | ||
1931 | int xC,yC,wC,hC; | ||
1926 | if ( i >= 5 ) { | 1932 | if ( i >= 5 ) { |
1927 | if ( i ==5 ) { | 1933 | if ( i ==5 ) { |
1928 | max = h/2; | 1934 | max = h/2; |
1929 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1935 | xC = x+weeklabelwid; |
1936 | yC = y; | ||
1937 | wC = w; | ||
1938 | hC = max; | ||
1930 | x -= w ;y += h/2; | 1939 | x -= w ;y += h/2; |
1931 | } else { | 1940 | } else { |
1932 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1941 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1933 | ++w; | 1942 | ++w; |
1934 | } | 1943 | } |
1935 | max = h-h/2; | 1944 | max = h-h/2; |
1936 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1945 | xC = x+weeklabelwid; |
1946 | yC = y; | ||
1947 | wC = w; | ||
1948 | hC = max; | ||
1937 | y -= h/2; | 1949 | y -= h/2; |
1938 | } | 1950 | } |
1939 | } else { | 1951 | } else { |
1940 | max = h; | 1952 | max = h; |
1941 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1953 | xC = x+weeklabelwid; |
1954 | yC = y; | ||
1955 | wC = w; | ||
1956 | hC = h; | ||
1942 | } | 1957 | } |
1958 | mCellsW[mapWeekLayout(i,landscape)]->setGeometry ( xC,yC,wC,hC ); | ||
1943 | 1959 | ||
1944 | 1960 | ||
1945 | x += w; | 1961 | x += w; |
1946 | if ( x + w/2 > wid ) { | 1962 | if ( x + w/2 > wid ) { |
1947 | x = 0; | 1963 | x = 0; |
1948 | y += h+dayLabelHei ; | 1964 | y += h+dayLabelHei ; |
1949 | } | 1965 | } |
1950 | //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); | 1966 | //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); |
1951 | } | 1967 | } |
1952 | y= dayLabelHei; | 1968 | y= dayLabelHei; |
1953 | h = cellHei ; | 1969 | h = cellHei ; |
1954 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1970 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1955 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1971 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1956 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1972 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1957 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1973 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1958 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; | 1974 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; |
1959 | updateDayLabels(); | 1975 | updateDayLabels(); |
1960 | //bool forceUpdate = !updatePossible; | 1976 | //bool forceUpdate = !updatePossible; |
1961 | updatePossible = true; | 1977 | updatePossible = true; |
1962 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1978 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1963 | //if ( forceUpdate ) | 1979 | //if ( forceUpdate ) |
1964 | // updateView(); | 1980 | // updateView(); |
1965 | } | 1981 | } |
1982 | void KOMonthView::computeLayoutWeek() | ||
1983 | { | ||
1984 | static int lastWid = 0; | ||
1985 | static int lastHei = 0; | ||
1986 | int tWid = topLevelWidget()->size().width(); | ||
1987 | int tHei = topLevelWidget()->size().height(); | ||
1988 | int wid = width();//e | ||
1989 | int hei = height()-1-mNavigatorBar->height(); | ||
1990 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | ||
1991 | return; | ||
1992 | |||
1993 | if ( lastWid == width() && lastHei == height() ) { | ||
1994 | //qDebug("KOListWeekView::No compute layout needed "); | ||
1995 | return; | ||
1996 | } | ||
1997 | lastWid = width(); | ||
1998 | lastHei = height(); | ||
1999 | doComputeLayoutWeek(); | ||
2000 | } | ||
2001 | int KOMonthView::mapWeekLayout( int index, bool landscape ) | ||
2002 | { | ||
2003 | if ( KOPrefs::instance()->mMonthViewWeekRowlayout ) | ||
2004 | return index; | ||
2005 | int diff = 0; | ||
2006 | if ( !landscape ) diff = 1; | ||
2007 | switch( index ) { | ||
2008 | case 0: | ||
2009 | case 5: | ||
2010 | case 6: | ||
2011 | return index; | ||
2012 | break; | ||
2013 | case 1: | ||
2014 | return 2+diff; | ||
2015 | break; | ||
2016 | case 2: | ||
2017 | return 4-(3*diff); | ||
2018 | break; | ||
2019 | case 3: | ||
2020 | return 1+(3*diff); | ||
2021 | break; | ||
2022 | case 4: | ||
2023 | return 3-diff; | ||
2024 | break; | ||
2025 | default: | ||
2026 | qDebug("KO: Error in mapping week layout "); | ||
2027 | return index; | ||
2028 | break; | ||
2029 | } | ||
2030 | return index; | ||
2031 | } | ||
1966 | void KOMonthView::computeLayout() | 2032 | void KOMonthView::computeLayout() |
1967 | { | 2033 | { |
1968 | 2034 | ||
1969 | 2035 | ||
1970 | static int lastWid = 0; | 2036 | static int lastWid = 0; |
1971 | static int lastHei = 0; | 2037 | static int lastHei = 0; |
1972 | 2038 | ||
1973 | if ( mShowWeekView ){ | 2039 | if ( mShowWeekView ){ |
1974 | computeLayoutWeek(); | 2040 | computeLayoutWeek(); |
1975 | return; | 2041 | return; |
1976 | } | 2042 | } |
1977 | int daysToShow = 7; | 2043 | int daysToShow = 7; |
1978 | bool combinedSatSun = false; | 2044 | bool combinedSatSun = false; |
1979 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 2045 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1980 | daysToShow = 6; | 2046 | daysToShow = 6; |
1981 | combinedSatSun = true; | 2047 | combinedSatSun = true; |
1982 | } | 2048 | } |
1983 | int tWid = topLevelWidget()->size().width(); | 2049 | int tWid = topLevelWidget()->size().width(); |
1984 | int tHei = topLevelWidget()->size().height(); | 2050 | int tHei = topLevelWidget()->size().height(); |
1985 | 2051 | ||
1986 | int wid = width();//e | 2052 | int wid = width();//e |
1987 | int hei = height()-1-mNavigatorBar->height(); | 2053 | int hei = height()-1-mNavigatorBar->height(); |
1988 | 2054 | ||
1989 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { | 2055 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { |
1990 | return; | 2056 | return; |
1991 | } | 2057 | } |
1992 | if ( lastWid == width() && lastHei == height() ){ | 2058 | if ( lastWid == width() && lastHei == height() ){ |
1993 | //qDebug("KOMonthview::No compute layout needed "); | 2059 | //qDebug("KOMonthview::No compute layout needed "); |
1994 | return; | 2060 | return; |
1995 | } | 2061 | } |
1996 | 2062 | ||
1997 | lastWid = width(); | 2063 | lastWid = width(); |