-rw-r--r-- | korganizer/calendarview.cpp | 33 | ||||
-rw-r--r-- | korganizer/calendarview.h | 3 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 5 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 28 | ||||
-rw-r--r-- | korganizer/ktimeedit.cpp | 8 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 27 | ||||
-rw-r--r-- | korganizer/navigatorbar.cpp | 3 | ||||
-rw-r--r-- | libkdepim/kdatepicker.cpp | 10 | ||||
-rw-r--r-- | microkde/kdatetbl.cpp | 26 | ||||
-rw-r--r-- | microkde/kglobalsettings.cpp | 10 |
10 files changed, 98 insertions, 55 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 0fbaa9a..a9de65a 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1695,1576 +1695,1579 @@ void CalendarView::watchSavedFile() | |||
1695 | loadedFileVersion = dt; | 1695 | loadedFileVersion = dt; |
1696 | } | 1696 | } |
1697 | 1697 | ||
1698 | bool CalendarView::checkFileVersion(QString fn) | 1698 | bool CalendarView::checkFileVersion(QString fn) |
1699 | { | 1699 | { |
1700 | QFileInfo finf ( fn ); | 1700 | QFileInfo finf ( fn ); |
1701 | if ( !finf.exists() ) | 1701 | if ( !finf.exists() ) |
1702 | return true; | 1702 | return true; |
1703 | QDateTime dt = finf.lastModified (); | 1703 | QDateTime dt = finf.lastModified (); |
1704 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1704 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1705 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1705 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1706 | if ( dt <= loadedFileVersion ) | 1706 | if ( dt <= loadedFileVersion ) |
1707 | return true; | 1707 | return true; |
1708 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1708 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1709 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1709 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1710 | i18n("Sync+save")); | 1710 | i18n("Sync+save")); |
1711 | 1711 | ||
1712 | if ( km == KMessageBox::Cancel ) | 1712 | if ( km == KMessageBox::Cancel ) |
1713 | return false; | 1713 | return false; |
1714 | if ( km == KMessageBox::Yes ) | 1714 | if ( km == KMessageBox::Yes ) |
1715 | return true; | 1715 | return true; |
1716 | 1716 | ||
1717 | setSyncDevice("deleteaftersync" ); | 1717 | setSyncDevice("deleteaftersync" ); |
1718 | mSyncManager->mAskForPreferences = true; | 1718 | mSyncManager->mAskForPreferences = true; |
1719 | mSyncManager->mSyncAlgoPrefs = 3; | 1719 | mSyncManager->mSyncAlgoPrefs = 3; |
1720 | mSyncManager->mWriteBackFile = false; | 1720 | mSyncManager->mWriteBackFile = false; |
1721 | mSyncManager->mWriteBackExistingOnly = false; | 1721 | mSyncManager->mWriteBackExistingOnly = false; |
1722 | mSyncManager->mShowSyncSummary = false; | 1722 | mSyncManager->mShowSyncSummary = false; |
1723 | syncCalendar( fn, 3 ); | 1723 | syncCalendar( fn, 3 ); |
1724 | Event * e = getLastSyncEvent(); | 1724 | Event * e = getLastSyncEvent(); |
1725 | mCalendar->deleteEvent ( e ); | 1725 | mCalendar->deleteEvent ( e ); |
1726 | updateView(); | 1726 | updateView(); |
1727 | return true; | 1727 | return true; |
1728 | } | 1728 | } |
1729 | 1729 | ||
1730 | bool CalendarView::saveCalendar( QString filename ) | 1730 | bool CalendarView::saveCalendar( QString filename ) |
1731 | { | 1731 | { |
1732 | 1732 | ||
1733 | // Store back all unsaved data into calendar object | 1733 | // Store back all unsaved data into calendar object |
1734 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1734 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1735 | if ( mViewManager->currentView() ) | 1735 | if ( mViewManager->currentView() ) |
1736 | mViewManager->currentView()->flushView(); | 1736 | mViewManager->currentView()->flushView(); |
1737 | 1737 | ||
1738 | 1738 | ||
1739 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1739 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1740 | mStorage->setSaveFormat( new ICalFormat() ); | 1740 | mStorage->setSaveFormat( new ICalFormat() ); |
1741 | mStorage->setFileName( filename ); | 1741 | mStorage->setFileName( filename ); |
1742 | bool success; | 1742 | bool success; |
1743 | success = mStorage->save(); | 1743 | success = mStorage->save(); |
1744 | if ( !success ) { | 1744 | if ( !success ) { |
1745 | return false; | 1745 | return false; |
1746 | } | 1746 | } |
1747 | if ( filename == MainWindow::defaultFileName() ) { | 1747 | if ( filename == MainWindow::defaultFileName() ) { |
1748 | setLoadedFileVersion( lfv ); | 1748 | setLoadedFileVersion( lfv ); |
1749 | watchSavedFile(); | 1749 | watchSavedFile(); |
1750 | } | 1750 | } |
1751 | return true; | 1751 | return true; |
1752 | } | 1752 | } |
1753 | 1753 | ||
1754 | void CalendarView::closeCalendar() | 1754 | void CalendarView::closeCalendar() |
1755 | { | 1755 | { |
1756 | 1756 | ||
1757 | // child windows no longer valid | 1757 | // child windows no longer valid |
1758 | emit closingDown(); | 1758 | emit closingDown(); |
1759 | 1759 | ||
1760 | mCalendar->close(); | 1760 | mCalendar->close(); |
1761 | setModified(false); | 1761 | setModified(false); |
1762 | updateView(); | 1762 | updateView(); |
1763 | } | 1763 | } |
1764 | 1764 | ||
1765 | void CalendarView::archiveCalendar() | 1765 | void CalendarView::archiveCalendar() |
1766 | { | 1766 | { |
1767 | mDialogManager->showArchiveDialog(); | 1767 | mDialogManager->showArchiveDialog(); |
1768 | } | 1768 | } |
1769 | 1769 | ||
1770 | 1770 | ||
1771 | void CalendarView::readSettings() | 1771 | void CalendarView::readSettings() |
1772 | { | 1772 | { |
1773 | 1773 | ||
1774 | 1774 | ||
1775 | // mViewManager->showAgendaView(); | 1775 | // mViewManager->showAgendaView(); |
1776 | QString str; | 1776 | QString str; |
1777 | //qDebug("CalendarView::readSettings() "); | 1777 | //qDebug("CalendarView::readSettings() "); |
1778 | // read settings from the KConfig, supplying reasonable | 1778 | // read settings from the KConfig, supplying reasonable |
1779 | // defaults where none are to be found | 1779 | // defaults where none are to be found |
1780 | KConfig *config = KOGlobals::config(); | 1780 | KConfig *config = KOGlobals::config(); |
1781 | #ifndef KORG_NOSPLITTER | 1781 | #ifndef KORG_NOSPLITTER |
1782 | config->setGroup("KOrganizer Geometry"); | 1782 | config->setGroup("KOrganizer Geometry"); |
1783 | 1783 | ||
1784 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1784 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1785 | if (sizes.count() != 2) { | 1785 | if (sizes.count() != 2) { |
1786 | sizes << mDateNavigator->minimumSizeHint().width(); | 1786 | sizes << mDateNavigator->minimumSizeHint().width(); |
1787 | sizes << 300; | 1787 | sizes << 300; |
1788 | } | 1788 | } |
1789 | mPanner->setSizes(sizes); | 1789 | mPanner->setSizes(sizes); |
1790 | 1790 | ||
1791 | sizes = config->readIntListEntry("Separator2"); | 1791 | sizes = config->readIntListEntry("Separator2"); |
1792 | if ( ( mResourceView && sizes.count() == 4 ) || | 1792 | if ( ( mResourceView && sizes.count() == 4 ) || |
1793 | ( !mResourceView && sizes.count() == 3 ) ) { | 1793 | ( !mResourceView && sizes.count() == 3 ) ) { |
1794 | mLeftSplitter->setSizes(sizes); | 1794 | mLeftSplitter->setSizes(sizes); |
1795 | } | 1795 | } |
1796 | #endif | 1796 | #endif |
1797 | globalFlagBlockAgenda = 1; | 1797 | globalFlagBlockAgenda = 1; |
1798 | mViewManager->showAgendaView(); | 1798 | mViewManager->showAgendaView(); |
1799 | //mViewManager->readSettings( config ); | 1799 | //mViewManager->readSettings( config ); |
1800 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1800 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1801 | readFilterSettings(config); | 1801 | readFilterSettings(config); |
1802 | config->setGroup( "Views" ); | 1802 | config->setGroup( "Views" ); |
1803 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1803 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1804 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1804 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1805 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1805 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1806 | else mNavigator->selectDates( dateCount ); | 1806 | else mNavigator->selectDates( dateCount ); |
1807 | // mViewManager->readSettings( config ); | 1807 | // mViewManager->readSettings( config ); |
1808 | updateConfig(); | 1808 | updateConfig(); |
1809 | globalFlagBlockAgenda = 2; | 1809 | globalFlagBlockAgenda = 2; |
1810 | mViewManager->readSettings( config ); | 1810 | mViewManager->readSettings( config ); |
1811 | #ifdef DESKTOP_VERSION | 1811 | #ifdef DESKTOP_VERSION |
1812 | config->setGroup("WidgetLayout"); | 1812 | config->setGroup("WidgetLayout"); |
1813 | QStringList list; | 1813 | QStringList list; |
1814 | list = config->readListEntry("MainLayout"); | 1814 | list = config->readListEntry("MainLayout"); |
1815 | int x,y,w,h; | 1815 | int x,y,w,h; |
1816 | if ( ! list.isEmpty() ) { | 1816 | if ( ! list.isEmpty() ) { |
1817 | x = list[0].toInt(); | 1817 | x = list[0].toInt(); |
1818 | y = list[1].toInt(); | 1818 | y = list[1].toInt(); |
1819 | w = list[2].toInt(); | 1819 | w = list[2].toInt(); |
1820 | h = list[3].toInt(); | 1820 | h = list[3].toInt(); |
1821 | topLevelWidget()->setGeometry(x,y,w,h); | 1821 | topLevelWidget()->setGeometry(x,y,w,h); |
1822 | 1822 | ||
1823 | } else { | 1823 | } else { |
1824 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1824 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1825 | } | 1825 | } |
1826 | list = config->readListEntry("EditEventLayout"); | 1826 | list = config->readListEntry("EditEventLayout"); |
1827 | if ( ! list.isEmpty() ) { | 1827 | if ( ! list.isEmpty() ) { |
1828 | x = list[0].toInt(); | 1828 | x = list[0].toInt(); |
1829 | y = list[1].toInt(); | 1829 | y = list[1].toInt(); |
1830 | w = list[2].toInt(); | 1830 | w = list[2].toInt(); |
1831 | h = list[3].toInt(); | 1831 | h = list[3].toInt(); |
1832 | mEventEditor->setGeometry(x,y,w,h); | 1832 | mEventEditor->setGeometry(x,y,w,h); |
1833 | 1833 | ||
1834 | } | 1834 | } |
1835 | list = config->readListEntry("EditTodoLayout"); | 1835 | list = config->readListEntry("EditTodoLayout"); |
1836 | if ( ! list.isEmpty() ) { | 1836 | if ( ! list.isEmpty() ) { |
1837 | x = list[0].toInt(); | 1837 | x = list[0].toInt(); |
1838 | y = list[1].toInt(); | 1838 | y = list[1].toInt(); |
1839 | w = list[2].toInt(); | 1839 | w = list[2].toInt(); |
1840 | h = list[3].toInt(); | 1840 | h = list[3].toInt(); |
1841 | mTodoEditor->setGeometry(x,y,w,h); | 1841 | mTodoEditor->setGeometry(x,y,w,h); |
1842 | 1842 | ||
1843 | } | 1843 | } |
1844 | list = config->readListEntry("ViewerLayout"); | 1844 | list = config->readListEntry("ViewerLayout"); |
1845 | if ( ! list.isEmpty() ) { | 1845 | if ( ! list.isEmpty() ) { |
1846 | x = list[0].toInt(); | 1846 | x = list[0].toInt(); |
1847 | y = list[1].toInt(); | 1847 | y = list[1].toInt(); |
1848 | w = list[2].toInt(); | 1848 | w = list[2].toInt(); |
1849 | h = list[3].toInt(); | 1849 | h = list[3].toInt(); |
1850 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1850 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1851 | } | 1851 | } |
1852 | #endif | 1852 | #endif |
1853 | 1853 | ||
1854 | } | 1854 | } |
1855 | 1855 | ||
1856 | 1856 | ||
1857 | void CalendarView::writeSettings() | 1857 | void CalendarView::writeSettings() |
1858 | { | 1858 | { |
1859 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1859 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1860 | 1860 | ||
1861 | KConfig *config = KOGlobals::config(); | 1861 | KConfig *config = KOGlobals::config(); |
1862 | 1862 | ||
1863 | #ifndef KORG_NOSPLITTER | 1863 | #ifndef KORG_NOSPLITTER |
1864 | config->setGroup("KOrganizer Geometry"); | 1864 | config->setGroup("KOrganizer Geometry"); |
1865 | 1865 | ||
1866 | QValueList<int> list = mPanner->sizes(); | 1866 | QValueList<int> list = mPanner->sizes(); |
1867 | config->writeEntry("Separator1",list); | 1867 | config->writeEntry("Separator1",list); |
1868 | 1868 | ||
1869 | list = mLeftSplitter->sizes(); | 1869 | list = mLeftSplitter->sizes(); |
1870 | config->writeEntry("Separator2",list); | 1870 | config->writeEntry("Separator2",list); |
1871 | #endif | 1871 | #endif |
1872 | 1872 | ||
1873 | mViewManager->writeSettings( config ); | 1873 | mViewManager->writeSettings( config ); |
1874 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1874 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1875 | mDialogManager->writeSettings( config ); | 1875 | mDialogManager->writeSettings( config ); |
1876 | //KOPrefs::instance()->usrWriteConfig(); | 1876 | //KOPrefs::instance()->usrWriteConfig(); |
1877 | KOPrefs::instance()->writeConfig(); | 1877 | KOPrefs::instance()->writeConfig(); |
1878 | 1878 | ||
1879 | writeFilterSettings(config); | 1879 | writeFilterSettings(config); |
1880 | 1880 | ||
1881 | config->setGroup( "Views" ); | 1881 | config->setGroup( "Views" ); |
1882 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1882 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1883 | 1883 | ||
1884 | #ifdef DESKTOP_VERSION | 1884 | #ifdef DESKTOP_VERSION |
1885 | config->setGroup("WidgetLayout"); | 1885 | config->setGroup("WidgetLayout"); |
1886 | QStringList list ;//= config->readListEntry("MainLayout"); | 1886 | QStringList list ;//= config->readListEntry("MainLayout"); |
1887 | int x,y,w,h; | 1887 | int x,y,w,h; |
1888 | QWidget* wid; | 1888 | QWidget* wid; |
1889 | wid = topLevelWidget(); | 1889 | wid = topLevelWidget(); |
1890 | x = wid->geometry().x(); | 1890 | x = wid->geometry().x(); |
1891 | y = wid->geometry().y(); | 1891 | y = wid->geometry().y(); |
1892 | w = wid->width(); | 1892 | w = wid->width(); |
1893 | h = wid->height(); | 1893 | h = wid->height(); |
1894 | list.clear(); | 1894 | list.clear(); |
1895 | list << QString::number( x ); | 1895 | list << QString::number( x ); |
1896 | list << QString::number( y ); | 1896 | list << QString::number( y ); |
1897 | list << QString::number( w ); | 1897 | list << QString::number( w ); |
1898 | list << QString::number( h ); | 1898 | list << QString::number( h ); |
1899 | config->writeEntry("MainLayout",list ); | 1899 | config->writeEntry("MainLayout",list ); |
1900 | 1900 | ||
1901 | wid = mEventEditor; | 1901 | wid = mEventEditor; |
1902 | x = wid->geometry().x(); | 1902 | x = wid->geometry().x(); |
1903 | y = wid->geometry().y(); | 1903 | y = wid->geometry().y(); |
1904 | w = wid->width(); | 1904 | w = wid->width(); |
1905 | h = wid->height(); | 1905 | h = wid->height(); |
1906 | list.clear(); | 1906 | list.clear(); |
1907 | list << QString::number( x ); | 1907 | list << QString::number( x ); |
1908 | list << QString::number( y ); | 1908 | list << QString::number( y ); |
1909 | list << QString::number( w ); | 1909 | list << QString::number( w ); |
1910 | list << QString::number( h ); | 1910 | list << QString::number( h ); |
1911 | config->writeEntry("EditEventLayout",list ); | 1911 | config->writeEntry("EditEventLayout",list ); |
1912 | 1912 | ||
1913 | wid = mTodoEditor; | 1913 | wid = mTodoEditor; |
1914 | x = wid->geometry().x(); | 1914 | x = wid->geometry().x(); |
1915 | y = wid->geometry().y(); | 1915 | y = wid->geometry().y(); |
1916 | w = wid->width(); | 1916 | w = wid->width(); |
1917 | h = wid->height(); | 1917 | h = wid->height(); |
1918 | list.clear(); | 1918 | list.clear(); |
1919 | list << QString::number( x ); | 1919 | list << QString::number( x ); |
1920 | list << QString::number( y ); | 1920 | list << QString::number( y ); |
1921 | list << QString::number( w ); | 1921 | list << QString::number( w ); |
1922 | list << QString::number( h ); | 1922 | list << QString::number( h ); |
1923 | config->writeEntry("EditTodoLayout",list ); | 1923 | config->writeEntry("EditTodoLayout",list ); |
1924 | wid = getEventViewerDialog(); | 1924 | wid = getEventViewerDialog(); |
1925 | x = wid->geometry().x(); | 1925 | x = wid->geometry().x(); |
1926 | y = wid->geometry().y(); | 1926 | y = wid->geometry().y(); |
1927 | w = wid->width(); | 1927 | w = wid->width(); |
1928 | h = wid->height(); | 1928 | h = wid->height(); |
1929 | list.clear(); | 1929 | list.clear(); |
1930 | list << QString::number( x ); | 1930 | list << QString::number( x ); |
1931 | list << QString::number( y ); | 1931 | list << QString::number( y ); |
1932 | list << QString::number( w ); | 1932 | list << QString::number( w ); |
1933 | list << QString::number( h ); | 1933 | list << QString::number( h ); |
1934 | config->writeEntry("ViewerLayout",list ); | 1934 | config->writeEntry("ViewerLayout",list ); |
1935 | wid = mDialogManager->getSearchDialog(); | 1935 | wid = mDialogManager->getSearchDialog(); |
1936 | if ( wid ) { | 1936 | if ( wid ) { |
1937 | x = wid->geometry().x(); | 1937 | x = wid->geometry().x(); |
1938 | y = wid->geometry().y(); | 1938 | y = wid->geometry().y(); |
1939 | w = wid->width(); | 1939 | w = wid->width(); |
1940 | h = wid->height(); | 1940 | h = wid->height(); |
1941 | list.clear(); | 1941 | list.clear(); |
1942 | list << QString::number( x ); | 1942 | list << QString::number( x ); |
1943 | list << QString::number( y ); | 1943 | list << QString::number( y ); |
1944 | list << QString::number( w ); | 1944 | list << QString::number( w ); |
1945 | list << QString::number( h ); | 1945 | list << QString::number( h ); |
1946 | config->writeEntry("SearchLayout",list ); | 1946 | config->writeEntry("SearchLayout",list ); |
1947 | } | 1947 | } |
1948 | #endif | 1948 | #endif |
1949 | 1949 | ||
1950 | 1950 | ||
1951 | config->sync(); | 1951 | config->sync(); |
1952 | } | 1952 | } |
1953 | 1953 | ||
1954 | void CalendarView::readFilterSettings(KConfig *config) | 1954 | void CalendarView::readFilterSettings(KConfig *config) |
1955 | { | 1955 | { |
1956 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1956 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1957 | 1957 | ||
1958 | mFilters.clear(); | 1958 | mFilters.clear(); |
1959 | 1959 | ||
1960 | config->setGroup("General"); | 1960 | config->setGroup("General"); |
1961 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1961 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1962 | 1962 | ||
1963 | QStringList::ConstIterator it = filterList.begin(); | 1963 | QStringList::ConstIterator it = filterList.begin(); |
1964 | QStringList::ConstIterator end = filterList.end(); | 1964 | QStringList::ConstIterator end = filterList.end(); |
1965 | while(it != end) { | 1965 | while(it != end) { |
1966 | // kdDebug() << " filter: " << (*it) << endl; | 1966 | // kdDebug() << " filter: " << (*it) << endl; |
1967 | 1967 | ||
1968 | CalFilter *filter; | 1968 | CalFilter *filter; |
1969 | filter = new CalFilter(*it); | 1969 | filter = new CalFilter(*it); |
1970 | config->setGroup("Filter_" + (*it)); | 1970 | config->setGroup("Filter_" + (*it)); |
1971 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1971 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1972 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1972 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1973 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1973 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1974 | mFilters.append(filter); | 1974 | mFilters.append(filter); |
1975 | 1975 | ||
1976 | ++it; | 1976 | ++it; |
1977 | } | 1977 | } |
1978 | 1978 | ||
1979 | if (mFilters.count() == 0) { | 1979 | if (mFilters.count() == 0) { |
1980 | CalFilter *filter = new CalFilter(i18n("Default")); | 1980 | CalFilter *filter = new CalFilter(i18n("Default")); |
1981 | mFilters.append(filter); | 1981 | mFilters.append(filter); |
1982 | } | 1982 | } |
1983 | mFilterView->updateFilters(); | 1983 | mFilterView->updateFilters(); |
1984 | config->setGroup("FilterView"); | 1984 | config->setGroup("FilterView"); |
1985 | 1985 | ||
1986 | mFilterView->blockSignals(true); | 1986 | mFilterView->blockSignals(true); |
1987 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1987 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1988 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1988 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1989 | mFilterView->blockSignals(false); | 1989 | mFilterView->blockSignals(false); |
1990 | // We do it manually to avoid it being done twice by the above calls | 1990 | // We do it manually to avoid it being done twice by the above calls |
1991 | updateFilter(); | 1991 | updateFilter(); |
1992 | } | 1992 | } |
1993 | 1993 | ||
1994 | void CalendarView::writeFilterSettings(KConfig *config) | 1994 | void CalendarView::writeFilterSettings(KConfig *config) |
1995 | { | 1995 | { |
1996 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1996 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1997 | 1997 | ||
1998 | QStringList filterList; | 1998 | QStringList filterList; |
1999 | 1999 | ||
2000 | CalFilter *filter = mFilters.first(); | 2000 | CalFilter *filter = mFilters.first(); |
2001 | while(filter) { | 2001 | while(filter) { |
2002 | // kdDebug() << " fn: " << filter->name() << endl; | 2002 | // kdDebug() << " fn: " << filter->name() << endl; |
2003 | filterList << filter->name(); | 2003 | filterList << filter->name(); |
2004 | config->setGroup("Filter_" + filter->name()); | 2004 | config->setGroup("Filter_" + filter->name()); |
2005 | config->writeEntry("Criteria",filter->criteria()); | 2005 | config->writeEntry("Criteria",filter->criteria()); |
2006 | config->writeEntry("CategoryList",filter->categoryList()); | 2006 | config->writeEntry("CategoryList",filter->categoryList()); |
2007 | filter = mFilters.next(); | 2007 | filter = mFilters.next(); |
2008 | } | 2008 | } |
2009 | config->setGroup("General"); | 2009 | config->setGroup("General"); |
2010 | config->writeEntry("CalendarFilters",filterList); | 2010 | config->writeEntry("CalendarFilters",filterList); |
2011 | 2011 | ||
2012 | config->setGroup("FilterView"); | 2012 | config->setGroup("FilterView"); |
2013 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2013 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2014 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2014 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2015 | } | 2015 | } |
2016 | 2016 | ||
2017 | 2017 | ||
2018 | void CalendarView::goToday() | 2018 | void CalendarView::goToday() |
2019 | { | 2019 | { |
2020 | if ( mViewManager->currentView()->isMonthView() ) | 2020 | if ( mViewManager->currentView()->isMonthView() ) |
2021 | mNavigator->selectTodayMonth(); | 2021 | mNavigator->selectTodayMonth(); |
2022 | else | 2022 | else |
2023 | mNavigator->selectToday(); | 2023 | mNavigator->selectToday(); |
2024 | } | 2024 | } |
2025 | 2025 | ||
2026 | void CalendarView::goNext() | 2026 | void CalendarView::goNext() |
2027 | { | 2027 | { |
2028 | mNavigator->selectNext(); | 2028 | mNavigator->selectNext(); |
2029 | } | 2029 | } |
2030 | 2030 | ||
2031 | void CalendarView::goPrevious() | 2031 | void CalendarView::goPrevious() |
2032 | { | 2032 | { |
2033 | mNavigator->selectPrevious(); | 2033 | mNavigator->selectPrevious(); |
2034 | } | 2034 | } |
2035 | void CalendarView::goNextMonth() | 2035 | void CalendarView::goNextMonth() |
2036 | { | 2036 | { |
2037 | mNavigator->selectNextMonth(); | 2037 | mNavigator->selectNextMonth(); |
2038 | } | 2038 | } |
2039 | 2039 | ||
2040 | void CalendarView::goPreviousMonth() | 2040 | void CalendarView::goPreviousMonth() |
2041 | { | 2041 | { |
2042 | mNavigator->selectPreviousMonth(); | 2042 | mNavigator->selectPreviousMonth(); |
2043 | } | 2043 | } |
2044 | void CalendarView::writeLocale() | 2044 | void CalendarView::writeLocale() |
2045 | { | 2045 | { |
2046 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2046 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2047 | #if 0 | 2047 | #if 0 |
2048 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2048 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2049 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2049 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2050 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2050 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2051 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2051 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2052 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2052 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2053 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2053 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2054 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2054 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2055 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2055 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2056 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2056 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2057 | KOPrefs::instance()->mDaylightsavingStart, | 2057 | KOPrefs::instance()->mDaylightsavingStart, |
2058 | KOPrefs::instance()->mDaylightsavingEnd ); | 2058 | KOPrefs::instance()->mDaylightsavingEnd ); |
2059 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2059 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2060 | #endif | 2060 | #endif |
2061 | } | 2061 | } |
2062 | void CalendarView::updateConfig() | 2062 | void CalendarView::updateConfig() |
2063 | { | 2063 | { |
2064 | writeLocale(); | 2064 | writeLocale(); |
2065 | if ( KOPrefs::instance()->mUseAppColors ) | 2065 | if ( KOPrefs::instance()->mUseAppColors ) |
2066 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2066 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2067 | emit configChanged(); | 2067 | emit configChanged(); |
2068 | mTodoList->updateConfig(); | 2068 | mTodoList->updateConfig(); |
2069 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2069 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2070 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2070 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2071 | // To make the "fill window" configurations work | 2071 | // To make the "fill window" configurations work |
2072 | //mViewManager->raiseCurrentView(); | 2072 | //mViewManager->raiseCurrentView(); |
2073 | } | 2073 | } |
2074 | 2074 | ||
2075 | 2075 | ||
2076 | void CalendarView::eventChanged(Event *event) | 2076 | void CalendarView::eventChanged(Event *event) |
2077 | { | 2077 | { |
2078 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2078 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2079 | //updateUnmanagedViews(); | 2079 | //updateUnmanagedViews(); |
2080 | } | 2080 | } |
2081 | 2081 | ||
2082 | void CalendarView::eventAdded(Event *event) | 2082 | void CalendarView::eventAdded(Event *event) |
2083 | { | 2083 | { |
2084 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2084 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2085 | } | 2085 | } |
2086 | 2086 | ||
2087 | void CalendarView::eventToBeDeleted(Event *) | 2087 | void CalendarView::eventToBeDeleted(Event *) |
2088 | { | 2088 | { |
2089 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2089 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2090 | } | 2090 | } |
2091 | 2091 | ||
2092 | void CalendarView::eventDeleted() | 2092 | void CalendarView::eventDeleted() |
2093 | { | 2093 | { |
2094 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2094 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2095 | } | 2095 | } |
2096 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2096 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2097 | { | 2097 | { |
2098 | changeIncidenceDisplay((Incidence *)which, action); | 2098 | changeIncidenceDisplay((Incidence *)which, action); |
2099 | mDateNavigator->updateView(); //LR | 2099 | mDateNavigator->updateView(); //LR |
2100 | //mDialogManager->updateSearchDialog(); | 2100 | //mDialogManager->updateSearchDialog(); |
2101 | 2101 | ||
2102 | if (which) { | 2102 | if (which) { |
2103 | mViewManager->updateWNview(); | 2103 | mViewManager->updateWNview(); |
2104 | //mTodoList->updateView(); | 2104 | //mTodoList->updateView(); |
2105 | } | 2105 | } |
2106 | 2106 | ||
2107 | } | 2107 | } |
2108 | 2108 | ||
2109 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2109 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2110 | { | 2110 | { |
2111 | updateUnmanagedViews(); | 2111 | updateUnmanagedViews(); |
2112 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2112 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2113 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2113 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2114 | mCalendar->checkAlarmForIncidence( 0, true ); | 2114 | mCalendar->checkAlarmForIncidence( 0, true ); |
2115 | if ( mEventViewerDialog ) | 2115 | if ( mEventViewerDialog ) |
2116 | mEventViewerDialog->hide(); | 2116 | mEventViewerDialog->hide(); |
2117 | } | 2117 | } |
2118 | else | 2118 | else |
2119 | mCalendar->checkAlarmForIncidence( which , false ); | 2119 | mCalendar->checkAlarmForIncidence( which , false ); |
2120 | } | 2120 | } |
2121 | 2121 | ||
2122 | // most of the changeEventDisplays() right now just call the view's | 2122 | // most of the changeEventDisplays() right now just call the view's |
2123 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2123 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2124 | void CalendarView::changeEventDisplay(Event *which, int action) | 2124 | void CalendarView::changeEventDisplay(Event *which, int action) |
2125 | { | 2125 | { |
2126 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2126 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2127 | changeIncidenceDisplay((Incidence *)which, action); | 2127 | changeIncidenceDisplay((Incidence *)which, action); |
2128 | mDateNavigator->updateView(); | 2128 | mDateNavigator->updateView(); |
2129 | //mDialogManager->updateSearchDialog(); | 2129 | //mDialogManager->updateSearchDialog(); |
2130 | 2130 | ||
2131 | if (which) { | 2131 | if (which) { |
2132 | // If there is an event view visible update the display | 2132 | // If there is an event view visible update the display |
2133 | mViewManager->currentView()->changeEventDisplay(which,action); | 2133 | mViewManager->currentView()->changeEventDisplay(which,action); |
2134 | // TODO: check, if update needed | 2134 | // TODO: check, if update needed |
2135 | // if (which->getTodoStatus()) { | 2135 | // if (which->getTodoStatus()) { |
2136 | mTodoList->updateView(); | 2136 | mTodoList->updateView(); |
2137 | // } | 2137 | // } |
2138 | } else { | 2138 | } else { |
2139 | mViewManager->currentView()->updateView(); | 2139 | mViewManager->currentView()->updateView(); |
2140 | } | 2140 | } |
2141 | } | 2141 | } |
2142 | 2142 | ||
2143 | 2143 | ||
2144 | void CalendarView::updateTodoViews() | 2144 | void CalendarView::updateTodoViews() |
2145 | { | 2145 | { |
2146 | mTodoList->updateView(); | 2146 | mTodoList->updateView(); |
2147 | mViewManager->currentView()->updateView(); | 2147 | mViewManager->currentView()->updateView(); |
2148 | 2148 | ||
2149 | } | 2149 | } |
2150 | 2150 | ||
2151 | 2151 | ||
2152 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2152 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2153 | { | 2153 | { |
2154 | mTodoList->updateView(); | 2154 | mTodoList->updateView(); |
2155 | mViewManager->updateView(start, end); | 2155 | mViewManager->updateView(start, end); |
2156 | //mDateNavigator->updateView(); | 2156 | //mDateNavigator->updateView(); |
2157 | } | 2157 | } |
2158 | 2158 | ||
2159 | void CalendarView::updateView() | 2159 | void CalendarView::updateView() |
2160 | { | 2160 | { |
2161 | DateList tmpList = mNavigator->selectedDates(); | 2161 | DateList tmpList = mNavigator->selectedDates(); |
2162 | 2162 | ||
2163 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2163 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2164 | mTodoList->updateView(); | 2164 | mTodoList->updateView(); |
2165 | // We assume that the navigator only selects consecutive days. | 2165 | // We assume that the navigator only selects consecutive days. |
2166 | updateView( tmpList.first(), tmpList.last() ); | 2166 | updateView( tmpList.first(), tmpList.last() ); |
2167 | } | 2167 | } |
2168 | 2168 | ||
2169 | void CalendarView::updateUnmanagedViews() | 2169 | void CalendarView::updateUnmanagedViews() |
2170 | { | 2170 | { |
2171 | mDateNavigator->updateDayMatrix(); | 2171 | mDateNavigator->updateDayMatrix(); |
2172 | } | 2172 | } |
2173 | 2173 | ||
2174 | int CalendarView::msgItemDelete(const QString name) | 2174 | int CalendarView::msgItemDelete(const QString name) |
2175 | { | 2175 | { |
2176 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2176 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2177 | i18n("This item will be\npermanently deleted."), | 2177 | i18n("This item will be\npermanently deleted."), |
2178 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2178 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2179 | } | 2179 | } |
2180 | 2180 | ||
2181 | 2181 | ||
2182 | void CalendarView::edit_cut() | 2182 | void CalendarView::edit_cut() |
2183 | { | 2183 | { |
2184 | Event *anEvent=0; | 2184 | Event *anEvent=0; |
2185 | 2185 | ||
2186 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2186 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2187 | 2187 | ||
2188 | if (mViewManager->currentView()->isEventView()) { | 2188 | if (mViewManager->currentView()->isEventView()) { |
2189 | if ( incidence && incidence->type() == "Event" ) { | 2189 | if ( incidence && incidence->type() == "Event" ) { |
2190 | anEvent = static_cast<Event *>(incidence); | 2190 | anEvent = static_cast<Event *>(incidence); |
2191 | } | 2191 | } |
2192 | } | 2192 | } |
2193 | 2193 | ||
2194 | if (!anEvent) { | 2194 | if (!anEvent) { |
2195 | KNotifyClient::beep(); | 2195 | KNotifyClient::beep(); |
2196 | return; | 2196 | return; |
2197 | } | 2197 | } |
2198 | DndFactory factory( mCalendar ); | 2198 | DndFactory factory( mCalendar ); |
2199 | factory.cutIncidence(anEvent); | 2199 | factory.cutIncidence(anEvent); |
2200 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2200 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2201 | } | 2201 | } |
2202 | 2202 | ||
2203 | void CalendarView::edit_copy() | 2203 | void CalendarView::edit_copy() |
2204 | { | 2204 | { |
2205 | Event *anEvent=0; | 2205 | Event *anEvent=0; |
2206 | 2206 | ||
2207 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2207 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2208 | 2208 | ||
2209 | if (mViewManager->currentView()->isEventView()) { | 2209 | if (mViewManager->currentView()->isEventView()) { |
2210 | if ( incidence && incidence->type() == "Event" ) { | 2210 | if ( incidence && incidence->type() == "Event" ) { |
2211 | anEvent = static_cast<Event *>(incidence); | 2211 | anEvent = static_cast<Event *>(incidence); |
2212 | } | 2212 | } |
2213 | } | 2213 | } |
2214 | 2214 | ||
2215 | if (!anEvent) { | 2215 | if (!anEvent) { |
2216 | KNotifyClient::beep(); | 2216 | KNotifyClient::beep(); |
2217 | return; | 2217 | return; |
2218 | } | 2218 | } |
2219 | DndFactory factory( mCalendar ); | 2219 | DndFactory factory( mCalendar ); |
2220 | factory.copyIncidence(anEvent); | 2220 | factory.copyIncidence(anEvent); |
2221 | } | 2221 | } |
2222 | 2222 | ||
2223 | void CalendarView::edit_paste() | 2223 | void CalendarView::edit_paste() |
2224 | { | 2224 | { |
2225 | QDate date = mNavigator->selectedDates().first(); | 2225 | QDate date = mNavigator->selectedDates().first(); |
2226 | 2226 | ||
2227 | DndFactory factory( mCalendar ); | 2227 | DndFactory factory( mCalendar ); |
2228 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2228 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2229 | 2229 | ||
2230 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2230 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2231 | } | 2231 | } |
2232 | 2232 | ||
2233 | void CalendarView::edit_options() | 2233 | void CalendarView::edit_options() |
2234 | { | 2234 | { |
2235 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2235 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2236 | emit save(); | 2236 | emit save(); |
2237 | emit saveStopTimer(); | 2237 | emit saveStopTimer(); |
2238 | mDialogManager->showOptionsDialog(); | 2238 | mDialogManager->showOptionsDialog(); |
2239 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2239 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2240 | emit saveStopTimer(); | 2240 | emit saveStopTimer(); |
2241 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), | 2241 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), |
2242 | i18n("Timezone settings"),i18n("Reload"))) { | 2242 | i18n("Timezone settings"),i18n("Reload"))) { |
2243 | qDebug("KO: TZ reload cancelled "); | 2243 | qDebug("KO: TZ reload cancelled "); |
2244 | return; | 2244 | return; |
2245 | } | 2245 | } |
2246 | qDebug("KO: Timezone change "); | 2246 | qDebug("KO: Timezone change "); |
2247 | openCalendar( MainWindow::defaultFileName() ); | 2247 | openCalendar( MainWindow::defaultFileName() ); |
2248 | setModified(true); | 2248 | setModified(true); |
2249 | } | 2249 | } |
2250 | else | 2250 | else |
2251 | qDebug("KO: No tz change "); | 2251 | qDebug("KO: No tz change "); |
2252 | 2252 | ||
2253 | } | 2253 | } |
2254 | 2254 | ||
2255 | 2255 | ||
2256 | void CalendarView::slotSelectPickerDate( QDate d) | 2256 | void CalendarView::slotSelectPickerDate( QDate d) |
2257 | { | 2257 | { |
2258 | mDateFrame->hide(); | 2258 | mDateFrame->hide(); |
2259 | if ( mDatePickerMode == 1 ) { | 2259 | if ( mDatePickerMode == 1 ) { |
2260 | mNavigator->slotDaySelect( d ); | 2260 | mNavigator->slotDaySelect( d ); |
2261 | } else if ( mDatePickerMode == 2 ) { | 2261 | } else if ( mDatePickerMode == 2 ) { |
2262 | if ( mMoveIncidence->type() == "Todo" ) { | 2262 | if ( mMoveIncidence->type() == "Todo" ) { |
2263 | Todo * to = (Todo *) mMoveIncidence; | 2263 | Todo * to = (Todo *) mMoveIncidence; |
2264 | QTime tim; | 2264 | QTime tim; |
2265 | if ( to->hasDueDate() ) | 2265 | if ( to->hasDueDate() ) |
2266 | tim = to->dtDue().time(); | 2266 | tim = to->dtDue().time(); |
2267 | else { | 2267 | else { |
2268 | tim = QTime ( 0,0,0 ); | 2268 | tim = QTime ( 0,0,0 ); |
2269 | to->setFloats( true ); | 2269 | to->setFloats( true ); |
2270 | to->setHasDueDate( true ); | 2270 | to->setHasDueDate( true ); |
2271 | } | 2271 | } |
2272 | QDateTime dt ( d,tim ); | 2272 | QDateTime dt ( d,tim ); |
2273 | to->setDtDue( dt ); | 2273 | to->setDtDue( dt ); |
2274 | todoChanged( to ); | 2274 | todoChanged( to ); |
2275 | } else { | 2275 | } else { |
2276 | if ( mMoveIncidence->doesRecur() ) { | 2276 | if ( mMoveIncidence->doesRecur() ) { |
2277 | #if 0 | 2277 | #if 0 |
2278 | // PENDING implement this | 2278 | // PENDING implement this |
2279 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2279 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2280 | mCalendar()->addIncidence( newInc ); | 2280 | mCalendar()->addIncidence( newInc ); |
2281 | if ( mMoveIncidence->type() == "Todo" ) | 2281 | if ( mMoveIncidence->type() == "Todo" ) |
2282 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2282 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2283 | else | 2283 | else |
2284 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2284 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2285 | mMoveIncidence = newInc; | 2285 | mMoveIncidence = newInc; |
2286 | 2286 | ||
2287 | #endif | 2287 | #endif |
2288 | } | 2288 | } |
2289 | QTime tim = mMoveIncidence->dtStart().time(); | 2289 | QTime tim = mMoveIncidence->dtStart().time(); |
2290 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2290 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2291 | QDateTime dt ( d,tim ); | 2291 | QDateTime dt ( d,tim ); |
2292 | mMoveIncidence->setDtStart( dt ); | 2292 | mMoveIncidence->setDtStart( dt ); |
2293 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2293 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2294 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2294 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2295 | } | 2295 | } |
2296 | 2296 | ||
2297 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2297 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2298 | } | 2298 | } |
2299 | } | 2299 | } |
2300 | 2300 | ||
2301 | void CalendarView::removeCategories() | 2301 | void CalendarView::removeCategories() |
2302 | { | 2302 | { |
2303 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2303 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2304 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2304 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2305 | QStringList catIncList; | 2305 | QStringList catIncList; |
2306 | QStringList newCatList; | 2306 | QStringList newCatList; |
2307 | Incidence* inc = incList.first(); | 2307 | Incidence* inc = incList.first(); |
2308 | int i; | 2308 | int i; |
2309 | int count = 0; | 2309 | int count = 0; |
2310 | while ( inc ) { | 2310 | while ( inc ) { |
2311 | newCatList.clear(); | 2311 | newCatList.clear(); |
2312 | catIncList = inc->categories() ; | 2312 | catIncList = inc->categories() ; |
2313 | for( i = 0; i< catIncList.count(); ++i ) { | 2313 | for( i = 0; i< catIncList.count(); ++i ) { |
2314 | if ( catList.contains (catIncList[i])) | 2314 | if ( catList.contains (catIncList[i])) |
2315 | newCatList.append( catIncList[i] ); | 2315 | newCatList.append( catIncList[i] ); |
2316 | } | 2316 | } |
2317 | newCatList.sort(); | 2317 | newCatList.sort(); |
2318 | inc->setCategories( newCatList.join(",") ); | 2318 | inc->setCategories( newCatList.join(",") ); |
2319 | inc = incList.next(); | 2319 | inc = incList.next(); |
2320 | } | 2320 | } |
2321 | } | 2321 | } |
2322 | 2322 | ||
2323 | int CalendarView::addCategories() | 2323 | int CalendarView::addCategories() |
2324 | { | 2324 | { |
2325 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2325 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2326 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2326 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2327 | QStringList catIncList; | 2327 | QStringList catIncList; |
2328 | Incidence* inc = incList.first(); | 2328 | Incidence* inc = incList.first(); |
2329 | int i; | 2329 | int i; |
2330 | int count = 0; | 2330 | int count = 0; |
2331 | while ( inc ) { | 2331 | while ( inc ) { |
2332 | catIncList = inc->categories() ; | 2332 | catIncList = inc->categories() ; |
2333 | for( i = 0; i< catIncList.count(); ++i ) { | 2333 | for( i = 0; i< catIncList.count(); ++i ) { |
2334 | if ( !catList.contains (catIncList[i])) { | 2334 | if ( !catList.contains (catIncList[i])) { |
2335 | catList.append( catIncList[i] ); | 2335 | catList.append( catIncList[i] ); |
2336 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2336 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2337 | ++count; | 2337 | ++count; |
2338 | } | 2338 | } |
2339 | } | 2339 | } |
2340 | inc = incList.next(); | 2340 | inc = incList.next(); |
2341 | } | 2341 | } |
2342 | catList.sort(); | 2342 | catList.sort(); |
2343 | KOPrefs::instance()->mCustomCategories = catList; | 2343 | KOPrefs::instance()->mCustomCategories = catList; |
2344 | return count; | 2344 | return count; |
2345 | } | 2345 | } |
2346 | 2346 | ||
2347 | void CalendarView::manageCategories() | 2347 | void CalendarView::manageCategories() |
2348 | { | 2348 | { |
2349 | KOCatPrefs* cp = new KOCatPrefs(); | 2349 | KOCatPrefs* cp = new KOCatPrefs(); |
2350 | cp->show(); | 2350 | cp->show(); |
2351 | int w =cp->sizeHint().width() ; | 2351 | int w =cp->sizeHint().width() ; |
2352 | int h = cp->sizeHint().height() ; | 2352 | int h = cp->sizeHint().height() ; |
2353 | int dw = QApplication::desktop()->width(); | 2353 | int dw = QApplication::desktop()->width(); |
2354 | int dh = QApplication::desktop()->height(); | 2354 | int dh = QApplication::desktop()->height(); |
2355 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2355 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2356 | if ( !cp->exec() ) { | 2356 | if ( !cp->exec() ) { |
2357 | delete cp; | 2357 | delete cp; |
2358 | return; | 2358 | return; |
2359 | } | 2359 | } |
2360 | int count = 0; | 2360 | int count = 0; |
2361 | if ( cp->addCat() ) { | 2361 | if ( cp->addCat() ) { |
2362 | count = addCategories(); | 2362 | count = addCategories(); |
2363 | if ( count ) { | 2363 | if ( count ) { |
2364 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2364 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2365 | writeSettings(); | 2365 | writeSettings(); |
2366 | } else | 2366 | } else |
2367 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2367 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2368 | } else { | 2368 | } else { |
2369 | removeCategories(); | 2369 | removeCategories(); |
2370 | updateView(); | 2370 | updateView(); |
2371 | } | 2371 | } |
2372 | delete cp; | 2372 | delete cp; |
2373 | } | 2373 | } |
2374 | 2374 | ||
2375 | void CalendarView::beamIncidence(Incidence * Inc) | 2375 | void CalendarView::beamIncidence(Incidence * Inc) |
2376 | { | 2376 | { |
2377 | QPtrList<Incidence> delSel ; | 2377 | QPtrList<Incidence> delSel ; |
2378 | delSel.append(Inc); | 2378 | delSel.append(Inc); |
2379 | beamIncidenceList( delSel ); | 2379 | beamIncidenceList( delSel ); |
2380 | } | 2380 | } |
2381 | void CalendarView::beamCalendar() | 2381 | void CalendarView::beamCalendar() |
2382 | { | 2382 | { |
2383 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2383 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2384 | //qDebug("beamCalendar() "); | 2384 | //qDebug("beamCalendar() "); |
2385 | beamIncidenceList( delSel ); | 2385 | beamIncidenceList( delSel ); |
2386 | } | 2386 | } |
2387 | void CalendarView::beamFilteredCalendar() | 2387 | void CalendarView::beamFilteredCalendar() |
2388 | { | 2388 | { |
2389 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2389 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2390 | //qDebug("beamFilteredCalendar() "); | 2390 | //qDebug("beamFilteredCalendar() "); |
2391 | beamIncidenceList( delSel ); | 2391 | beamIncidenceList( delSel ); |
2392 | } | 2392 | } |
2393 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2393 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2394 | { | 2394 | { |
2395 | if ( beamDialog->exec () == QDialog::Rejected ) | 2395 | if ( beamDialog->exec () == QDialog::Rejected ) |
2396 | return; | 2396 | return; |
2397 | #ifdef DESKTOP_VERSION | 2397 | #ifdef DESKTOP_VERSION |
2398 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2398 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2399 | #else | 2399 | #else |
2400 | QString fn = "/tmp/kopibeamfile"; | 2400 | QString fn = "/tmp/kopibeamfile"; |
2401 | #endif | 2401 | #endif |
2402 | QString mes; | 2402 | QString mes; |
2403 | bool createbup = true; | 2403 | bool createbup = true; |
2404 | if ( createbup ) { | 2404 | if ( createbup ) { |
2405 | QString description = "\n"; | 2405 | QString description = "\n"; |
2406 | CalendarLocal* cal = new CalendarLocal(); | 2406 | CalendarLocal* cal = new CalendarLocal(); |
2407 | if ( beamDialog->beamLocal() ) | 2407 | if ( beamDialog->beamLocal() ) |
2408 | cal->setLocalTime(); | 2408 | cal->setLocalTime(); |
2409 | else | 2409 | else |
2410 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2410 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2411 | Incidence *incidence = delSel.first(); | 2411 | Incidence *incidence = delSel.first(); |
2412 | bool addText = false; | 2412 | bool addText = false; |
2413 | if ( delSel.count() < 10 ) | 2413 | if ( delSel.count() < 10 ) |
2414 | addText = true; | 2414 | addText = true; |
2415 | else { | 2415 | else { |
2416 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2416 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2417 | } | 2417 | } |
2418 | while ( incidence ) { | 2418 | while ( incidence ) { |
2419 | Incidence *in = incidence->clone(); | 2419 | Incidence *in = incidence->clone(); |
2420 | if ( ! in->summary().isEmpty() ) { | 2420 | if ( ! in->summary().isEmpty() ) { |
2421 | in->setDescription(""); | 2421 | in->setDescription(""); |
2422 | } else { | 2422 | } else { |
2423 | in->setSummary( in->description().left(20)); | 2423 | in->setSummary( in->description().left(20)); |
2424 | in->setDescription(""); | 2424 | in->setDescription(""); |
2425 | } | 2425 | } |
2426 | if ( addText ) | 2426 | if ( addText ) |
2427 | description += in->summary() + "\n"; | 2427 | description += in->summary() + "\n"; |
2428 | cal->addIncidence( in ); | 2428 | cal->addIncidence( in ); |
2429 | incidence = delSel.next(); | 2429 | incidence = delSel.next(); |
2430 | } | 2430 | } |
2431 | if ( beamDialog->beamVcal() ) { | 2431 | if ( beamDialog->beamVcal() ) { |
2432 | fn += ".vcs"; | 2432 | fn += ".vcs"; |
2433 | FileStorage storage( cal, fn, new VCalFormat ); | 2433 | FileStorage storage( cal, fn, new VCalFormat ); |
2434 | storage.save(); | 2434 | storage.save(); |
2435 | } else { | 2435 | } else { |
2436 | fn += ".ics"; | 2436 | fn += ".ics"; |
2437 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2437 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2438 | storage.save(); | 2438 | storage.save(); |
2439 | } | 2439 | } |
2440 | delete cal; | 2440 | delete cal; |
2441 | mes = i18n("KO/Pi: Ready for beaming"); | 2441 | mes = i18n("KO/Pi: Ready for beaming"); |
2442 | topLevelWidget()->setCaption(mes); | 2442 | topLevelWidget()->setCaption(mes); |
2443 | KApplication::convert2latin1( fn ); | 2443 | KApplication::convert2latin1( fn ); |
2444 | #ifndef DESKTOP_VERSION | 2444 | #ifndef DESKTOP_VERSION |
2445 | Ir *ir = new Ir( this ); | 2445 | Ir *ir = new Ir( this ); |
2446 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2446 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2447 | ir->send( fn, description, "text/x-vCalendar" ); | 2447 | ir->send( fn, description, "text/x-vCalendar" ); |
2448 | #endif | 2448 | #endif |
2449 | } | 2449 | } |
2450 | } | 2450 | } |
2451 | void CalendarView::beamDone( Ir *ir ) | 2451 | void CalendarView::beamDone( Ir *ir ) |
2452 | { | 2452 | { |
2453 | #ifndef DESKTOP_VERSION | 2453 | #ifndef DESKTOP_VERSION |
2454 | delete ir; | 2454 | delete ir; |
2455 | #endif | 2455 | #endif |
2456 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2456 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2457 | topLevelWidget()->raise(); | 2457 | topLevelWidget()->raise(); |
2458 | } | 2458 | } |
2459 | 2459 | ||
2460 | void CalendarView::moveIncidence(Incidence * inc ) | 2460 | void CalendarView::moveIncidence(Incidence * inc ) |
2461 | { | 2461 | { |
2462 | if ( !inc ) return; | 2462 | if ( !inc ) return; |
2463 | // qDebug("showDatePickerForIncidence( ) "); | 2463 | showDatePickerPopup(); |
2464 | if ( mDateFrame->isVisible() ) | ||
2465 | mDateFrame->hide(); | ||
2466 | else { | ||
2467 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | ||
2468 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | ||
2469 | int dw = QApplication::desktop()->width(); | ||
2470 | int dh = QApplication::desktop()->height(); | ||
2471 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
2472 | mDateFrame->show(); | ||
2473 | } | ||
2474 | mDatePickerMode = 2; | 2464 | mDatePickerMode = 2; |
2475 | mMoveIncidence = inc ; | 2465 | mMoveIncidence = inc ; |
2476 | QDate da; | 2466 | QDate da; |
2477 | if ( mMoveIncidence->type() == "Todo" ) { | 2467 | if ( mMoveIncidence->type() == "Todo" ) { |
2478 | Todo * to = (Todo *) mMoveIncidence; | 2468 | Todo * to = (Todo *) mMoveIncidence; |
2479 | if ( to->hasDueDate() ) | 2469 | if ( to->hasDueDate() ) |
2480 | da = to->dtDue().date(); | 2470 | da = to->dtDue().date(); |
2481 | else | 2471 | else |
2482 | da = QDate::currentDate(); | 2472 | da = QDate::currentDate(); |
2483 | } else { | 2473 | } else { |
2484 | da = mMoveIncidence->dtStart().date(); | 2474 | da = mMoveIncidence->dtStart().date(); |
2485 | } | 2475 | } |
2486 | //PENDING set date for recurring incidence to date of recurrence | 2476 | //PENDING set date for recurring incidence to date of recurrence |
2487 | //mMoveIncidenceOldDate; | 2477 | //mMoveIncidenceOldDate; |
2488 | mDatePicker->setDate( da ); | 2478 | mDatePicker->setDate( da ); |
2489 | } | 2479 | } |
2490 | void CalendarView::showDatePicker( ) | 2480 | void CalendarView::showDatePickerPopup() |
2491 | { | 2481 | { |
2492 | //qDebug("CalendarView::showDatePicker( ) "); | 2482 | if ( mDateFrame->isVisible() ) |
2493 | if ( mDateFrame->isVisible() ) | ||
2494 | mDateFrame->hide(); | 2483 | mDateFrame->hide(); |
2495 | else { | 2484 | else { |
2485 | int offX = 0, offY = 0; | ||
2486 | #ifdef DESKTOP_VERSION | ||
2487 | int w =mDatePicker->sizeHint().width() ; | ||
2488 | int h = mDatePicker->sizeHint().height() ; | ||
2489 | int dw = topLevelWidget()->width(); | ||
2490 | int dh = topLevelWidget()->height(); | ||
2491 | offX = topLevelWidget()->x(); | ||
2492 | offY = topLevelWidget()->y(); | ||
2493 | #else | ||
2496 | int w =mDatePicker->sizeHint().width() ; | 2494 | int w =mDatePicker->sizeHint().width() ; |
2497 | int h = mDatePicker->sizeHint().height() ; | 2495 | int h = mDatePicker->sizeHint().height() ; |
2498 | int dw = QApplication::desktop()->width(); | 2496 | int dw = QApplication::desktop()->width(); |
2499 | int dh = QApplication::desktop()->height(); | 2497 | int dh = QApplication::desktop()->height(); |
2500 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2498 | #endif |
2499 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | ||
2501 | mDateFrame->show(); | 2500 | mDateFrame->show(); |
2502 | } | 2501 | } |
2502 | } | ||
2503 | void CalendarView::showDatePicker( ) | ||
2504 | { | ||
2505 | showDatePickerPopup(); | ||
2503 | mDatePickerMode = 1; | 2506 | mDatePickerMode = 1; |
2504 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2507 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2505 | } | 2508 | } |
2506 | 2509 | ||
2507 | void CalendarView::showEventEditor() | 2510 | void CalendarView::showEventEditor() |
2508 | { | 2511 | { |
2509 | #ifdef DESKTOP_VERSION | 2512 | #ifdef DESKTOP_VERSION |
2510 | mEventEditor->show(); | 2513 | mEventEditor->show(); |
2511 | #else | 2514 | #else |
2512 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2515 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2513 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2516 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2514 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2517 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2515 | qApp->processEvents(); | 2518 | qApp->processEvents(); |
2516 | delete mEventEditor; | 2519 | delete mEventEditor; |
2517 | mEventEditor = mDialogManager->getEventEditor(); | 2520 | mEventEditor = mDialogManager->getEventEditor(); |
2518 | topLevelWidget()->setCaption( i18n("") ); | 2521 | topLevelWidget()->setCaption( i18n("") ); |
2519 | } | 2522 | } |
2520 | mEventEditor->showMaximized(); | 2523 | mEventEditor->showMaximized(); |
2521 | #endif | 2524 | #endif |
2522 | } | 2525 | } |
2523 | void CalendarView::showTodoEditor() | 2526 | void CalendarView::showTodoEditor() |
2524 | { | 2527 | { |
2525 | #ifdef DESKTOP_VERSION | 2528 | #ifdef DESKTOP_VERSION |
2526 | mTodoEditor->show(); | 2529 | mTodoEditor->show(); |
2527 | #else | 2530 | #else |
2528 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2531 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2529 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2532 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2530 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2533 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2531 | qApp->processEvents(); | 2534 | qApp->processEvents(); |
2532 | delete mTodoEditor; | 2535 | delete mTodoEditor; |
2533 | mTodoEditor = mDialogManager->getTodoEditor(); | 2536 | mTodoEditor = mDialogManager->getTodoEditor(); |
2534 | topLevelWidget()->setCaption( i18n("") ); | 2537 | topLevelWidget()->setCaption( i18n("") ); |
2535 | } | 2538 | } |
2536 | mTodoEditor->showMaximized(); | 2539 | mTodoEditor->showMaximized(); |
2537 | #endif | 2540 | #endif |
2538 | } | 2541 | } |
2539 | 2542 | ||
2540 | void CalendarView::cloneIncidence() | 2543 | void CalendarView::cloneIncidence() |
2541 | { | 2544 | { |
2542 | Incidence *incidence = currentSelection(); | 2545 | Incidence *incidence = currentSelection(); |
2543 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2546 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2544 | if ( incidence ) { | 2547 | if ( incidence ) { |
2545 | cloneIncidence(incidence); | 2548 | cloneIncidence(incidence); |
2546 | } | 2549 | } |
2547 | } | 2550 | } |
2548 | void CalendarView::moveIncidence() | 2551 | void CalendarView::moveIncidence() |
2549 | { | 2552 | { |
2550 | Incidence *incidence = currentSelection(); | 2553 | Incidence *incidence = currentSelection(); |
2551 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2554 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2552 | if ( incidence ) { | 2555 | if ( incidence ) { |
2553 | moveIncidence(incidence); | 2556 | moveIncidence(incidence); |
2554 | } | 2557 | } |
2555 | } | 2558 | } |
2556 | void CalendarView::beamIncidence() | 2559 | void CalendarView::beamIncidence() |
2557 | { | 2560 | { |
2558 | Incidence *incidence = currentSelection(); | 2561 | Incidence *incidence = currentSelection(); |
2559 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2562 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2560 | if ( incidence ) { | 2563 | if ( incidence ) { |
2561 | beamIncidence(incidence); | 2564 | beamIncidence(incidence); |
2562 | } | 2565 | } |
2563 | } | 2566 | } |
2564 | void CalendarView::toggleCancelIncidence() | 2567 | void CalendarView::toggleCancelIncidence() |
2565 | { | 2568 | { |
2566 | Incidence *incidence = currentSelection(); | 2569 | Incidence *incidence = currentSelection(); |
2567 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2570 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2568 | if ( incidence ) { | 2571 | if ( incidence ) { |
2569 | cancelIncidence(incidence); | 2572 | cancelIncidence(incidence); |
2570 | } | 2573 | } |
2571 | } | 2574 | } |
2572 | 2575 | ||
2573 | 2576 | ||
2574 | void CalendarView::cancelIncidence(Incidence * inc ) | 2577 | void CalendarView::cancelIncidence(Incidence * inc ) |
2575 | { | 2578 | { |
2576 | inc->setCancelled( ! inc->cancelled() ); | 2579 | inc->setCancelled( ! inc->cancelled() ); |
2577 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2580 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2578 | updateView(); | 2581 | updateView(); |
2579 | } | 2582 | } |
2580 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2583 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2581 | { | 2584 | { |
2582 | Incidence * newInc = orgInc->clone(); | 2585 | Incidence * newInc = orgInc->clone(); |
2583 | newInc->recreate(); | 2586 | newInc->recreate(); |
2584 | 2587 | ||
2585 | if ( newInc->type() == "Todo" ) { | 2588 | if ( newInc->type() == "Todo" ) { |
2586 | Todo* t = (Todo*) newInc; | 2589 | Todo* t = (Todo*) newInc; |
2587 | showTodoEditor(); | 2590 | showTodoEditor(); |
2588 | mTodoEditor->editTodo( t ); | 2591 | mTodoEditor->editTodo( t ); |
2589 | if ( mTodoEditor->exec() ) { | 2592 | if ( mTodoEditor->exec() ) { |
2590 | mCalendar->addTodo( t ); | 2593 | mCalendar->addTodo( t ); |
2591 | updateView(); | 2594 | updateView(); |
2592 | } else { | 2595 | } else { |
2593 | delete t; | 2596 | delete t; |
2594 | } | 2597 | } |
2595 | } | 2598 | } |
2596 | else { | 2599 | else { |
2597 | Event* e = (Event*) newInc; | 2600 | Event* e = (Event*) newInc; |
2598 | showEventEditor(); | 2601 | showEventEditor(); |
2599 | mEventEditor->editEvent( e ); | 2602 | mEventEditor->editEvent( e ); |
2600 | if ( mEventEditor->exec() ) { | 2603 | if ( mEventEditor->exec() ) { |
2601 | mCalendar->addEvent( e ); | 2604 | mCalendar->addEvent( e ); |
2602 | updateView(); | 2605 | updateView(); |
2603 | } else { | 2606 | } else { |
2604 | delete e; | 2607 | delete e; |
2605 | } | 2608 | } |
2606 | } | 2609 | } |
2607 | } | 2610 | } |
2608 | 2611 | ||
2609 | void CalendarView::newEvent() | 2612 | void CalendarView::newEvent() |
2610 | { | 2613 | { |
2611 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2614 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2612 | KOAgendaView *aView = mViewManager->agendaView(); | 2615 | KOAgendaView *aView = mViewManager->agendaView(); |
2613 | if (aView) { | 2616 | if (aView) { |
2614 | if (aView->selectionStart().isValid()) { | 2617 | if (aView->selectionStart().isValid()) { |
2615 | if (aView->selectedIsAllDay()) { | 2618 | if (aView->selectedIsAllDay()) { |
2616 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2619 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2617 | } else { | 2620 | } else { |
2618 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2621 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2619 | } | 2622 | } |
2620 | return; | 2623 | return; |
2621 | } | 2624 | } |
2622 | } | 2625 | } |
2623 | 2626 | ||
2624 | QDate date = mNavigator->selectedDates().first(); | 2627 | QDate date = mNavigator->selectedDates().first(); |
2625 | QDateTime current = QDateTime::currentDateTime(); | 2628 | QDateTime current = QDateTime::currentDateTime(); |
2626 | if ( date <= current.date() ) { | 2629 | if ( date <= current.date() ) { |
2627 | int hour = current.time().hour() +1; | 2630 | int hour = current.time().hour() +1; |
2628 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2631 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2629 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2632 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2630 | } else | 2633 | } else |
2631 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2634 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2632 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2635 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2633 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2636 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2634 | } | 2637 | } |
2635 | 2638 | ||
2636 | void CalendarView::newEvent(QDateTime fh) | 2639 | void CalendarView::newEvent(QDateTime fh) |
2637 | { | 2640 | { |
2638 | newEvent(fh, | 2641 | newEvent(fh, |
2639 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2642 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2640 | } | 2643 | } |
2641 | 2644 | ||
2642 | void CalendarView::newEvent(QDate dt) | 2645 | void CalendarView::newEvent(QDate dt) |
2643 | { | 2646 | { |
2644 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2647 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2645 | QDateTime(dt, QTime(0,0,0)), true); | 2648 | QDateTime(dt, QTime(0,0,0)), true); |
2646 | } | 2649 | } |
2647 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 2650 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
2648 | { | 2651 | { |
2649 | newEvent(fromHint, toHint, false); | 2652 | newEvent(fromHint, toHint, false); |
2650 | } | 2653 | } |
2651 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2654 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2652 | { | 2655 | { |
2653 | 2656 | ||
2654 | showEventEditor(); | 2657 | showEventEditor(); |
2655 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2658 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2656 | if ( mFilterView->filtersEnabled() ) { | 2659 | if ( mFilterView->filtersEnabled() ) { |
2657 | CalFilter *filter = mFilterView->selectedFilter(); | 2660 | CalFilter *filter = mFilterView->selectedFilter(); |
2658 | if (filter && filter->showCategories()) { | 2661 | if (filter && filter->showCategories()) { |
2659 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2662 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2660 | } | 2663 | } |
2661 | if ( filter ) | 2664 | if ( filter ) |
2662 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2665 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2663 | } | 2666 | } |
2664 | } | 2667 | } |
2665 | void CalendarView::todoAdded(Todo * t) | 2668 | void CalendarView::todoAdded(Todo * t) |
2666 | { | 2669 | { |
2667 | 2670 | ||
2668 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2671 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2669 | updateTodoViews(); | 2672 | updateTodoViews(); |
2670 | } | 2673 | } |
2671 | void CalendarView::todoChanged(Todo * t) | 2674 | void CalendarView::todoChanged(Todo * t) |
2672 | { | 2675 | { |
2673 | emit todoModified( t, 4 ); | 2676 | emit todoModified( t, 4 ); |
2674 | // updateTodoViews(); | 2677 | // updateTodoViews(); |
2675 | } | 2678 | } |
2676 | void CalendarView::todoToBeDeleted(Todo *) | 2679 | void CalendarView::todoToBeDeleted(Todo *) |
2677 | { | 2680 | { |
2678 | //qDebug("todoToBeDeleted(Todo *) "); | 2681 | //qDebug("todoToBeDeleted(Todo *) "); |
2679 | updateTodoViews(); | 2682 | updateTodoViews(); |
2680 | } | 2683 | } |
2681 | void CalendarView::todoDeleted() | 2684 | void CalendarView::todoDeleted() |
2682 | { | 2685 | { |
2683 | //qDebug(" todoDeleted()"); | 2686 | //qDebug(" todoDeleted()"); |
2684 | updateTodoViews(); | 2687 | updateTodoViews(); |
2685 | } | 2688 | } |
2686 | 2689 | ||
2687 | 2690 | ||
2688 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 2691 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
2689 | { | 2692 | { |
2690 | showTodoEditor(); | 2693 | showTodoEditor(); |
2691 | mTodoEditor->newTodo(dt,0,allday); | 2694 | mTodoEditor->newTodo(dt,0,allday); |
2692 | if ( mFilterView->filtersEnabled() ) { | 2695 | if ( mFilterView->filtersEnabled() ) { |
2693 | CalFilter *filter = mFilterView->selectedFilter(); | 2696 | CalFilter *filter = mFilterView->selectedFilter(); |
2694 | if (filter && filter->showCategories()) { | 2697 | if (filter && filter->showCategories()) { |
2695 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2698 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2696 | } | 2699 | } |
2697 | if ( filter ) | 2700 | if ( filter ) |
2698 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2701 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2699 | } | 2702 | } |
2700 | } | 2703 | } |
2701 | 2704 | ||
2702 | void CalendarView::newTodo() | 2705 | void CalendarView::newTodo() |
2703 | { | 2706 | { |
2704 | newTodoDateTime( QDateTime(),true ); | 2707 | newTodoDateTime( QDateTime(),true ); |
2705 | } | 2708 | } |
2706 | 2709 | ||
2707 | void CalendarView::newSubTodo() | 2710 | void CalendarView::newSubTodo() |
2708 | { | 2711 | { |
2709 | Todo *todo = selectedTodo(); | 2712 | Todo *todo = selectedTodo(); |
2710 | if ( todo ) newSubTodo( todo ); | 2713 | if ( todo ) newSubTodo( todo ); |
2711 | } | 2714 | } |
2712 | 2715 | ||
2713 | void CalendarView::newSubTodo(Todo *parentEvent) | 2716 | void CalendarView::newSubTodo(Todo *parentEvent) |
2714 | { | 2717 | { |
2715 | 2718 | ||
2716 | showTodoEditor(); | 2719 | showTodoEditor(); |
2717 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 2720 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
2718 | } | 2721 | } |
2719 | 2722 | ||
2720 | void CalendarView::newFloatingEvent() | 2723 | void CalendarView::newFloatingEvent() |
2721 | { | 2724 | { |
2722 | DateList tmpList = mNavigator->selectedDates(); | 2725 | DateList tmpList = mNavigator->selectedDates(); |
2723 | QDate date = tmpList.first(); | 2726 | QDate date = tmpList.first(); |
2724 | 2727 | ||
2725 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2728 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2726 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2729 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2727 | } | 2730 | } |
2728 | 2731 | ||
2729 | 2732 | ||
2730 | void CalendarView::editEvent( Event *event ) | 2733 | void CalendarView::editEvent( Event *event ) |
2731 | { | 2734 | { |
2732 | 2735 | ||
2733 | if ( !event ) return; | 2736 | if ( !event ) return; |
2734 | if ( event->isReadOnly() ) { | 2737 | if ( event->isReadOnly() ) { |
2735 | showEvent( event ); | 2738 | showEvent( event ); |
2736 | return; | 2739 | return; |
2737 | } | 2740 | } |
2738 | showEventEditor(); | 2741 | showEventEditor(); |
2739 | mEventEditor->editEvent( event , mFlagEditDescription); | 2742 | mEventEditor->editEvent( event , mFlagEditDescription); |
2740 | } | 2743 | } |
2741 | void CalendarView::editJournal( Journal *jour ) | 2744 | void CalendarView::editJournal( Journal *jour ) |
2742 | { | 2745 | { |
2743 | if ( !jour ) return; | 2746 | if ( !jour ) return; |
2744 | mDialogManager->hideSearchDialog(); | 2747 | mDialogManager->hideSearchDialog(); |
2745 | mViewManager->showJournalView(); | 2748 | mViewManager->showJournalView(); |
2746 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2749 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2747 | } | 2750 | } |
2748 | void CalendarView::editTodo( Todo *todo ) | 2751 | void CalendarView::editTodo( Todo *todo ) |
2749 | { | 2752 | { |
2750 | if ( !todo ) return; | 2753 | if ( !todo ) return; |
2751 | 2754 | ||
2752 | if ( todo->isReadOnly() ) { | 2755 | if ( todo->isReadOnly() ) { |
2753 | showTodo( todo ); | 2756 | showTodo( todo ); |
2754 | return; | 2757 | return; |
2755 | } | 2758 | } |
2756 | showTodoEditor(); | 2759 | showTodoEditor(); |
2757 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2760 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2758 | 2761 | ||
2759 | } | 2762 | } |
2760 | 2763 | ||
2761 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2764 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2762 | { | 2765 | { |
2763 | if ( !mEventViewerDialog ) { | 2766 | if ( !mEventViewerDialog ) { |
2764 | mEventViewerDialog = new KOEventViewerDialog(this); | 2767 | mEventViewerDialog = new KOEventViewerDialog(this); |
2765 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2768 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2766 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2769 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2767 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2770 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2768 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2771 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2769 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2772 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2770 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2773 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2771 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 2774 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
2772 | this, SLOT( todoChanged(Todo *) ) ); | 2775 | this, SLOT( todoChanged(Todo *) ) ); |
2773 | mEventViewerDialog->resize( 640, 480 ); | 2776 | mEventViewerDialog->resize( 640, 480 ); |
2774 | 2777 | ||
2775 | } | 2778 | } |
2776 | return mEventViewerDialog; | 2779 | return mEventViewerDialog; |
2777 | } | 2780 | } |
2778 | void CalendarView::showEvent(Event *event) | 2781 | void CalendarView::showEvent(Event *event) |
2779 | { | 2782 | { |
2780 | getEventViewerDialog()->setEvent(event); | 2783 | getEventViewerDialog()->setEvent(event); |
2781 | getEventViewerDialog()->showMe(); | 2784 | getEventViewerDialog()->showMe(); |
2782 | } | 2785 | } |
2783 | 2786 | ||
2784 | void CalendarView::showTodo(Todo *event) | 2787 | void CalendarView::showTodo(Todo *event) |
2785 | { | 2788 | { |
2786 | getEventViewerDialog()->setTodo(event); | 2789 | getEventViewerDialog()->setTodo(event); |
2787 | getEventViewerDialog()->showMe(); | 2790 | getEventViewerDialog()->showMe(); |
2788 | } | 2791 | } |
2789 | void CalendarView::showJournal( Journal *jour ) | 2792 | void CalendarView::showJournal( Journal *jour ) |
2790 | { | 2793 | { |
2791 | getEventViewerDialog()->setJournal(jour); | 2794 | getEventViewerDialog()->setJournal(jour); |
2792 | getEventViewerDialog()->showMe(); | 2795 | getEventViewerDialog()->showMe(); |
2793 | 2796 | ||
2794 | } | 2797 | } |
2795 | // void CalendarView::todoModified (Todo *event, int changed) | 2798 | // void CalendarView::todoModified (Todo *event, int changed) |
2796 | // { | 2799 | // { |
2797 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2800 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2798 | // // kdDebug() << "Todo modified and open" << endl; | 2801 | // // kdDebug() << "Todo modified and open" << endl; |
2799 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2802 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2800 | // // temp->modified (changed); | 2803 | // // temp->modified (changed); |
2801 | 2804 | ||
2802 | // // } | 2805 | // // } |
2803 | 2806 | ||
2804 | // mViewManager->updateView(); | 2807 | // mViewManager->updateView(); |
2805 | // } | 2808 | // } |
2806 | 2809 | ||
2807 | void CalendarView::appointment_show() | 2810 | void CalendarView::appointment_show() |
2808 | { | 2811 | { |
2809 | Event *anEvent = 0; | 2812 | Event *anEvent = 0; |
2810 | 2813 | ||
2811 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2814 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2812 | 2815 | ||
2813 | if (mViewManager->currentView()->isEventView()) { | 2816 | if (mViewManager->currentView()->isEventView()) { |
2814 | if ( incidence && incidence->type() == "Event" ) { | 2817 | if ( incidence && incidence->type() == "Event" ) { |
2815 | anEvent = static_cast<Event *>(incidence); | 2818 | anEvent = static_cast<Event *>(incidence); |
2816 | } | 2819 | } |
2817 | } | 2820 | } |
2818 | 2821 | ||
2819 | if (!anEvent) { | 2822 | if (!anEvent) { |
2820 | KNotifyClient::beep(); | 2823 | KNotifyClient::beep(); |
2821 | return; | 2824 | return; |
2822 | } | 2825 | } |
2823 | 2826 | ||
2824 | showEvent(anEvent); | 2827 | showEvent(anEvent); |
2825 | } | 2828 | } |
2826 | 2829 | ||
2827 | void CalendarView::appointment_edit() | 2830 | void CalendarView::appointment_edit() |
2828 | { | 2831 | { |
2829 | Event *anEvent = 0; | 2832 | Event *anEvent = 0; |
2830 | 2833 | ||
2831 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2834 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2832 | 2835 | ||
2833 | if (mViewManager->currentView()->isEventView()) { | 2836 | if (mViewManager->currentView()->isEventView()) { |
2834 | if ( incidence && incidence->type() == "Event" ) { | 2837 | if ( incidence && incidence->type() == "Event" ) { |
2835 | anEvent = static_cast<Event *>(incidence); | 2838 | anEvent = static_cast<Event *>(incidence); |
2836 | } | 2839 | } |
2837 | } | 2840 | } |
2838 | 2841 | ||
2839 | if (!anEvent) { | 2842 | if (!anEvent) { |
2840 | KNotifyClient::beep(); | 2843 | KNotifyClient::beep(); |
2841 | return; | 2844 | return; |
2842 | } | 2845 | } |
2843 | 2846 | ||
2844 | editEvent(anEvent); | 2847 | editEvent(anEvent); |
2845 | } | 2848 | } |
2846 | 2849 | ||
2847 | void CalendarView::appointment_delete() | 2850 | void CalendarView::appointment_delete() |
2848 | { | 2851 | { |
2849 | Event *anEvent = 0; | 2852 | Event *anEvent = 0; |
2850 | 2853 | ||
2851 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2854 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2852 | 2855 | ||
2853 | if (mViewManager->currentView()->isEventView()) { | 2856 | if (mViewManager->currentView()->isEventView()) { |
2854 | if ( incidence && incidence->type() == "Event" ) { | 2857 | if ( incidence && incidence->type() == "Event" ) { |
2855 | anEvent = static_cast<Event *>(incidence); | 2858 | anEvent = static_cast<Event *>(incidence); |
2856 | } | 2859 | } |
2857 | } | 2860 | } |
2858 | 2861 | ||
2859 | if (!anEvent) { | 2862 | if (!anEvent) { |
2860 | KNotifyClient::beep(); | 2863 | KNotifyClient::beep(); |
2861 | return; | 2864 | return; |
2862 | } | 2865 | } |
2863 | 2866 | ||
2864 | deleteEvent(anEvent); | 2867 | deleteEvent(anEvent); |
2865 | } | 2868 | } |
2866 | 2869 | ||
2867 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2870 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2868 | { | 2871 | { |
2869 | if (!sub) return; | 2872 | if (!sub) return; |
2870 | if (!parent) return; | 2873 | if (!parent) return; |
2871 | if ( sub->relatedTo() ) | 2874 | if ( sub->relatedTo() ) |
2872 | sub->relatedTo()->removeRelation(sub); | 2875 | sub->relatedTo()->removeRelation(sub); |
2873 | sub->setRelatedTo(parent); | 2876 | sub->setRelatedTo(parent); |
2874 | sub->setRelatedToUid(parent->uid()); | 2877 | sub->setRelatedToUid(parent->uid()); |
2875 | parent->addRelation(sub); | 2878 | parent->addRelation(sub); |
2876 | sub->updated(); | 2879 | sub->updated(); |
2877 | parent->updated(); | 2880 | parent->updated(); |
2878 | setModified(true); | 2881 | setModified(true); |
2879 | updateView(); | 2882 | updateView(); |
2880 | } | 2883 | } |
2881 | void CalendarView::todo_unsub(Todo *anTodo ) | 2884 | void CalendarView::todo_unsub(Todo *anTodo ) |
2882 | { | 2885 | { |
2883 | // Todo *anTodo = selectedTodo(); | 2886 | // Todo *anTodo = selectedTodo(); |
2884 | if (!anTodo) return; | 2887 | if (!anTodo) return; |
2885 | if (!anTodo->relatedTo()) return; | 2888 | if (!anTodo->relatedTo()) return; |
2886 | anTodo->relatedTo()->removeRelation(anTodo); | 2889 | anTodo->relatedTo()->removeRelation(anTodo); |
2887 | anTodo->setRelatedTo(0); | 2890 | anTodo->setRelatedTo(0); |
2888 | anTodo->updated(); | 2891 | anTodo->updated(); |
2889 | anTodo->setRelatedToUid(""); | 2892 | anTodo->setRelatedToUid(""); |
2890 | setModified(true); | 2893 | setModified(true); |
2891 | updateView(); | 2894 | updateView(); |
2892 | } | 2895 | } |
2893 | 2896 | ||
2894 | void CalendarView::deleteTodo(Todo *todo) | 2897 | void CalendarView::deleteTodo(Todo *todo) |
2895 | { | 2898 | { |
2896 | if (!todo) { | 2899 | if (!todo) { |
2897 | KNotifyClient::beep(); | 2900 | KNotifyClient::beep(); |
2898 | return; | 2901 | return; |
2899 | } | 2902 | } |
2900 | if (KOPrefs::instance()->mConfirm) { | 2903 | if (KOPrefs::instance()->mConfirm) { |
2901 | QString text = todo->summary().left(20); | 2904 | QString text = todo->summary().left(20); |
2902 | if (!todo->relations().isEmpty()) { | 2905 | if (!todo->relations().isEmpty()) { |
2903 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 2906 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
2904 | 2907 | ||
2905 | } | 2908 | } |
2906 | switch (msgItemDelete(text)) { | 2909 | switch (msgItemDelete(text)) { |
2907 | case KMessageBox::Continue: // OK | 2910 | case KMessageBox::Continue: // OK |
2908 | bool deleteT = false; | 2911 | bool deleteT = false; |
2909 | if (!todo->relations().isEmpty()) { | 2912 | if (!todo->relations().isEmpty()) { |
2910 | deleteT = removeCompletedSubTodos( todo ); | 2913 | deleteT = removeCompletedSubTodos( todo ); |
2911 | } | 2914 | } |
2912 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 2915 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
2913 | if ( !deleteT ) { | 2916 | if ( !deleteT ) { |
2914 | checkExternalId( todo ); | 2917 | checkExternalId( todo ); |
2915 | calendar()->deleteTodo(todo); | 2918 | calendar()->deleteTodo(todo); |
2916 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2919 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2917 | updateView(); | 2920 | updateView(); |
2918 | } | 2921 | } |
2919 | break; | 2922 | break; |
2920 | } // switch | 2923 | } // switch |
2921 | } else { | 2924 | } else { |
2922 | checkExternalId( todo ); | 2925 | checkExternalId( todo ); |
2923 | mCalendar->deleteTodo(todo); | 2926 | mCalendar->deleteTodo(todo); |
2924 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2927 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2925 | updateView(); | 2928 | updateView(); |
2926 | } | 2929 | } |
2927 | 2930 | ||
2928 | emit updateSearchDialog(); | 2931 | emit updateSearchDialog(); |
2929 | } | 2932 | } |
2930 | void CalendarView::deleteJournal(Journal *jour) | 2933 | void CalendarView::deleteJournal(Journal *jour) |
2931 | { | 2934 | { |
2932 | if (!jour) { | 2935 | if (!jour) { |
2933 | KNotifyClient::beep(); | 2936 | KNotifyClient::beep(); |
2934 | return; | 2937 | return; |
2935 | } | 2938 | } |
2936 | if (KOPrefs::instance()->mConfirm) { | 2939 | if (KOPrefs::instance()->mConfirm) { |
2937 | switch (msgItemDelete( jour->description().left(20))) { | 2940 | switch (msgItemDelete( jour->description().left(20))) { |
2938 | case KMessageBox::Continue: // OK | 2941 | case KMessageBox::Continue: // OK |
2939 | calendar()->deleteJournal(jour); | 2942 | calendar()->deleteJournal(jour); |
2940 | updateView(); | 2943 | updateView(); |
2941 | break; | 2944 | break; |
2942 | } // switch | 2945 | } // switch |
2943 | } else { | 2946 | } else { |
2944 | calendar()->deleteJournal(jour);; | 2947 | calendar()->deleteJournal(jour);; |
2945 | updateView(); | 2948 | updateView(); |
2946 | } | 2949 | } |
2947 | emit updateSearchDialog(); | 2950 | emit updateSearchDialog(); |
2948 | } | 2951 | } |
2949 | 2952 | ||
2950 | void CalendarView::deleteEvent(Event *anEvent) | 2953 | void CalendarView::deleteEvent(Event *anEvent) |
2951 | { | 2954 | { |
2952 | if (!anEvent) { | 2955 | if (!anEvent) { |
2953 | KNotifyClient::beep(); | 2956 | KNotifyClient::beep(); |
2954 | return; | 2957 | return; |
2955 | } | 2958 | } |
2956 | 2959 | ||
2957 | if (anEvent->recurrence()->doesRecur()) { | 2960 | if (anEvent->recurrence()->doesRecur()) { |
2958 | QDate itemDate = mViewManager->currentSelectionDate(); | 2961 | QDate itemDate = mViewManager->currentSelectionDate(); |
2959 | int km; | 2962 | int km; |
2960 | if (!itemDate.isValid()) { | 2963 | if (!itemDate.isValid()) { |
2961 | //kdDebug() << "Date Not Valid" << endl; | 2964 | //kdDebug() << "Date Not Valid" << endl; |
2962 | if (KOPrefs::instance()->mConfirm) { | 2965 | if (KOPrefs::instance()->mConfirm) { |
2963 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 2966 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
2964 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2967 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2965 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2968 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2966 | if ( km == KMessageBox::Continue ) | 2969 | if ( km == KMessageBox::Continue ) |
2967 | km = KMessageBox::No; // No = all below | 2970 | km = KMessageBox::No; // No = all below |
2968 | } else | 2971 | } else |
2969 | km = KMessageBox::No; | 2972 | km = KMessageBox::No; |
2970 | } else { | 2973 | } else { |
2971 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 2974 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
2972 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2975 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2973 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2976 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2974 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2977 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2975 | i18n("All")); | 2978 | i18n("All")); |
2976 | } | 2979 | } |
2977 | switch(km) { | 2980 | switch(km) { |
2978 | 2981 | ||
2979 | case KMessageBox::No: // Continue // all | 2982 | case KMessageBox::No: // Continue // all |
2980 | //qDebug("KMessageBox::No "); | 2983 | //qDebug("KMessageBox::No "); |
2981 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2984 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2982 | schedule(Scheduler::Cancel,anEvent); | 2985 | schedule(Scheduler::Cancel,anEvent); |
2983 | 2986 | ||
2984 | checkExternalId( anEvent); | 2987 | checkExternalId( anEvent); |
2985 | mCalendar->deleteEvent(anEvent); | 2988 | mCalendar->deleteEvent(anEvent); |
2986 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2989 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2987 | break; | 2990 | break; |
2988 | 2991 | ||
2989 | // Disabled because it does not work | 2992 | // Disabled because it does not work |
2990 | //#if 0 | 2993 | //#if 0 |
2991 | case KMessageBox::Yes: // just this one | 2994 | case KMessageBox::Yes: // just this one |
2992 | //QDate qd = mNavigator->selectedDates().first(); | 2995 | //QDate qd = mNavigator->selectedDates().first(); |
2993 | //if (!qd.isValid()) { | 2996 | //if (!qd.isValid()) { |
2994 | // kdDebug() << "no date selected, or invalid date" << endl; | 2997 | // kdDebug() << "no date selected, or invalid date" << endl; |
2995 | // KNotifyClient::beep(); | 2998 | // KNotifyClient::beep(); |
2996 | // return; | 2999 | // return; |
2997 | //} | 3000 | //} |
2998 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3001 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
2999 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3002 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3000 | anEvent->addExDate(itemDate); | 3003 | anEvent->addExDate(itemDate); |
3001 | int duration = anEvent->recurrence()->duration(); | 3004 | int duration = anEvent->recurrence()->duration(); |
3002 | if ( duration > 0 ) { | 3005 | if ( duration > 0 ) { |
3003 | anEvent->recurrence()->setDuration( duration - 1 ); | 3006 | anEvent->recurrence()->setDuration( duration - 1 ); |
3004 | } | 3007 | } |
3005 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3008 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3006 | } | 3009 | } |
3007 | break; | 3010 | break; |
3008 | //#endif | 3011 | //#endif |
3009 | } // switch | 3012 | } // switch |
3010 | } else { | 3013 | } else { |
3011 | if (KOPrefs::instance()->mConfirm) { | 3014 | if (KOPrefs::instance()->mConfirm) { |
3012 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3015 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3013 | i18n("\nAre you sure you want\nto delete this event?"), | 3016 | i18n("\nAre you sure you want\nto delete this event?"), |
3014 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3017 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3015 | case KMessageBox::Continue: // OK | 3018 | case KMessageBox::Continue: // OK |
3016 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3019 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3017 | schedule(Scheduler::Cancel,anEvent); | 3020 | schedule(Scheduler::Cancel,anEvent); |
3018 | checkExternalId( anEvent); | 3021 | checkExternalId( anEvent); |
3019 | mCalendar->deleteEvent(anEvent); | 3022 | mCalendar->deleteEvent(anEvent); |
3020 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3023 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3021 | break; | 3024 | break; |
3022 | } // switch | 3025 | } // switch |
3023 | } else { | 3026 | } else { |
3024 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3027 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3025 | schedule(Scheduler::Cancel,anEvent); | 3028 | schedule(Scheduler::Cancel,anEvent); |
3026 | checkExternalId( anEvent); | 3029 | checkExternalId( anEvent); |
3027 | mCalendar->deleteEvent(anEvent); | 3030 | mCalendar->deleteEvent(anEvent); |
3028 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3031 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3029 | } | 3032 | } |
3030 | } // if-else | 3033 | } // if-else |
3031 | emit updateSearchDialog(); | 3034 | emit updateSearchDialog(); |
3032 | } | 3035 | } |
3033 | 3036 | ||
3034 | bool CalendarView::deleteEvent(const QString &uid) | 3037 | bool CalendarView::deleteEvent(const QString &uid) |
3035 | { | 3038 | { |
3036 | Event *ev = mCalendar->event(uid); | 3039 | Event *ev = mCalendar->event(uid); |
3037 | if (ev) { | 3040 | if (ev) { |
3038 | deleteEvent(ev); | 3041 | deleteEvent(ev); |
3039 | return true; | 3042 | return true; |
3040 | } else { | 3043 | } else { |
3041 | return false; | 3044 | return false; |
3042 | } | 3045 | } |
3043 | } | 3046 | } |
3044 | 3047 | ||
3045 | /*****************************************************************************/ | 3048 | /*****************************************************************************/ |
3046 | 3049 | ||
3047 | void CalendarView::action_mail() | 3050 | void CalendarView::action_mail() |
3048 | { | 3051 | { |
3049 | #ifndef KORG_NOMAIL | 3052 | #ifndef KORG_NOMAIL |
3050 | KOMailClient mailClient; | 3053 | KOMailClient mailClient; |
3051 | 3054 | ||
3052 | Incidence *incidence = currentSelection(); | 3055 | Incidence *incidence = currentSelection(); |
3053 | 3056 | ||
3054 | if (!incidence) { | 3057 | if (!incidence) { |
3055 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3058 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3056 | return; | 3059 | return; |
3057 | } | 3060 | } |
3058 | if(incidence->attendeeCount() == 0 ) { | 3061 | if(incidence->attendeeCount() == 0 ) { |
3059 | KMessageBox::sorry(this, | 3062 | KMessageBox::sorry(this, |
3060 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3063 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3061 | return; | 3064 | return; |
3062 | } | 3065 | } |
3063 | 3066 | ||
3064 | CalendarLocal cal_tmp; | 3067 | CalendarLocal cal_tmp; |
3065 | Event *event = 0; | 3068 | Event *event = 0; |
3066 | Event *ev = 0; | 3069 | Event *ev = 0; |
3067 | if ( incidence && incidence->type() == "Event" ) { | 3070 | if ( incidence && incidence->type() == "Event" ) { |
3068 | event = static_cast<Event *>(incidence); | 3071 | event = static_cast<Event *>(incidence); |
3069 | ev = new Event(*event); | 3072 | ev = new Event(*event); |
3070 | cal_tmp.addEvent(ev); | 3073 | cal_tmp.addEvent(ev); |
3071 | } | 3074 | } |
3072 | ICalFormat mForm(); | 3075 | ICalFormat mForm(); |
3073 | QString attachment = mForm.toString( &cal_tmp ); | 3076 | QString attachment = mForm.toString( &cal_tmp ); |
3074 | if (ev) delete(ev); | 3077 | if (ev) delete(ev); |
3075 | 3078 | ||
3076 | mailClient.mailAttendees(currentSelection(), attachment); | 3079 | mailClient.mailAttendees(currentSelection(), attachment); |
3077 | 3080 | ||
3078 | #endif | 3081 | #endif |
3079 | 3082 | ||
3080 | #if 0 | 3083 | #if 0 |
3081 | Event *anEvent = 0; | 3084 | Event *anEvent = 0; |
3082 | if (mViewManager->currentView()->isEventView()) { | 3085 | if (mViewManager->currentView()->isEventView()) { |
3083 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3086 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3084 | } | 3087 | } |
3085 | 3088 | ||
3086 | if (!anEvent) { | 3089 | if (!anEvent) { |
3087 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3090 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3088 | return; | 3091 | return; |
3089 | } | 3092 | } |
3090 | if(anEvent->attendeeCount() == 0 ) { | 3093 | if(anEvent->attendeeCount() == 0 ) { |
3091 | KMessageBox::sorry(this, | 3094 | KMessageBox::sorry(this, |
3092 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3095 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3093 | return; | 3096 | return; |
3094 | } | 3097 | } |
3095 | 3098 | ||
3096 | mailobject.emailEvent(anEvent); | 3099 | mailobject.emailEvent(anEvent); |
3097 | #endif | 3100 | #endif |
3098 | } | 3101 | } |
3099 | 3102 | ||
3100 | 3103 | ||
3101 | void CalendarView::schedule_publish(Incidence *incidence) | 3104 | void CalendarView::schedule_publish(Incidence *incidence) |
3102 | { | 3105 | { |
3103 | Event *event = 0; | 3106 | Event *event = 0; |
3104 | Todo *todo = 0; | 3107 | Todo *todo = 0; |
3105 | 3108 | ||
3106 | if (incidence == 0) { | 3109 | if (incidence == 0) { |
3107 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3110 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3108 | if (incidence == 0) { | 3111 | if (incidence == 0) { |
3109 | incidence = mTodoList->selectedIncidences().first(); | 3112 | incidence = mTodoList->selectedIncidences().first(); |
3110 | } | 3113 | } |
3111 | } | 3114 | } |
3112 | if ( incidence && incidence->type() == "Event" ) { | 3115 | if ( incidence && incidence->type() == "Event" ) { |
3113 | event = static_cast<Event *>(incidence); | 3116 | event = static_cast<Event *>(incidence); |
3114 | } else { | 3117 | } else { |
3115 | if ( incidence && incidence->type() == "Todo" ) { | 3118 | if ( incidence && incidence->type() == "Todo" ) { |
3116 | todo = static_cast<Todo *>(incidence); | 3119 | todo = static_cast<Todo *>(incidence); |
3117 | } | 3120 | } |
3118 | } | 3121 | } |
3119 | 3122 | ||
3120 | if (!event && !todo) { | 3123 | if (!event && !todo) { |
3121 | KMessageBox::sorry(this,i18n("No event selected.")); | 3124 | KMessageBox::sorry(this,i18n("No event selected.")); |
3122 | return; | 3125 | return; |
3123 | } | 3126 | } |
3124 | 3127 | ||
3125 | PublishDialog *publishdlg = new PublishDialog(); | 3128 | PublishDialog *publishdlg = new PublishDialog(); |
3126 | if (incidence->attendeeCount()>0) { | 3129 | if (incidence->attendeeCount()>0) { |
3127 | QPtrList<Attendee> attendees = incidence->attendees(); | 3130 | QPtrList<Attendee> attendees = incidence->attendees(); |
3128 | attendees.first(); | 3131 | attendees.first(); |
3129 | while ( attendees.current()!=0 ) { | 3132 | while ( attendees.current()!=0 ) { |
3130 | publishdlg->addAttendee(attendees.current()); | 3133 | publishdlg->addAttendee(attendees.current()); |
3131 | attendees.next(); | 3134 | attendees.next(); |
3132 | } | 3135 | } |
3133 | } | 3136 | } |
3134 | bool send = true; | 3137 | bool send = true; |
3135 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3138 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3136 | if ( publishdlg->exec() != QDialog::Accepted ) | 3139 | if ( publishdlg->exec() != QDialog::Accepted ) |
3137 | send = false; | 3140 | send = false; |
3138 | } | 3141 | } |
3139 | if ( send ) { | 3142 | if ( send ) { |
3140 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3143 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3141 | if ( event ) { | 3144 | if ( event ) { |
3142 | Event *ev = new Event(*event); | 3145 | Event *ev = new Event(*event); |
3143 | ev->registerObserver(0); | 3146 | ev->registerObserver(0); |
3144 | ev->clearAttendees(); | 3147 | ev->clearAttendees(); |
3145 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3148 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3146 | delete(ev); | 3149 | delete(ev); |
3147 | } | 3150 | } |
3148 | } else { | 3151 | } else { |
3149 | if ( todo ) { | 3152 | if ( todo ) { |
3150 | Todo *ev = new Todo(*todo); | 3153 | Todo *ev = new Todo(*todo); |
3151 | ev->registerObserver(0); | 3154 | ev->registerObserver(0); |
3152 | ev->clearAttendees(); | 3155 | ev->clearAttendees(); |
3153 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3156 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3154 | delete(ev); | 3157 | delete(ev); |
3155 | } | 3158 | } |
3156 | } | 3159 | } |
3157 | } | 3160 | } |
3158 | } | 3161 | } |
3159 | delete publishdlg; | 3162 | delete publishdlg; |
3160 | } | 3163 | } |
3161 | 3164 | ||
3162 | void CalendarView::schedule_request(Incidence *incidence) | 3165 | void CalendarView::schedule_request(Incidence *incidence) |
3163 | { | 3166 | { |
3164 | schedule(Scheduler::Request,incidence); | 3167 | schedule(Scheduler::Request,incidence); |
3165 | } | 3168 | } |
3166 | 3169 | ||
3167 | void CalendarView::schedule_refresh(Incidence *incidence) | 3170 | void CalendarView::schedule_refresh(Incidence *incidence) |
3168 | { | 3171 | { |
3169 | schedule(Scheduler::Refresh,incidence); | 3172 | schedule(Scheduler::Refresh,incidence); |
3170 | } | 3173 | } |
3171 | 3174 | ||
3172 | void CalendarView::schedule_cancel(Incidence *incidence) | 3175 | void CalendarView::schedule_cancel(Incidence *incidence) |
3173 | { | 3176 | { |
3174 | schedule(Scheduler::Cancel,incidence); | 3177 | schedule(Scheduler::Cancel,incidence); |
3175 | } | 3178 | } |
3176 | 3179 | ||
3177 | void CalendarView::schedule_add(Incidence *incidence) | 3180 | void CalendarView::schedule_add(Incidence *incidence) |
3178 | { | 3181 | { |
3179 | schedule(Scheduler::Add,incidence); | 3182 | schedule(Scheduler::Add,incidence); |
3180 | } | 3183 | } |
3181 | 3184 | ||
3182 | void CalendarView::schedule_reply(Incidence *incidence) | 3185 | void CalendarView::schedule_reply(Incidence *incidence) |
3183 | { | 3186 | { |
3184 | schedule(Scheduler::Reply,incidence); | 3187 | schedule(Scheduler::Reply,incidence); |
3185 | } | 3188 | } |
3186 | 3189 | ||
3187 | void CalendarView::schedule_counter(Incidence *incidence) | 3190 | void CalendarView::schedule_counter(Incidence *incidence) |
3188 | { | 3191 | { |
3189 | schedule(Scheduler::Counter,incidence); | 3192 | schedule(Scheduler::Counter,incidence); |
3190 | } | 3193 | } |
3191 | 3194 | ||
3192 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3195 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3193 | { | 3196 | { |
3194 | schedule(Scheduler::Declinecounter,incidence); | 3197 | schedule(Scheduler::Declinecounter,incidence); |
3195 | } | 3198 | } |
3196 | 3199 | ||
3197 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3200 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3198 | { | 3201 | { |
3199 | QDateTime start = QDateTime::currentDateTime(); | 3202 | QDateTime start = QDateTime::currentDateTime(); |
3200 | QDateTime end = start.addDays(daysToPublish); | 3203 | QDateTime end = start.addDays(daysToPublish); |
3201 | 3204 | ||
3202 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3205 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3203 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3206 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3204 | 3207 | ||
3205 | 3208 | ||
3206 | PublishDialog *publishdlg = new PublishDialog(); | 3209 | PublishDialog *publishdlg = new PublishDialog(); |
3207 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3210 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3208 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3211 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3209 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3212 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3210 | delete(freebusy); | 3213 | delete(freebusy); |
3211 | } | 3214 | } |
3212 | } | 3215 | } |
3213 | delete publishdlg; | 3216 | delete publishdlg; |
3214 | } | 3217 | } |
3215 | 3218 | ||
3216 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3219 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3217 | { | 3220 | { |
3218 | Event *event = 0; | 3221 | Event *event = 0; |
3219 | Todo *todo = 0; | 3222 | Todo *todo = 0; |
3220 | 3223 | ||
3221 | if (incidence == 0) { | 3224 | if (incidence == 0) { |
3222 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3225 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3223 | if (incidence == 0) { | 3226 | if (incidence == 0) { |
3224 | incidence = mTodoList->selectedIncidences().first(); | 3227 | incidence = mTodoList->selectedIncidences().first(); |
3225 | } | 3228 | } |
3226 | } | 3229 | } |
3227 | if ( incidence && incidence->type() == "Event" ) { | 3230 | if ( incidence && incidence->type() == "Event" ) { |
3228 | event = static_cast<Event *>(incidence); | 3231 | event = static_cast<Event *>(incidence); |
3229 | } | 3232 | } |
3230 | if ( incidence && incidence->type() == "Todo" ) { | 3233 | if ( incidence && incidence->type() == "Todo" ) { |
3231 | todo = static_cast<Todo *>(incidence); | 3234 | todo = static_cast<Todo *>(incidence); |
3232 | } | 3235 | } |
3233 | 3236 | ||
3234 | if (!event && !todo) { | 3237 | if (!event && !todo) { |
3235 | KMessageBox::sorry(this,i18n("No event selected.")); | 3238 | KMessageBox::sorry(this,i18n("No event selected.")); |
3236 | return; | 3239 | return; |
3237 | } | 3240 | } |
3238 | 3241 | ||
3239 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3242 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3240 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3243 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3241 | return; | 3244 | return; |
3242 | } | 3245 | } |
3243 | 3246 | ||
3244 | Event *ev = 0; | 3247 | Event *ev = 0; |
3245 | if (event) ev = new Event(*event); | 3248 | if (event) ev = new Event(*event); |
3246 | Todo *to = 0; | 3249 | Todo *to = 0; |
3247 | if (todo) to = new Todo(*todo); | 3250 | if (todo) to = new Todo(*todo); |
3248 | 3251 | ||
3249 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3252 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3250 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3253 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3251 | if (!me) { | 3254 | if (!me) { |
3252 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3255 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3253 | return; | 3256 | return; |
3254 | } | 3257 | } |
3255 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3258 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3256 | StatusDialog *statdlg = new StatusDialog(this); | 3259 | StatusDialog *statdlg = new StatusDialog(this); |
3257 | if (!statdlg->exec()==QDialog::Accepted) return; | 3260 | if (!statdlg->exec()==QDialog::Accepted) return; |
3258 | me->setStatus( statdlg->status() ); | 3261 | me->setStatus( statdlg->status() ); |
3259 | delete(statdlg); | 3262 | delete(statdlg); |
3260 | } | 3263 | } |
3261 | Attendee *menew = new Attendee(*me); | 3264 | Attendee *menew = new Attendee(*me); |
3262 | if (ev) { | 3265 | if (ev) { |
3263 | ev->clearAttendees(); | 3266 | ev->clearAttendees(); |
3264 | ev->addAttendee(menew,false); | 3267 | ev->addAttendee(menew,false); |
3265 | } else { | 3268 | } else { |
3266 | if (to) { | 3269 | if (to) { |
3267 | todo->clearAttendees(); | 3270 | todo->clearAttendees(); |
3268 | todo->addAttendee(menew,false); | 3271 | todo->addAttendee(menew,false); |
3269 | } | 3272 | } |
3270 | } | 3273 | } |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 731298d..e626ea3 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -1,611 +1,612 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000, 2001 | 3 | Copyright (c) 2000, 2001 |
4 | Cornelius Schumacher <schumacher@kde.org> | 4 | Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef CALENDARVIEW_H | 24 | #ifndef CALENDARVIEW_H |
25 | #define CALENDARVIEW_H | 25 | #define CALENDARVIEW_H |
26 | 26 | ||
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qptrlist.h> | 30 | #include <qptrlist.h> |
31 | #include <qvbox.h> | 31 | #include <qvbox.h> |
32 | #include <qmap.h> | 32 | #include <qmap.h> |
33 | #ifndef DESKTOP_VERSION | 33 | #ifndef DESKTOP_VERSION |
34 | #include <qtopia/ir.h> | 34 | #include <qtopia/ir.h> |
35 | #else | 35 | #else |
36 | #define Ir char | 36 | #define Ir char |
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendar.h> | 38 | #include <libkcal/calendar.h> |
39 | #include <libkcal/scheduler.h> | 39 | #include <libkcal/scheduler.h> |
40 | #include <libkcal/calendarresources.h> | 40 | #include <libkcal/calendarresources.h> |
41 | #include <libkcal/resourcecalendar.h> | 41 | #include <libkcal/resourcecalendar.h> |
42 | 42 | ||
43 | #include <korganizer/calendarviewbase.h> | 43 | #include <korganizer/calendarviewbase.h> |
44 | 44 | ||
45 | #include <ksyncmanager.h> | 45 | #include <ksyncmanager.h> |
46 | 46 | ||
47 | class QWidgetStack; | 47 | class QWidgetStack; |
48 | class QSplitter; | 48 | class QSplitter; |
49 | 49 | ||
50 | class CalPrinter; | 50 | class CalPrinter; |
51 | class KOFilterView; | 51 | class KOFilterView; |
52 | class KOViewManager; | 52 | class KOViewManager; |
53 | class KODialogManager; | 53 | class KODialogManager; |
54 | class KOTodoView; | 54 | class KOTodoView; |
55 | class KDateNavigator; | 55 | class KDateNavigator; |
56 | class DateNavigator; | 56 | class DateNavigator; |
57 | class KOIncidenceEditor; | 57 | class KOIncidenceEditor; |
58 | class KDatePicker; | 58 | class KDatePicker; |
59 | class ResourceView; | 59 | class ResourceView; |
60 | class KOEventEditor; | 60 | class KOEventEditor; |
61 | class KOTodoEditor ; | 61 | class KOTodoEditor ; |
62 | class KOEventViewerDialog; | 62 | class KOEventViewerDialog; |
63 | class KOBeamPrefs; | 63 | class KOBeamPrefs; |
64 | class KSyncProfile; | 64 | class KSyncProfile; |
65 | class AlarmDialog; | 65 | class AlarmDialog; |
66 | class KCal::Attendee; | 66 | class KCal::Attendee; |
67 | 67 | ||
68 | namespace KCal { class FileStorage; } | 68 | namespace KCal { class FileStorage; } |
69 | 69 | ||
70 | using namespace KCal; | 70 | using namespace KCal; |
71 | 71 | ||
72 | /** | 72 | /** |
73 | This is the main calendar widget. It provides the different vies on t he | 73 | This is the main calendar widget. It provides the different vies on t he |
74 | calendar data as well as the date navigator. It also handles synchronisation | 74 | calendar data as well as the date navigator. It also handles synchronisation |
75 | of the different views and controls the different dialogs like preferences, | 75 | of the different views and controls the different dialogs like preferences, |
76 | event editor, search dialog etc. | 76 | event editor, search dialog etc. |
77 | 77 | ||
78 | @short main calendar view widget | 78 | @short main calendar view widget |
79 | @author Cornelius Schumacher | 79 | @author Cornelius Schumacher |
80 | */ | 80 | */ |
81 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface | 81 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface |
82 | { | 82 | { |
83 | Q_OBJECT | 83 | Q_OBJECT |
84 | public: | 84 | public: |
85 | /** | 85 | /** |
86 | Constructs a new calendar view widget. | 86 | Constructs a new calendar view widget. |
87 | 87 | ||
88 | @param calendar calendar document | 88 | @param calendar calendar document |
89 | @param parent parent window | 89 | @param parent parent window |
90 | @param name Qt internal widget object name | 90 | @param name Qt internal widget object name |
91 | */ | 91 | */ |
92 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, | 92 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, |
93 | const char *name = 0 ); | 93 | const char *name = 0 ); |
94 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 94 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
95 | const char *name = 0 ); | 95 | const char *name = 0 ); |
96 | virtual ~CalendarView(); | 96 | virtual ~CalendarView(); |
97 | 97 | ||
98 | Calendar *calendar() { return mCalendar; } | 98 | Calendar *calendar() { return mCalendar; } |
99 | 99 | ||
100 | KOViewManager *viewManager(); | 100 | KOViewManager *viewManager(); |
101 | KODialogManager *dialogManager(); | 101 | KODialogManager *dialogManager(); |
102 | 102 | ||
103 | QDate startDate(); | 103 | QDate startDate(); |
104 | QDate endDate(); | 104 | QDate endDate(); |
105 | 105 | ||
106 | QWidgetStack *viewStack(); | 106 | QWidgetStack *viewStack(); |
107 | QWidget *leftFrame(); | 107 | QWidget *leftFrame(); |
108 | 108 | ||
109 | DateNavigator *dateNavigator(); | 109 | DateNavigator *dateNavigator(); |
110 | KDateNavigator *dateNavigatorWidget(); | 110 | KDateNavigator *dateNavigatorWidget(); |
111 | 111 | ||
112 | void addView(KOrg::BaseView *); | 112 | void addView(KOrg::BaseView *); |
113 | void showView(KOrg::BaseView *); | 113 | void showView(KOrg::BaseView *); |
114 | KOEventViewerDialog* getEventViewerDialog(); | 114 | KOEventViewerDialog* getEventViewerDialog(); |
115 | Incidence *currentSelection(); | 115 | Incidence *currentSelection(); |
116 | 116 | ||
117 | signals: | 117 | signals: |
118 | void save (); | 118 | void save (); |
119 | void saveStopTimer (); | 119 | void saveStopTimer (); |
120 | void tempDisableBR(bool); | 120 | void tempDisableBR(bool); |
121 | /** This todo has been modified */ | 121 | /** This todo has been modified */ |
122 | void todoModified(Todo *, int); | 122 | void todoModified(Todo *, int); |
123 | 123 | ||
124 | /** when change is made to options dialog, the topwidget will catch this | 124 | /** when change is made to options dialog, the topwidget will catch this |
125 | * and emit this signal which notifies all widgets which have registered | 125 | * and emit this signal which notifies all widgets which have registered |
126 | * for notification to update their settings. */ | 126 | * for notification to update their settings. */ |
127 | void configChanged(); | 127 | void configChanged(); |
128 | /** emitted when the topwidget is closing down, so that any attached | 128 | /** emitted when the topwidget is closing down, so that any attached |
129 | child windows can also close. */ | 129 | child windows can also close. */ |
130 | void closingDown(); | 130 | void closingDown(); |
131 | /** emitted right before we die */ | 131 | /** emitted right before we die */ |
132 | void closed(QWidget *); | 132 | void closed(QWidget *); |
133 | 133 | ||
134 | /** Emitted when state of modified flag changes */ | 134 | /** Emitted when state of modified flag changes */ |
135 | void modifiedChanged(bool); | 135 | void modifiedChanged(bool); |
136 | void signalmodified(); | 136 | void signalmodified(); |
137 | 137 | ||
138 | /** Emitted when state of read-only flag changes */ | 138 | /** Emitted when state of read-only flag changes */ |
139 | void readOnlyChanged(bool); | 139 | void readOnlyChanged(bool); |
140 | 140 | ||
141 | /** Emitted when the unit of navigation changes */ | 141 | /** Emitted when the unit of navigation changes */ |
142 | void changeNavStringPrev(const QString &); | 142 | void changeNavStringPrev(const QString &); |
143 | void changeNavStringNext(const QString &); | 143 | void changeNavStringNext(const QString &); |
144 | 144 | ||
145 | /** Emitted when state of events selection has changed and user is organizer*/ | 145 | /** Emitted when state of events selection has changed and user is organizer*/ |
146 | void organizerEventsSelected(bool); | 146 | void organizerEventsSelected(bool); |
147 | /** Emitted when state of events selection has changed and user is attendee*/ | 147 | /** Emitted when state of events selection has changed and user is attendee*/ |
148 | void groupEventsSelected(bool); | 148 | void groupEventsSelected(bool); |
149 | /** | 149 | /** |
150 | Emitted when an incidence gets selected. If the selection is cleared the | 150 | Emitted when an incidence gets selected. If the selection is cleared the |
151 | signal is emitted with 0 as argument. | 151 | signal is emitted with 0 as argument. |
152 | */ | 152 | */ |
153 | void incidenceSelected( Incidence * ); | 153 | void incidenceSelected( Incidence * ); |
154 | /** Emitted, when a todoitem is selected or deselected. */ | 154 | /** Emitted, when a todoitem is selected or deselected. */ |
155 | void todoSelected( bool ); | 155 | void todoSelected( bool ); |
156 | 156 | ||
157 | /** | 157 | /** |
158 | Emitted, when clipboard content changes. Parameter indicates if paste | 158 | Emitted, when clipboard content changes. Parameter indicates if paste |
159 | is possible or not. | 159 | is possible or not. |
160 | */ | 160 | */ |
161 | void pasteEnabled(bool); | 161 | void pasteEnabled(bool); |
162 | 162 | ||
163 | /** Emitted, when the number of incoming messages has changed. */ | 163 | /** Emitted, when the number of incoming messages has changed. */ |
164 | void numIncomingChanged(int); | 164 | void numIncomingChanged(int); |
165 | 165 | ||
166 | /** Emitted, when the number of outgoing messages has changed. */ | 166 | /** Emitted, when the number of outgoing messages has changed. */ |
167 | void numOutgoingChanged(int); | 167 | void numOutgoingChanged(int); |
168 | 168 | ||
169 | /** Send status message, which can e.g. be displayed in the status bar. */ | 169 | /** Send status message, which can e.g. be displayed in the status bar. */ |
170 | void statusMessage(const QString &); | 170 | void statusMessage(const QString &); |
171 | 171 | ||
172 | void calendarViewExpanded( bool ); | 172 | void calendarViewExpanded( bool ); |
173 | void updateSearchDialog(); | 173 | void updateSearchDialog(); |
174 | 174 | ||
175 | 175 | ||
176 | public slots: | 176 | public slots: |
177 | void showOpenError(); | 177 | void showOpenError(); |
178 | void watchSavedFile(); | 178 | void watchSavedFile(); |
179 | void recheckTimerAlarm(); | 179 | void recheckTimerAlarm(); |
180 | void checkNextTimerAlarm(); | 180 | void checkNextTimerAlarm(); |
181 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 181 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
182 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 182 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
183 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 183 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
184 | 184 | ||
185 | /** options dialog made a changed to the configuration. we catch this | 185 | /** options dialog made a changed to the configuration. we catch this |
186 | * and notify all widgets which need to update their configuration. */ | 186 | * and notify all widgets which need to update their configuration. */ |
187 | void updateConfig(); | 187 | void updateConfig(); |
188 | 188 | ||
189 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, | 189 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, |
190 | const QStringList& anniversaryList, const QStringList& realNameList, | 190 | const QStringList& anniversaryList, const QStringList& realNameList, |
191 | const QStringList& emailList, const QStringList& assembledNameList, | 191 | const QStringList& emailList, const QStringList& assembledNameList, |
192 | const QStringList& uidList); | 192 | const QStringList& uidList); |
193 | 193 | ||
194 | /** | 194 | /** |
195 | Load calendar from file \a filename. If \a merge is true, load | 195 | Load calendar from file \a filename. If \a merge is true, load |
196 | calendar into existing one, if it is false, clear calendar, before | 196 | calendar into existing one, if it is false, clear calendar, before |
197 | loading. Return true, if calendar could be successfully loaded. | 197 | loading. Return true, if calendar could be successfully loaded. |
198 | */ | 198 | */ |
199 | bool openCalendar(QString filename, bool merge=false); | 199 | bool openCalendar(QString filename, bool merge=false); |
200 | bool syncCalendar(QString filename,int mode = 0 ); | 200 | bool syncCalendar(QString filename,int mode = 0 ); |
201 | 201 | ||
202 | /** | 202 | /** |
203 | Save calendar data to file. Return true if calendar could be | 203 | Save calendar data to file. Return true if calendar could be |
204 | successfully saved. | 204 | successfully saved. |
205 | */ | 205 | */ |
206 | bool saveCalendar(QString filename); | 206 | bool saveCalendar(QString filename); |
207 | 207 | ||
208 | /** | 208 | /** |
209 | Close calendar. Clear calendar data and reset views to display an empty | 209 | Close calendar. Clear calendar data and reset views to display an empty |
210 | calendar. | 210 | calendar. |
211 | */ | 211 | */ |
212 | void closeCalendar(); | 212 | void closeCalendar(); |
213 | 213 | ||
214 | /** Archive old events of calendar */ | 214 | /** Archive old events of calendar */ |
215 | void archiveCalendar(); | 215 | void archiveCalendar(); |
216 | 216 | ||
217 | void showIncidence(); | 217 | void showIncidence(); |
218 | void editIncidence(); | 218 | void editIncidence(); |
219 | void editIncidenceDescription(); | 219 | void editIncidenceDescription(); |
220 | void deleteIncidence(); | 220 | void deleteIncidence(); |
221 | void cloneIncidence(); | 221 | void cloneIncidence(); |
222 | void moveIncidence(); | 222 | void moveIncidence(); |
223 | void beamIncidence(); | 223 | void beamIncidence(); |
224 | void toggleCancelIncidence(); | 224 | void toggleCancelIncidence(); |
225 | 225 | ||
226 | /** create an editeventwin with supplied date/time, and if bool is true, | 226 | /** create an editeventwin with supplied date/time, and if bool is true, |
227 | * make the event take all day. */ | 227 | * make the event take all day. */ |
228 | void newEvent(QDateTime, QDateTime, bool allDay ); | 228 | void newEvent(QDateTime, QDateTime, bool allDay ); |
229 | void newEvent(QDateTime, QDateTime); | 229 | void newEvent(QDateTime, QDateTime); |
230 | void newEvent(QDateTime fh); | 230 | void newEvent(QDateTime fh); |
231 | void newEvent(QDate dt); | 231 | void newEvent(QDate dt); |
232 | /** create new event without having a date hint. Takes current date as | 232 | /** create new event without having a date hint. Takes current date as |
233 | default hint. */ | 233 | default hint. */ |
234 | void newEvent(); | 234 | void newEvent(); |
235 | void newFloatingEvent(); | 235 | void newFloatingEvent(); |
236 | 236 | ||
237 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 237 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
238 | void showIncidence(Incidence *); | 238 | void showIncidence(Incidence *); |
239 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 239 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
240 | void editIncidence(Incidence *); | 240 | void editIncidence(Incidence *); |
241 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 241 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
242 | void deleteIncidence(Incidence *); | 242 | void deleteIncidence(Incidence *); |
243 | void cloneIncidence(Incidence *); | 243 | void cloneIncidence(Incidence *); |
244 | void cancelIncidence(Incidence *); | 244 | void cancelIncidence(Incidence *); |
245 | /** Create an editor for the supplied event. */ | 245 | /** Create an editor for the supplied event. */ |
246 | void editEvent(Event *); | 246 | void editEvent(Event *); |
247 | /** Delete the supplied event. */ | 247 | /** Delete the supplied event. */ |
248 | void deleteEvent(Event *); | 248 | void deleteEvent(Event *); |
249 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 249 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
250 | found. */ | 250 | found. */ |
251 | bool deleteEvent(const QString &uid); | 251 | bool deleteEvent(const QString &uid); |
252 | /** Create a read-only viewer dialog for the supplied event. */ | 252 | /** Create a read-only viewer dialog for the supplied event. */ |
253 | void showEvent(Event *); | 253 | void showEvent(Event *); |
254 | 254 | ||
255 | void editJournal(Journal *); | 255 | void editJournal(Journal *); |
256 | void showJournal(Journal *); | 256 | void showJournal(Journal *); |
257 | void deleteJournal(Journal *); | 257 | void deleteJournal(Journal *); |
258 | /** Create an editor dialog for a todo */ | 258 | /** Create an editor dialog for a todo */ |
259 | void editTodo(Todo *); | 259 | void editTodo(Todo *); |
260 | /** Create a read-only viewer dialog for the supplied todo */ | 260 | /** Create a read-only viewer dialog for the supplied todo */ |
261 | void showTodo(Todo *); | 261 | void showTodo(Todo *); |
262 | /** create new todo */ | 262 | /** create new todo */ |
263 | void newTodo(); | 263 | void newTodo(); |
264 | void newTodoDateTime(QDateTime, bool allday); | 264 | void newTodoDateTime(QDateTime, bool allday); |
265 | /** create new todo with a parent todo */ | 265 | /** create new todo with a parent todo */ |
266 | void newSubTodo(); | 266 | void newSubTodo(); |
267 | /** create new todo with a parent todo */ | 267 | /** create new todo with a parent todo */ |
268 | void newSubTodo(Todo *); | 268 | void newSubTodo(Todo *); |
269 | /** Delete todo */ | 269 | /** Delete todo */ |
270 | void deleteTodo(Todo *); | 270 | void deleteTodo(Todo *); |
271 | 271 | ||
272 | 272 | ||
273 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 273 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
274 | * emitted as result. */ | 274 | * emitted as result. */ |
275 | void checkClipboard(); | 275 | void checkClipboard(); |
276 | 276 | ||
277 | /** using the KConfig associated with the kapp variable, read in the | 277 | /** using the KConfig associated with the kapp variable, read in the |
278 | * settings from the config file. | 278 | * settings from the config file. |
279 | */ | 279 | */ |
280 | void readSettings(); | 280 | void readSettings(); |
281 | 281 | ||
282 | /** write current state to config file. */ | 282 | /** write current state to config file. */ |
283 | void writeSettings(); | 283 | void writeSettings(); |
284 | 284 | ||
285 | /** read settings for calendar filters */ | 285 | /** read settings for calendar filters */ |
286 | void readFilterSettings(KConfig *config); | 286 | void readFilterSettings(KConfig *config); |
287 | 287 | ||
288 | /** write settings for calendar filters */ | 288 | /** write settings for calendar filters */ |
289 | void writeFilterSettings(KConfig *config); | 289 | void writeFilterSettings(KConfig *config); |
290 | 290 | ||
291 | /** passes on the message that an event has changed to the currently | 291 | /** passes on the message that an event has changed to the currently |
292 | * activated view so that it can make appropriate display changes. */ | 292 | * activated view so that it can make appropriate display changes. */ |
293 | void changeEventDisplay(Event *, int); | 293 | void changeEventDisplay(Event *, int); |
294 | void changeIncidenceDisplay(Incidence *, int); | 294 | void changeIncidenceDisplay(Incidence *, int); |
295 | void changeTodoDisplay(Todo *, int); | 295 | void changeTodoDisplay(Todo *, int); |
296 | 296 | ||
297 | void eventAdded(Event *); | 297 | void eventAdded(Event *); |
298 | void eventChanged(Event *); | 298 | void eventChanged(Event *); |
299 | void eventToBeDeleted(Event *); | 299 | void eventToBeDeleted(Event *); |
300 | void eventDeleted(); | 300 | void eventDeleted(); |
301 | 301 | ||
302 | void todoAdded(Todo *); | 302 | void todoAdded(Todo *); |
303 | void todoChanged(Todo *); | 303 | void todoChanged(Todo *); |
304 | void todoToBeDeleted(Todo *); | 304 | void todoToBeDeleted(Todo *); |
305 | void todoDeleted(); | 305 | void todoDeleted(); |
306 | 306 | ||
307 | void updateView(const QDate &start, const QDate &end); | 307 | void updateView(const QDate &start, const QDate &end); |
308 | void updateView(); | 308 | void updateView(); |
309 | 309 | ||
310 | /** Full update of visible todo views */ | 310 | /** Full update of visible todo views */ |
311 | void updateTodoViews(); | 311 | void updateTodoViews(); |
312 | 312 | ||
313 | void updateUnmanagedViews(); | 313 | void updateUnmanagedViews(); |
314 | 314 | ||
315 | /** cut the current appointment to the clipboard */ | 315 | /** cut the current appointment to the clipboard */ |
316 | void edit_cut(); | 316 | void edit_cut(); |
317 | 317 | ||
318 | /** copy the current appointment(s) to the clipboard */ | 318 | /** copy the current appointment(s) to the clipboard */ |
319 | void edit_copy(); | 319 | void edit_copy(); |
320 | 320 | ||
321 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 321 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
322 | void edit_paste(); | 322 | void edit_paste(); |
323 | 323 | ||
324 | /** edit viewing and configuration options. */ | 324 | /** edit viewing and configuration options. */ |
325 | void edit_options(); | 325 | void edit_options(); |
326 | /** | 326 | /** |
327 | Functions for printing, previewing a print, and setting up printing | 327 | Functions for printing, previewing a print, and setting up printing |
328 | parameters. | 328 | parameters. |
329 | */ | 329 | */ |
330 | void print(); | 330 | void print(); |
331 | void printSetup(); | 331 | void printSetup(); |
332 | void printPreview(); | 332 | void printPreview(); |
333 | 333 | ||
334 | /** Export as iCalendar file */ | 334 | /** Export as iCalendar file */ |
335 | void exportICalendar(); | 335 | void exportICalendar(); |
336 | 336 | ||
337 | /** Export as vCalendar file */ | 337 | /** Export as vCalendar file */ |
338 | bool exportVCalendar( QString fn); | 338 | bool exportVCalendar( QString fn); |
339 | 339 | ||
340 | /** pop up a dialog to show an existing appointment. */ | 340 | /** pop up a dialog to show an existing appointment. */ |
341 | void appointment_show(); | 341 | void appointment_show(); |
342 | /** | 342 | /** |
343 | * pop up an Appointment Dialog to edit an existing appointment.Get | 343 | * pop up an Appointment Dialog to edit an existing appointment.Get |
344 | * information on the appointment from the list of unique IDs that is | 344 | * information on the appointment from the list of unique IDs that is |
345 | * currently in the View, called currIds. | 345 | * currently in the View, called currIds. |
346 | */ | 346 | */ |
347 | void appointment_edit(); | 347 | void appointment_edit(); |
348 | /** | 348 | /** |
349 | * pop up dialog confirming deletion of currently selected event in the | 349 | * pop up dialog confirming deletion of currently selected event in the |
350 | * View. | 350 | * View. |
351 | */ | 351 | */ |
352 | void appointment_delete(); | 352 | void appointment_delete(); |
353 | 353 | ||
354 | /** mails the currently selected event to a particular user as a vCalendar | 354 | /** mails the currently selected event to a particular user as a vCalendar |
355 | attachment. */ | 355 | attachment. */ |
356 | void action_mail(); | 356 | void action_mail(); |
357 | 357 | ||
358 | /* frees a subtodo from it's relation */ | 358 | /* frees a subtodo from it's relation */ |
359 | void todo_unsub( Todo * ); | 359 | void todo_unsub( Todo * ); |
360 | void todo_resub( Todo * parent, Todo * sub ); | 360 | void todo_resub( Todo * parent, Todo * sub ); |
361 | 361 | ||
362 | /** Take ownership of selected event. */ | 362 | /** Take ownership of selected event. */ |
363 | void takeOverEvent(); | 363 | void takeOverEvent(); |
364 | 364 | ||
365 | /** Take ownership of all events in calendar. */ | 365 | /** Take ownership of all events in calendar. */ |
366 | void takeOverCalendar(); | 366 | void takeOverCalendar(); |
367 | 367 | ||
368 | /** query whether or not the calendar is "dirty". */ | 368 | /** query whether or not the calendar is "dirty". */ |
369 | bool isModified(); | 369 | bool isModified(); |
370 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 370 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
371 | void setModified(bool modified=true); | 371 | void setModified(bool modified=true); |
372 | 372 | ||
373 | /** query if the calendar is read-only. */ | 373 | /** query if the calendar is read-only. */ |
374 | bool isReadOnly(); | 374 | bool isReadOnly(); |
375 | /** set state of calendar to read-only */ | 375 | /** set state of calendar to read-only */ |
376 | void setReadOnly(bool readOnly=true); | 376 | void setReadOnly(bool readOnly=true); |
377 | 377 | ||
378 | void eventUpdated(Incidence *); | 378 | void eventUpdated(Incidence *); |
379 | 379 | ||
380 | /* iTIP scheduling actions */ | 380 | /* iTIP scheduling actions */ |
381 | void schedule_publish(Incidence *incidence = 0); | 381 | void schedule_publish(Incidence *incidence = 0); |
382 | void schedule_request(Incidence *incidence = 0); | 382 | void schedule_request(Incidence *incidence = 0); |
383 | void schedule_refresh(Incidence *incidence = 0); | 383 | void schedule_refresh(Incidence *incidence = 0); |
384 | void schedule_cancel(Incidence *incidence = 0); | 384 | void schedule_cancel(Incidence *incidence = 0); |
385 | void schedule_add(Incidence *incidence = 0); | 385 | void schedule_add(Incidence *incidence = 0); |
386 | void schedule_reply(Incidence *incidence = 0); | 386 | void schedule_reply(Incidence *incidence = 0); |
387 | void schedule_counter(Incidence *incidence = 0); | 387 | void schedule_counter(Incidence *incidence = 0); |
388 | void schedule_declinecounter(Incidence *incidence = 0); | 388 | void schedule_declinecounter(Incidence *incidence = 0); |
389 | void schedule_publish_freebusy(int daysToPublish = 30); | 389 | void schedule_publish_freebusy(int daysToPublish = 30); |
390 | 390 | ||
391 | void openAddressbook(); | 391 | void openAddressbook(); |
392 | 392 | ||
393 | void editFilters(); | 393 | void editFilters(); |
394 | void toggleFilerEnabled(); | 394 | void toggleFilerEnabled(); |
395 | QPtrList<CalFilter> filters(); | 395 | QPtrList<CalFilter> filters(); |
396 | void toggleFilter(); | 396 | void toggleFilter(); |
397 | void showFilter(bool visible); | 397 | void showFilter(bool visible); |
398 | void updateFilter(); | 398 | void updateFilter(); |
399 | void filterEdited(); | 399 | void filterEdited(); |
400 | void selectFilter( int ); | 400 | void selectFilter( int ); |
401 | KOFilterView *filterView(); | 401 | KOFilterView *filterView(); |
402 | 402 | ||
403 | void showIntro(); | 403 | void showIntro(); |
404 | 404 | ||
405 | /** Move the curdatepient view date to today */ | 405 | /** Move the curdatepient view date to today */ |
406 | void goToday(); | 406 | void goToday(); |
407 | 407 | ||
408 | /** Move to the next date(s) in the current view */ | 408 | /** Move to the next date(s) in the current view */ |
409 | void goNext(); | 409 | void goNext(); |
410 | 410 | ||
411 | /** Move to the previous date(s) in the current view */ | 411 | /** Move to the previous date(s) in the current view */ |
412 | void goPrevious(); | 412 | void goPrevious(); |
413 | /** Move to the next date(s) in the current view */ | 413 | /** Move to the next date(s) in the current view */ |
414 | void goNextMonth(); | 414 | void goNextMonth(); |
415 | 415 | ||
416 | /** Move to the previous date(s) in the current view */ | 416 | /** Move to the previous date(s) in the current view */ |
417 | void goPreviousMonth(); | 417 | void goPreviousMonth(); |
418 | 418 | ||
419 | void toggleExpand(); | 419 | void toggleExpand(); |
420 | void toggleDateNavigatorWidget(); | 420 | void toggleDateNavigatorWidget(); |
421 | void toggleAllDaySize(); | 421 | void toggleAllDaySize(); |
422 | void dialogClosing(Incidence *); | 422 | void dialogClosing(Incidence *); |
423 | 423 | ||
424 | /** Look for new messages in the inbox */ | 424 | /** Look for new messages in the inbox */ |
425 | void lookForIncomingMessages(); | 425 | void lookForIncomingMessages(); |
426 | /** Look for new messages in the outbox */ | 426 | /** Look for new messages in the outbox */ |
427 | void lookForOutgoingMessages(); | 427 | void lookForOutgoingMessages(); |
428 | 428 | ||
429 | void processMainViewSelection( Incidence * ); | 429 | void processMainViewSelection( Incidence * ); |
430 | void processTodoListSelection( Incidence * ); | 430 | void processTodoListSelection( Incidence * ); |
431 | 431 | ||
432 | void processIncidenceSelection( Incidence * ); | 432 | void processIncidenceSelection( Incidence * ); |
433 | 433 | ||
434 | void purgeCompleted(); | 434 | void purgeCompleted(); |
435 | bool removeCompletedSubTodos( Todo* ); | 435 | bool removeCompletedSubTodos( Todo* ); |
436 | void slotCalendarChanged(); | 436 | void slotCalendarChanged(); |
437 | bool importBday(); | 437 | bool importBday(); |
438 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 438 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
439 | bool importQtopia( const QString &categoriesFile, | 439 | bool importQtopia( const QString &categoriesFile, |
440 | const QString &datebookFile, | 440 | const QString &datebookFile, |
441 | const QString &tasklistFile ); | 441 | const QString &tasklistFile ); |
442 | void syncExternal( int mode ); | 442 | void syncExternal( int mode ); |
443 | void slotSelectPickerDate( QDate ) ; | 443 | void slotSelectPickerDate( QDate ) ; |
444 | void showDatePicker( ) ; | 444 | void showDatePicker() ; |
445 | void showDatePickerPopup() ; | ||
445 | void moveIncidence(Incidence *) ; | 446 | void moveIncidence(Incidence *) ; |
446 | void beamIncidence(Incidence *) ; | 447 | void beamIncidence(Incidence *) ; |
447 | void beamCalendar() ; | 448 | void beamCalendar() ; |
448 | void beamFilteredCalendar() ; | 449 | void beamFilteredCalendar() ; |
449 | void beamIncidenceList(QPtrList<Incidence>) ; | 450 | void beamIncidenceList(QPtrList<Incidence>) ; |
450 | void manageCategories(); | 451 | void manageCategories(); |
451 | int addCategories(); | 452 | int addCategories(); |
452 | void removeCategories(); | 453 | void removeCategories(); |
453 | void setSyncDevice( QString ); | 454 | void setSyncDevice( QString ); |
454 | void setSyncName( QString ); | 455 | void setSyncName( QString ); |
455 | void showDay( QDate ); | 456 | void showDay( QDate ); |
456 | void undo_delete(); | 457 | void undo_delete(); |
457 | protected slots: | 458 | protected slots: |
458 | void timerAlarm(); | 459 | void timerAlarm(); |
459 | void suspendAlarm(); | 460 | void suspendAlarm(); |
460 | void beamDone( Ir *ir ); | 461 | void beamDone( Ir *ir ); |
461 | /** Select a view or adapt the current view to display the specified dates. */ | 462 | /** Select a view or adapt the current view to display the specified dates. */ |
462 | void showDates( const KCal::DateList & ); | 463 | void showDates( const KCal::DateList & ); |
463 | void selectWeekNum ( int ); | 464 | void selectWeekNum ( int ); |
464 | 465 | ||
465 | public: | 466 | public: |
466 | // show a standard warning | 467 | // show a standard warning |
467 | // returns KMsgBox::yesNoCancel() | 468 | // returns KMsgBox::yesNoCancel() |
468 | int msgCalModified(); | 469 | int msgCalModified(); |
469 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 470 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
470 | 471 | ||
471 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 472 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
472 | virtual void removeSyncInfo( QString syncProfile); | 473 | virtual void removeSyncInfo( QString syncProfile); |
473 | void setSyncManager(KSyncManager* manager); | 474 | void setSyncManager(KSyncManager* manager); |
474 | void setLoadedFileVersion(QDateTime); | 475 | void setLoadedFileVersion(QDateTime); |
475 | bool checkFileVersion(QString fn); | 476 | bool checkFileVersion(QString fn); |
476 | bool checkFileChanged(QString fn); | 477 | bool checkFileChanged(QString fn); |
477 | Event* getLastSyncEvent(); | 478 | Event* getLastSyncEvent(); |
478 | /** Adapt navigation units correpsonding to step size of navigation of the | 479 | /** Adapt navigation units correpsonding to step size of navigation of the |
479 | * current view. | 480 | * current view. |
480 | */ | 481 | */ |
481 | void adaptNavigationUnits(); | 482 | void adaptNavigationUnits(); |
482 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 483 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
483 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 484 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
484 | //Attendee* getYourAttendee(Event *event); | 485 | //Attendee* getYourAttendee(Event *event); |
485 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} | 486 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} |
486 | protected: | 487 | protected: |
487 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 488 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
488 | 489 | ||
489 | // returns KMsgBox::OKCandel() | 490 | // returns KMsgBox::OKCandel() |
490 | int msgItemDelete(const QString name); | 491 | int msgItemDelete(const QString name); |
491 | void showEventEditor(); | 492 | void showEventEditor(); |
492 | void showTodoEditor(); | 493 | void showTodoEditor(); |
493 | void writeLocale(); | 494 | void writeLocale(); |
494 | Todo *selectedTodo(); | 495 | Todo *selectedTodo(); |
495 | 496 | ||
496 | private: | 497 | private: |
497 | bool mBlockShowDates; | 498 | bool mBlockShowDates; |
498 | KSyncManager* mSyncManager; | 499 | KSyncManager* mSyncManager; |
499 | AlarmDialog * mAlarmDialog; | 500 | AlarmDialog * mAlarmDialog; |
500 | QString mAlarmNotification; | 501 | QString mAlarmNotification; |
501 | QString mSuspendAlarmNotification; | 502 | QString mSuspendAlarmNotification; |
502 | QTimer* mSuspendTimer; | 503 | QTimer* mSuspendTimer; |
503 | QTimer* mAlarmTimer; | 504 | QTimer* mAlarmTimer; |
504 | QTimer* mRecheckAlarmTimer; | 505 | QTimer* mRecheckAlarmTimer; |
505 | void computeAlarm( QString ); | 506 | void computeAlarm( QString ); |
506 | void startAlarm( QString, QString ); | 507 | void startAlarm( QString, QString ); |
507 | void setSyncEventsReadOnly(); | 508 | void setSyncEventsReadOnly(); |
508 | 509 | ||
509 | QDateTime loadedFileVersion; | 510 | QDateTime loadedFileVersion; |
510 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 511 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
511 | void checkExternalId( Incidence * inc ); | 512 | void checkExternalId( Incidence * inc ); |
512 | int mGlobalSyncMode; | 513 | int mGlobalSyncMode; |
513 | QString mCurrentSyncDevice; | 514 | QString mCurrentSyncDevice; |
514 | QString mCurrentSyncName; | 515 | QString mCurrentSyncName; |
515 | KOBeamPrefs* beamDialog; | 516 | KOBeamPrefs* beamDialog; |
516 | void init(); | 517 | void init(); |
517 | int mDatePickerMode; | 518 | int mDatePickerMode; |
518 | bool mFlagEditDescription; | 519 | bool mFlagEditDescription; |
519 | QDateTime mLastCalendarSync; | 520 | QDateTime mLastCalendarSync; |
520 | void createPrinter(); | 521 | void createPrinter(); |
521 | 522 | ||
522 | void calendarModified( bool, Calendar * ); | 523 | void calendarModified( bool, Calendar * ); |
523 | 524 | ||
524 | CalPrinter *mCalPrinter; | 525 | CalPrinter *mCalPrinter; |
525 | 526 | ||
526 | QSplitter *mPanner; | 527 | QSplitter *mPanner; |
527 | QSplitter *mLeftSplitter; | 528 | QSplitter *mLeftSplitter; |
528 | QWidget *mLeftFrame; | 529 | QWidget *mLeftFrame; |
529 | QWidgetStack *mRightFrame; | 530 | QWidgetStack *mRightFrame; |
530 | 531 | ||
531 | KDatePicker* mDatePicker; | 532 | KDatePicker* mDatePicker; |
532 | QVBox* mDateFrame; | 533 | QVBox* mDateFrame; |
533 | 534 | ||
534 | KDateNavigator *mDateNavigator; // widget showing small month view. | 535 | KDateNavigator *mDateNavigator; // widget showing small month view. |
535 | 536 | ||
536 | KOFilterView *mFilterView; | 537 | KOFilterView *mFilterView; |
537 | 538 | ||
538 | ResourceView *mResourceView; | 539 | ResourceView *mResourceView; |
539 | 540 | ||
540 | // calendar object for this viewing instance | 541 | // calendar object for this viewing instance |
541 | Calendar *mCalendar; | 542 | Calendar *mCalendar; |
542 | 543 | ||
543 | CalendarResourceManager *mResourceManager; | 544 | CalendarResourceManager *mResourceManager; |
544 | 545 | ||
545 | FileStorage *mStorage; | 546 | FileStorage *mStorage; |
546 | 547 | ||
547 | DateNavigator *mNavigator; | 548 | DateNavigator *mNavigator; |
548 | 549 | ||
549 | KOViewManager *mViewManager; | 550 | KOViewManager *mViewManager; |
550 | KODialogManager *mDialogManager; | 551 | KODialogManager *mDialogManager; |
551 | 552 | ||
552 | // Calendar filters | 553 | // Calendar filters |
553 | QPtrList<CalFilter> mFilters; | 554 | QPtrList<CalFilter> mFilters; |
554 | 555 | ||
555 | // various housekeeping variables. | 556 | // various housekeeping variables. |
556 | bool mModified; // flag indicating if calendar is modified | 557 | bool mModified; // flag indicating if calendar is modified |
557 | bool mReadOnly; // flag indicating if calendar is read-only | 558 | bool mReadOnly; // flag indicating if calendar is read-only |
558 | QDate mSaveSingleDate; | 559 | QDate mSaveSingleDate; |
559 | 560 | ||
560 | Incidence *mSelectedIncidence; | 561 | Incidence *mSelectedIncidence; |
561 | Incidence *mMoveIncidence; | 562 | Incidence *mMoveIncidence; |
562 | QDate mMoveIncidenceOldDate; | 563 | QDate mMoveIncidenceOldDate; |
563 | KOTodoView *mTodoList; | 564 | KOTodoView *mTodoList; |
564 | KOEventEditor * mEventEditor; | 565 | KOEventEditor * mEventEditor; |
565 | KOTodoEditor * mTodoEditor; | 566 | KOTodoEditor * mTodoEditor; |
566 | KOEventViewerDialog * mEventViewerDialog; | 567 | KOEventViewerDialog * mEventViewerDialog; |
567 | void keyPressEvent ( QKeyEvent *e) ; | 568 | void keyPressEvent ( QKeyEvent *e) ; |
568 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 569 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
569 | }; | 570 | }; |
570 | 571 | ||
571 | 572 | ||
572 | class CalendarViewVisitor : public Incidence::Visitor | 573 | class CalendarViewVisitor : public Incidence::Visitor |
573 | { | 574 | { |
574 | public: | 575 | public: |
575 | CalendarViewVisitor() : mView( 0 ) {} | 576 | CalendarViewVisitor() : mView( 0 ) {} |
576 | 577 | ||
577 | bool act( Incidence *incidence, CalendarView *view ) | 578 | bool act( Incidence *incidence, CalendarView *view ) |
578 | { | 579 | { |
579 | mView = view; | 580 | mView = view; |
580 | return incidence->accept( *this ); | 581 | return incidence->accept( *this ); |
581 | } | 582 | } |
582 | 583 | ||
583 | protected: | 584 | protected: |
584 | CalendarView *mView; | 585 | CalendarView *mView; |
585 | }; | 586 | }; |
586 | 587 | ||
587 | class ShowIncidenceVisitor : public CalendarViewVisitor | 588 | class ShowIncidenceVisitor : public CalendarViewVisitor |
588 | { | 589 | { |
589 | protected: | 590 | protected: |
590 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 591 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
591 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 592 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
592 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 593 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
593 | }; | 594 | }; |
594 | 595 | ||
595 | class EditIncidenceVisitor : public CalendarViewVisitor | 596 | class EditIncidenceVisitor : public CalendarViewVisitor |
596 | { | 597 | { |
597 | protected: | 598 | protected: |
598 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 599 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
599 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 600 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
600 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 601 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
601 | }; | 602 | }; |
602 | 603 | ||
603 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 604 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
604 | { | 605 | { |
605 | protected: | 606 | protected: |
606 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 607 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
607 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 608 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
608 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 609 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
609 | }; | 610 | }; |
610 | 611 | ||
611 | #endif | 612 | #endif |
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 6ae4c6f..02d2585 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -160,1441 +160,1444 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | |||
160 | void KNoScrollListBox::oneDown() | 160 | void KNoScrollListBox::oneDown() |
161 | { | 161 | { |
162 | setCurrentItem((currentItem()+1)%count()); | 162 | setCurrentItem((currentItem()+1)%count()); |
163 | if(!itemVisible(currentItem())) { | 163 | if(!itemVisible(currentItem())) { |
164 | if(currentItem() == 0) { | 164 | if(currentItem() == 0) { |
165 | setTopItem(0); | 165 | setTopItem(0); |
166 | } else { | 166 | } else { |
167 | setTopItem(topItem()+1); | 167 | setTopItem(topItem()+1); |
168 | } | 168 | } |
169 | } | 169 | } |
170 | } | 170 | } |
171 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 171 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
172 | { | 172 | { |
173 | switch(e->key()) { | 173 | switch(e->key()) { |
174 | case Key_Shift: | 174 | case Key_Shift: |
175 | emit shiftUp(); | 175 | emit shiftUp(); |
176 | break; | 176 | break; |
177 | default: | 177 | default: |
178 | break; | 178 | break; |
179 | } | 179 | } |
180 | } | 180 | } |
181 | 181 | ||
182 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 182 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
183 | { | 183 | { |
184 | QListBox::mousePressEvent(e); | 184 | QListBox::mousePressEvent(e); |
185 | 185 | ||
186 | if(e->button() == RightButton) { | 186 | if(e->button() == RightButton) { |
187 | emit rightClick(); | 187 | emit rightClick(); |
188 | } | 188 | } |
189 | } | 189 | } |
190 | 190 | ||
191 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 191 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
192 | : QListBoxItem() | 192 | : QListBoxItem() |
193 | { | 193 | { |
194 | setText( s ); | 194 | setText( s ); |
195 | 195 | ||
196 | mIncidence = incidence; | 196 | mIncidence = incidence; |
197 | mDate = qd; | 197 | mDate = qd; |
198 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); | 198 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); |
199 | mRecur = false; | 199 | mRecur = false; |
200 | mAlarm = false; | 200 | mAlarm = false; |
201 | mReply = false; | 201 | mReply = false; |
202 | mInfo = false; | 202 | mInfo = false; |
203 | } | 203 | } |
204 | 204 | ||
205 | void MonthViewItem::paint(QPainter *p) | 205 | void MonthViewItem::paint(QPainter *p) |
206 | { | 206 | { |
207 | #if QT_VERSION >= 0x030000 | 207 | #if QT_VERSION >= 0x030000 |
208 | bool sel = isSelected(); | 208 | bool sel = isSelected(); |
209 | #else | 209 | #else |
210 | bool sel = selected(); | 210 | bool sel = selected(); |
211 | #endif | 211 | #endif |
212 | 212 | ||
213 | 213 | ||
214 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 214 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
215 | { | 215 | { |
216 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 216 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
217 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 217 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
218 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 218 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
219 | } | 219 | } |
220 | int x = 1; | 220 | int x = 1; |
221 | int y = 3;//(height() - mRecurPixmap.height()) /2; | 221 | int y = 3;//(height() - mRecurPixmap.height()) /2; |
222 | int size = PIXMAP_SIZE; | 222 | int size = PIXMAP_SIZE; |
223 | if ( QApplication::desktop()->width() < 300 ) | 223 | if ( QApplication::desktop()->width() < 300 ) |
224 | size = 3; | 224 | size = 3; |
225 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 225 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
226 | if ( mInfo ) { | 226 | if ( mInfo ) { |
227 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 227 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
228 | x += size + 1; | 228 | x += size + 1; |
229 | } | 229 | } |
230 | if ( mRecur ) { | 230 | if ( mRecur ) { |
231 | p->fillRect ( x, y,size,size, Qt::blue ); | 231 | p->fillRect ( x, y,size,size, Qt::blue ); |
232 | x += size + 1; | 232 | x += size + 1; |
233 | } | 233 | } |
234 | if ( mAlarm ) { | 234 | if ( mAlarm ) { |
235 | p->fillRect ( x, y,size,size, Qt::red ); | 235 | p->fillRect ( x, y,size,size, Qt::red ); |
236 | x += size + 1; | 236 | x += size + 1; |
237 | } | 237 | } |
238 | if ( mReply ) { | 238 | if ( mReply ) { |
239 | p->fillRect ( x, y,size,size, Qt::yellow ); | 239 | p->fillRect ( x, y,size,size, Qt::yellow ); |
240 | x += size + 1; | 240 | x += size + 1; |
241 | } | 241 | } |
242 | } | 242 | } |
243 | QFontMetrics fm = p->fontMetrics(); | 243 | QFontMetrics fm = p->fontMetrics(); |
244 | int yPos; | 244 | int yPos; |
245 | int pmheight = size; | 245 | int pmheight = size; |
246 | if( pmheight < fm.height() ) | 246 | if( pmheight < fm.height() ) |
247 | yPos = fm.ascent() + fm.leading()/2; | 247 | yPos = fm.ascent() + fm.leading()/2; |
248 | else | 248 | else |
249 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 249 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
250 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 250 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
251 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 251 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
252 | p->drawText( x, yPos, text() ); | 252 | p->drawText( x, yPos, text() ); |
253 | if ( mIncidence->cancelled() ) { | 253 | if ( mIncidence->cancelled() ) { |
254 | int wid = fm.width( text() ); | 254 | int wid = fm.width( text() ); |
255 | p->drawLine( x, yPos- fm.height()/2+3,x+wid, yPos- fm.height()/2 +3); | 255 | p->drawLine( x, yPos- fm.height()/2+3,x+wid, yPos- fm.height()/2 +3); |
256 | } | 256 | } |
257 | 257 | ||
258 | } | 258 | } |
259 | 259 | ||
260 | int MonthViewItem::height(const QListBox *lb) const | 260 | int MonthViewItem::height(const QListBox *lb) const |
261 | { | 261 | { |
262 | return lb->fontMetrics().lineSpacing()+1; | 262 | return lb->fontMetrics().lineSpacing()+1; |
263 | } | 263 | } |
264 | 264 | ||
265 | int MonthViewItem::width(const QListBox *lb) const | 265 | int MonthViewItem::width(const QListBox *lb) const |
266 | { | 266 | { |
267 | int size = PIXMAP_SIZE; | 267 | int size = PIXMAP_SIZE; |
268 | if ( QApplication::desktop()->width() < 300 ) | 268 | if ( QApplication::desktop()->width() < 300 ) |
269 | size = 3; | 269 | size = 3; |
270 | int x = 1; | 270 | int x = 1; |
271 | if ( mInfo ) { | 271 | if ( mInfo ) { |
272 | x += size + 1; | 272 | x += size + 1; |
273 | } | 273 | } |
274 | if( mRecur ) { | 274 | if( mRecur ) { |
275 | x += size+1; | 275 | x += size+1; |
276 | } | 276 | } |
277 | if( mAlarm ) { | 277 | if( mAlarm ) { |
278 | x += size+1; | 278 | x += size+1; |
279 | } | 279 | } |
280 | if( mReply ) { | 280 | if( mReply ) { |
281 | x += size+1; | 281 | x += size+1; |
282 | } | 282 | } |
283 | 283 | ||
284 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 284 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
285 | } | 285 | } |
286 | 286 | ||
287 | 287 | ||
288 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 288 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
289 | : QWidget( par ), | 289 | : QWidget( par ), |
290 | mMonthView( parent ) | 290 | mMonthView( parent ) |
291 | { | 291 | { |
292 | 292 | ||
293 | QVBoxLayout *topLayout = new QVBoxLayout( this ); | 293 | QVBoxLayout *topLayout = new QVBoxLayout( this ); |
294 | 294 | ||
295 | // mLabel = new QLabel( this );QPushButton | 295 | // mLabel = new QLabel( this );QPushButton |
296 | mLabel = new QPushButton( this ); | 296 | mLabel = new QPushButton( this ); |
297 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 297 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
298 | //mLabel->setLineWidth( 1 ); | 298 | //mLabel->setLineWidth( 1 ); |
299 | //mLabel->setAlignment( AlignCenter ); | 299 | //mLabel->setAlignment( AlignCenter ); |
300 | mLabel->setFlat( true ); | 300 | mLabel->setFlat( true ); |
301 | mLabel->setFocusPolicy(NoFocus); | 301 | mLabel->setFocusPolicy(NoFocus); |
302 | mItemList = new KNoScrollListBox( this ); | 302 | mItemList = new KNoScrollListBox( this ); |
303 | mItemList->setMinimumSize( 10, 10 ); | 303 | mItemList->setMinimumSize( 10, 10 ); |
304 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 304 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
305 | mItemList->setLineWidth( 1 ); | 305 | mItemList->setLineWidth( 1 ); |
306 | topLayout->addWidget( mItemList ); | 306 | topLayout->addWidget( mItemList ); |
307 | mLabel->raise(); | 307 | mLabel->raise(); |
308 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 308 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
309 | mStandardPalette = palette(); | 309 | mStandardPalette = palette(); |
310 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 310 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
311 | 311 | ||
312 | enableScrollBars( false ); | 312 | enableScrollBars( false ); |
313 | updateConfig(); | 313 | updateConfig(); |
314 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 314 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
315 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 315 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
316 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), | 316 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), |
317 | SLOT( defaultAction( QListBoxItem * ) ) ); | 317 | SLOT( defaultAction( QListBoxItem * ) ) ); |
318 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, | 318 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, |
319 | const QPoint &) ), | 319 | const QPoint &) ), |
320 | SLOT( contextMenu( QListBoxItem * ) ) ); | 320 | SLOT( contextMenu( QListBoxItem * ) ) ); |
321 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), | 321 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), |
322 | SLOT( selection( QListBoxItem * ) ) ); | 322 | SLOT( selection( QListBoxItem * ) ) ); |
323 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 323 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
324 | SLOT( cellClicked( QListBoxItem * ) ) ); | 324 | SLOT( cellClicked( QListBoxItem * ) ) ); |
325 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 325 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
326 | SLOT( selection( QListBoxItem * ) ) ); | 326 | SLOT( selection( QListBoxItem * ) ) ); |
327 | } | 327 | } |
328 | #ifdef DESKTOP_VERSION | 328 | #ifdef DESKTOP_VERSION |
329 | QToolTipGroup *MonthViewCell::toolTipGroup() | 329 | QToolTipGroup *MonthViewCell::toolTipGroup() |
330 | { | 330 | { |
331 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 331 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
332 | return mToolTipGroup; | 332 | return mToolTipGroup; |
333 | } | 333 | } |
334 | #endif | 334 | #endif |
335 | 335 | ||
336 | void MonthViewCell::setDate( const QDate &date ) | 336 | void MonthViewCell::setDate( const QDate &date ) |
337 | { | 337 | { |
338 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 338 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
339 | mDate = date; | 339 | mDate = date; |
340 | 340 | ||
341 | 341 | ||
342 | 342 | ||
343 | //resizeEvent( 0 ); | 343 | //resizeEvent( 0 ); |
344 | } | 344 | } |
345 | 345 | ||
346 | QDate MonthViewCell::date() const | 346 | QDate MonthViewCell::date() const |
347 | { | 347 | { |
348 | return mDate; | 348 | return mDate; |
349 | } | 349 | } |
350 | 350 | ||
351 | void MonthViewCell::setPrimary( bool primary ) | 351 | void MonthViewCell::setPrimary( bool primary ) |
352 | { | 352 | { |
353 | mPrimary = primary; | 353 | mPrimary = primary; |
354 | //setMyPalette(); | 354 | //setMyPalette(); |
355 | } | 355 | } |
356 | void MonthViewCell::setMyPalette() | 356 | void MonthViewCell::setMyPalette() |
357 | { | 357 | { |
358 | 358 | ||
359 | if ( mHoliday) { | 359 | if ( mHoliday) { |
360 | setPalette( mHolidayPalette ); | 360 | setPalette( mHolidayPalette ); |
361 | } else { | 361 | } else { |
362 | if ( mPrimary ) { | 362 | if ( mPrimary ) { |
363 | setPalette( mPrimaryPalette ); | 363 | setPalette( mPrimaryPalette ); |
364 | } else { | 364 | } else { |
365 | setPalette( mNonPrimaryPalette ); | 365 | setPalette( mNonPrimaryPalette ); |
366 | } | 366 | } |
367 | } | 367 | } |
368 | QPalette pal = palette(); | 368 | QPalette pal = palette(); |
369 | 369 | ||
370 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 370 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
371 | } | 371 | } |
372 | QPalette MonthViewCell::getPalette () | 372 | QPalette MonthViewCell::getPalette () |
373 | { | 373 | { |
374 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 374 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
375 | return mStandardPalette; | 375 | return mStandardPalette; |
376 | if ( mHoliday) { | 376 | if ( mHoliday) { |
377 | return mHolidayPalette ; | 377 | return mHolidayPalette ; |
378 | } else { | 378 | } else { |
379 | if ( mPrimary ) { | 379 | if ( mPrimary ) { |
380 | return mPrimaryPalette ; | 380 | return mPrimaryPalette ; |
381 | } | 381 | } |
382 | } | 382 | } |
383 | return mNonPrimaryPalette; | 383 | return mNonPrimaryPalette; |
384 | } | 384 | } |
385 | bool MonthViewCell::isPrimary() const | 385 | bool MonthViewCell::isPrimary() const |
386 | { | 386 | { |
387 | return mPrimary; | 387 | return mPrimary; |
388 | } | 388 | } |
389 | 389 | ||
390 | void MonthViewCell::setHoliday( bool holiday ) | 390 | void MonthViewCell::setHoliday( bool holiday ) |
391 | { | 391 | { |
392 | mHoliday = holiday; | 392 | mHoliday = holiday; |
393 | //setMyPalette(); | 393 | //setMyPalette(); |
394 | } | 394 | } |
395 | 395 | ||
396 | void MonthViewCell::setHoliday( const QString &holiday ) | 396 | void MonthViewCell::setHoliday( const QString &holiday ) |
397 | { | 397 | { |
398 | mHolidayString = holiday; | 398 | mHolidayString = holiday; |
399 | 399 | ||
400 | if ( !holiday.isEmpty() ) { | 400 | if ( !holiday.isEmpty() ) { |
401 | setHoliday( true ); | 401 | setHoliday( true ); |
402 | } | 402 | } |
403 | } | 403 | } |
404 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) | 404 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) |
405 | { | 405 | { |
406 | 406 | ||
407 | e->ignore(); | 407 | e->ignore(); |
408 | 408 | ||
409 | } | 409 | } |
410 | 410 | ||
411 | void MonthViewCell::startUpdateCell() | 411 | void MonthViewCell::startUpdateCell() |
412 | { | 412 | { |
413 | 413 | ||
414 | mItemList->setFocusPolicy(NoFocus); | 414 | mItemList->setFocusPolicy(NoFocus); |
415 | if ( !mMonthView->isUpdatePossible() ) | 415 | if ( !mMonthView->isUpdatePossible() ) |
416 | return; | 416 | return; |
417 | 417 | ||
418 | /* | 418 | /* |
419 | if ( !isVisible() ){ | 419 | if ( !isVisible() ){ |
420 | return; | 420 | return; |
421 | } | 421 | } |
422 | */ | 422 | */ |
423 | // qDebug("MonthViewCell::updateCell() "); | 423 | // qDebug("MonthViewCell::updateCell() "); |
424 | setPrimary( mDate.month()%2 ); | 424 | setPrimary( mDate.month()%2 ); |
425 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 425 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
426 | if ( mDate == QDate::currentDate() ) { | 426 | if ( mDate == QDate::currentDate() ) { |
427 | mItemList->setLineWidth( 3 ); | 427 | mItemList->setLineWidth( 3 ); |
428 | } else { | 428 | } else { |
429 | mItemList->setLineWidth( 1 ); | 429 | mItemList->setLineWidth( 1 ); |
430 | } | 430 | } |
431 | mItemList->clear(); | 431 | mItemList->clear(); |
432 | 432 | ||
433 | #ifdef DESKTOP_VERSION | 433 | #ifdef DESKTOP_VERSION |
434 | QToolTip::remove(this); | 434 | QToolTip::remove(this); |
435 | #endif | 435 | #endif |
436 | mToolTip = ""; | 436 | mToolTip = ""; |
437 | //qApp->processEvents(); | 437 | //qApp->processEvents(); |
438 | if ( !mHolidayString.isEmpty() ) { | 438 | if ( !mHolidayString.isEmpty() ) { |
439 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 439 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
440 | item->setPalette( mHolidayPalette ); | 440 | item->setPalette( mHolidayPalette ); |
441 | mItemList->insertItem( item ); | 441 | mItemList->insertItem( item ); |
442 | mToolTip += mHolidayString+"\n"; | 442 | mToolTip += mHolidayString+"\n"; |
443 | } | 443 | } |
444 | } | 444 | } |
445 | 445 | ||
446 | void MonthViewCell::insertEvent(Event *event) | 446 | void MonthViewCell::insertEvent(Event *event) |
447 | { | 447 | { |
448 | 448 | ||
449 | mItemList->setFocusPolicy(WheelFocus); | 449 | mItemList->setFocusPolicy(WheelFocus); |
450 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 450 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
451 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 451 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
452 | return; | 452 | return; |
453 | else | 453 | else |
454 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 454 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
455 | return; | 455 | return; |
456 | } | 456 | } |
457 | 457 | ||
458 | if ( event->categories().contains("Holiday") || | 458 | if ( event->categories().contains("Holiday") || |
459 | event->categories().contains(i18n("Holiday"))) { | 459 | event->categories().contains(i18n("Holiday"))) { |
460 | setHoliday( true ); | 460 | setHoliday( true ); |
461 | if ( mDate.dayOfWeek() == 7 ) | 461 | if ( mDate.dayOfWeek() == 7 ) |
462 | mItemList->setLineWidth( 3 ); | 462 | mItemList->setLineWidth( 3 ); |
463 | } | 463 | } |
464 | QString text; | 464 | QString text; |
465 | if (event->isMultiDay()) { | 465 | if (event->isMultiDay()) { |
466 | QString prefix = "<->"; | 466 | QString prefix = "<->"; |
467 | if ( event->doesRecur() ) { | 467 | if ( event->doesRecur() ) { |
468 | if ( event->recursOn( mDate) ) | 468 | if ( event->recursOn( mDate) ) |
469 | prefix ="->" ; | 469 | prefix ="->" ; |
470 | else { | 470 | else { |
471 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 471 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
472 | if ( event->recursOn( mDate.addDays( -days)) ) | 472 | if ( event->recursOn( mDate.addDays( -days)) ) |
473 | prefix ="<-" ; | 473 | prefix ="<-" ; |
474 | } | 474 | } |
475 | 475 | ||
476 | } else { | 476 | } else { |
477 | if (mDate == event->dtStart().date()) { | 477 | if (mDate == event->dtStart().date()) { |
478 | prefix ="->" ; | 478 | prefix ="->" ; |
479 | } else if (mDate == event->dtEnd().date()) { | 479 | } else if (mDate == event->dtEnd().date()) { |
480 | prefix ="<-" ; | 480 | prefix ="<-" ; |
481 | } | 481 | } |
482 | } | 482 | } |
483 | if ( !event->doesFloat() ) { | 483 | if ( !event->doesFloat() ) { |
484 | if ( mDate == event->dtStart().date () ) | 484 | if ( mDate == event->dtStart().date () ) |
485 | prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 485 | prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
486 | else if ( mDate == event->dtEnd().date () ) | 486 | else if ( mDate == event->dtEnd().date () ) |
487 | prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 487 | prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
488 | 488 | ||
489 | } | 489 | } |
490 | text = prefix + event->summary(); | 490 | text = prefix + event->summary(); |
491 | mToolTip += text; | 491 | mToolTip += text; |
492 | } else { | 492 | } else { |
493 | if (event->doesFloat()) { | 493 | if (event->doesFloat()) { |
494 | text = event->summary(); | 494 | text = event->summary(); |
495 | mToolTip += text; | 495 | mToolTip += text; |
496 | } | 496 | } |
497 | else { | 497 | else { |
498 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 498 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
499 | text += " " + event->summary(); | 499 | text += " " + event->summary(); |
500 | mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 500 | mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
501 | } | 501 | } |
502 | } | 502 | } |
503 | 503 | ||
504 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); | 504 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); |
505 | QPalette pal; | 505 | QPalette pal; |
506 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 506 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
507 | QStringList categories = event->categories(); | 507 | QStringList categories = event->categories(); |
508 | QString cat = categories.first(); | 508 | QString cat = categories.first(); |
509 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 509 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
510 | pal = getPalette(); | 510 | pal = getPalette(); |
511 | if (cat.isEmpty()) { | 511 | if (cat.isEmpty()) { |
512 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 512 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
513 | } else { | 513 | } else { |
514 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 514 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
515 | } | 515 | } |
516 | 516 | ||
517 | } else { | 517 | } else { |
518 | if (cat.isEmpty()) { | 518 | if (cat.isEmpty()) { |
519 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 519 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
520 | } else { | 520 | } else { |
521 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 521 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
522 | } | 522 | } |
523 | } | 523 | } |
524 | 524 | ||
525 | } else { | 525 | } else { |
526 | pal = mStandardPalette ; | 526 | pal = mStandardPalette ; |
527 | } | 527 | } |
528 | item->setPalette( pal ); | 528 | item->setPalette( pal ); |
529 | item->setRecur( event->recurrence()->doesRecur() ); | 529 | item->setRecur( event->recurrence()->doesRecur() ); |
530 | item->setAlarm( event->isAlarmEnabled() ); | 530 | item->setAlarm( event->isAlarmEnabled() ); |
531 | item->setMoreInfo( event->description().length() > 0 ); | 531 | item->setMoreInfo( event->description().length() > 0 ); |
532 | #ifdef DESKTOP_VERSION | 532 | #ifdef DESKTOP_VERSION |
533 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 533 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
534 | KOPrefs::instance()->email()); | 534 | KOPrefs::instance()->email()); |
535 | if ( me != 0 ) { | 535 | if ( me != 0 ) { |
536 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 536 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
537 | item->setReply(true); | 537 | item->setReply(true); |
538 | else | 538 | else |
539 | item->setReply(false); | 539 | item->setReply(false); |
540 | } else | 540 | } else |
541 | item->setReply(false); | 541 | item->setReply(false); |
542 | #endif | 542 | #endif |
543 | mItemList->insertItem( item ); | 543 | mItemList->insertItem( item ); |
544 | mToolTip += "\n"; | 544 | mToolTip += "\n"; |
545 | } | 545 | } |
546 | void MonthViewCell::insertTodo(Todo *todo) | 546 | void MonthViewCell::insertTodo(Todo *todo) |
547 | { | 547 | { |
548 | mItemList->setFocusPolicy(WheelFocus); | 548 | mItemList->setFocusPolicy(WheelFocus); |
549 | QString text; | 549 | QString text; |
550 | if (todo->hasDueDate()) { | 550 | if (todo->hasDueDate()) { |
551 | if (!todo->doesFloat()) { | 551 | if (!todo->doesFloat()) { |
552 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 552 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
553 | text += " "; | 553 | text += " "; |
554 | } | 554 | } |
555 | } | 555 | } |
556 | text += i18n("Td: %1").arg(todo->summary()); | 556 | text += i18n("Td: %1").arg(todo->summary()); |
557 | 557 | ||
558 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 558 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
559 | //item->setPalette( mStandardPalette ); | 559 | //item->setPalette( mStandardPalette ); |
560 | QPalette pal; | 560 | QPalette pal; |
561 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 561 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
562 | QStringList categories = todo->categories(); | 562 | QStringList categories = todo->categories(); |
563 | QString cat = categories.first(); | 563 | QString cat = categories.first(); |
564 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 564 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
565 | pal = getPalette(); | 565 | pal = getPalette(); |
566 | if (cat.isEmpty()) { | 566 | if (cat.isEmpty()) { |
567 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 567 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
568 | } else { | 568 | } else { |
569 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 569 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
570 | } | 570 | } |
571 | 571 | ||
572 | } else { | 572 | } else { |
573 | if (cat.isEmpty()) { | 573 | if (cat.isEmpty()) { |
574 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 574 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
575 | } else { | 575 | } else { |
576 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 576 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
577 | } | 577 | } |
578 | } | 578 | } |
579 | 579 | ||
580 | } else { | 580 | } else { |
581 | pal = mStandardPalette ; | 581 | pal = mStandardPalette ; |
582 | } | 582 | } |
583 | item->setPalette( pal ); | 583 | item->setPalette( pal ); |
584 | mItemList->insertItem( item ); | 584 | mItemList->insertItem( item ); |
585 | mToolTip += text+"\n"; | 585 | mToolTip += text+"\n"; |
586 | } | 586 | } |
587 | void MonthViewCell::finishUpdateCell() | 587 | void MonthViewCell::finishUpdateCell() |
588 | { | 588 | { |
589 | #ifdef DESKTOP_VERSION | 589 | #ifdef DESKTOP_VERSION |
590 | if (mToolTip != "") | 590 | if (mToolTip != "") |
591 | QToolTip::add(this,mToolTip,toolTipGroup(),""); | 591 | QToolTip::add(this,mToolTip,toolTipGroup(),""); |
592 | #endif | 592 | #endif |
593 | mItemList->sort(); | 593 | mItemList->sort(); |
594 | //setMyPalette(); | 594 | //setMyPalette(); |
595 | setMyPalette(); | 595 | setMyPalette(); |
596 | QString text; | 596 | QString text; |
597 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 597 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
598 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 598 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
599 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 599 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
600 | mLabel->resize( mLabelBigSize ); | 600 | mLabel->resize( mLabelBigSize ); |
601 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 601 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
602 | } else { | 602 | } else { |
603 | mLabel->resize( mLabelSize ); | 603 | mLabel->resize( mLabelSize ); |
604 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 604 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
605 | } | 605 | } |
606 | 606 | ||
607 | mLabel->setText( text ); | 607 | mLabel->setText( text ); |
608 | resizeEvent( 0 ); | 608 | resizeEvent( 0 ); |
609 | } | 609 | } |
610 | void MonthViewCell::updateCell() | 610 | void MonthViewCell::updateCell() |
611 | { | 611 | { |
612 | qDebug("MonthViewCell::updateCell() "); | 612 | qDebug("MonthViewCell::updateCell() "); |
613 | if ( !mMonthView->isUpdatePossible() ) | 613 | if ( !mMonthView->isUpdatePossible() ) |
614 | return; | 614 | return; |
615 | startUpdateCell(); | 615 | startUpdateCell(); |
616 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 616 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
617 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 617 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
618 | Event *event; | 618 | Event *event; |
619 | for( event = events.first(); event; event = events.next() ) { // for event | 619 | for( event = events.first(); event; event = events.next() ) { // for event |
620 | insertEvent(event); | 620 | insertEvent(event); |
621 | } | 621 | } |
622 | // insert due todos | 622 | // insert due todos |
623 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 623 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
624 | Todo *todo; | 624 | Todo *todo; |
625 | for(todo = todos.first(); todo; todo = todos.next()) { | 625 | for(todo = todos.first(); todo; todo = todos.next()) { |
626 | insertTodo( todo ); | 626 | insertTodo( todo ); |
627 | } | 627 | } |
628 | finishUpdateCell(); | 628 | finishUpdateCell(); |
629 | // if ( isVisible()) | 629 | // if ( isVisible()) |
630 | //qApp->processEvents(); | 630 | //qApp->processEvents(); |
631 | } | 631 | } |
632 | 632 | ||
633 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 633 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
634 | { | 634 | { |
635 | 635 | ||
636 | if ( bigFont ) { | 636 | if ( bigFont ) { |
637 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 637 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
638 | int ps = fo.pointSize() + 2; | 638 | int ps = fo.pointSize() + 2; |
639 | if ( ps < 18 ) | 639 | if ( ps < 18 ) |
640 | ps += 2; | 640 | ps += 2; |
641 | fo.setPointSize( ps ); | 641 | fo.setPointSize( ps ); |
642 | setFont( fo ); | 642 | setFont( fo ); |
643 | } else | 643 | } else |
644 | setFont( KOPrefs::instance()->mMonthViewFont ); | 644 | setFont( KOPrefs::instance()->mMonthViewFont ); |
645 | 645 | ||
646 | QFontMetrics fm( font() ); | 646 | QFontMetrics fm( font() ); |
647 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 647 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
648 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 648 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
649 | mHolidayPalette = mStandardPalette; | 649 | mHolidayPalette = mStandardPalette; |
650 | mPrimaryPalette = mStandardPalette; | 650 | mPrimaryPalette = mStandardPalette; |
651 | mNonPrimaryPalette = mStandardPalette; | 651 | mNonPrimaryPalette = mStandardPalette; |
652 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 652 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
653 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 653 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
654 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 654 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
655 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 655 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
656 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 656 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
657 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 657 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
658 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 658 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
659 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 659 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
660 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 660 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
661 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 661 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
662 | } | 662 | } |
663 | //updateCell(); | 663 | //updateCell(); |
664 | } | 664 | } |
665 | 665 | ||
666 | void MonthViewCell::enableScrollBars( bool enabled ) | 666 | void MonthViewCell::enableScrollBars( bool enabled ) |
667 | { | 667 | { |
668 | if ( enabled ) { | 668 | if ( enabled ) { |
669 | mItemList->setVScrollBarMode(QScrollView::Auto); | 669 | mItemList->setVScrollBarMode(QScrollView::Auto); |
670 | mItemList->setHScrollBarMode(QScrollView::Auto); | 670 | mItemList->setHScrollBarMode(QScrollView::Auto); |
671 | } else { | 671 | } else { |
672 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); | 672 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); |
673 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); | 673 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); |
674 | } | 674 | } |
675 | } | 675 | } |
676 | 676 | ||
677 | Incidence *MonthViewCell::selectedIncidence() | 677 | Incidence *MonthViewCell::selectedIncidence() |
678 | { | 678 | { |
679 | int index = mItemList->currentItem(); | 679 | int index = mItemList->currentItem(); |
680 | if ( index < 0 ) return 0; | 680 | if ( index < 0 ) return 0; |
681 | 681 | ||
682 | MonthViewItem *item = | 682 | MonthViewItem *item = |
683 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 683 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
684 | 684 | ||
685 | if ( !item ) return 0; | 685 | if ( !item ) return 0; |
686 | 686 | ||
687 | return item->incidence(); | 687 | return item->incidence(); |
688 | } | 688 | } |
689 | 689 | ||
690 | QDate MonthViewCell::selectedIncidenceDate() | 690 | QDate MonthViewCell::selectedIncidenceDate() |
691 | { | 691 | { |
692 | QDate qd; | 692 | QDate qd; |
693 | int index = mItemList->currentItem(); | 693 | int index = mItemList->currentItem(); |
694 | if ( index < 0 ) return qd; | 694 | if ( index < 0 ) return qd; |
695 | 695 | ||
696 | MonthViewItem *item = | 696 | MonthViewItem *item = |
697 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 697 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
698 | 698 | ||
699 | if ( !item ) return qd; | 699 | if ( !item ) return qd; |
700 | 700 | ||
701 | return item->incidenceDate(); | 701 | return item->incidenceDate(); |
702 | } | 702 | } |
703 | 703 | ||
704 | void MonthViewCell::deselect() | 704 | void MonthViewCell::deselect() |
705 | { | 705 | { |
706 | mItemList->clearSelection(); | 706 | mItemList->clearSelection(); |
707 | enableScrollBars( false ); | 707 | enableScrollBars( false ); |
708 | // updateCell(); | 708 | // updateCell(); |
709 | } | 709 | } |
710 | void MonthViewCell::select() | 710 | void MonthViewCell::select() |
711 | { | 711 | { |
712 | ;// updateCell(); | 712 | ;// updateCell(); |
713 | } | 713 | } |
714 | 714 | ||
715 | void MonthViewCell::resizeEvent ( QResizeEvent * ) | 715 | void MonthViewCell::resizeEvent ( QResizeEvent * ) |
716 | { | 716 | { |
717 | if ( !mMonthView->isUpdatePossible() ) | 717 | if ( !mMonthView->isUpdatePossible() ) |
718 | return; | 718 | return; |
719 | 719 | ||
720 | int size = height() - mLabel->height() - 2; | 720 | int size = height() - mLabel->height() - 2; |
721 | if ( size > 0 ) | 721 | if ( size > 0 ) |
722 | mItemList->verticalScrollBar()->setMaximumHeight( size ); | 722 | mItemList->verticalScrollBar()->setMaximumHeight( size ); |
723 | size = width() - mLabel->width() -2; | 723 | size = width() - mLabel->width() -2; |
724 | if ( size > 0 ) | 724 | if ( size > 0 ) |
725 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); | 725 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); |
726 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); | 726 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); |
727 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 727 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
728 | } | 728 | } |
729 | 729 | ||
730 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 730 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
731 | { | 731 | { |
732 | if ( !item ) return; | 732 | if ( !item ) return; |
733 | 733 | ||
734 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 734 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
735 | Incidence *incidence = eventItem->incidence(); | 735 | Incidence *incidence = eventItem->incidence(); |
736 | if ( incidence ) mMonthView->defaultAction( incidence ); | 736 | if ( incidence ) mMonthView->defaultAction( incidence ); |
737 | } | 737 | } |
738 | void MonthViewCell::showDay() | 738 | void MonthViewCell::showDay() |
739 | { | 739 | { |
740 | emit showDaySignal( date() ); | 740 | emit showDaySignal( date() ); |
741 | } | 741 | } |
742 | void MonthViewCell::newEvent() | 742 | void MonthViewCell::newEvent() |
743 | { | 743 | { |
744 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 744 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
745 | emit newEventSignal( dt ); | 745 | emit newEventSignal( dt ); |
746 | } | 746 | } |
747 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 747 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
748 | { | 748 | { |
749 | static QListBoxItem * lastClicked = 0; | 749 | static QListBoxItem * lastClicked = 0; |
750 | if ( item == 0 ) { | 750 | if ( item == 0 ) { |
751 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 751 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
752 | emit newEventSignal( dt ); | 752 | emit newEventSignal( dt ); |
753 | return; | 753 | return; |
754 | } | 754 | } |
755 | /* | 755 | /* |
756 | if ( lastClicked ) | 756 | if ( lastClicked ) |
757 | if ( ! item ) { | 757 | if ( ! item ) { |
758 | if ( lastClicked->listBox() != item->listBox() ) | 758 | if ( lastClicked->listBox() != item->listBox() ) |
759 | lastClicked->listBox()->clearSelection(); | 759 | lastClicked->listBox()->clearSelection(); |
760 | } | 760 | } |
761 | */ | 761 | */ |
762 | 762 | ||
763 | mMonthView->setSelectedCell( this ); | 763 | mMonthView->setSelectedCell( this ); |
764 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); | 764 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); |
765 | select(); | 765 | select(); |
766 | } | 766 | } |
767 | 767 | ||
768 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 768 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
769 | { | 769 | { |
770 | if ( !item ) return; | 770 | if ( !item ) return; |
771 | 771 | ||
772 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 772 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
773 | Incidence *incidence = eventItem->incidence(); | 773 | Incidence *incidence = eventItem->incidence(); |
774 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 774 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
775 | } | 775 | } |
776 | 776 | ||
777 | void MonthViewCell::selection( QListBoxItem *item ) | 777 | void MonthViewCell::selection( QListBoxItem *item ) |
778 | { | 778 | { |
779 | if ( !item ) return; | 779 | if ( !item ) return; |
780 | 780 | ||
781 | mMonthView->setSelectedCell( this ); | 781 | mMonthView->setSelectedCell( this ); |
782 | } | 782 | } |
783 | 783 | ||
784 | 784 | ||
785 | // ******************************************************************************* | 785 | // ******************************************************************************* |
786 | // ******************************************************************************* | 786 | // ******************************************************************************* |
787 | // ******************************************************************************* | 787 | // ******************************************************************************* |
788 | 788 | ||
789 | 789 | ||
790 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 790 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
791 | : KOEventView( calendar, parent, name ), | 791 | : KOEventView( calendar, parent, name ), |
792 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 792 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
793 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 793 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
794 | { | 794 | { |
795 | mShortDayLabelsM = false; | 795 | mShortDayLabelsM = false; |
796 | mShortDayLabelsW = false; | 796 | mShortDayLabelsW = false; |
797 | skipResize = false; | 797 | skipResize = false; |
798 | clPending = true; | 798 | clPending = true; |
799 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 799 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
800 | mWidStack = new QWidgetStack( this ); | 800 | mWidStack = new QWidgetStack( this ); |
801 | QVBoxLayout* hb = new QVBoxLayout( this ); | 801 | QVBoxLayout* hb = new QVBoxLayout( this ); |
802 | mMonthView = new QWidget( mWidStack ); | 802 | mMonthView = new QWidget( mWidStack ); |
803 | mWeekView = new QWidget( mWidStack ); | 803 | mWeekView = new QWidget( mWidStack ); |
804 | #if QT_VERSION >= 0x030000 | 804 | #if QT_VERSION >= 0x030000 |
805 | mWidStack->addWidget(mMonthView ); | 805 | mWidStack->addWidget(mMonthView ); |
806 | mWidStack->addWidget(mWeekView ); | 806 | mWidStack->addWidget(mWeekView ); |
807 | #else | 807 | #else |
808 | mWidStack->addWidget( mMonthView, 1 ); | 808 | mWidStack->addWidget( mMonthView, 1 ); |
809 | mWidStack->addWidget( mWeekView , 1 ); | 809 | mWidStack->addWidget( mWeekView , 1 ); |
810 | #endif | 810 | #endif |
811 | hb->addWidget( mNavigatorBar ); | 811 | hb->addWidget( mNavigatorBar ); |
812 | hb->addWidget( mWidStack ); | 812 | hb->addWidget( mWidStack ); |
813 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 813 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
814 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 814 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
815 | if ( mShowWeekView ) | 815 | if ( mShowWeekView ) |
816 | mWeekStartsMonday = true; | 816 | mWeekStartsMonday = true; |
817 | updatePossible = false; | 817 | updatePossible = false; |
818 | //updatePossible = true; | 818 | //updatePossible = true; |
819 | mCells.setAutoDelete( true ); | 819 | mCells.setAutoDelete( true ); |
820 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 820 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
821 | mDayLabels.resize( mDaysPerWeek ); | 821 | mDayLabels.resize( mDaysPerWeek ); |
822 | mDayLabelsW.resize( mDaysPerWeek ); | 822 | mDayLabelsW.resize( mDaysPerWeek ); |
823 | QFont bfont = font(); | 823 | QFont bfont = font(); |
824 | if ( QApplication::desktop()->width() < 650 ) { | 824 | if ( QApplication::desktop()->width() < 650 ) { |
825 | bfont.setPointSize( bfont.pointSize() - 2 ); | 825 | bfont.setPointSize( bfont.pointSize() - 2 ); |
826 | } | 826 | } |
827 | bfont.setBold( true ); | 827 | bfont.setBold( true ); |
828 | int i; | 828 | int i; |
829 | 829 | ||
830 | for( i = 0; i < mDaysPerWeek; i++ ) { | 830 | for( i = 0; i < mDaysPerWeek; i++ ) { |
831 | QLabel *label = new QLabel( mMonthView ); | 831 | QLabel *label = new QLabel( mMonthView ); |
832 | label->setFont(bfont); | 832 | label->setFont(bfont); |
833 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 833 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
834 | label->setLineWidth(1); | 834 | label->setLineWidth(1); |
835 | label->setAlignment(AlignCenter); | 835 | label->setAlignment(AlignCenter); |
836 | mDayLabels.insert( i, label ); | 836 | mDayLabels.insert( i, label ); |
837 | label = new QLabel( mWeekView ); | 837 | label = new QLabel( mWeekView ); |
838 | label->setFont(bfont); | 838 | label->setFont(bfont); |
839 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 839 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
840 | label->setLineWidth(1); | 840 | label->setLineWidth(1); |
841 | label->setAlignment(AlignCenter); | 841 | label->setAlignment(AlignCenter); |
842 | mDayLabelsW.insert( i, label ); | 842 | mDayLabelsW.insert( i, label ); |
843 | } | 843 | } |
844 | 844 | ||
845 | bfont.setBold( false ); | 845 | bfont.setBold( false ); |
846 | mWeekLabels.resize( mNumWeeks+1 ); | 846 | mWeekLabels.resize( mNumWeeks+1 ); |
847 | mWeekLabelsW.resize( 2 ); | 847 | mWeekLabelsW.resize( 2 ); |
848 | for( i = 0; i < mNumWeeks+1; i++ ) { | 848 | for( i = 0; i < mNumWeeks+1; i++ ) { |
849 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 849 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
850 | label->setFocusPolicy(NoFocus); | 850 | label->setFocusPolicy(NoFocus); |
851 | label->setFont(bfont); | 851 | label->setFont(bfont); |
852 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 852 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
853 | label->setFlat(true); | 853 | label->setFlat(true); |
854 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 854 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
855 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 855 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
856 | //label->setLineWidth(1); | 856 | //label->setLineWidth(1); |
857 | //label->setAlignment(AlignCenter); | 857 | //label->setAlignment(AlignCenter); |
858 | mWeekLabels.insert( i, label ); | 858 | mWeekLabels.insert( i, label ); |
859 | } | 859 | } |
860 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 860 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
861 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 861 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
862 | 862 | ||
863 | for( i = 0; i < 1+1; i++ ) { | 863 | for( i = 0; i < 1+1; i++ ) { |
864 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 864 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
865 | label->setFocusPolicy(NoFocus); | 865 | label->setFocusPolicy(NoFocus); |
866 | label->setFont(bfont); | 866 | label->setFont(bfont); |
867 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 867 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
868 | label->setFlat(true); | 868 | label->setFlat(true); |
869 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 869 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
870 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 870 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
871 | //label->setLineWidth(1); | 871 | //label->setLineWidth(1); |
872 | //label->setAlignment(AlignCenter); | 872 | //label->setAlignment(AlignCenter); |
873 | mWeekLabelsW.insert( i, label ); | 873 | mWeekLabelsW.insert( i, label ); |
874 | } | 874 | } |
875 | mWeekLabelsW[1]->setText( i18n("W")); | 875 | mWeekLabelsW[1]->setText( i18n("W")); |
876 | 876 | ||
877 | 877 | ||
878 | int row, col; | 878 | int row, col; |
879 | mCells.resize( mNumCells ); | 879 | mCells.resize( mNumCells ); |
880 | for( row = 0; row < mNumWeeks; ++row ) { | 880 | for( row = 0; row < mNumWeeks; ++row ) { |
881 | for( col = 0; col < mDaysPerWeek; ++col ) { | 881 | for( col = 0; col < mDaysPerWeek; ++col ) { |
882 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 882 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
883 | mCells.insert( row * mDaysPerWeek + col, cell ); | 883 | mCells.insert( row * mDaysPerWeek + col, cell ); |
884 | 884 | ||
885 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 885 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
886 | SLOT( defaultAction( Incidence * ) ) ); | 886 | SLOT( defaultAction( Incidence * ) ) ); |
887 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 887 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
888 | SIGNAL( newEventSignal( QDateTime ) ) ); | 888 | SIGNAL( newEventSignal( QDateTime ) ) ); |
889 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 889 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
890 | SIGNAL( showDaySignal( QDate ) ) ); | 890 | SIGNAL( showDaySignal( QDate ) ) ); |
891 | } | 891 | } |
892 | } | 892 | } |
893 | mCellsW.resize( mDaysPerWeek ); | 893 | mCellsW.resize( mDaysPerWeek ); |
894 | for( col = 0; col < mDaysPerWeek; ++col ) { | 894 | for( col = 0; col < mDaysPerWeek; ++col ) { |
895 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 895 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
896 | mCellsW.insert( col, cell ); | 896 | mCellsW.insert( col, cell ); |
897 | 897 | ||
898 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 898 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
899 | SLOT( defaultAction( Incidence * ) ) ); | 899 | SLOT( defaultAction( Incidence * ) ) ); |
900 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 900 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
901 | SIGNAL( newEventSignal( QDateTime ) ) ); | 901 | SIGNAL( newEventSignal( QDateTime ) ) ); |
902 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 902 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
903 | SIGNAL( showDaySignal( QDate ) ) ); | 903 | SIGNAL( showDaySignal( QDate ) ) ); |
904 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 904 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
905 | } | 905 | } |
906 | 906 | ||
907 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 907 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
908 | mContextMenu = eventPopup(); | 908 | mContextMenu = eventPopup(); |
909 | // updateConfig(); //useless here... | 909 | // updateConfig(); //useless here... |
910 | // ... but we need mWidthLongDayLabel computed | 910 | // ... but we need mWidthLongDayLabel computed |
911 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 911 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
912 | mWidthLongDayLabel = 0; | 912 | mWidthLongDayLabel = 0; |
913 | for (int i = 0; i < 7; i++) { | 913 | for (int i = 0; i < 7; i++) { |
914 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 914 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
915 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 915 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
916 | } | 916 | } |
917 | 917 | ||
918 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 918 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
919 | 919 | ||
920 | if ( mShowWeekView ) | 920 | if ( mShowWeekView ) |
921 | mWidStack->raiseWidget( mWeekView ); | 921 | mWidStack->raiseWidget( mWeekView ); |
922 | else | 922 | else |
923 | mWidStack->raiseWidget( mMonthView ); | 923 | mWidStack->raiseWidget( mMonthView ); |
924 | 924 | ||
925 | emit incidenceSelected( 0 ); | 925 | emit incidenceSelected( 0 ); |
926 | #ifndef DESKTOP_VERSION | 926 | #ifndef DESKTOP_VERSION |
927 | resize( QApplication::desktop()->size() ); | 927 | resize( QApplication::desktop()->size() ); |
928 | computeLayout(); | 928 | #else |
929 | resize(640, 480 ); | ||
929 | #endif | 930 | #endif |
931 | computeLayout(); | ||
932 | |||
930 | } | 933 | } |
931 | 934 | ||
932 | KOMonthView::~KOMonthView() | 935 | KOMonthView::~KOMonthView() |
933 | { | 936 | { |
934 | delete mContextMenu; | 937 | delete mContextMenu; |
935 | } | 938 | } |
936 | 939 | ||
937 | void KOMonthView::selectInternalWeekNum ( int n ) | 940 | void KOMonthView::selectInternalWeekNum ( int n ) |
938 | { | 941 | { |
939 | switchView(); | 942 | switchView(); |
940 | emit selectWeekNum ( n ); | 943 | emit selectWeekNum ( n ); |
941 | } | 944 | } |
942 | 945 | ||
943 | int KOMonthView::currentWeek() | 946 | int KOMonthView::currentWeek() |
944 | { | 947 | { |
945 | if ( mShowWeekView ) | 948 | if ( mShowWeekView ) |
946 | return mWeekLabelsW[0]->getWeekNum(); | 949 | return mWeekLabelsW[0]->getWeekNum(); |
947 | return mWeekLabels[0]->getWeekNum(); | 950 | return mWeekLabels[0]->getWeekNum(); |
948 | } | 951 | } |
949 | void KOMonthView::switchView() | 952 | void KOMonthView::switchView() |
950 | { | 953 | { |
951 | 954 | ||
952 | if ( selectedCell( ) ) | 955 | if ( selectedCell( ) ) |
953 | selectedCell()->deselect(); | 956 | selectedCell()->deselect(); |
954 | mShowWeekView = !mShowWeekView; | 957 | mShowWeekView = !mShowWeekView; |
955 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 958 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
956 | if ( clPending ) { | 959 | if ( clPending ) { |
957 | computeLayout(); | 960 | computeLayout(); |
958 | updateConfig(); | 961 | updateConfig(); |
959 | } | 962 | } |
960 | if ( mShowWeekView ) | 963 | if ( mShowWeekView ) |
961 | mWidStack->raiseWidget( mWeekView ); | 964 | mWidStack->raiseWidget( mWeekView ); |
962 | else | 965 | else |
963 | mWidStack->raiseWidget( mMonthView ); | 966 | mWidStack->raiseWidget( mMonthView ); |
964 | clPending = false; | 967 | clPending = false; |
965 | } | 968 | } |
966 | 969 | ||
967 | int KOMonthView::maxDatesHint() | 970 | int KOMonthView::maxDatesHint() |
968 | { | 971 | { |
969 | return mNumCells; | 972 | return mNumCells; |
970 | } | 973 | } |
971 | 974 | ||
972 | int KOMonthView::currentDateCount() | 975 | int KOMonthView::currentDateCount() |
973 | { | 976 | { |
974 | return mNumCells; | 977 | return mNumCells; |
975 | } | 978 | } |
976 | 979 | ||
977 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 980 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
978 | { | 981 | { |
979 | QPtrList<Incidence> selected; | 982 | QPtrList<Incidence> selected; |
980 | 983 | ||
981 | if ( mSelectedCell ) { | 984 | if ( mSelectedCell ) { |
982 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 985 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
983 | if ( incidence ) selected.append( incidence ); | 986 | if ( incidence ) selected.append( incidence ); |
984 | } | 987 | } |
985 | 988 | ||
986 | return selected; | 989 | return selected; |
987 | } | 990 | } |
988 | 991 | ||
989 | DateList KOMonthView::selectedDates() | 992 | DateList KOMonthView::selectedDates() |
990 | { | 993 | { |
991 | DateList selected; | 994 | DateList selected; |
992 | 995 | ||
993 | if ( mSelectedCell ) { | 996 | if ( mSelectedCell ) { |
994 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 997 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
995 | if ( qd.isValid() ) selected.append( qd ); | 998 | if ( qd.isValid() ) selected.append( qd ); |
996 | } | 999 | } |
997 | 1000 | ||
998 | return selected; | 1001 | return selected; |
999 | } | 1002 | } |
1000 | 1003 | ||
1001 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1004 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1002 | const QDate &td) | 1005 | const QDate &td) |
1003 | { | 1006 | { |
1004 | #ifndef KORG_NOPRINTER | 1007 | #ifndef KORG_NOPRINTER |
1005 | calPrinter->preview(CalPrinter::Month, fd, td); | 1008 | calPrinter->preview(CalPrinter::Month, fd, td); |
1006 | #endif | 1009 | #endif |
1007 | } | 1010 | } |
1008 | 1011 | ||
1009 | void KOMonthView::updateConfig() | 1012 | void KOMonthView::updateConfig() |
1010 | { | 1013 | { |
1011 | 1014 | ||
1012 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1015 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1013 | 1016 | ||
1014 | if ( mShowWeekView ) { | 1017 | if ( mShowWeekView ) { |
1015 | mWeekStartsMonday = true; | 1018 | mWeekStartsMonday = true; |
1016 | } | 1019 | } |
1017 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1020 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1018 | mWidthLongDayLabel = 0; | 1021 | mWidthLongDayLabel = 0; |
1019 | 1022 | ||
1020 | for (int i = 0; i < 7; i++) { | 1023 | for (int i = 0; i < 7; i++) { |
1021 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1024 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1022 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1025 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1023 | } | 1026 | } |
1024 | bool temp = mShowSatSunComp ; | 1027 | bool temp = mShowSatSunComp ; |
1025 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1028 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1026 | if ( ! mShowWeekView ) { | 1029 | if ( ! mShowWeekView ) { |
1027 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 1030 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
1028 | computeLayout(); | 1031 | computeLayout(); |
1029 | } | 1032 | } |
1030 | updateDayLabels(); | 1033 | updateDayLabels(); |
1031 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1034 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1032 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1035 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1033 | //resizeEvent( 0 ); | 1036 | //resizeEvent( 0 ); |
1034 | for (uint i = 0; i < mCells.count(); ++i) { | 1037 | for (uint i = 0; i < mCells.count(); ++i) { |
1035 | mCells[i]->updateConfig(); | 1038 | mCells[i]->updateConfig(); |
1036 | } | 1039 | } |
1037 | 1040 | ||
1038 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1041 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1039 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1042 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1040 | } | 1043 | } |
1041 | #ifdef DESKTOP_VERSION | 1044 | #ifdef DESKTOP_VERSION |
1042 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1045 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1043 | #endif | 1046 | #endif |
1044 | updateView(); | 1047 | updateView(); |
1045 | } | 1048 | } |
1046 | 1049 | ||
1047 | void KOMonthView::updateDayLabels() | 1050 | void KOMonthView::updateDayLabels() |
1048 | { | 1051 | { |
1049 | 1052 | ||
1050 | QPtrVector<QLabel> *mDayLabelsT; | 1053 | QPtrVector<QLabel> *mDayLabelsT; |
1051 | 1054 | ||
1052 | mDayLabelsT = &mDayLabelsW; | 1055 | mDayLabelsT = &mDayLabelsW; |
1053 | for (int i = 0; i < 7; i++) { | 1056 | for (int i = 0; i < 7; i++) { |
1054 | if (mWeekStartsMonday) { | 1057 | if (mWeekStartsMonday) { |
1055 | bool show = mShortDayLabelsW; | 1058 | bool show = mShortDayLabelsW; |
1056 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1059 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1057 | show = true; | 1060 | show = true; |
1058 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1061 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1059 | } else { | 1062 | } else { |
1060 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW)); | 1063 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW)); |
1061 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW)); | 1064 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW)); |
1062 | 1065 | ||
1063 | } | 1066 | } |
1064 | } | 1067 | } |
1065 | mDayLabelsT = &mDayLabels; | 1068 | mDayLabelsT = &mDayLabels; |
1066 | for (int i = 0; i < 7; i++) { | 1069 | for (int i = 0; i < 7; i++) { |
1067 | if (mWeekStartsMonday) { | 1070 | if (mWeekStartsMonday) { |
1068 | bool show = mShortDayLabelsM; | 1071 | bool show = mShortDayLabelsM; |
1069 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1072 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1070 | show = true; | 1073 | show = true; |
1071 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1074 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1072 | } else { | 1075 | } else { |
1073 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); | 1076 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); |
1074 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); | 1077 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1075 | 1078 | ||
1076 | } | 1079 | } |
1077 | } | 1080 | } |
1078 | 1081 | ||
1079 | } | 1082 | } |
1080 | 1083 | ||
1081 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1084 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1082 | { | 1085 | { |
1083 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1086 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1084 | 1087 | ||
1085 | QPtrVector<MonthViewCell> *cells; | 1088 | QPtrVector<MonthViewCell> *cells; |
1086 | QPtrVector<QLabel> *dayLabels; | 1089 | QPtrVector<QLabel> *dayLabels; |
1087 | QPtrVector<KOWeekButton> *weekLabels; | 1090 | QPtrVector<KOWeekButton> *weekLabels; |
1088 | int weekNum = 6; | 1091 | int weekNum = 6; |
1089 | if ( mShowWeekView ) { | 1092 | if ( mShowWeekView ) { |
1090 | weekNum = 1; | 1093 | weekNum = 1; |
1091 | cells = &mCellsW; | 1094 | cells = &mCellsW; |
1092 | dayLabels = &mDayLabelsW; | 1095 | dayLabels = &mDayLabelsW; |
1093 | weekLabels = &mWeekLabelsW; | 1096 | weekLabels = &mWeekLabelsW; |
1094 | } else { | 1097 | } else { |
1095 | cells = &mCells; | 1098 | cells = &mCells; |
1096 | dayLabels = &mDayLabels; | 1099 | dayLabels = &mDayLabels; |
1097 | weekLabels = &mWeekLabels; | 1100 | weekLabels = &mWeekLabels; |
1098 | } | 1101 | } |
1099 | 1102 | ||
1100 | mStartDate = start; | 1103 | mStartDate = start; |
1101 | 1104 | ||
1102 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 1105 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
1103 | 1106 | ||
1104 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 1107 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
1105 | mStartDate = mStartDate.addDays( -1 ); | 1108 | mStartDate = mStartDate.addDays( -1 ); |
1106 | } | 1109 | } |
1107 | 1110 | ||
1108 | bool primary = false; | 1111 | bool primary = false; |
1109 | uint i; | 1112 | uint i; |
1110 | for( i = 0; i < (*cells).size(); ++i ) { | 1113 | for( i = 0; i < (*cells).size(); ++i ) { |
1111 | QDate date = mStartDate.addDays( i ); | 1114 | QDate date = mStartDate.addDays( i ); |
1112 | (*cells)[i]->setDate( date ); | 1115 | (*cells)[i]->setDate( date ); |
1113 | 1116 | ||
1114 | #ifndef KORG_NOPLUGINS | 1117 | #ifndef KORG_NOPLUGINS |
1115 | // add holiday, if present | 1118 | // add holiday, if present |
1116 | QString hstring(KOCore::self()->holiday(date)); | 1119 | QString hstring(KOCore::self()->holiday(date)); |
1117 | (*cells)[i]->setHoliday( hstring ); | 1120 | (*cells)[i]->setHoliday( hstring ); |
1118 | #endif | 1121 | #endif |
1119 | 1122 | ||
1120 | } | 1123 | } |
1121 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 1124 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
1122 | for( i = 0; i < weekNum; ++i ) { | 1125 | for( i = 0; i < weekNum; ++i ) { |
1123 | int wno; | 1126 | int wno; |
1124 | // remember, according to ISO 8601, the first week of the year is the | 1127 | // remember, according to ISO 8601, the first week of the year is the |
1125 | // first week that contains a thursday. Thus we must subtract off 4, | 1128 | // first week that contains a thursday. Thus we must subtract off 4, |
1126 | // not just 1. | 1129 | // not just 1. |
1127 | int dayOfYear = date.dayOfYear(); | 1130 | int dayOfYear = date.dayOfYear(); |
1128 | if (dayOfYear % 7 != 0) | 1131 | if (dayOfYear % 7 != 0) |
1129 | wno = dayOfYear / 7 + 1; | 1132 | wno = dayOfYear / 7 + 1; |
1130 | else | 1133 | else |
1131 | wno =dayOfYear / 7; | 1134 | wno =dayOfYear / 7; |
1132 | (*weekLabels)[i]->setWeekNum( wno ); | 1135 | (*weekLabels)[i]->setWeekNum( wno ); |
1133 | date = date.addDays( 7 ); | 1136 | date = date.addDays( 7 ); |
1134 | } | 1137 | } |
1135 | updateView(); | 1138 | updateView(); |
1136 | } | 1139 | } |
1137 | 1140 | ||
1138 | void KOMonthView::showEvents(QPtrList<Event>) | 1141 | void KOMonthView::showEvents(QPtrList<Event>) |
1139 | { | 1142 | { |
1140 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 1143 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
1141 | } | 1144 | } |
1142 | 1145 | ||
1143 | void KOMonthView::changeEventDisplay(Event *, int) | 1146 | void KOMonthView::changeEventDisplay(Event *, int) |
1144 | { | 1147 | { |
1145 | // this should be re-written to be much more efficient, but this | 1148 | // this should be re-written to be much more efficient, but this |
1146 | // quick-and-dirty-hack gets the job done for right now. | 1149 | // quick-and-dirty-hack gets the job done for right now. |
1147 | updateView(); | 1150 | updateView(); |
1148 | } | 1151 | } |
1149 | 1152 | ||
1150 | void KOMonthView::updateView() | 1153 | void KOMonthView::updateView() |
1151 | { | 1154 | { |
1152 | 1155 | ||
1153 | if ( !updatePossible ) | 1156 | if ( !updatePossible ) |
1154 | return; | 1157 | return; |
1155 | //QTime ti; | 1158 | //QTime ti; |
1156 | //ti.start(); | 1159 | //ti.start(); |
1157 | QPtrVector<MonthViewCell> *cells; | 1160 | QPtrVector<MonthViewCell> *cells; |
1158 | if ( mShowWeekView ) { | 1161 | if ( mShowWeekView ) { |
1159 | cells = &mCellsW; | 1162 | cells = &mCellsW; |
1160 | } else { | 1163 | } else { |
1161 | cells = &mCells; | 1164 | cells = &mCells; |
1162 | } | 1165 | } |
1163 | #if 1 | 1166 | #if 1 |
1164 | int i; | 1167 | int i; |
1165 | int timeSpan = (*cells).size()-1; | 1168 | int timeSpan = (*cells).size()-1; |
1166 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1169 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1167 | timeSpan = 6; | 1170 | timeSpan = 6; |
1168 | for( i = 0; i < timeSpan + 1; ++i ) { | 1171 | for( i = 0; i < timeSpan + 1; ++i ) { |
1169 | (*cells)[i]->startUpdateCell(); | 1172 | (*cells)[i]->startUpdateCell(); |
1170 | } | 1173 | } |
1171 | 1174 | ||
1172 | QPtrList<Event> events = calendar()->events(); | 1175 | QPtrList<Event> events = calendar()->events(); |
1173 | Event *event; | 1176 | Event *event; |
1174 | QDateTime dt; | 1177 | QDateTime dt; |
1175 | bool ok; | 1178 | bool ok; |
1176 | QDate endDate = mStartDate.addDays( timeSpan ); | 1179 | QDate endDate = mStartDate.addDays( timeSpan ); |
1177 | for( event = events.first(); event; event = events.next() ) { // for event | 1180 | for( event = events.first(); event; event = events.next() ) { // for event |
1178 | if ( event->doesRecur() ) { | 1181 | if ( event->doesRecur() ) { |
1179 | bool last; | 1182 | bool last; |
1180 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1183 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
1181 | QDateTime incidenceEnd; | 1184 | QDateTime incidenceEnd; |
1182 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1185 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
1183 | bool invalid = false; | 1186 | bool invalid = false; |
1184 | while( true ) { | 1187 | while( true ) { |
1185 | if ( incidenceStart.isValid() ) { | 1188 | if ( incidenceStart.isValid() ) { |
1186 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1189 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1187 | int st = incidenceStart.date().daysTo( endDate ); | 1190 | int st = incidenceStart.date().daysTo( endDate ); |
1188 | if ( st >= 0 ) { // start before timeend | 1191 | if ( st >= 0 ) { // start before timeend |
1189 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1192 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1190 | if ( end >= 0 ) { // end after timestart --- got one! | 1193 | if ( end >= 0 ) { // end after timestart --- got one! |
1191 | //normalize | 1194 | //normalize |
1192 | st = timeSpan - st; | 1195 | st = timeSpan - st; |
1193 | if ( st < 0 ) st = 0; | 1196 | if ( st < 0 ) st = 0; |
1194 | if ( end > timeSpan ) end = timeSpan; | 1197 | if ( end > timeSpan ) end = timeSpan; |
1195 | int iii; | 1198 | int iii; |
1196 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1199 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1197 | for ( iii = st;iii<= end;++iii) | 1200 | for ( iii = st;iii<= end;++iii) |
1198 | (*cells)[iii]->insertEvent( event ); | 1201 | (*cells)[iii]->insertEvent( event ); |
1199 | } | 1202 | } |
1200 | } | 1203 | } |
1201 | } else { | 1204 | } else { |
1202 | if ( invalid ) | 1205 | if ( invalid ) |
1203 | break; | 1206 | break; |
1204 | invalid = true; | 1207 | invalid = true; |
1205 | //qDebug("invalid %s", event->summary().latin1()); | 1208 | //qDebug("invalid %s", event->summary().latin1()); |
1206 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 1209 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
1207 | } | 1210 | } |
1208 | if ( last ) | 1211 | if ( last ) |
1209 | break; | 1212 | break; |
1210 | bool ok; | 1213 | bool ok; |
1211 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 1214 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
1212 | if ( ! ok ) | 1215 | if ( ! ok ) |
1213 | break; | 1216 | break; |
1214 | if ( incidenceStart.date() > endDate ) | 1217 | if ( incidenceStart.date() > endDate ) |
1215 | break; | 1218 | break; |
1216 | } | 1219 | } |
1217 | } else { // no recur | 1220 | } else { // no recur |
1218 | int st = event->dtStart().date().daysTo( endDate ); | 1221 | int st = event->dtStart().date().daysTo( endDate ); |
1219 | if ( st >= 0 ) { // start before timeend | 1222 | if ( st >= 0 ) { // start before timeend |
1220 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 1223 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
1221 | if ( end >= 0 ) { // end after timestart --- got one! | 1224 | if ( end >= 0 ) { // end after timestart --- got one! |
1222 | //normalize | 1225 | //normalize |
1223 | st = timeSpan - st; | 1226 | st = timeSpan - st; |
1224 | if ( st < 0 ) st = 0; | 1227 | if ( st < 0 ) st = 0; |
1225 | if ( end > timeSpan ) end = timeSpan; | 1228 | if ( end > timeSpan ) end = timeSpan; |
1226 | int iii; | 1229 | int iii; |
1227 | for ( iii = st;iii<= end;++iii) | 1230 | for ( iii = st;iii<= end;++iii) |
1228 | (*cells)[iii]->insertEvent( event ); | 1231 | (*cells)[iii]->insertEvent( event ); |
1229 | } | 1232 | } |
1230 | } | 1233 | } |
1231 | } | 1234 | } |
1232 | } | 1235 | } |
1233 | // insert due todos | 1236 | // insert due todos |
1234 | QPtrList<Todo> todos = calendar()->todos( ); | 1237 | QPtrList<Todo> todos = calendar()->todos( ); |
1235 | Todo *todo; | 1238 | Todo *todo; |
1236 | for(todo = todos.first(); todo; todo = todos.next()) { | 1239 | for(todo = todos.first(); todo; todo = todos.next()) { |
1237 | //insertTodo( todo ); | 1240 | //insertTodo( todo ); |
1238 | if ( todo->hasDueDate() ) { | 1241 | if ( todo->hasDueDate() ) { |
1239 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1242 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1240 | if ( day >= 0 && day < timeSpan + 1) { | 1243 | if ( day >= 0 && day < timeSpan + 1) { |
1241 | (*cells)[day]->insertTodo( todo ); | 1244 | (*cells)[day]->insertTodo( todo ); |
1242 | } | 1245 | } |
1243 | } | 1246 | } |
1244 | } | 1247 | } |
1245 | 1248 | ||
1246 | for( i = 0; i < timeSpan+1; ++i ) { | 1249 | for( i = 0; i < timeSpan+1; ++i ) { |
1247 | (*cells)[i]->finishUpdateCell(); | 1250 | (*cells)[i]->finishUpdateCell(); |
1248 | } | 1251 | } |
1249 | processSelectionChange(); | 1252 | processSelectionChange(); |
1250 | (*cells)[0]->setFocus(); | 1253 | (*cells)[0]->setFocus(); |
1251 | 1254 | ||
1252 | 1255 | ||
1253 | #else | 1256 | #else |
1254 | // old code | 1257 | // old code |
1255 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1258 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1256 | int i; | 1259 | int i; |
1257 | for( i = 0; i < (*cells).count(); ++i ) { | 1260 | for( i = 0; i < (*cells).count(); ++i ) { |
1258 | (*cells)[i]->updateCell(); | 1261 | (*cells)[i]->updateCell(); |
1259 | } | 1262 | } |
1260 | 1263 | ||
1261 | //qDebug("KOMonthView::updateView() "); | 1264 | //qDebug("KOMonthView::updateView() "); |
1262 | processSelectionChange(); | 1265 | processSelectionChange(); |
1263 | // qDebug("---------------------------------------------------------------------+ "); | 1266 | // qDebug("---------------------------------------------------------------------+ "); |
1264 | (*cells)[0]->setFocus(); | 1267 | (*cells)[0]->setFocus(); |
1265 | #endif | 1268 | #endif |
1266 | 1269 | ||
1267 | //qDebug("update time %d ", ti.elapsed()); | 1270 | //qDebug("update time %d ", ti.elapsed()); |
1268 | } | 1271 | } |
1269 | 1272 | ||
1270 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1273 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1271 | { | 1274 | { |
1272 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); | 1275 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); |
1273 | computeLayout(); | 1276 | computeLayout(); |
1274 | clPending = true; | 1277 | clPending = true; |
1275 | if ( mShowWeekView ) | 1278 | if ( mShowWeekView ) |
1276 | mCellsW[0]->setFocus(); | 1279 | mCellsW[0]->setFocus(); |
1277 | else | 1280 | else |
1278 | mCells[0]->setFocus(); | 1281 | mCells[0]->setFocus(); |
1279 | } | 1282 | } |
1280 | void KOMonthView::computeLayoutWeek() | 1283 | void KOMonthView::computeLayoutWeek() |
1281 | { | 1284 | { |
1282 | static int lastWid = 0; | 1285 | static int lastWid = 0; |
1283 | static int lastHei = 0; | 1286 | static int lastHei = 0; |
1284 | int daysToShow; | 1287 | int daysToShow; |
1285 | bool combinedSatSun = false; | 1288 | bool combinedSatSun = false; |
1286 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1289 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1287 | daysToShow = 6; | 1290 | daysToShow = 6; |
1288 | combinedSatSun = true; | 1291 | combinedSatSun = true; |
1289 | } | 1292 | } |
1290 | int tWid = topLevelWidget()->size().width(); | 1293 | int tWid = topLevelWidget()->size().width(); |
1291 | int tHei = topLevelWidget()->size().height(); | 1294 | int tHei = topLevelWidget()->size().height(); |
1292 | 1295 | ||
1293 | int wid = width();//e | 1296 | int wid = width();//e |
1294 | int hei = height()-1-mNavigatorBar->height(); | 1297 | int hei = height()-1-mNavigatorBar->height(); |
1295 | 1298 | ||
1296 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1299 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1297 | return; | 1300 | return; |
1298 | 1301 | ||
1299 | if ( lastWid == width() && lastHei == height() ) | 1302 | if ( lastWid == width() && lastHei == height() ) |
1300 | return; | 1303 | return; |
1301 | lastWid = width(); | 1304 | lastWid = width(); |
1302 | lastHei = height(); | 1305 | lastHei = height(); |
1303 | 1306 | ||
1304 | 1307 | ||
1305 | if ( wid < hei ) | 1308 | if ( wid < hei ) |
1306 | daysToShow = 2; | 1309 | daysToShow = 2; |
1307 | else | 1310 | else |
1308 | daysToShow = 3; | 1311 | daysToShow = 3; |
1309 | mShowSatSunComp = true; | 1312 | mShowSatSunComp = true; |
1310 | combinedSatSun = true; | 1313 | combinedSatSun = true; |
1311 | 1314 | ||
1312 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); | 1315 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); |
1313 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1316 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1314 | int weeklabelwid = fm.width( "888" ); | 1317 | int weeklabelwid = fm.width( "888" ); |
1315 | wid -= weeklabelwid; | 1318 | wid -= weeklabelwid; |
1316 | 1319 | ||
1317 | int colWid = wid / daysToShow; | 1320 | int colWid = wid / daysToShow; |
1318 | int lastCol = wid - ( colWid*6 ); | 1321 | int lastCol = wid - ( colWid*6 ); |
1319 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); | 1322 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); |
1320 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1323 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1321 | int colModulo = wid % daysToShow; | 1324 | int colModulo = wid % daysToShow; |
1322 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1325 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1323 | //qDebug("rowmod %d ", rowModulo); | 1326 | //qDebug("rowmod %d ", rowModulo); |
1324 | int i; | 1327 | int i; |
1325 | int x,y,w,h; | 1328 | int x,y,w,h; |
1326 | x= 0; | 1329 | x= 0; |
1327 | y= 0; | 1330 | y= 0; |
1328 | w = colWid; | 1331 | w = colWid; |
1329 | h = dayLabelHei ; | 1332 | h = dayLabelHei ; |
1330 | for ( i = 0; i < 7; i++) { | 1333 | for ( i = 0; i < 7; i++) { |
1331 | if ( i && !( i % daysToShow) && i < 6) { | 1334 | if ( i && !( i % daysToShow) && i < 6) { |
1332 | y += hei/(5-daysToShow); | 1335 | y += hei/(5-daysToShow); |
1333 | x = 0; | 1336 | x = 0; |
1334 | w = colWid; | 1337 | w = colWid; |
1335 | } | 1338 | } |
1336 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1339 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1337 | ++w; | 1340 | ++w; |
1338 | } | 1341 | } |
1339 | if ( i >= 5 ) { | 1342 | if ( i >= 5 ) { |
1340 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); | 1343 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); |
1341 | x -= (w/2 ); | 1344 | x -= (w/2 ); |
1342 | } | 1345 | } |
1343 | else | 1346 | else |
1344 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); | 1347 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); |
1345 | x += w; | 1348 | x += w; |
1346 | } | 1349 | } |
1347 | x= 0; | 1350 | x= 0; |
1348 | y= dayLabelHei; | 1351 | y= dayLabelHei; |
1349 | w = colWid; | 1352 | w = colWid; |
1350 | h = cellHei; | 1353 | h = cellHei; |
1351 | for ( i = 0; i < mCellsW.count(); ++i) { | 1354 | for ( i = 0; i < mCellsW.count(); ++i) { |
1352 | if ( i > 6 ) { | 1355 | if ( i > 6 ) { |
1353 | mCellsW[i]->hide(); | 1356 | mCellsW[i]->hide(); |
1354 | continue; | 1357 | continue; |
1355 | } | 1358 | } |
1356 | 1359 | ||
1357 | w = colWid; | 1360 | w = colWid; |
1358 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1361 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1359 | ++w; | 1362 | ++w; |
1360 | } | 1363 | } |
1361 | if ( i == (daysToShow-1-rowModulo)*7) | 1364 | if ( i == (daysToShow-1-rowModulo)*7) |
1362 | ++h; | 1365 | ++h; |
1363 | 1366 | ||
1364 | if ( i >= 5 ) { | 1367 | if ( i >= 5 ) { |
1365 | if ( i ==5 ) { | 1368 | if ( i ==5 ) { |
1366 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1369 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1367 | x -= w ;y += h/2; | 1370 | x -= w ;y += h/2; |
1368 | } else { | 1371 | } else { |
1369 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1372 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1370 | ++w; | 1373 | ++w; |
1371 | } | 1374 | } |
1372 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1375 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1373 | y -= h/2; | 1376 | y -= h/2; |
1374 | } | 1377 | } |
1375 | } else | 1378 | } else |
1376 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1379 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1377 | 1380 | ||
1378 | 1381 | ||
1379 | x += w; | 1382 | x += w; |
1380 | if ( x + w/2 > wid ) { | 1383 | if ( x + w/2 > wid ) { |
1381 | x = 0; | 1384 | x = 0; |
1382 | y += h+dayLabelHei ; | 1385 | y += h+dayLabelHei ; |
1383 | } | 1386 | } |
1384 | } | 1387 | } |
1385 | y= dayLabelHei; | 1388 | y= dayLabelHei; |
1386 | h = cellHei ; | 1389 | h = cellHei ; |
1387 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1390 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1388 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1391 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1389 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1392 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1390 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1393 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1391 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; | 1394 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; |
1392 | updateDayLabels(); | 1395 | updateDayLabels(); |
1393 | //bool forceUpdate = !updatePossible; | 1396 | //bool forceUpdate = !updatePossible; |
1394 | updatePossible = true; | 1397 | updatePossible = true; |
1395 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1398 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1396 | //if ( forceUpdate ) | 1399 | //if ( forceUpdate ) |
1397 | // updateView(); | 1400 | // updateView(); |
1398 | } | 1401 | } |
1399 | void KOMonthView::computeLayout() | 1402 | void KOMonthView::computeLayout() |
1400 | { | 1403 | { |
1401 | 1404 | ||
1402 | 1405 | ||
1403 | static int lastWid = 0; | 1406 | static int lastWid = 0; |
1404 | static int lastHei = 0; | 1407 | static int lastHei = 0; |
1405 | 1408 | ||
1406 | if ( mShowWeekView ){ | 1409 | if ( mShowWeekView ){ |
1407 | computeLayoutWeek(); | 1410 | computeLayoutWeek(); |
1408 | return; | 1411 | return; |
1409 | } | 1412 | } |
1410 | int daysToShow = 7; | 1413 | int daysToShow = 7; |
1411 | bool combinedSatSun = false; | 1414 | bool combinedSatSun = false; |
1412 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1415 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1413 | daysToShow = 6; | 1416 | daysToShow = 6; |
1414 | combinedSatSun = true; | 1417 | combinedSatSun = true; |
1415 | } | 1418 | } |
1416 | int tWid = topLevelWidget()->size().width(); | 1419 | int tWid = topLevelWidget()->size().width(); |
1417 | int tHei = topLevelWidget()->size().height(); | 1420 | int tHei = topLevelWidget()->size().height(); |
1418 | 1421 | ||
1419 | int wid = width();//e | 1422 | int wid = width();//e |
1420 | int hei = height()-1-mNavigatorBar->height(); | 1423 | int hei = height()-1-mNavigatorBar->height(); |
1421 | 1424 | ||
1422 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { | 1425 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { |
1423 | return; | 1426 | return; |
1424 | } | 1427 | } |
1425 | if ( lastWid == width() && lastHei == height() ){ | 1428 | if ( lastWid == width() && lastHei == height() ){ |
1426 | return; | 1429 | return; |
1427 | } | 1430 | } |
1428 | 1431 | ||
1429 | lastWid = width(); | 1432 | lastWid = width(); |
1430 | lastHei = height(); | 1433 | lastHei = height(); |
1431 | //qDebug("KOMonthView::computeLayout() MMM ------------------------------------ "); | 1434 | //qDebug("KOMonthView::computeLayout() MMM ------------------------------------ "); |
1432 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1435 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1433 | int weeklabelwid = fm.width( "888" ); | 1436 | int weeklabelwid = fm.width( "888" ); |
1434 | wid -= weeklabelwid; | 1437 | wid -= weeklabelwid; |
1435 | 1438 | ||
1436 | int colWid = wid / daysToShow; | 1439 | int colWid = wid / daysToShow; |
1437 | int lastCol = wid - ( colWid*6 ); | 1440 | int lastCol = wid - ( colWid*6 ); |
1438 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1441 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1439 | int cellHei = (hei - dayLabelHei) /6; | 1442 | int cellHei = (hei - dayLabelHei) /6; |
1440 | int colModulo = wid % daysToShow; | 1443 | int colModulo = wid % daysToShow; |
1441 | int rowModulo = (hei- dayLabelHei) % 6; | 1444 | int rowModulo = (hei- dayLabelHei) % 6; |
1442 | //qDebug("rowmod %d ", rowModulo); | 1445 | //qDebug("rowmod %d ", rowModulo); |
1443 | int i; | 1446 | int i; |
1444 | int x,y,w,h; | 1447 | int x,y,w,h; |
1445 | x= 0; | 1448 | x= 0; |
1446 | y= 0; | 1449 | y= 0; |
1447 | w = colWid; | 1450 | w = colWid; |
1448 | h = dayLabelHei ; | 1451 | h = dayLabelHei ; |
1449 | for ( i = 0; i < 7; i++) { | 1452 | for ( i = 0; i < 7; i++) { |
1450 | if ( i == daysToShow-colModulo ) | 1453 | if ( i == daysToShow-colModulo ) |
1451 | ++w; | 1454 | ++w; |
1452 | if ( combinedSatSun ) { | 1455 | if ( combinedSatSun ) { |
1453 | if ( i >= daysToShow-1 ) { | 1456 | if ( i >= daysToShow-1 ) { |
1454 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1457 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
1455 | x -= w/2 ; | 1458 | x -= w/2 ; |
1456 | } | 1459 | } |
1457 | else | 1460 | else |
1458 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1461 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1459 | } else | 1462 | } else |
1460 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1463 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1461 | x += w; | 1464 | x += w; |
1462 | } | 1465 | } |
1463 | x= 0; | 1466 | x= 0; |
1464 | y= dayLabelHei; | 1467 | y= dayLabelHei; |
1465 | w = colWid; | 1468 | w = colWid; |
1466 | h = cellHei ; | 1469 | h = cellHei ; |
1467 | for ( i = 0; i < mCells.count(); ++i) { | 1470 | for ( i = 0; i < mCells.count(); ++i) { |
1468 | //qDebug("iii %d ", i); | 1471 | //qDebug("iii %d ", i); |
1469 | w = colWid; | 1472 | w = colWid; |
1470 | if ( ((i) % 7) >= 7-colModulo ) { | 1473 | if ( ((i) % 7) >= 7-colModulo ) { |
1471 | ++w; | 1474 | ++w; |
1472 | } | 1475 | } |
1473 | if ( i == (6-rowModulo)*7) | 1476 | if ( i == (6-rowModulo)*7) |
1474 | ++h; | 1477 | ++h; |
1475 | if ( combinedSatSun ) { | 1478 | if ( combinedSatSun ) { |
1476 | if ( (i)%7 >= daysToShow-1 ) { | 1479 | if ( (i)%7 >= daysToShow-1 ) { |
1477 | if ( (i)%7 == daysToShow-1 ) { | 1480 | if ( (i)%7 == daysToShow-1 ) { |
1478 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1481 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1479 | x -= w ;y += h/2; | 1482 | x -= w ;y += h/2; |
1480 | } else { | 1483 | } else { |
1481 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1484 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1482 | y -= h/2; | 1485 | y -= h/2; |
1483 | } | 1486 | } |
1484 | } else | 1487 | } else |
1485 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1488 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1486 | 1489 | ||
1487 | } | 1490 | } |
1488 | else | 1491 | else |
1489 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1492 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1490 | x += w; | 1493 | x += w; |
1491 | if ( x + w/2 > wid ) { | 1494 | if ( x + w/2 > wid ) { |
1492 | x = 0; | 1495 | x = 0; |
1493 | y += h; | 1496 | y += h; |
1494 | } | 1497 | } |
1495 | } | 1498 | } |
1496 | y= dayLabelHei; | 1499 | y= dayLabelHei; |
1497 | h = cellHei ; | 1500 | h = cellHei ; |
1498 | for ( i = 0; i < 6; i++) { | 1501 | for ( i = 0; i < 6; i++) { |
1499 | if ( i == (6-rowModulo)) | 1502 | if ( i == (6-rowModulo)) |
1500 | ++h; | 1503 | ++h; |
1501 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1504 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
1502 | y += h; | 1505 | y += h; |
1503 | } | 1506 | } |
1504 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1507 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1505 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1508 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1506 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1509 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1507 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; | 1510 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; |
1508 | updateDayLabels(); | 1511 | updateDayLabels(); |
1509 | //bool forceUpdate = !updatePossible; | 1512 | //bool forceUpdate = !updatePossible; |
1510 | updatePossible = true; | 1513 | updatePossible = true; |
1511 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1514 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1512 | } | 1515 | } |
1513 | 1516 | ||
1514 | void KOMonthView::showContextMenu( Incidence *incidence ) | 1517 | void KOMonthView::showContextMenu( Incidence *incidence ) |
1515 | { | 1518 | { |
1516 | mContextMenu->showIncidencePopup(incidence); | 1519 | mContextMenu->showIncidencePopup(incidence); |
1517 | /* | 1520 | /* |
1518 | if( incidence && incidence->type() == "Event" ) { | 1521 | if( incidence && incidence->type() == "Event" ) { |
1519 | Event *event = static_cast<Event *>(incidence); | 1522 | Event *event = static_cast<Event *>(incidence); |
1520 | mContextMenu->showEventPopup(event); | 1523 | mContextMenu->showEventPopup(event); |
1521 | } else { | 1524 | } else { |
1522 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 1525 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
1523 | } | 1526 | } |
1524 | */ | 1527 | */ |
1525 | } | 1528 | } |
1526 | MonthViewCell * KOMonthView::selectedCell( ) | 1529 | MonthViewCell * KOMonthView::selectedCell( ) |
1527 | { | 1530 | { |
1528 | return mSelectedCell; | 1531 | return mSelectedCell; |
1529 | } | 1532 | } |
1530 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 1533 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
1531 | { | 1534 | { |
1532 | // qDebug("KOMonthView::setSelectedCell "); | 1535 | // qDebug("KOMonthView::setSelectedCell "); |
1533 | if ( mSelectedCell && mSelectedCell != cell ) { | 1536 | if ( mSelectedCell && mSelectedCell != cell ) { |
1534 | MonthViewCell * mvc = mSelectedCell; | 1537 | MonthViewCell * mvc = mSelectedCell; |
1535 | mSelectedCell = cell; | 1538 | mSelectedCell = cell; |
1536 | mvc->deselect(); | 1539 | mvc->deselect(); |
1537 | } else | 1540 | } else |
1538 | mSelectedCell = cell; | 1541 | mSelectedCell = cell; |
1539 | // if ( mSelectedCell ) | 1542 | // if ( mSelectedCell ) |
1540 | // mSelectedCell->select(); | 1543 | // mSelectedCell->select(); |
1541 | if ( !mSelectedCell ) | 1544 | if ( !mSelectedCell ) |
1542 | emit incidenceSelected( 0 ); | 1545 | emit incidenceSelected( 0 ); |
1543 | else | 1546 | else |
1544 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 1547 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
1545 | } | 1548 | } |
1546 | 1549 | ||
1547 | void KOMonthView::processSelectionChange() | 1550 | void KOMonthView::processSelectionChange() |
1548 | { | 1551 | { |
1549 | QPtrList<Incidence> incidences = selectedIncidences(); | 1552 | QPtrList<Incidence> incidences = selectedIncidences(); |
1550 | if (incidences.count() > 0) { | 1553 | if (incidences.count() > 0) { |
1551 | emit incidenceSelected( incidences.first() ); | 1554 | emit incidenceSelected( incidences.first() ); |
1552 | } else { | 1555 | } else { |
1553 | emit incidenceSelected( 0 ); | 1556 | emit incidenceSelected( 0 ); |
1554 | } | 1557 | } |
1555 | } | 1558 | } |
1556 | 1559 | ||
1557 | void KOMonthView::clearSelection() | 1560 | void KOMonthView::clearSelection() |
1558 | { | 1561 | { |
1559 | if ( mSelectedCell ) { | 1562 | if ( mSelectedCell ) { |
1560 | mSelectedCell->deselect(); | 1563 | mSelectedCell->deselect(); |
1561 | mSelectedCell = 0; | 1564 | mSelectedCell = 0; |
1562 | } | 1565 | } |
1563 | } | 1566 | } |
1564 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 1567 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
1565 | { | 1568 | { |
1566 | //qDebug("KOMonthView::keyPressEvent "); | 1569 | //qDebug("KOMonthView::keyPressEvent "); |
1567 | switch(e->key()) { | 1570 | switch(e->key()) { |
1568 | case Key_Up: | 1571 | case Key_Up: |
1569 | { | 1572 | { |
1570 | emit prevMonth(); | 1573 | emit prevMonth(); |
1571 | if ( mShowWeekView ) | 1574 | if ( mShowWeekView ) |
1572 | mCellsW[0]->setFocus(); | 1575 | mCellsW[0]->setFocus(); |
1573 | else | 1576 | else |
1574 | mCells[0]->setFocus(); | 1577 | mCells[0]->setFocus(); |
1575 | } | 1578 | } |
1576 | e->accept(); | 1579 | e->accept(); |
1577 | break; | 1580 | break; |
1578 | case Key_Down: | 1581 | case Key_Down: |
1579 | { | 1582 | { |
1580 | emit nextMonth(); | 1583 | emit nextMonth(); |
1581 | if ( mShowWeekView ) | 1584 | if ( mShowWeekView ) |
1582 | mCellsW[0]->setFocus(); | 1585 | mCellsW[0]->setFocus(); |
1583 | else | 1586 | else |
1584 | mCells[0]->setFocus(); | 1587 | mCells[0]->setFocus(); |
1585 | 1588 | ||
1586 | } | 1589 | } |
1587 | e->accept(); | 1590 | e->accept(); |
1588 | break; | 1591 | break; |
1589 | case Key_Return: | 1592 | case Key_Return: |
1590 | case Key_Enter: | 1593 | case Key_Enter: |
1591 | { | 1594 | { |
1592 | selectInternalWeekNum ( currentWeek() ); | 1595 | selectInternalWeekNum ( currentWeek() ); |
1593 | } | 1596 | } |
1594 | e->accept(); | 1597 | e->accept(); |
1595 | break; | 1598 | break; |
1596 | default: | 1599 | default: |
1597 | e->ignore(); | 1600 | e->ignore(); |
1598 | break; | 1601 | break; |
1599 | } | 1602 | } |
1600 | } | 1603 | } |
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 576c265..5bfe2a1 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -1,490 +1,494 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <time.h> | 24 | #include <time.h> |
25 | #ifndef _WIN32_ | 25 | #ifndef _WIN32_ |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #endif | 27 | #endif |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
30 | #include <qtextcodec.h> | 30 | #include <qtextcodec.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | #include <qregexp.h> | 32 | #include <qregexp.h> |
33 | #include <qfont.h> | 33 | #include <qfont.h> |
34 | #include <qcolor.h> | 34 | #include <qcolor.h> |
35 | #include <qstringlist.h> | 35 | #include <qstringlist.h> |
36 | #include <stdlib.h> | 36 | #include <stdlib.h> |
37 | 37 | ||
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kglobalsettings.h> | ||
39 | #include <kconfig.h> | 40 | #include <kconfig.h> |
40 | #include <klocale.h> | 41 | #include <klocale.h> |
41 | #include <kdebug.h> | 42 | #include <kdebug.h> |
42 | #include <kemailsettings.h> | 43 | #include <kemailsettings.h> |
43 | #include <kstaticdeleter.h> | 44 | #include <kstaticdeleter.h> |
44 | #include <libkdepim/kpimglobalprefs.h> | 45 | #include <libkdepim/kpimglobalprefs.h> |
45 | 46 | ||
46 | #include "koprefs.h" | 47 | #include "koprefs.h" |
47 | #include "mainwindow.h" | 48 | #include "mainwindow.h" |
48 | 49 | ||
49 | KOPrefs *KOPrefs::mInstance = 0; | 50 | KOPrefs *KOPrefs::mInstance = 0; |
50 | static KStaticDeleter<KOPrefs> insd; | 51 | static KStaticDeleter<KOPrefs> insd; |
51 | 52 | ||
52 | KOPrefs::KOPrefs() : | 53 | KOPrefs::KOPrefs() : |
53 | KPimPrefs("korganizerrc") | 54 | KPimPrefs("korganizerrc") |
54 | { | 55 | { |
55 | mCategoryColors.setAutoDelete(true); | 56 | mCategoryColors.setAutoDelete(true); |
56 | fillMailDefaults(); | 57 | fillMailDefaults(); |
57 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); | 58 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); |
58 | QColor defaultHolidayColor = QColor(255,0,0); | 59 | QColor defaultHolidayColor = QColor(255,0,0); |
59 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); | 60 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); |
60 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); | 61 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); |
61 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); | 62 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); |
62 | QColor defaultTodoDueTodayColor = QColor(255,220,100); | 63 | QColor defaultTodoDueTodayColor = QColor(255,220,100); |
63 | QColor defaultTodoOverdueColor = QColor(255,153,125); | 64 | QColor defaultTodoOverdueColor = QColor(255,153,125); |
64 | 65 | ||
66 | /* | ||
65 | mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); | 67 | mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); |
66 | mDefaultViewFont = QFont("helvetica",10); | 68 | mDefaultViewFont = QFont("helvetica",10); |
67 | mDefaultMonthViewFont = QFont("helvetica",8); | 69 | mDefaultMonthViewFont = QFont("helvetica",8); |
68 | mMarcusBainsFont= QFont("helvetica",10); | 70 | mMarcusBainsFont= QFont("helvetica",10); |
69 | mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); | 71 | mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); |
70 | mEditBoxFont = QFont("helvetica",12); | 72 | mEditBoxFont = QFont("helvetica",12); |
71 | mJornalViewFont = QFont("helvetica",12); | 73 | mJornalViewFont = QFont("helvetica",12); |
74 | */ | ||
75 | |||
72 | 76 | ||
73 | KPrefs::setCurrentGroup("General"); | 77 | KPrefs::setCurrentGroup("General"); |
74 | 78 | ||
75 | 79 | ||
76 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 80 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
77 | 81 | ||
78 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); | 82 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); |
79 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); | 83 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); |
80 | addItemBool("ShowIconSearch",&mShowIconSearch,true); | 84 | addItemBool("ShowIconSearch",&mShowIconSearch,true); |
81 | addItemBool("ShowIconList",&mShowIconList,true); | 85 | addItemBool("ShowIconList",&mShowIconList,true); |
82 | addItemBool("ShowIconDay1",&mShowIconDay1,true); | 86 | addItemBool("ShowIconDay1",&mShowIconDay1,true); |
83 | addItemBool("ShowIconDay5",&mShowIconDay5,true); | 87 | addItemBool("ShowIconDay5",&mShowIconDay5,true); |
84 | addItemBool("ShowIconDay7",&mShowIconDay7,true); | 88 | addItemBool("ShowIconDay7",&mShowIconDay7,true); |
85 | addItemBool("ShowIconMonth",&mShowIconMonth,true); | 89 | addItemBool("ShowIconMonth",&mShowIconMonth,true); |
86 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); | 90 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); |
87 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); | 91 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); |
88 | addItemBool("ShowIconBack",&mShowIconBack,true); | 92 | addItemBool("ShowIconBack",&mShowIconBack,true); |
89 | addItemBool("ShowIconToday",&mShowIconToday,true); | 93 | addItemBool("ShowIconToday",&mShowIconToday,true); |
90 | addItemBool("ShowIconForward",&mShowIconForward,true); | 94 | addItemBool("ShowIconForward",&mShowIconForward,true); |
91 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); | 95 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); |
92 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); | 96 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); |
93 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); | 97 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); |
94 | addItemBool("ShowIconNext",&mShowIconNext,true); | 98 | addItemBool("ShowIconNext",&mShowIconNext,true); |
95 | addItemBool("ShowIconJournal",&mShowIconJournal,true); | 99 | addItemBool("ShowIconJournal",&mShowIconJournal,true); |
96 | addItemBool("ShowIconStretch",&mShowIconStretch,true); | 100 | addItemBool("ShowIconStretch",&mShowIconStretch,true); |
97 | addItemInt("LastLoadedLanguage",&mOldLanguage,0); | 101 | addItemInt("LastLoadedLanguage",&mOldLanguage,0); |
98 | 102 | ||
99 | addItemBool("AskForQuit",&mAskForQuit,false); | 103 | addItemBool("AskForQuit",&mAskForQuit,false); |
100 | 104 | ||
101 | #ifndef DESKTOP_VERSION | 105 | #ifndef DESKTOP_VERSION |
102 | addItemBool("ShowFullMenu",&mShowFullMenu,false); | 106 | addItemBool("ShowFullMenu",&mShowFullMenu,false); |
103 | #else | 107 | #else |
104 | addItemBool("ShowFullMenu",&mShowFullMenu,true); | 108 | addItemBool("ShowFullMenu",&mShowFullMenu,true); |
105 | #endif | 109 | #endif |
106 | addItemBool("ToolBarHor",&mToolBarHor, true ); | 110 | addItemBool("ToolBarHor",&mToolBarHor, true ); |
107 | addItemBool("ToolBarUp",&mToolBarUp, false ); | 111 | addItemBool("ToolBarUp",&mToolBarUp, false ); |
108 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); | 112 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); |
109 | addItemInt("Whats Next Days",&mWhatsNextDays,3); | 113 | addItemInt("Whats Next Days",&mWhatsNextDays,3); |
110 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); | 114 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); |
111 | 115 | ||
112 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); | 116 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); |
113 | addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); | 117 | addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); |
114 | addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); | 118 | addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); |
115 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); | 119 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); |
116 | addItemInt("AllDay Size",&mAllDaySize,28); | 120 | addItemInt("AllDay Size",&mAllDaySize,28); |
117 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; | 121 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; |
118 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); | 122 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); |
119 | 123 | ||
120 | addItemStringList("LocationDefaults",&mLocationDefaults ); | 124 | addItemStringList("LocationDefaults",&mLocationDefaults ); |
121 | addItemStringList("EventSummary User",&mEventSummaryUser); | 125 | addItemStringList("EventSummary User",&mEventSummaryUser); |
122 | addItemStringList("TodoSummary User",&mTodoSummaryUser); | 126 | addItemStringList("TodoSummary User",&mTodoSummaryUser); |
123 | 127 | ||
124 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 128 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
125 | addItemBool("Enable Project View",&mEnableProjectView,false); | 129 | addItemBool("Enable Project View",&mEnableProjectView,false); |
126 | addItemBool("Auto Save",&mAutoSave,false); | 130 | addItemBool("Auto Save",&mAutoSave,false); |
127 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); | 131 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); |
128 | addItemBool("Confirm Deletes",&mConfirm,true); | 132 | addItemBool("Confirm Deletes",&mConfirm,true); |
129 | addItemString("Archive File",&mArchiveFile); | 133 | addItemString("Archive File",&mArchiveFile); |
130 | addItemString("Html Export File",&mHtmlExportFile, | 134 | addItemString("Html Export File",&mHtmlExportFile, |
131 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); | 135 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); |
132 | addItemBool("Html With Save",&mHtmlWithSave,false); | 136 | addItemBool("Html With Save",&mHtmlWithSave,false); |
133 | 137 | ||
134 | KPrefs::setCurrentGroup("Personal Settings"); | 138 | KPrefs::setCurrentGroup("Personal Settings"); |
135 | 139 | ||
136 | addItemInt("Mail Client",&mMailClient,MailClientKMail); | 140 | addItemInt("Mail Client",&mMailClient,MailClientKMail); |
137 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); | 141 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); |
138 | addItemBool("Bcc",&mBcc,false); | 142 | addItemBool("Bcc",&mBcc,false); |
139 | 143 | ||
140 | KPrefs::setCurrentGroup("Time & Date"); | 144 | KPrefs::setCurrentGroup("Time & Date"); |
141 | 145 | ||
142 | 146 | ||
143 | addItemInt("Default Start Time",&mStartTime,10); | 147 | addItemInt("Default Start Time",&mStartTime,10); |
144 | addItemInt("Default Duration",&mDefaultDuration,2); | 148 | addItemInt("Default Duration",&mDefaultDuration,2); |
145 | addItemInt("Default Alarm Time",&mAlarmTime,3); | 149 | addItemInt("Default Alarm Time",&mAlarmTime,3); |
146 | KPrefs::setCurrentGroup("AlarmSettings"); | 150 | KPrefs::setCurrentGroup("AlarmSettings"); |
147 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); | 151 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); |
148 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); | 152 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); |
149 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); | 153 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); |
150 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); | 154 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); |
151 | 155 | ||
152 | 156 | ||
153 | KPrefs::setCurrentGroup("Calendar"); | 157 | KPrefs::setCurrentGroup("Calendar"); |
154 | 158 | ||
155 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); | 159 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); |
156 | 160 | ||
157 | KPrefs::setCurrentGroup("Fonts"); | 161 | KPrefs::setCurrentGroup("Fonts"); |
158 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); | 162 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); |
159 | addItemFont("TimeBar Font",&mTimeBarFont); | 163 | addItemFont("TimeBar Font",&mTimeBarFont,KGlobalSettings::generalFont() ); |
160 | addItemFont("MonthView Font",&mMonthViewFont); | 164 | addItemFont("MonthView Font",&mMonthViewFont,KGlobalSettings::generalFont()); |
161 | addItemFont("AgendaView Font",&mAgendaViewFont); | 165 | addItemFont("AgendaView Font",&mAgendaViewFont,KGlobalSettings::generalFont()); |
162 | addItemFont("MarcusBains Font",&mMarcusBainsFont); | 166 | addItemFont("MarcusBains Font",&mMarcusBainsFont,KGlobalSettings::generalFont()); |
163 | addItemFont("TimeLabels Font",&mTimeLabelsFont); | 167 | addItemFont("TimeLabels Font",&mTimeLabelsFont,KGlobalSettings::generalFont()); |
164 | addItemFont("TodoView Font",&mTodoViewFont); | 168 | addItemFont("TodoView Font",&mTodoViewFont,KGlobalSettings::generalFont()); |
165 | addItemFont("ListView Font",&mListViewFont); | 169 | addItemFont("ListView Font",&mListViewFont,KGlobalSettings::generalFont()); |
166 | addItemFont("DateNavigator Font",&mDateNavigatorFont); | 170 | addItemFont("DateNavigator Font",&mDateNavigatorFont,KGlobalSettings::generalFont()); |
167 | addItemFont("EditBox Font",&mEditBoxFont); | 171 | addItemFont("EditBox Font",&mEditBoxFont,KGlobalSettings::generalFont()); |
168 | addItemFont("JournalView Font",&mJornalViewFont); | 172 | addItemFont("JournalView Font",&mJornalViewFont,KGlobalSettings::generalFont()); |
169 | addItemFont("WhatsNextView Font",&mWhatsNextFont); | 173 | addItemFont("WhatsNextView Font",&mWhatsNextFont,KGlobalSettings::generalFont()); |
170 | addItemFont("EventView Font",&mEventViewFont); | 174 | addItemFont("EventView Font",&mEventViewFont,KGlobalSettings::generalFont()); |
171 | 175 | ||
172 | KPrefs::setCurrentGroup("RemoteSyncing"); | 176 | KPrefs::setCurrentGroup("RemoteSyncing"); |
173 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); | 177 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); |
174 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); | 178 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); |
175 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); | 179 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); |
176 | addItemInt("LastSyncTime",&mLastSyncTime,0); | 180 | addItemInt("LastSyncTime",&mLastSyncTime,0); |
177 | 181 | ||
178 | #ifdef _WIN32_ | 182 | #ifdef _WIN32_ |
179 | QString hdp= locateLocal("data","korganizer")+"\\\\"; | 183 | QString hdp= locateLocal("data","korganizer")+"\\\\"; |
180 | #else | 184 | #else |
181 | QString hdp= locateLocal("data","korganizer")+"/"; | 185 | QString hdp= locateLocal("data","korganizer")+"/"; |
182 | #endif | 186 | #endif |
183 | 187 | ||
184 | KPrefs::setCurrentGroup("LoadSaveFileNames"); | 188 | KPrefs::setCurrentGroup("LoadSaveFileNames"); |
185 | 189 | ||
186 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); | 190 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); |
187 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); | 191 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); |
188 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); | 192 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); |
189 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); | 193 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); |
190 | 194 | ||
191 | 195 | ||
192 | KPrefs::setCurrentGroup("Locale"); | 196 | KPrefs::setCurrentGroup("Locale"); |
193 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); | 197 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); |
194 | 198 | ||
195 | 199 | ||
196 | KPrefs::setCurrentGroup("Colors"); | 200 | KPrefs::setCurrentGroup("Colors"); |
197 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); | 201 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); |
198 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); | 202 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); |
199 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); | 203 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); |
200 | addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); | 204 | addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); |
201 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); | 205 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); |
202 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); | 206 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); |
203 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); | 207 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); |
204 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); | 208 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); |
205 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); | 209 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); |
206 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); | 210 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); |
207 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); | 211 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); |
208 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); | 212 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); |
209 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); | 213 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); |
210 | addItemBool("MonthViewWeek",&mMonthViewWeek,false); | 214 | addItemBool("MonthViewWeek",&mMonthViewWeek,false); |
211 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); | 215 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); |
212 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); | 216 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); |
213 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); | 217 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); |
214 | addItemBool("UseAppColors",&mUseAppColors,false); | 218 | addItemBool("UseAppColors",&mUseAppColors,false); |
215 | 219 | ||
216 | 220 | ||
217 | 221 | ||
218 | KPrefs::setCurrentGroup("Views"); | 222 | KPrefs::setCurrentGroup("Views"); |
219 | addItemBool("Show Date Navigator",&mShowDateNavigator,true); | 223 | addItemBool("Show Date Navigator",&mShowDateNavigator,true); |
220 | addItemInt("Hour Size",&mHourSize,8); | 224 | addItemInt("Hour Size",&mHourSize,8); |
221 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); | 225 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); |
222 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); | 226 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); |
223 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); | 227 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); |
224 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); | 228 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); |
225 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); | 229 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); |
226 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); | 230 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); |
227 | #ifdef DESKTOP_VERION | 231 | #ifdef DESKTOP_VERION |
228 | addItemBool("Enable ToolTips",&mEnableToolTips,true); | 232 | addItemBool("Enable ToolTips",&mEnableToolTips,true); |
229 | #else | 233 | #else |
230 | addItemBool("Enable ToolTips",&mEnableToolTips,false); | 234 | addItemBool("Enable ToolTips",&mEnableToolTips,false); |
231 | #endif | 235 | #endif |
232 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); | 236 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); |
233 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); | 237 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); |
234 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); | 238 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); |
235 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); | 239 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); |
236 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); | 240 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); |
237 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); | 241 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); |
238 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); | 242 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); |
239 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); | 243 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); |
240 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); | 244 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); |
241 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; | 245 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; |
242 | addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); | 246 | addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); |
243 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); | 247 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); |
244 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); | 248 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); |
245 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); | 249 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); |
246 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); | 250 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); |
247 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); | 251 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); |
248 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); | 252 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); |
249 | addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); | 253 | addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); |
250 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); | 254 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); |
251 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); | 255 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); |
252 | #ifdef DESKTOP_VERSION | 256 | #ifdef DESKTOP_VERSION |
253 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); | 257 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); |
254 | #else | 258 | #else |
255 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); | 259 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); |
256 | #endif | 260 | #endif |
257 | addItemInt("Day Begins",&mDayBegins,7); | 261 | addItemInt("Day Begins",&mDayBegins,7); |
258 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); | 262 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); |
259 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); | 263 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); |
260 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); | 264 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); |
261 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); | 265 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); |
262 | 266 | ||
263 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); | 267 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); |
264 | addItemBool("Full View Month",&mFullViewMonth,true); | 268 | addItemBool("Full View Month",&mFullViewMonth,true); |
265 | addItemBool("Full View Todo",&mFullViewTodo,true); | 269 | addItemBool("Full View Todo",&mFullViewTodo,true); |
266 | addItemBool("Quick Todo",&mEnableQuickTodo,false); | 270 | addItemBool("Quick Todo",&mEnableQuickTodo,false); |
267 | 271 | ||
268 | addItemInt("Next X Days",&mNextXDays,3); | 272 | addItemInt("Next X Days",&mNextXDays,3); |
269 | 273 | ||
270 | KPrefs::setCurrentGroup("Printer"); | 274 | KPrefs::setCurrentGroup("Printer"); |
271 | 275 | ||
272 | KPrefs::setCurrentGroup("Layout"); | 276 | KPrefs::setCurrentGroup("Layout"); |
273 | 277 | ||
274 | addItemBool("CompactDialogs",&mCompactDialogs,false); | 278 | addItemBool("CompactDialogs",&mCompactDialogs,false); |
275 | addItemBool("VerticalScreen",&mVerticalScreen,true); | 279 | addItemBool("VerticalScreen",&mVerticalScreen,true); |
276 | 280 | ||
277 | KPrefs::setCurrentGroup("KOrganizer Plugins"); | 281 | KPrefs::setCurrentGroup("KOrganizer Plugins"); |
278 | 282 | ||
279 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); | 283 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); |
280 | 284 | ||
281 | KPrefs::setCurrentGroup("Group Scheduling"); | 285 | KPrefs::setCurrentGroup("Group Scheduling"); |
282 | 286 | ||
283 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); | 287 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); |
284 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); | 288 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); |
285 | addItemStringList("AdditionalMails",&mAdditionalMails,""); | 289 | addItemStringList("AdditionalMails",&mAdditionalMails,""); |
286 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); | 290 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); |
287 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); | 291 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); |
288 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); | 292 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); |
289 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); | 293 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); |
290 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); | 294 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); |
291 | 295 | ||
292 | KPrefs::setCurrentGroup( "Editors" ); | 296 | KPrefs::setCurrentGroup( "Editors" ); |
293 | 297 | ||
294 | addItemStringList( "EventTemplates", &mEventTemplates ); | 298 | addItemStringList( "EventTemplates", &mEventTemplates ); |
295 | addItemStringList( "TodoTemplates", &mTodoTemplates ); | 299 | addItemStringList( "TodoTemplates", &mTodoTemplates ); |
296 | 300 | ||
297 | addItemInt("DestinationPolicy",&mDestination,standardDestination); | 301 | addItemInt("DestinationPolicy",&mDestination,standardDestination); |
298 | 302 | ||
299 | 303 | ||
300 | 304 | ||
301 | } | 305 | } |
302 | 306 | ||
303 | 307 | ||
304 | KOPrefs::~KOPrefs() | 308 | KOPrefs::~KOPrefs() |
305 | { | 309 | { |
306 | if (mInstance == this) | 310 | if (mInstance == this) |
307 | mInstance = insd.setObject(0); | 311 | mInstance = insd.setObject(0); |
308 | 312 | ||
309 | //qDebug("KOPrefs::~KOPrefs() "); | 313 | //qDebug("KOPrefs::~KOPrefs() "); |
310 | } | 314 | } |
311 | 315 | ||
312 | 316 | ||
313 | KOPrefs *KOPrefs::instance() | 317 | KOPrefs *KOPrefs::instance() |
314 | { | 318 | { |
315 | if (!mInstance) { | 319 | if (!mInstance) { |
316 | mInstance = insd.setObject(new KOPrefs()); | 320 | mInstance = insd.setObject(new KOPrefs()); |
317 | mInstance->readConfig(); | 321 | mInstance->readConfig(); |
318 | } | 322 | } |
319 | 323 | ||
320 | return mInstance; | 324 | return mInstance; |
321 | } | 325 | } |
322 | 326 | ||
323 | void KOPrefs::usrSetDefaults() | 327 | void KOPrefs::usrSetDefaults() |
324 | { | 328 | { |
325 | 329 | ||
326 | } | 330 | } |
327 | 331 | ||
328 | void KOPrefs::fillMailDefaults() | 332 | void KOPrefs::fillMailDefaults() |
329 | { | 333 | { |
330 | if (mName.isEmpty()) mName = i18n("Anonymous"); | 334 | if (mName.isEmpty()) mName = i18n("Anonymous"); |
331 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); | 335 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); |
332 | } | 336 | } |
333 | 337 | ||
334 | void KOPrefs::setTimeZoneIdDefault() | 338 | void KOPrefs::setTimeZoneIdDefault() |
335 | { | 339 | { |
336 | ; | 340 | ; |
337 | } | 341 | } |
338 | 342 | ||
339 | void KOPrefs::setAllDefaults() | 343 | void KOPrefs::setAllDefaults() |
340 | { | 344 | { |
341 | setCategoryDefaults(); | 345 | setCategoryDefaults(); |
342 | mEventSummaryUser = getDefaultList() ; | 346 | mEventSummaryUser = getDefaultList() ; |
343 | mTodoSummaryUser = getDefaultList() ; | 347 | mTodoSummaryUser = getDefaultList() ; |
344 | mLocationDefaults = getLocationDefaultList(); | 348 | mLocationDefaults = getLocationDefaultList(); |
345 | } | 349 | } |
346 | 350 | ||
347 | void KOPrefs::setCategoryDefaults() | 351 | void KOPrefs::setCategoryDefaults() |
348 | { | 352 | { |
349 | mCustomCategories.clear(); | 353 | mCustomCategories.clear(); |
350 | mCustomCategories = getDefaultList(); | 354 | mCustomCategories = getDefaultList(); |
351 | 355 | ||
352 | QStringList::Iterator it; | 356 | QStringList::Iterator it; |
353 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 357 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
354 | setCategoryColor(*it,mDefaultCategoryColor); | 358 | setCategoryColor(*it,mDefaultCategoryColor); |
355 | } | 359 | } |
356 | } | 360 | } |
357 | QStringList KOPrefs::getLocationDefaultList() | 361 | QStringList KOPrefs::getLocationDefaultList() |
358 | { | 362 | { |
359 | QStringList retval ; | 363 | QStringList retval ; |
360 | retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") | 364 | retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") |
361 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") | 365 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") |
362 | << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") | 366 | << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") |
363 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; | 367 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; |
364 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") | 368 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") |
365 | 369 | ||
366 | retval.sort(); | 370 | retval.sort(); |
367 | return retval; | 371 | return retval; |
368 | } | 372 | } |
369 | QStringList KOPrefs::getDefaultList() | 373 | QStringList KOPrefs::getDefaultList() |
370 | { | 374 | { |
371 | QStringList retval ; | 375 | QStringList retval ; |
372 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") | 376 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") |
373 | << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") | 377 | << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") |
374 | << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") | 378 | << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") |
375 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") | 379 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") |
376 | << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") | 380 | << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") |
377 | << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") | 381 | << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") |
378 | << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") | 382 | << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") |
379 | << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; | 383 | << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; |
380 | retval.sort(); | 384 | retval.sort(); |
381 | //qDebug("cat %s ", retval.join("-").latin1()); | 385 | //qDebug("cat %s ", retval.join("-").latin1()); |
382 | return retval; | 386 | return retval; |
383 | } | 387 | } |
384 | 388 | ||
385 | void KOPrefs::usrReadConfig() | 389 | void KOPrefs::usrReadConfig() |
386 | { | 390 | { |
387 | config()->setGroup("General"); | 391 | config()->setGroup("General"); |
388 | 392 | ||
389 | //qDebug("KOPrefs::usrReadConfig() "); | 393 | //qDebug("KOPrefs::usrReadConfig() "); |
390 | mCustomCategories = config()->readListEntry("Custom Categories"); | 394 | mCustomCategories = config()->readListEntry("Custom Categories"); |
391 | mOldLoadedLanguage = mOldLanguage ; | 395 | mOldLoadedLanguage = mOldLanguage ; |
392 | mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; | 396 | mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; |
393 | if (mLocationDefaults.isEmpty()) { | 397 | if (mLocationDefaults.isEmpty()) { |
394 | mLocationDefaults = getLocationDefaultList(); | 398 | mLocationDefaults = getLocationDefaultList(); |
395 | } | 399 | } |
396 | 400 | ||
397 | if (mEventSummaryUser.isEmpty()) { | 401 | if (mEventSummaryUser.isEmpty()) { |
398 | mEventSummaryUser = getDefaultList() ; | 402 | mEventSummaryUser = getDefaultList() ; |
399 | } | 403 | } |
400 | if (mTodoSummaryUser.isEmpty()) { | 404 | if (mTodoSummaryUser.isEmpty()) { |
401 | mTodoSummaryUser = getDefaultList() ; | 405 | mTodoSummaryUser = getDefaultList() ; |
402 | } | 406 | } |
403 | 407 | ||
404 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); | 408 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); |
405 | 409 | ||
406 | config()->setGroup("Personal Settings"); | 410 | config()->setGroup("Personal Settings"); |
407 | mName = config()->readEntry("user_name",""); | 411 | mName = config()->readEntry("user_name",""); |
408 | mEmail = config()->readEntry("user_email",""); | 412 | mEmail = config()->readEntry("user_email",""); |
409 | fillMailDefaults(); | 413 | fillMailDefaults(); |
410 | 414 | ||
411 | config()->setGroup("Category Colors"); | 415 | config()->setGroup("Category Colors"); |
412 | QStringList::Iterator it; | 416 | QStringList::Iterator it; |
413 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 417 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
414 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); | 418 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); |
415 | 419 | ||
416 | } | 420 | } |
417 | 421 | ||
418 | KPimPrefs::usrReadConfig(); | 422 | KPimPrefs::usrReadConfig(); |
419 | } | 423 | } |
420 | 424 | ||
421 | 425 | ||
422 | void KOPrefs::usrWriteConfig() | 426 | void KOPrefs::usrWriteConfig() |
423 | { | 427 | { |
424 | config()->setGroup("General"); | 428 | config()->setGroup("General"); |
425 | config()->writeEntry("Custom Categories",mCustomCategories); | 429 | config()->writeEntry("Custom Categories",mCustomCategories); |
426 | 430 | ||
427 | config()->setGroup("Personal Settings"); | 431 | config()->setGroup("Personal Settings"); |
428 | config()->writeEntry("user_name",mName); | 432 | config()->writeEntry("user_name",mName); |
429 | config()->writeEntry("user_email",mEmail); | 433 | config()->writeEntry("user_email",mEmail); |
430 | 434 | ||
431 | config()->setGroup("Category Colors"); | 435 | config()->setGroup("Category Colors"); |
432 | QDictIterator<QColor> it(mCategoryColors); | 436 | QDictIterator<QColor> it(mCategoryColors); |
433 | while (it.current()) { | 437 | while (it.current()) { |
434 | config()->writeEntry(it.currentKey(),*(it.current())); | 438 | config()->writeEntry(it.currentKey(),*(it.current())); |
435 | ++it; | 439 | ++it; |
436 | } | 440 | } |
437 | 441 | ||
438 | 442 | ||
439 | KPimPrefs::usrWriteConfig(); | 443 | KPimPrefs::usrWriteConfig(); |
440 | } | 444 | } |
441 | 445 | ||
442 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) | 446 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) |
443 | { | 447 | { |
444 | mCategoryColors.replace(cat,new QColor(color)); | 448 | mCategoryColors.replace(cat,new QColor(color)); |
445 | } | 449 | } |
446 | 450 | ||
447 | QColor *KOPrefs::categoryColor(QString cat) | 451 | QColor *KOPrefs::categoryColor(QString cat) |
448 | { | 452 | { |
449 | QColor *color = 0; | 453 | QColor *color = 0; |
450 | 454 | ||
451 | if (!cat.isEmpty()) color = mCategoryColors[cat]; | 455 | if (!cat.isEmpty()) color = mCategoryColors[cat]; |
452 | 456 | ||
453 | if (color) return color; | 457 | if (color) return color; |
454 | else return &mDefaultCategoryColor; | 458 | else return &mDefaultCategoryColor; |
455 | } | 459 | } |
456 | 460 | ||
457 | void KOPrefs::setFullName(const QString &name) | 461 | void KOPrefs::setFullName(const QString &name) |
458 | { | 462 | { |
459 | mName = name; | 463 | mName = name; |
460 | } | 464 | } |
461 | 465 | ||
462 | void KOPrefs::setEmail(const QString &email) | 466 | void KOPrefs::setEmail(const QString &email) |
463 | { | 467 | { |
464 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); | 468 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); |
465 | mEmail = email; | 469 | mEmail = email; |
466 | } | 470 | } |
467 | 471 | ||
468 | QString KOPrefs::fullName() | 472 | QString KOPrefs::fullName() |
469 | { | 473 | { |
470 | if (mEmailControlCenter) { | 474 | if (mEmailControlCenter) { |
471 | KEMailSettings settings; | 475 | KEMailSettings settings; |
472 | return settings.getSetting(KEMailSettings::RealName); | 476 | return settings.getSetting(KEMailSettings::RealName); |
473 | } else { | 477 | } else { |
474 | return mName; | 478 | return mName; |
475 | } | 479 | } |
476 | } | 480 | } |
477 | 481 | ||
478 | QString KOPrefs::email() | 482 | QString KOPrefs::email() |
479 | { | 483 | { |
480 | if (mEmailControlCenter) { | 484 | if (mEmailControlCenter) { |
481 | KEMailSettings settings; | 485 | KEMailSettings settings; |
482 | return settings.getSetting(KEMailSettings::EmailAddress); | 486 | return settings.getSetting(KEMailSettings::EmailAddress); |
483 | } else { | 487 | } else { |
484 | return mEmail; | 488 | return mEmail; |
485 | } | 489 | } |
486 | } | 490 | } |
487 | KConfig* KOPrefs::getConfig() | 491 | KConfig* KOPrefs::getConfig() |
488 | { | 492 | { |
489 | return config(); | 493 | return config(); |
490 | } | 494 | } |
diff --git a/korganizer/ktimeedit.cpp b/korganizer/ktimeedit.cpp index 5222ac9..61a0931 100644 --- a/korganizer/ktimeedit.cpp +++ b/korganizer/ktimeedit.cpp | |||
@@ -1,474 +1,476 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1999 Preston Brown, Ian Dawes | 3 | Copyright (c) 1999 Preston Brown, Ian Dawes |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qkeycode.h> | 24 | #include <qkeycode.h> |
25 | #include <qcombobox.h> | 25 | #include <qcombobox.h> |
26 | #include <qdatetime.h> | 26 | #include <qdatetime.h> |
27 | #include <qlineedit.h> | 27 | #include <qlineedit.h> |
28 | #include <qlistbox.h> | 28 | #include <qlistbox.h> |
29 | #include <qapplication.h> | 29 | #include <qapplication.h> |
30 | 30 | ||
31 | #include <kmessagebox.h> | 31 | #include <kmessagebox.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <kdebug.h> | 33 | #include <kdebug.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kpimglobalprefs.h> | 35 | #include <kpimglobalprefs.h> |
36 | 36 | ||
37 | #include "ktimeedit.h" | 37 | #include "ktimeedit.h" |
38 | #include "koprefs.h" | 38 | #include "koprefs.h" |
39 | #include <qvalidator.h> | 39 | #include <qvalidator.h> |
40 | 40 | ||
41 | // Validator for a time value with only hours and minutes (no seconds) | 41 | // Validator for a time value with only hours and minutes (no seconds) |
42 | // Mostly locale aware. Author: David Faure <faure@kde.org> | 42 | // Mostly locale aware. Author: David Faure <faure@kde.org> |
43 | 43 | ||
44 | // KTimeWidget/QTimeEdit provide nicer editing, but don't provide a combobox. | 44 | // KTimeWidget/QTimeEdit provide nicer editing, but don't provide a combobox. |
45 | // Difficult to get all in one... | 45 | // Difficult to get all in one... |
46 | // But Qt-3.2 will offer QLineEdit::setMask, so a "99:99" mask would help. | 46 | // But Qt-3.2 will offer QLineEdit::setMask, so a "99:99" mask would help. |
47 | KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name) | 47 | KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name) |
48 | : QComboBox(TRUE, parent, name) | 48 | : QComboBox(TRUE, parent, name) |
49 | { | 49 | { |
50 | setInsertionPolicy(NoInsertion); | 50 | setInsertionPolicy(NoInsertion); |
51 | mFlagKeyPressed = false; | 51 | mFlagKeyPressed = false; |
52 | 52 | if ( QApplication::desktop()->height() <= 480 ) { | |
53 | if ( QApplication::desktop()->width() < 650 ) | ||
54 | setSizeLimit ( 6 ); | 53 | setSizeLimit ( 6 ); |
55 | mTime = qt; | 54 | } else { |
55 | setSizeLimit ( 12 ); | ||
56 | } | ||
57 | mTime = qt; | ||
56 | 58 | ||
57 | // mNoTimeString = i18n("No Time"); | 59 | // mNoTimeString = i18n("No Time"); |
58 | // insertItem( mNoTimeString ); | 60 | // insertItem( mNoTimeString ); |
59 | 61 | ||
60 | // Fill combo box with selection of times in localized format. | 62 | // Fill combo box with selection of times in localized format. |
61 | QTime timeEntry(0,0,0); | 63 | QTime timeEntry(0,0,0); |
62 | do { | 64 | do { |
63 | insertItem(KGlobal::locale()->formatTime(timeEntry)); | 65 | insertItem(KGlobal::locale()->formatTime(timeEntry)); |
64 | timeEntry = timeEntry.addSecs(60*15); | 66 | timeEntry = timeEntry.addSecs(60*15); |
65 | } while (!timeEntry.isNull()); | 67 | } while (!timeEntry.isNull()); |
66 | // Add end of day. | 68 | // Add end of day. |
67 | insertItem( KGlobal::locale()->formatTime( QTime( 23, 59, 59 ) ) ); | 69 | insertItem( KGlobal::locale()->formatTime( QTime( 23, 59, 59 ) ) ); |
68 | 70 | ||
69 | updateText(); | 71 | updateText(); |
70 | setFocusPolicy(QWidget::StrongFocus); | 72 | setFocusPolicy(QWidget::StrongFocus); |
71 | 73 | ||
72 | connect(this, SIGNAL(activated(int)), this, SLOT(activ(int))); | 74 | connect(this, SIGNAL(activated(int)), this, SLOT(activ(int))); |
73 | connect(this, SIGNAL(highlighted(int)), this, SLOT(hilit(int))); | 75 | connect(this, SIGNAL(highlighted(int)), this, SLOT(hilit(int))); |
74 | connect(this,SIGNAL(textChanged(const QString&)),this,SLOT(changedText())); | 76 | connect(this,SIGNAL(textChanged(const QString&)),this,SLOT(changedText())); |
75 | QFontMetrics fm ( font() ); | 77 | QFontMetrics fm ( font() ); |
76 | QString timeString = "24:00"; | 78 | QString timeString = "24:00"; |
77 | if ( KPimGlobalPrefs::instance()->mPreferredTime == 1 ) | 79 | if ( KPimGlobalPrefs::instance()->mPreferredTime == 1 ) |
78 | timeString = "02:00pm"; | 80 | timeString = "02:00pm"; |
79 | int addSpace = 32; | 81 | int addSpace = 32; |
80 | if ( QApplication::desktop()->width() > 320 ) | 82 | if ( QApplication::desktop()->width() > 320 ) |
81 | timeString += ":00"; | 83 | timeString += ":00"; |
82 | setFixedWidth(fm.width( timeString ) + 32 ); | 84 | setFixedWidth(fm.width( timeString ) + 32 ); |
83 | 85 | ||
84 | // Highlight Background and Textcolor change from default | 86 | // Highlight Background and Textcolor change from default |
85 | QPalette palette = QWidget::palette(); | 87 | QPalette palette = QWidget::palette(); |
86 | unsigned char red, green, blue; | 88 | unsigned char red, green, blue; |
87 | red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10; | 89 | red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10; |
88 | green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10; | 90 | green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10; |
89 | blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10; | 91 | blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10; |
90 | palette.setColor( QColorGroup::Highlight, QColor(red,green,blue) ); | 92 | palette.setColor( QColorGroup::Highlight, QColor(red,green,blue) ); |
91 | palette.setColor( QColorGroup::HighlightedText, palette.color( QPalette::Normal , QColorGroup::Foreground ) ); | 93 | palette.setColor( QColorGroup::HighlightedText, palette.color( QPalette::Normal , QColorGroup::Foreground ) ); |
92 | setPalette( palette ); | 94 | setPalette( palette ); |
93 | } | 95 | } |
94 | 96 | ||
95 | KOTimeEdit::~KOTimeEdit() | 97 | KOTimeEdit::~KOTimeEdit() |
96 | { | 98 | { |
97 | } | 99 | } |
98 | 100 | ||
99 | bool KOTimeEdit::hasTime() const | 101 | bool KOTimeEdit::hasTime() const |
100 | { | 102 | { |
101 | // Can't happen | 103 | // Can't happen |
102 | if ( currentText().isEmpty() ) return false; | 104 | if ( currentText().isEmpty() ) return false; |
103 | //if ( currentText() == mNoTimeString ) return false; | 105 | //if ( currentText() == mNoTimeString ) return false; |
104 | 106 | ||
105 | return true; // always | 107 | return true; // always |
106 | } | 108 | } |
107 | 109 | ||
108 | QTime KOTimeEdit::getTime() const | 110 | QTime KOTimeEdit::getTime() const |
109 | { | 111 | { |
110 | return KGlobal::locale()->readTime(currentText()); | 112 | return KGlobal::locale()->readTime(currentText()); |
111 | } | 113 | } |
112 | /* | 114 | /* |
113 | QSizePolicy KOTimeEdit::sizePolicy() const | 115 | QSizePolicy KOTimeEdit::sizePolicy() const |
114 | { | 116 | { |
115 | // Set size policy to Fixed, because edit cannot contain more text than the | 117 | // Set size policy to Fixed, because edit cannot contain more text than the |
116 | // string representing the time. It doesn't make sense to provide more space. | 118 | // string representing the time. It doesn't make sense to provide more space. |
117 | QSizePolicy sizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); | 119 | QSizePolicy sizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); |
118 | 120 | ||
119 | return sizePolicy; | 121 | return sizePolicy; |
120 | } | 122 | } |
121 | */ | 123 | */ |
122 | void KOTimeEdit::setTime(QTime newTime) | 124 | void KOTimeEdit::setTime(QTime newTime) |
123 | { | 125 | { |
124 | if ( mTime != newTime ) | 126 | if ( mTime != newTime ) |
125 | { | 127 | { |
126 | mTime = newTime; | 128 | mTime = newTime; |
127 | updateText(); | 129 | updateText(); |
128 | } | 130 | } |
129 | 131 | ||
130 | } | 132 | } |
131 | 133 | ||
132 | void KOTimeEdit::activ(int i) | 134 | void KOTimeEdit::activ(int i) |
133 | { | 135 | { |
134 | // The last entry, 23:59, is a special case | 136 | // The last entry, 23:59, is a special case |
135 | if( i == count() - 1 ) | 137 | if( i == count() - 1 ) |
136 | mTime = QTime( 23, 59, 0 ); | 138 | mTime = QTime( 23, 59, 0 ); |
137 | else | 139 | else |
138 | mTime = QTime(0,0,0).addSecs(i*15*60); | 140 | mTime = QTime(0,0,0).addSecs(i*15*60); |
139 | emit timeChanged(mTime); | 141 | emit timeChanged(mTime); |
140 | } | 142 | } |
141 | 143 | ||
142 | void KOTimeEdit::hilit(int ) | 144 | void KOTimeEdit::hilit(int ) |
143 | { | 145 | { |
144 | // we don't currently need to do anything here. | 146 | // we don't currently need to do anything here. |
145 | } | 147 | } |
146 | 148 | ||
147 | void KOTimeEdit::addTime(QTime qt, bool update) | 149 | void KOTimeEdit::addTime(QTime qt, bool update) |
148 | { | 150 | { |
149 | // Calculate the new time. | 151 | // Calculate the new time. |
150 | //qDebug("add h %d min %d ", qt.hour(),qt.minute() ); | 152 | //qDebug("add h %d min %d ", qt.hour(),qt.minute() ); |
151 | mTime = mTime.addSecs(qt.minute()*60+qt.hour()*3600); | 153 | mTime = mTime.addSecs(qt.minute()*60+qt.hour()*3600); |
152 | // if ( update ) | 154 | // if ( update ) |
153 | updateText(); | 155 | updateText(); |
154 | emit timeChanged(mTime); | 156 | emit timeChanged(mTime); |
155 | } | 157 | } |
156 | 158 | ||
157 | void KOTimeEdit::subTime(QTime qt, bool update) | 159 | void KOTimeEdit::subTime(QTime qt, bool update) |
158 | { | 160 | { |
159 | int h, m; | 161 | int h, m; |
160 | //qDebug("sub h %d min %d ", qt.hour(),qt.minute() ); | 162 | //qDebug("sub h %d min %d ", qt.hour(),qt.minute() ); |
161 | 163 | ||
162 | mTime = mTime.addSecs(-(qt.minute()*60+qt.hour()*3600)); | 164 | mTime = mTime.addSecs(-(qt.minute()*60+qt.hour()*3600)); |
163 | // store the newly calculated time. | 165 | // store the newly calculated time. |
164 | // mTime.setHMS(h, m, 0); | 166 | // mTime.setHMS(h, m, 0); |
165 | //if ( update ) | 167 | //if ( update ) |
166 | updateText(); | 168 | updateText(); |
167 | emit timeChanged(mTime); | 169 | emit timeChanged(mTime); |
168 | } | 170 | } |
169 | 171 | ||
170 | // void KOTimeEdit::mouseReleaseEvent ( QMouseEvent * ) | 172 | // void KOTimeEdit::mouseReleaseEvent ( QMouseEvent * ) |
171 | // { | 173 | // { |
172 | // qDebug("mouseReleaseEvent ( QMouseEvent * ) "); | 174 | // qDebug("mouseReleaseEvent ( QMouseEvent * ) "); |
173 | // } | 175 | // } |
174 | 176 | ||
175 | // void KOTimeEdit::focusInEvent ( QFocusEvent * ) | 177 | // void KOTimeEdit::focusInEvent ( QFocusEvent * ) |
176 | // { | 178 | // { |
177 | // qDebug("focusInEvent ( QFocusEvent * ) "); | 179 | // qDebug("focusInEvent ( QFocusEvent * ) "); |
178 | // } | 180 | // } |
179 | 181 | ||
180 | void KOTimeEdit::keyReleaseEvent(QKeyEvent *e) | 182 | void KOTimeEdit::keyReleaseEvent(QKeyEvent *e) |
181 | { | 183 | { |
182 | if ( !e->isAutoRepeat() ) { | 184 | if ( !e->isAutoRepeat() ) { |
183 | mFlagKeyPressed = false; | 185 | mFlagKeyPressed = false; |
184 | } | 186 | } |
185 | 187 | ||
186 | } | 188 | } |
187 | void KOTimeEdit::setSelect( int from, int to ) | 189 | void KOTimeEdit::setSelect( int from, int to ) |
188 | { | 190 | { |
189 | if ( KOPrefs::instance()->mHightlightDateTimeEdit) | 191 | if ( KOPrefs::instance()->mHightlightDateTimeEdit) |
190 | lineEdit()->setSelection( from , to ); | 192 | lineEdit()->setSelection( from , to ); |
191 | } | 193 | } |
192 | 194 | ||
193 | 195 | ||
194 | void KOTimeEdit::keyPressEvent(QKeyEvent *e) | 196 | void KOTimeEdit::keyPressEvent(QKeyEvent *e) |
195 | { | 197 | { |
196 | 198 | ||
197 | qApp->processEvents(); | 199 | qApp->processEvents(); |
198 | bool hour12Format = ( KPimGlobalPrefs::instance()->mPreferredTime == 1 ); | 200 | bool hour12Format = ( KPimGlobalPrefs::instance()->mPreferredTime == 1 ); |
199 | int maxpos = hour12Format?7:5; | 201 | int maxpos = hour12Format?7:5; |
200 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 202 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
201 | e->ignore(); | 203 | e->ignore(); |
202 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 204 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
203 | return; | 205 | return; |
204 | } | 206 | } |
205 | if (! e->isAutoRepeat() ) { | 207 | if (! e->isAutoRepeat() ) { |
206 | mFlagKeyPressed = true; | 208 | mFlagKeyPressed = true; |
207 | } | 209 | } |
208 | // Tap -> Focus Next Widget | 210 | // Tap -> Focus Next Widget |
209 | if ( e->key() == Key_Tab ) { | 211 | if ( e->key() == Key_Tab ) { |
210 | QComboBox::keyPressEvent(e); | 212 | QComboBox::keyPressEvent(e); |
211 | return; | 213 | return; |
212 | } | 214 | } |
213 | 215 | ||
214 | // save Text from QLineEdit and CursorPosition | 216 | // save Text from QLineEdit and CursorPosition |
215 | QString text = lineEdit()->text(); | 217 | QString text = lineEdit()->text(); |
216 | int cpos = lineEdit()->cursorPosition(); | 218 | int cpos = lineEdit()->cursorPosition(); |
217 | // qDebug("cpos %d ", cpos); | 219 | // qDebug("cpos %d ", cpos); |
218 | 220 | ||
219 | // Switch for arrows, backspace and escape | 221 | // Switch for arrows, backspace and escape |
220 | switch(e->key()) { | 222 | switch(e->key()) { |
221 | case Key_Escape: | 223 | case Key_Escape: |
222 | lineEdit()->deselect(); | 224 | lineEdit()->deselect(); |
223 | case Key_Tab: | 225 | case Key_Tab: |
224 | QComboBox::keyPressEvent(e); | 226 | QComboBox::keyPressEvent(e); |
225 | break; | 227 | break; |
226 | case Key_Up: | 228 | case Key_Up: |
227 | if ( e->state () == Qt::ControlButton ) { | 229 | if ( e->state () == Qt::ControlButton ) { |
228 | addTime(QTime(0,15,0), false ); | 230 | addTime(QTime(0,15,0), false ); |
229 | lineEdit()->setCursorPosition(3); | 231 | lineEdit()->setCursorPosition(3); |
230 | setSelect( 3 , 2 ); | 232 | setSelect( 3 , 2 ); |
231 | } | 233 | } |
232 | else | 234 | else |
233 | if ( e->state () == Qt::ShiftButton ) { | 235 | if ( e->state () == Qt::ShiftButton ) { |
234 | addTime(QTime(1,0,0), false ); | 236 | addTime(QTime(1,0,0), false ); |
235 | lineEdit()->setCursorPosition(0); | 237 | lineEdit()->setCursorPosition(0); |
236 | setSelect( 0 , 2 ); | 238 | setSelect( 0 , 2 ); |
237 | } | 239 | } |
238 | else | 240 | else |
239 | // switch time up, cursor location depend | 241 | // switch time up, cursor location depend |
240 | switch (cpos) { | 242 | switch (cpos) { |
241 | case 7: | 243 | case 7: |
242 | case 6: | 244 | case 6: |
243 | case 5: | 245 | case 5: |
244 | if(!hour12Format) { | 246 | if(!hour12Format) { |
245 | lineEdit()->setCursorPosition(cpos = 4); | 247 | lineEdit()->setCursorPosition(cpos = 4); |
246 | } else { | 248 | } else { |
247 | addTime(QTime(12,0,0), false ); | 249 | addTime(QTime(12,0,0), false ); |
248 | setSelect ( 5 , 2 ); | 250 | setSelect ( 5 , 2 ); |
249 | break; | 251 | break; |
250 | } | 252 | } |
251 | case 4: | 253 | case 4: |
252 | addTime(QTime(0,1,0), false ); | 254 | addTime(QTime(0,1,0), false ); |
253 | setSelect ( cpos , 1 ); | 255 | setSelect ( cpos , 1 ); |
254 | break; | 256 | break; |
255 | case 3: | 257 | case 3: |
256 | addTime(QTime(0,10,0), false ); | 258 | addTime(QTime(0,10,0), false ); |
257 | setSelect ( cpos , 1 ); | 259 | setSelect ( cpos , 1 ); |
258 | break; | 260 | break; |
259 | case 2: | 261 | case 2: |
260 | lineEdit()->setCursorPosition(--cpos); | 262 | lineEdit()->setCursorPosition(--cpos); |
261 | case 1: | 263 | case 1: |
262 | case 0: | 264 | case 0: |
263 | addTime(QTime(1,0,0), false ); | 265 | addTime(QTime(1,0,0), false ); |
264 | setSelect ( 0, 2 ); | 266 | setSelect ( 0, 2 ); |
265 | break; | 267 | break; |
266 | } | 268 | } |
267 | break; | 269 | break; |
268 | case Key_Down: | 270 | case Key_Down: |
269 | if ( e->state () == Qt::ControlButton ) { | 271 | if ( e->state () == Qt::ControlButton ) { |
270 | subTime(QTime(0,15,0), false ); | 272 | subTime(QTime(0,15,0), false ); |
271 | lineEdit()->setCursorPosition(3); | 273 | lineEdit()->setCursorPosition(3); |
272 | setSelect( 3 , 2 ); | 274 | setSelect( 3 , 2 ); |
273 | } | 275 | } |
274 | else | 276 | else |
275 | if ( e->state () == Qt::ShiftButton ) { | 277 | if ( e->state () == Qt::ShiftButton ) { |
276 | subTime(QTime(1,0,0), false ); | 278 | subTime(QTime(1,0,0), false ); |
277 | lineEdit()->setCursorPosition(0); | 279 | lineEdit()->setCursorPosition(0); |
278 | setSelect( 0 , 2 ); | 280 | setSelect( 0 , 2 ); |
279 | } | 281 | } |
280 | else | 282 | else |
281 | // switch time down, cursor location depend | 283 | // switch time down, cursor location depend |
282 | switch (cpos) { | 284 | switch (cpos) { |
283 | case 7: | 285 | case 7: |
284 | case 6: | 286 | case 6: |
285 | case 5: | 287 | case 5: |
286 | if(!hour12Format) { | 288 | if(!hour12Format) { |
287 | lineEdit()->setCursorPosition(cpos = 4); | 289 | lineEdit()->setCursorPosition(cpos = 4); |
288 | } else { | 290 | } else { |
289 | subTime(QTime(12,0,0), false ); | 291 | subTime(QTime(12,0,0), false ); |
290 | setSelect ( 5 , 2 ); | 292 | setSelect ( 5 , 2 ); |
291 | break; | 293 | break; |
292 | } | 294 | } |
293 | case 4: | 295 | case 4: |
294 | subTime(QTime(0,1,0), false ); | 296 | subTime(QTime(0,1,0), false ); |
295 | setSelect ( cpos , 1 ); | 297 | setSelect ( cpos , 1 ); |
296 | break; | 298 | break; |
297 | case 3: | 299 | case 3: |
298 | subTime(QTime(0,10,0), false ); | 300 | subTime(QTime(0,10,0), false ); |
299 | setSelect ( cpos , 1 ); | 301 | setSelect ( cpos , 1 ); |
300 | break; | 302 | break; |
301 | case 2: | 303 | case 2: |
302 | lineEdit()->setCursorPosition(--cpos); | 304 | lineEdit()->setCursorPosition(--cpos); |
303 | case 1: | 305 | case 1: |
304 | case 0: | 306 | case 0: |
305 | subTime(QTime(1,0,0), false ); | 307 | subTime(QTime(1,0,0), false ); |
306 | setSelect ( 0 , 2 ); | 308 | setSelect ( 0 , 2 ); |
307 | break; | 309 | break; |
308 | } | 310 | } |
309 | break; | 311 | break; |
310 | // set cursor to correct place | 312 | // set cursor to correct place |
311 | case Key_Left: | 313 | case Key_Left: |
312 | if ( cpos == 3 ) | 314 | if ( cpos == 3 ) |
313 | --cpos; | 315 | --cpos; |
314 | if ( cpos > 0) { | 316 | if ( cpos > 0) { |
315 | lineEdit()->setCursorPosition(--cpos); | 317 | lineEdit()->setCursorPosition(--cpos); |
316 | setSelect ( cpos , 1 ); | 318 | setSelect ( cpos , 1 ); |
317 | } | 319 | } |
318 | else | 320 | else |
319 | setSelect ( 0 , 1 ); | 321 | setSelect ( 0 , 1 ); |
320 | break; | 322 | break; |
321 | // set cursor to correct place | 323 | // set cursor to correct place |
322 | case Key_Right: | 324 | case Key_Right: |
323 | if ( cpos == 1 ) | 325 | if ( cpos == 1 ) |
324 | ++cpos; | 326 | ++cpos; |
325 | if ( cpos < maxpos ) { | 327 | if ( cpos < maxpos ) { |
326 | lineEdit()->setCursorPosition(++cpos); | 328 | lineEdit()->setCursorPosition(++cpos); |
327 | setSelect ( cpos , 1 ); | 329 | setSelect ( cpos , 1 ); |
328 | } | 330 | } |
329 | break; | 331 | break; |
330 | // rest | 332 | // rest |
331 | case Key_Prior: | 333 | case Key_Prior: |
332 | subTime(QTime(1,0,0)); | 334 | subTime(QTime(1,0,0)); |
333 | break; | 335 | break; |
334 | case Key_Next: | 336 | case Key_Next: |
335 | addTime(QTime(1,0,0)); | 337 | addTime(QTime(1,0,0)); |
336 | break; | 338 | break; |
337 | case Key_Backspace: | 339 | case Key_Backspace: |
338 | qDebug("+++++++++++back "); | 340 | qDebug("+++++++++++back "); |
339 | if ( cpos > 0) { | 341 | if ( cpos > 0) { |
340 | if ( cpos == 3 ) | 342 | if ( cpos == 3 ) |
341 | --cpos; | 343 | --cpos; |
342 | if ( cpos > 5) | 344 | if ( cpos > 5) |
343 | cpos = 5; | 345 | cpos = 5; |
344 | text.at( cpos-1 ) = '0'; | 346 | text.at( cpos-1 ) = '0'; |
345 | lineEdit()->setText( text ); | 347 | lineEdit()->setText( text ); |
346 | lineEdit()->setCursorPosition(--cpos); | 348 | lineEdit()->setCursorPosition(--cpos); |
347 | setSelect ( cpos , 1 ); | 349 | setSelect ( cpos , 1 ); |
348 | changedText(); | 350 | changedText(); |
349 | qDebug("---------back "); | 351 | qDebug("---------back "); |
350 | } | 352 | } |
351 | break; | 353 | break; |
352 | } // switch arrows | 354 | } // switch arrows |
353 | 355 | ||
354 | // if cursor at string end, alltext market and keyEvent don't ArrowLeft -> deselect and cpos | 356 | // if cursor at string end, alltext market and keyEvent don't ArrowLeft -> deselect and cpos |
355 | if( cpos > 4 && lineEdit()->markedText().length() == 5 && e->key() != Key_Left ) { | 357 | if( cpos > 4 && lineEdit()->markedText().length() == 5 && e->key() != Key_Left ) { |
356 | lineEdit()->deselect(); | 358 | lineEdit()->deselect(); |
357 | cpos = 0; | 359 | cpos = 0; |
358 | lineEdit()->setCursorPosition(cpos); | 360 | lineEdit()->setCursorPosition(cpos); |
359 | setSelect(cpos , 1); | 361 | setSelect(cpos , 1); |
360 | } | 362 | } |
361 | 363 | ||
362 | if ( cpos == 2 ) { | 364 | if ( cpos == 2 ) { |
363 | lineEdit()->setCursorPosition(++cpos); | 365 | lineEdit()->setCursorPosition(++cpos); |
364 | } | 366 | } |
365 | 367 | ||
366 | // num keys when cursorPos preEnd | 368 | // num keys when cursorPos preEnd |
367 | if ( cpos < 5 ) { | 369 | if ( cpos < 5 ) { |
368 | // switch another keys | 370 | // switch another keys |
369 | switch(e->key()) { | 371 | switch(e->key()) { |
370 | case Key_Delete: | 372 | case Key_Delete: |
371 | text.at( cpos ) = '0'; | 373 | text.at( cpos ) = '0'; |
372 | lineEdit()->setText( text ); | 374 | lineEdit()->setText( text ); |
373 | lineEdit()->setCursorPosition(cpos); | 375 | lineEdit()->setCursorPosition(cpos); |
374 | setSelect ( cpos , 1 ); | 376 | setSelect ( cpos , 1 ); |
375 | changedText(); | 377 | changedText(); |
376 | break; | 378 | break; |
377 | case Key_9: | 379 | case Key_9: |
378 | case Key_8: | 380 | case Key_8: |
379 | case Key_7: | 381 | case Key_7: |
380 | case Key_6: | 382 | case Key_6: |
381 | if ( !(cpos == 1 || cpos == 4) ) | 383 | if ( !(cpos == 1 || cpos == 4) ) |
382 | return; | 384 | return; |
383 | if ( cpos == 1 && text.at( 0 ) > '1') | 385 | if ( cpos == 1 && text.at( 0 ) > '1') |
384 | text.at( 0 ) = '1'; | 386 | text.at( 0 ) = '1'; |
385 | case Key_5: | 387 | case Key_5: |
386 | case Key_4: | 388 | case Key_4: |
387 | case Key_3: | 389 | case Key_3: |
388 | if ( cpos < 1 ) | 390 | if ( cpos < 1 ) |
389 | return; | 391 | return; |
390 | if ( hour12Format && cpos == 1 ) | 392 | if ( hour12Format && cpos == 1 ) |
391 | return; | 393 | return; |
392 | case Key_2: | 394 | case Key_2: |
393 | if ( hour12Format && cpos == 0 ) | 395 | if ( hour12Format && cpos == 0 ) |
394 | return; | 396 | return; |
395 | if ( cpos == 0 && text.at( 1 ) > '3') | 397 | if ( cpos == 0 && text.at( 1 ) > '3') |
396 | text.at( 1 ) = '3'; | 398 | text.at( 1 ) = '3'; |
397 | case Key_1: | 399 | case Key_1: |
398 | case Key_0: | 400 | case Key_0: |
399 | if ( hour12Format ) { | 401 | if ( hour12Format ) { |
400 | if ( e->key() == Key_0 && cpos == 1 && text.at( 0 ) == '0' ) | 402 | if ( e->key() == Key_0 && cpos == 1 && text.at( 0 ) == '0' ) |
401 | return; | 403 | return; |
402 | if ( e->key() == Key_0 && cpos == 0 && text.at( 1 ) == '0' ) | 404 | if ( e->key() == Key_0 && cpos == 0 && text.at( 1 ) == '0' ) |
403 | text.at( 1 ) = '1'; | 405 | text.at( 1 ) = '1'; |
404 | } | 406 | } |
405 | text.at( cpos ) = QChar ( e->key() ); | 407 | text.at( cpos ) = QChar ( e->key() ); |
406 | lineEdit()->setText( text ); | 408 | lineEdit()->setText( text ); |
407 | if ( cpos == 1 ) | 409 | if ( cpos == 1 ) |
408 | ++cpos; | 410 | ++cpos; |
409 | if ( cpos < 5) | 411 | if ( cpos < 5) |
410 | lineEdit()->setCursorPosition(++cpos); | 412 | lineEdit()->setCursorPosition(++cpos); |
411 | setSelect( cpos , 1 ); | 413 | setSelect( cpos , 1 ); |
412 | changedText(); | 414 | changedText(); |
413 | break; | 415 | break; |
414 | case Key_Home: | 416 | case Key_Home: |
415 | lineEdit()->setCursorPosition(0); | 417 | lineEdit()->setCursorPosition(0); |
416 | setSelect( cpos , 1 ); | 418 | setSelect( cpos , 1 ); |
417 | break; | 419 | break; |
418 | case Key_End: | 420 | case Key_End: |
419 | lineEdit()->setCursorPosition(5); | 421 | lineEdit()->setCursorPosition(5); |
420 | lineEdit()->deselect(); | 422 | lineEdit()->deselect(); |
421 | break; | 423 | break; |
422 | default: | 424 | default: |
423 | // QComboBox::keyPressEvent(e); | 425 | // QComboBox::keyPressEvent(e); |
424 | break; | 426 | break; |
425 | } // switch num keys | 427 | } // switch num keys |
426 | } else if ( cpos == 5 ) {// if cpos < 5 | 428 | } else if ( cpos == 5 ) {// if cpos < 5 |
427 | if ( hour12Format ) { | 429 | if ( hour12Format ) { |
428 | if ( e->key() == Key_A ) { | 430 | if ( e->key() == Key_A ) { |
429 | text.at( 5 ) = 'a'; | 431 | text.at( 5 ) = 'a'; |
430 | lineEdit()->setText( text ); | 432 | lineEdit()->setText( text ); |
431 | lineEdit()->setCursorPosition(5); | 433 | lineEdit()->setCursorPosition(5); |
432 | 434 | ||
433 | } else if ( e->key() == Key_P ) { | 435 | } else if ( e->key() == Key_P ) { |
434 | text.at( 5 ) = 'p'; | 436 | text.at( 5 ) = 'p'; |
435 | lineEdit()->setText( text ); | 437 | lineEdit()->setText( text ); |
436 | lineEdit()->setCursorPosition(5); | 438 | lineEdit()->setCursorPosition(5); |
437 | 439 | ||
438 | } | 440 | } |
439 | } | 441 | } |
440 | } | 442 | } |
441 | 443 | ||
442 | 444 | ||
443 | } | 445 | } |
444 | 446 | ||
445 | void KOTimeEdit::updateText() | 447 | void KOTimeEdit::updateText() |
446 | { | 448 | { |
447 | listBox()->blockSignals( true ); | 449 | listBox()->blockSignals( true ); |
448 | blockSignals( true ); | 450 | blockSignals( true ); |
449 | QString s = KGlobal::locale()->formatTime(mTime); | 451 | QString s = KGlobal::locale()->formatTime(mTime); |
450 | // Set the text but without emitting signals, nor losing the cursor position | 452 | // Set the text but without emitting signals, nor losing the cursor position |
451 | QLineEdit *line = lineEdit(); | 453 | QLineEdit *line = lineEdit(); |
452 | line->blockSignals(true); | 454 | line->blockSignals(true); |
453 | int pos = line->cursorPosition(); | 455 | int pos = line->cursorPosition(); |
454 | setCurrentItem((mTime.hour()*4)+(mTime.minute()/15)); | 456 | setCurrentItem((mTime.hour()*4)+(mTime.minute()/15)); |
455 | line->setText(s); | 457 | line->setText(s); |
456 | line->setCursorPosition(pos); | 458 | line->setCursorPosition(pos); |
457 | line->blockSignals(false); | 459 | line->blockSignals(false); |
458 | blockSignals( false ); | 460 | blockSignals( false ); |
459 | listBox()->blockSignals( false ); | 461 | listBox()->blockSignals( false ); |
460 | 462 | ||
461 | } | 463 | } |
462 | 464 | ||
463 | void KOTimeEdit::changedText() | 465 | void KOTimeEdit::changedText() |
464 | { | 466 | { |
465 | int pos = lineEdit()->cursorPosition(); | 467 | int pos = lineEdit()->cursorPosition(); |
466 | mTime = getTime(); | 468 | mTime = getTime(); |
467 | blockSignals( true ); | 469 | blockSignals( true ); |
468 | QString text = lineEdit()->text(); | 470 | QString text = lineEdit()->text(); |
469 | setCurrentItem((mTime.hour()*4)+(mTime.minute()/15)); | 471 | setCurrentItem((mTime.hour()*4)+(mTime.minute()/15)); |
470 | lineEdit()->setText(text); | 472 | lineEdit()->setText(text); |
471 | blockSignals( false ); | 473 | blockSignals( false ); |
472 | emit timeChanged(mTime); | 474 | emit timeChanged(mTime); |
473 | lineEdit()->setCursorPosition(pos); | 475 | lineEdit()->setCursorPosition(pos); |
474 | } | 476 | } |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 7810bf9..61c39f5 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1265,785 +1265,802 @@ void MainWindow::keyBindings() | |||
1265 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1265 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1266 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1266 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1267 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ | 1267 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ |
1268 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1268 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1269 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1269 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1270 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ | 1270 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ |
1271 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1271 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1272 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1272 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1273 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1273 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1274 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1274 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1275 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1275 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1276 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ | 1276 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ |
1277 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1277 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1278 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1278 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1279 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1279 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1280 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1280 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1281 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1281 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1282 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1282 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1283 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1283 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1284 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1284 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1285 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1285 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1286 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1286 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1287 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ | 1287 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ |
1288 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ | 1288 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ |
1289 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ | 1289 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ |
1290 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1290 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1291 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1291 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1292 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1292 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1293 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1293 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1294 | i18n("<p><h3>In list view:</h3></p>\n") + | 1294 | i18n("<p><h3>In list view:</h3></p>\n") + |
1295 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1295 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1296 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1296 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1297 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1297 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1298 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1298 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1299 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1299 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1300 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1300 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1301 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1301 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1302 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1302 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1303 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1303 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1304 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1304 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1305 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1305 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1306 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1306 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1307 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1307 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1308 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1308 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1309 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1309 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1310 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1310 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1311 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1311 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1312 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1312 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1313 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1313 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1314 | displayText( text, cap); | 1314 | displayText( text, cap); |
1315 | } | 1315 | } |
1316 | void MainWindow::aboutAutoSaving() | 1316 | void MainWindow::aboutAutoSaving() |
1317 | { | 1317 | { |
1318 | QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); | 1318 | QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); |
1319 | 1319 | ||
1320 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); | 1320 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); |
1321 | 1321 | ||
1322 | } | 1322 | } |
1323 | void MainWindow::aboutKnownBugs() | 1323 | void MainWindow::aboutKnownBugs() |
1324 | { | 1324 | { |
1325 | QMessageBox* msg; | 1325 | QMessageBox* msg; |
1326 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1326 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1327 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ | 1327 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ |
1328 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1328 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1329 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + | 1329 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + |
1330 | i18n("\nor report them in the bugtracker on\n") + | 1330 | i18n("\nor report them in the bugtracker on\n") + |
1331 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1331 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1332 | QMessageBox::NoIcon, | 1332 | QMessageBox::NoIcon, |
1333 | QMessageBox::Ok, | 1333 | QMessageBox::Ok, |
1334 | QMessageBox::NoButton, | 1334 | QMessageBox::NoButton, |
1335 | QMessageBox::NoButton); | 1335 | QMessageBox::NoButton); |
1336 | msg->exec(); | 1336 | msg->exec(); |
1337 | delete msg; | 1337 | delete msg; |
1338 | 1338 | ||
1339 | } | 1339 | } |
1340 | 1340 | ||
1341 | QString MainWindow::defaultFileName() | 1341 | QString MainWindow::defaultFileName() |
1342 | { | 1342 | { |
1343 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1343 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1344 | } | 1344 | } |
1345 | QString MainWindow::syncFileName() | 1345 | QString MainWindow::syncFileName() |
1346 | { | 1346 | { |
1347 | #ifdef DESKTOP_VERSION | 1347 | #ifdef DESKTOP_VERSION |
1348 | return locateLocal( "tmp", "synccalendar.ics" ); | 1348 | return locateLocal( "tmp", "synccalendar.ics" ); |
1349 | #else | 1349 | #else |
1350 | return QString( "/tmp/synccalendar.ics" ); | 1350 | return QString( "/tmp/synccalendar.ics" ); |
1351 | #endif | 1351 | #endif |
1352 | } | 1352 | } |
1353 | void MainWindow::updateWeek(QDate seda) | 1353 | void MainWindow::updateWeek(QDate seda) |
1354 | { | 1354 | { |
1355 | int weekNum = 0; | 1355 | int weekNum = 0; |
1356 | QDate d = QDate ( seda.year(), 1,1); | 1356 | QDate d = QDate ( seda.year(), 1,1); |
1357 | seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday | 1357 | seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday |
1358 | if ( seda.addDays(6).year() != seda.year() ) { | 1358 | if ( seda.addDays(6).year() != seda.year() ) { |
1359 | if ( seda.year() != d.year() ) { | 1359 | if ( seda.year() != d.year() ) { |
1360 | if ( d.dayOfWeek() > 4 ) | 1360 | if ( d.dayOfWeek() > 4 ) |
1361 | d = QDate ( seda.year(), 1,1); | 1361 | d = QDate ( seda.year(), 1,1); |
1362 | else | 1362 | else |
1363 | weekNum = 1; | 1363 | weekNum = 1; |
1364 | } else { | 1364 | } else { |
1365 | QDate dd( seda.year()+1, 1,1); | 1365 | QDate dd( seda.year()+1, 1,1); |
1366 | if ( dd.dayOfWeek() <= 4 ) | 1366 | if ( dd.dayOfWeek() <= 4 ) |
1367 | weekNum = 1; | 1367 | weekNum = 1; |
1368 | } | 1368 | } |
1369 | } | 1369 | } |
1370 | if ( weekNum == 0 ){ | 1370 | if ( weekNum == 0 ){ |
1371 | int dow = d.dayOfWeek(); | 1371 | int dow = d.dayOfWeek(); |
1372 | if ( dow <= 4 ) | 1372 | if ( dow <= 4 ) |
1373 | d = d.addDays( 1-dow ); | 1373 | d = d.addDays( 1-dow ); |
1374 | else // 5,6,7 | 1374 | else // 5,6,7 |
1375 | d = d.addDays( 8-dow ); | 1375 | d = d.addDays( 8-dow ); |
1376 | // we have the first week of the year.we are on monday | 1376 | // we have the first week of the year.we are on monday |
1377 | weekNum = d.daysTo( seda ) / 7 +1; | 1377 | weekNum = d.daysTo( seda ) / 7 +1; |
1378 | } | 1378 | } |
1379 | 1379 | ||
1380 | mWeekPixmap.fill( mWeekBgColor ); | 1380 | mWeekPixmap.fill( mWeekBgColor ); |
1381 | QPainter p ( &mWeekPixmap ); | 1381 | QPainter p ( &mWeekPixmap ); |
1382 | p.setFont( mWeekFont ); | 1382 | p.setFont( mWeekFont ); |
1383 | p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); | 1383 | p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); |
1384 | p.end(); | 1384 | p.end(); |
1385 | QIconSet icon3 ( mWeekPixmap ); | 1385 | QIconSet icon3 ( mWeekPixmap ); |
1386 | mWeekAction->setIconSet ( icon3 ); | 1386 | mWeekAction->setIconSet ( icon3 ); |
1387 | 1387 | ||
1388 | } | 1388 | } |
1389 | void MainWindow::updateWeekNum(const DateList &selectedDates) | 1389 | void MainWindow::updateWeekNum(const DateList &selectedDates) |
1390 | { | 1390 | { |
1391 | updateWeek( selectedDates.first() ); | 1391 | updateWeek( selectedDates.first() ); |
1392 | } | 1392 | } |
1393 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1393 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1394 | { | 1394 | { |
1395 | 1395 | ||
1396 | if ( !incidence ) { | 1396 | if ( !incidence ) { |
1397 | enableIncidenceActions( false ); | 1397 | enableIncidenceActions( false ); |
1398 | 1398 | ||
1399 | mNewSubTodoAction->setEnabled( false ); | 1399 | mNewSubTodoAction->setEnabled( false ); |
1400 | setCaptionToDates(); | 1400 | setCaptionToDates(); |
1401 | return; | 1401 | return; |
1402 | 1402 | ||
1403 | } | 1403 | } |
1404 | 1404 | ||
1405 | //KGlobal::locale()->formatDateTime(nextA, true); | 1405 | //KGlobal::locale()->formatDateTime(nextA, true); |
1406 | QString startString = ""; | 1406 | QString startString = ""; |
1407 | if ( incidence->type() != "Todo" ) { | 1407 | if ( incidence->type() != "Todo" ) { |
1408 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1408 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1409 | if ( incidence->doesFloat() ) { | 1409 | if ( incidence->doesFloat() ) { |
1410 | startString += ": "+incidence->dtStartDateStr( true ); | 1410 | startString += ": "+incidence->dtStartDateStr( true ); |
1411 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1411 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1412 | 1412 | ||
1413 | } else { | 1413 | } else { |
1414 | startString = ": "+incidence->dtStartStr(true); | 1414 | startString = ": "+incidence->dtStartStr(true); |
1415 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1415 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1416 | 1416 | ||
1417 | } | 1417 | } |
1418 | 1418 | ||
1419 | } else { | 1419 | } else { |
1420 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1420 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1421 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1421 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1422 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1422 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1423 | if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) { | 1423 | if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) { |
1424 | bool ok; | 1424 | bool ok; |
1425 | QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); | 1425 | QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); |
1426 | if ( ok ) { | 1426 | if ( ok ) { |
1427 | int years = noc.date().year() - incidence->dtStart().date().year(); | 1427 | int years = noc.date().year() - incidence->dtStart().date().year(); |
1428 | startString += i18n(" (%1 y.)"). arg( years ); | 1428 | startString += i18n(" (%1 y.)"). arg( years ); |
1429 | } | 1429 | } |
1430 | } | 1430 | } |
1431 | else | 1431 | else |
1432 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1432 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1433 | } | 1433 | } |
1434 | 1434 | ||
1435 | } | 1435 | } |
1436 | else | 1436 | else |
1437 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1437 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1438 | if ( !incidence->location().isEmpty() ) | 1438 | if ( !incidence->location().isEmpty() ) |
1439 | startString += " (" +incidence->location()+")"; | 1439 | startString += " (" +incidence->location()+")"; |
1440 | setCaption( incidence->summary()+startString); | 1440 | setCaption( incidence->summary()+startString); |
1441 | 1441 | ||
1442 | enableIncidenceActions( true ); | 1442 | enableIncidenceActions( true ); |
1443 | 1443 | ||
1444 | if ( incidence->type() == "Event" ) { | 1444 | if ( incidence->type() == "Event" ) { |
1445 | mShowAction->setText( i18n("Show Event...") ); | 1445 | mShowAction->setText( i18n("Show Event...") ); |
1446 | mEditAction->setText( i18n("Edit Event...") ); | 1446 | mEditAction->setText( i18n("Edit Event...") ); |
1447 | mDeleteAction->setText( i18n("Delete Event...") ); | 1447 | mDeleteAction->setText( i18n("Delete Event...") ); |
1448 | 1448 | ||
1449 | mNewSubTodoAction->setEnabled( false ); | 1449 | mNewSubTodoAction->setEnabled( false ); |
1450 | } else if ( incidence->type() == "Todo" ) { | 1450 | } else if ( incidence->type() == "Todo" ) { |
1451 | mShowAction->setText( i18n("Show Todo...") ); | 1451 | mShowAction->setText( i18n("Show Todo...") ); |
1452 | mEditAction->setText( i18n("Edit Todo...") ); | 1452 | mEditAction->setText( i18n("Edit Todo...") ); |
1453 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1453 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1454 | 1454 | ||
1455 | mNewSubTodoAction->setEnabled( true ); | 1455 | mNewSubTodoAction->setEnabled( true ); |
1456 | } else { | 1456 | } else { |
1457 | mShowAction->setText( i18n("Show...") ); | 1457 | mShowAction->setText( i18n("Show...") ); |
1458 | mShowAction->setText( i18n("Edit...") ); | 1458 | mShowAction->setText( i18n("Edit...") ); |
1459 | mShowAction->setText( i18n("Delete...") ); | 1459 | mShowAction->setText( i18n("Delete...") ); |
1460 | 1460 | ||
1461 | mNewSubTodoAction->setEnabled( false ); | 1461 | mNewSubTodoAction->setEnabled( false ); |
1462 | } | 1462 | } |
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | void MainWindow::enableIncidenceActions( bool enabled ) | 1465 | void MainWindow::enableIncidenceActions( bool enabled ) |
1466 | { | 1466 | { |
1467 | mShowAction->setEnabled( enabled ); | 1467 | mShowAction->setEnabled( enabled ); |
1468 | mEditAction->setEnabled( enabled ); | 1468 | mEditAction->setEnabled( enabled ); |
1469 | mDeleteAction->setEnabled( enabled ); | 1469 | mDeleteAction->setEnabled( enabled ); |
1470 | 1470 | ||
1471 | mCloneAction->setEnabled( enabled ); | 1471 | mCloneAction->setEnabled( enabled ); |
1472 | mMoveAction->setEnabled( enabled ); | 1472 | mMoveAction->setEnabled( enabled ); |
1473 | mBeamAction->setEnabled( enabled ); | 1473 | mBeamAction->setEnabled( enabled ); |
1474 | mCancelAction->setEnabled( enabled ); | 1474 | mCancelAction->setEnabled( enabled ); |
1475 | } | 1475 | } |
1476 | 1476 | ||
1477 | void MainWindow::importOL() | 1477 | void MainWindow::importOL() |
1478 | { | 1478 | { |
1479 | #ifdef _OL_IMPORT_ | 1479 | #ifdef _OL_IMPORT_ |
1480 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1480 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1481 | id->exec(); | 1481 | id->exec(); |
1482 | delete id; | 1482 | delete id; |
1483 | mView->updateView(); | 1483 | mView->updateView(); |
1484 | #endif | 1484 | #endif |
1485 | } | 1485 | } |
1486 | void MainWindow::importBday() | 1486 | void MainWindow::importBday() |
1487 | { | 1487 | { |
1488 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1488 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1489 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1489 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1490 | i18n("Import!"), i18n("Cancel"), 0, | 1490 | i18n("Import!"), i18n("Cancel"), 0, |
1491 | 0, 1 ); | 1491 | 0, 1 ); |
1492 | if ( result == 0 ) { | 1492 | if ( result == 0 ) { |
1493 | mView->importBday(); | 1493 | mView->importBday(); |
1494 | 1494 | ||
1495 | } | 1495 | } |
1496 | 1496 | ||
1497 | 1497 | ||
1498 | } | 1498 | } |
1499 | void MainWindow::importQtopia() | 1499 | void MainWindow::importQtopia() |
1500 | { | 1500 | { |
1501 | #ifndef DESKTOP_VERSION | 1501 | #ifndef DESKTOP_VERSION |
1502 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1502 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1503 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), | 1503 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), |
1504 | i18n("Import!"), i18n("Cancel"), 0, | 1504 | i18n("Import!"), i18n("Cancel"), 0, |
1505 | 0, 1 ); | 1505 | 0, 1 ); |
1506 | if ( result == 0 ) { | 1506 | if ( result == 0 ) { |
1507 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1507 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1508 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1508 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1509 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1509 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1510 | mView->importQtopia( categories, datebook, todolist ); | 1510 | mView->importQtopia( categories, datebook, todolist ); |
1511 | } | 1511 | } |
1512 | #else | 1512 | #else |
1513 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1513 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1514 | i18n("Not supported \non desktop!\n"), | 1514 | i18n("Not supported \non desktop!\n"), |
1515 | i18n("Ok"), i18n("Cancel"), 0, | 1515 | i18n("Ok"), i18n("Cancel"), 0, |
1516 | 0, 1 ); | 1516 | 0, 1 ); |
1517 | 1517 | ||
1518 | #endif | 1518 | #endif |
1519 | } | 1519 | } |
1520 | 1520 | ||
1521 | void MainWindow::saveOnClose() | 1521 | void MainWindow::saveOnClose() |
1522 | { | 1522 | { |
1523 | KOPrefs *p = KOPrefs::instance(); | 1523 | KOPrefs *p = KOPrefs::instance(); |
1524 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1524 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1525 | p->mToolBarUp = iconToolBar->x() > width()/2 || | 1525 | p->mToolBarUp = iconToolBar->x() > width()/2 || |
1526 | iconToolBar->y() > height()/2; | 1526 | iconToolBar->y() > height()/2; |
1527 | mView->writeSettings(); | 1527 | mView->writeSettings(); |
1528 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1528 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1529 | save(); | 1529 | save(); |
1530 | } | 1530 | } |
1531 | void MainWindow::slotModifiedChanged( bool changed ) | 1531 | void MainWindow::slotModifiedChanged( bool changed ) |
1532 | { | 1532 | { |
1533 | if ( mBlockAtStartup ) | 1533 | if ( mBlockAtStartup ) |
1534 | return; | 1534 | return; |
1535 | 1535 | ||
1536 | int msec; | 1536 | int msec; |
1537 | // we store the changes after 1 minute, | 1537 | // we store the changes after 1 minute, |
1538 | // and for safety reasons after 10 minutes again | 1538 | // and for safety reasons after 10 minutes again |
1539 | if ( !mSyncManager->blockSave() ) | 1539 | if ( !mSyncManager->blockSave() ) |
1540 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1540 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1541 | else | 1541 | else |
1542 | msec = 1000 * 600; | 1542 | msec = 1000 * 600; |
1543 | mSaveTimer.start( msec, true ); // 1 minute | 1543 | mSaveTimer.start( msec, true ); // 1 minute |
1544 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1544 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1545 | mCalendarModifiedFlag = true; | 1545 | mCalendarModifiedFlag = true; |
1546 | } | 1546 | } |
1547 | void MainWindow::saveStopTimer() | 1547 | void MainWindow::saveStopTimer() |
1548 | { | 1548 | { |
1549 | mSaveTimer.stop(); | 1549 | mSaveTimer.stop(); |
1550 | if (mSaveTimer.isActive() ) | 1550 | if (mSaveTimer.isActive() ) |
1551 | qDebug("ti active "); | 1551 | qDebug("ti active "); |
1552 | else | 1552 | else |
1553 | qDebug("KO: Save timer stopped"); | 1553 | qDebug("KO: Save timer stopped"); |
1554 | } | 1554 | } |
1555 | void MainWindow::save() | 1555 | void MainWindow::save() |
1556 | { | 1556 | { |
1557 | if ( !mCalendarModifiedFlag ) { | 1557 | if ( !mCalendarModifiedFlag ) { |
1558 | qDebug("KO: Calendar not modified. Nothing saved."); | 1558 | qDebug("KO: Calendar not modified. Nothing saved."); |
1559 | return; | 1559 | return; |
1560 | } | 1560 | } |
1561 | if ( mSyncManager->blockSave() ) | 1561 | if ( mSyncManager->blockSave() ) |
1562 | return; | 1562 | return; |
1563 | mSyncManager->setBlockSave(true); | 1563 | mSyncManager->setBlockSave(true); |
1564 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1564 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1565 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1565 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1566 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1566 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1567 | qDebug("KO: Start saving data to file!"); | 1567 | qDebug("KO: Start saving data to file!"); |
1568 | mView->saveCalendar( defaultFileName() ); | 1568 | mView->saveCalendar( defaultFileName() ); |
1569 | mCalendarModifiedFlag = false; | 1569 | mCalendarModifiedFlag = false; |
1570 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1570 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1571 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1571 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1572 | QString savemes; | 1572 | QString savemes; |
1573 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1573 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1574 | setCaption(savemes); | 1574 | setCaption(savemes); |
1575 | } else | 1575 | } else |
1576 | setCaption(i18n("Saving cancelled!")); | 1576 | setCaption(i18n("Saving cancelled!")); |
1577 | mSyncManager->setBlockSave( false ); | 1577 | mSyncManager->setBlockSave( false ); |
1578 | } | 1578 | } |
1579 | 1579 | ||
1580 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1580 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1581 | { | 1581 | { |
1582 | if ( !e->isAutoRepeat() ) { | 1582 | if ( !e->isAutoRepeat() ) { |
1583 | mFlagKeyPressed = false; | 1583 | mFlagKeyPressed = false; |
1584 | } | 1584 | } |
1585 | } | 1585 | } |
1586 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1586 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1587 | { | 1587 | { |
1588 | qApp->processEvents(); | 1588 | qApp->processEvents(); |
1589 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1589 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1590 | e->ignore(); | 1590 | e->ignore(); |
1591 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1591 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1592 | return; | 1592 | return; |
1593 | } | 1593 | } |
1594 | if (! e->isAutoRepeat() ) | 1594 | if (! e->isAutoRepeat() ) |
1595 | mFlagKeyPressed = true; | 1595 | mFlagKeyPressed = true; |
1596 | KOPrefs *p = KOPrefs::instance(); | 1596 | KOPrefs *p = KOPrefs::instance(); |
1597 | bool showSelectedDates = false; | 1597 | bool showSelectedDates = false; |
1598 | int size; | 1598 | int size; |
1599 | int pro = 0; | 1599 | int pro = 0; |
1600 | //qDebug("MainWindow::keyPressEvent "); | 1600 | //qDebug("MainWindow::keyPressEvent "); |
1601 | switch ( e->key() ) { | 1601 | switch ( e->key() ) { |
1602 | case Qt::Key_Right: | 1602 | case Qt::Key_Right: |
1603 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1603 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1604 | mView->goNextMonth(); | 1604 | mView->goNextMonth(); |
1605 | else | 1605 | else |
1606 | mView->goNext(); | 1606 | mView->goNext(); |
1607 | showSelectedDates = true; | 1607 | showSelectedDates = true; |
1608 | break; | 1608 | break; |
1609 | case Qt::Key_Left: | 1609 | case Qt::Key_Left: |
1610 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1610 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1611 | mView->goPreviousMonth(); | 1611 | mView->goPreviousMonth(); |
1612 | else | 1612 | else |
1613 | mView->goPrevious(); | 1613 | mView->goPrevious(); |
1614 | showSelectedDates = true; | 1614 | showSelectedDates = true; |
1615 | break; | 1615 | break; |
1616 | case Qt::Key_Down: | 1616 | case Qt::Key_Down: |
1617 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1617 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1618 | break; | 1618 | break; |
1619 | case Qt::Key_Up: | 1619 | case Qt::Key_Up: |
1620 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1620 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1621 | break; | 1621 | break; |
1622 | case Qt::Key_I: | 1622 | case Qt::Key_I: |
1623 | mView->showIncidence(); | 1623 | mView->showIncidence(); |
1624 | break; | 1624 | break; |
1625 | case Qt::Key_Delete: | 1625 | case Qt::Key_Delete: |
1626 | case Qt::Key_Backspace: | 1626 | case Qt::Key_Backspace: |
1627 | mView->deleteIncidence(); | 1627 | mView->deleteIncidence(); |
1628 | break; | 1628 | break; |
1629 | case Qt::Key_D: | 1629 | case Qt::Key_D: |
1630 | mView->viewManager()->showDayView(); | 1630 | mView->viewManager()->showDayView(); |
1631 | showSelectedDates = true; | 1631 | showSelectedDates = true; |
1632 | break; | 1632 | break; |
1633 | case Qt::Key_O: | 1633 | case Qt::Key_O: |
1634 | mView->toggleFilerEnabled( ); | 1634 | mView->toggleFilerEnabled( ); |
1635 | break; | 1635 | break; |
1636 | case Qt::Key_0: | 1636 | case Qt::Key_0: |
1637 | case Qt::Key_1: | 1637 | case Qt::Key_1: |
1638 | case Qt::Key_2: | 1638 | case Qt::Key_2: |
1639 | case Qt::Key_3: | 1639 | case Qt::Key_3: |
1640 | case Qt::Key_4: | 1640 | case Qt::Key_4: |
1641 | case Qt::Key_5: | 1641 | case Qt::Key_5: |
1642 | case Qt::Key_6: | 1642 | case Qt::Key_6: |
1643 | case Qt::Key_7: | 1643 | case Qt::Key_7: |
1644 | case Qt::Key_8: | 1644 | case Qt::Key_8: |
1645 | case Qt::Key_9: | 1645 | case Qt::Key_9: |
1646 | pro = e->key()-48; | 1646 | pro = e->key()-48; |
1647 | if ( pro == 0 ) | 1647 | if ( pro == 0 ) |
1648 | pro = 10; | 1648 | pro = 10; |
1649 | if ( e->state() == Qt::ControlButton) | 1649 | if ( e->state() == Qt::ControlButton) |
1650 | pro += 10; | 1650 | pro += 10; |
1651 | break; | 1651 | break; |
1652 | case Qt::Key_M: | 1652 | case Qt::Key_M: |
1653 | mView->viewManager()->showMonthView(); | 1653 | mView->viewManager()->showMonthView(); |
1654 | showSelectedDates = true; | 1654 | showSelectedDates = true; |
1655 | break; | 1655 | break; |
1656 | case Qt::Key_Insert: | 1656 | case Qt::Key_Insert: |
1657 | mView->newEvent(); | 1657 | mView->newEvent(); |
1658 | break; | 1658 | break; |
1659 | case Qt::Key_S : | 1659 | case Qt::Key_S : |
1660 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1660 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1661 | mView->newSubTodo(); | 1661 | mView->newSubTodo(); |
1662 | else | 1662 | else |
1663 | mView->dialogManager()->showSearchDialog(); | 1663 | mView->dialogManager()->showSearchDialog(); |
1664 | break; | 1664 | break; |
1665 | case Qt::Key_Y : | 1665 | case Qt::Key_Y : |
1666 | case Qt::Key_Z : | 1666 | case Qt::Key_Z : |
1667 | mView->viewManager()->showWorkWeekView(); | 1667 | mView->viewManager()->showWorkWeekView(); |
1668 | showSelectedDates = true; | 1668 | showSelectedDates = true; |
1669 | break; | 1669 | break; |
1670 | case Qt::Key_U : | 1670 | case Qt::Key_U : |
1671 | mView->viewManager()->showWeekView(); | 1671 | mView->viewManager()->showWeekView(); |
1672 | showSelectedDates = true; | 1672 | showSelectedDates = true; |
1673 | break; | 1673 | break; |
1674 | case Qt::Key_H : | 1674 | case Qt::Key_H : |
1675 | keyBindings(); | 1675 | keyBindings(); |
1676 | break; | 1676 | break; |
1677 | case Qt::Key_W: | 1677 | case Qt::Key_W: |
1678 | mView->viewManager()->showWhatsNextView(); | 1678 | mView->viewManager()->showWhatsNextView(); |
1679 | break; | 1679 | break; |
1680 | case Qt::Key_L: | 1680 | case Qt::Key_L: |
1681 | mView->viewManager()->showListView(); | 1681 | mView->viewManager()->showListView(); |
1682 | break; | 1682 | break; |
1683 | case Qt::Key_N: | 1683 | case Qt::Key_N: |
1684 | mView->viewManager()->showNextXView(); | 1684 | mView->viewManager()->showNextXView(); |
1685 | showSelectedDates = true; | 1685 | showSelectedDates = true; |
1686 | break; | 1686 | break; |
1687 | case Qt::Key_V: | 1687 | case Qt::Key_V: |
1688 | mView->viewManager()->showTodoView(); | 1688 | mView->viewManager()->showTodoView(); |
1689 | break; | 1689 | break; |
1690 | case Qt::Key_C: | 1690 | case Qt::Key_C: |
1691 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1691 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1692 | break; | 1692 | break; |
1693 | case Qt::Key_P: | 1693 | case Qt::Key_P: |
1694 | mView->showDatePicker( ); | 1694 | mView->showDatePicker( ); |
1695 | break; | 1695 | break; |
1696 | case Qt::Key_F: | 1696 | case Qt::Key_F: |
1697 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1697 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1698 | mView->editFilters(); | 1698 | mView->editFilters(); |
1699 | else | 1699 | else |
1700 | mView->toggleFilter(); | 1700 | mView->toggleFilter(); |
1701 | break; | 1701 | break; |
1702 | case Qt::Key_X: | 1702 | case Qt::Key_X: |
1703 | mView->toggleDateNavigatorWidget(); | 1703 | mView->toggleDateNavigatorWidget(); |
1704 | break; | 1704 | break; |
1705 | case Qt::Key_Space: | 1705 | case Qt::Key_Space: |
1706 | mView->toggleExpand(); | 1706 | mView->toggleExpand(); |
1707 | break; | 1707 | break; |
1708 | case Qt::Key_A: | 1708 | case Qt::Key_A: |
1709 | mView->toggleAllDaySize(); | 1709 | mView->toggleAllDaySize(); |
1710 | break; | 1710 | break; |
1711 | case Qt::Key_T: | 1711 | case Qt::Key_T: |
1712 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1712 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1713 | mView->newTodo(); | 1713 | mView->newTodo(); |
1714 | else { | 1714 | else { |
1715 | mView->goToday(); | 1715 | mView->goToday(); |
1716 | showSelectedDates = true; | 1716 | showSelectedDates = true; |
1717 | } | 1717 | } |
1718 | break; | 1718 | break; |
1719 | case Qt::Key_J: | 1719 | case Qt::Key_J: |
1720 | mView->viewManager()->showJournalView(); | 1720 | mView->viewManager()->showJournalView(); |
1721 | break; | 1721 | break; |
1722 | case Qt::Key_B: | 1722 | case Qt::Key_B: |
1723 | mView->editIncidenceDescription();; | 1723 | mView->editIncidenceDescription();; |
1724 | break; | 1724 | break; |
1725 | // case Qt::Key_Return: | 1725 | // case Qt::Key_Return: |
1726 | case Qt::Key_E: | 1726 | case Qt::Key_E: |
1727 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1727 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1728 | mView->newEvent(); | 1728 | mView->newEvent(); |
1729 | else | 1729 | else |
1730 | mView->editIncidence(); | 1730 | mView->editIncidence(); |
1731 | break; | 1731 | break; |
1732 | case Qt::Key_Plus: | 1732 | case Qt::Key_Plus: |
1733 | size = p->mHourSize +2; | 1733 | size = p->mHourSize +2; |
1734 | if ( size <= 22 ) | 1734 | if ( size <= 22 ) |
1735 | configureAgenda( size ); | 1735 | configureAgenda( size ); |
1736 | break; | 1736 | break; |
1737 | case Qt::Key_Minus: | 1737 | case Qt::Key_Minus: |
1738 | size = p->mHourSize - 2; | 1738 | size = p->mHourSize - 2; |
1739 | if ( size >= 4 ) | 1739 | if ( size >= 4 ) |
1740 | configureAgenda( size ); | 1740 | configureAgenda( size ); |
1741 | break; | 1741 | break; |
1742 | 1742 | ||
1743 | 1743 | ||
1744 | default: | 1744 | default: |
1745 | e->ignore(); | 1745 | e->ignore(); |
1746 | } | 1746 | } |
1747 | if ( pro > 0 ) { | 1747 | if ( pro > 0 ) { |
1748 | mView->selectFilter( pro-1 ); | 1748 | mView->selectFilter( pro-1 ); |
1749 | } | 1749 | } |
1750 | if ( showSelectedDates ) { | 1750 | if ( showSelectedDates ) { |
1751 | ;// setCaptionToDates(); | 1751 | ;// setCaptionToDates(); |
1752 | } | 1752 | } |
1753 | 1753 | ||
1754 | } | 1754 | } |
1755 | 1755 | ||
1756 | void MainWindow::fillFilterMenu() | 1756 | void MainWindow::fillFilterMenu() |
1757 | { | 1757 | { |
1758 | selectFilterMenu->clear(); | 1758 | selectFilterMenu->clear(); |
1759 | bool disable = false; | 1759 | bool disable = false; |
1760 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); | 1760 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); |
1761 | selectFilterMenu->insertSeparator(); | 1761 | selectFilterMenu->insertSeparator(); |
1762 | if ( mView->filterView()->filtersEnabled() ) { | 1762 | if ( mView->filterView()->filtersEnabled() ) { |
1763 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 ); | 1763 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 ); |
1764 | } | 1764 | } |
1765 | else { | 1765 | else { |
1766 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 ); | 1766 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 ); |
1767 | disable = true; | 1767 | disable = true; |
1768 | } | 1768 | } |
1769 | selectFilterMenu->insertSeparator(); | 1769 | selectFilterMenu->insertSeparator(); |
1770 | QPtrList<CalFilter> fili = mView->filters(); | 1770 | QPtrList<CalFilter> fili = mView->filters(); |
1771 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1771 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1772 | CalFilter *filter = fili.first(); | 1772 | CalFilter *filter = fili.first(); |
1773 | int iii = 2; | 1773 | int iii = 2; |
1774 | while(filter) { | 1774 | while(filter) { |
1775 | selectFilterMenu->insertItem( filter->name(), iii ); | 1775 | selectFilterMenu->insertItem( filter->name(), iii ); |
1776 | if ( filter == curfilter) | 1776 | if ( filter == curfilter) |
1777 | selectFilterMenu->setItemChecked( iii, true ); | 1777 | selectFilterMenu->setItemChecked( iii, true ); |
1778 | if ( disable ) | 1778 | if ( disable ) |
1779 | selectFilterMenu->setItemEnabled( iii, false ); | 1779 | selectFilterMenu->setItemEnabled( iii, false ); |
1780 | filter = fili.next(); | 1780 | filter = fili.next(); |
1781 | ++iii; | 1781 | ++iii; |
1782 | } | 1782 | } |
1783 | } | 1783 | } |
1784 | void MainWindow::selectFilter( int fil ) | 1784 | void MainWindow::selectFilter( int fil ) |
1785 | { | 1785 | { |
1786 | if ( fil == 0 ) { | 1786 | if ( fil == 0 ) { |
1787 | mView->editFilters( ); | 1787 | mView->editFilters( ); |
1788 | } else if ( fil == 1 ){ | 1788 | } else if ( fil == 1 ){ |
1789 | mView->toggleFilerEnabled( ); | 1789 | mView->toggleFilerEnabled( ); |
1790 | } else { | 1790 | } else { |
1791 | mView->selectFilter( fil-2 ); | 1791 | mView->selectFilter( fil-2 ); |
1792 | } | 1792 | } |
1793 | } | 1793 | } |
1794 | void MainWindow::configureToolBar( int item ) | 1794 | void MainWindow::configureToolBar( int item ) |
1795 | { | 1795 | { |
1796 | 1796 | ||
1797 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 1797 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
1798 | KOPrefs *p = KOPrefs::instance(); | 1798 | KOPrefs *p = KOPrefs::instance(); |
1799 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 1799 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
1800 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 1800 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
1801 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 1801 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
1802 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 1802 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
1803 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 1803 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
1804 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 1804 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
1805 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 1805 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
1806 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 1806 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
1807 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 1807 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
1808 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 1808 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
1809 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 1809 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
1810 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 1810 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
1811 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 1811 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
1812 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 1812 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
1813 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 1813 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
1814 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 1814 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
1815 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 1815 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
1816 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 1816 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
1817 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 1817 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
1818 | // initActions(); | 1818 | // initActions(); |
1819 | } | 1819 | } |
1820 | 1820 | ||
1821 | void MainWindow::setCaptionToDates() | 1821 | void MainWindow::setCaptionToDates() |
1822 | { | 1822 | { |
1823 | QString selDates; | 1823 | QString selDates; |
1824 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); | 1824 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); |
1825 | if (mView->startDate() < mView->endDate() ) | 1825 | if (mView->startDate() < mView->endDate() ) |
1826 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 1826 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
1827 | else { | 1827 | else { |
1828 | QString addString; | 1828 | QString addString; |
1829 | if ( mView->startDate() == QDateTime::currentDateTime().date() ) | 1829 | if ( mView->startDate() == QDateTime::currentDateTime().date() ) |
1830 | addString = i18n("Today"); | 1830 | addString = i18n("Today"); |
1831 | else if ( mView->startDate() == QDateTime::currentDateTime().date().addDays(1) ) | 1831 | else if ( mView->startDate() == QDateTime::currentDateTime().date().addDays(1) ) |
1832 | addString = i18n("Tomorrow"); | 1832 | addString = i18n("Tomorrow"); |
1833 | if ( !addString.isEmpty() ) | 1833 | if ( !addString.isEmpty() ) |
1834 | selDates = addString+", "+selDates ; | 1834 | selDates = addString+", "+selDates ; |
1835 | } | 1835 | } |
1836 | setCaption( i18n("Dates: ") + selDates ); | 1836 | setCaption( i18n("Dates: ") + selDates ); |
1837 | 1837 | ||
1838 | } | 1838 | } |
1839 | void MainWindow::showConfigureAgenda( ) | 1839 | void MainWindow::showConfigureAgenda( ) |
1840 | { | 1840 | { |
1841 | int iii; | 1841 | int iii; |
1842 | for ( iii = 1;iii<= 10 ;++iii ){ | 1842 | for ( iii = 1;iii<= 10 ;++iii ){ |
1843 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); | 1843 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); |
1844 | } | 1844 | } |
1845 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); | 1845 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); |
1846 | } | 1846 | } |
1847 | void MainWindow::configureAgenda( int item ) | 1847 | void MainWindow::configureAgenda( int item ) |
1848 | { | 1848 | { |
1849 | if ( KOPrefs::instance()->mHourSize == item ) | 1849 | if ( KOPrefs::instance()->mHourSize == item ) |
1850 | return; | 1850 | return; |
1851 | KOPrefs::instance()->mHourSize=item; | 1851 | KOPrefs::instance()->mHourSize=item; |
1852 | mView->viewManager()->agendaView()->updateConfig(); | 1852 | mView->viewManager()->agendaView()->updateConfig(); |
1853 | } | 1853 | } |
1854 | 1854 | ||
1855 | void MainWindow::saveCalendar() | 1855 | void MainWindow::saveCalendar() |
1856 | { | 1856 | { |
1857 | QString fn = KOPrefs::instance()->mLastSaveFile; | 1857 | QString fn = KOPrefs::instance()->mLastSaveFile; |
1858 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | 1858 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); |
1859 | 1859 | ||
1860 | if ( fn == "" ) | 1860 | if ( fn == "" ) |
1861 | return; | 1861 | return; |
1862 | QFileInfo info; | 1862 | QFileInfo info; |
1863 | info.setFile( fn ); | 1863 | info.setFile( fn ); |
1864 | QString mes; | 1864 | QString mes; |
1865 | bool createbup = true; | 1865 | bool createbup = true; |
1866 | if ( info. exists() ) { | 1866 | if ( info. exists() ) { |
1867 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | 1867 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; |
1868 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1868 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1869 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1869 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1870 | 0, 1 ); | 1870 | 0, 1 ); |
1871 | if ( result != 0 ) { | 1871 | if ( result != 0 ) { |
1872 | createbup = false; | 1872 | createbup = false; |
1873 | } | 1873 | } |
1874 | } | 1874 | } |
1875 | if ( createbup ) { | 1875 | if ( createbup ) { |
1876 | mView->saveCalendar( fn ); | 1876 | mView->saveCalendar( fn ); |
1877 | mes = i18n("KO/Pi:Saved %1").arg(fn); | 1877 | mes = i18n("KO/Pi:Saved %1").arg(fn); |
1878 | KOPrefs::instance()->mLastSaveFile = fn; | 1878 | KOPrefs::instance()->mLastSaveFile = fn; |
1879 | setCaption(mes); | 1879 | setCaption(mes); |
1880 | } | 1880 | } |
1881 | } | 1881 | } |
1882 | void MainWindow::loadCalendar() | 1882 | void MainWindow::loadCalendar() |
1883 | { | 1883 | { |
1884 | 1884 | ||
1885 | QString fn = KOPrefs::instance()->mLastLoadFile; | 1885 | QString fn = KOPrefs::instance()->mLastLoadFile; |
1886 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 1886 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
1887 | 1887 | ||
1888 | if ( fn == "" ) | 1888 | if ( fn == "" ) |
1889 | return; | 1889 | return; |
1890 | QFileInfo info; | 1890 | QFileInfo info; |
1891 | info.setFile( fn ); | 1891 | info.setFile( fn ); |
1892 | QString mess; | 1892 | QString mess; |
1893 | bool loadbup = true; | 1893 | bool loadbup = true; |
1894 | if ( info. exists() ) { | 1894 | if ( info. exists() ) { |
1895 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1895 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1896 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1896 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1897 | mess, | 1897 | mess, |
1898 | i18n("Load!"), i18n("Cancel"), 0, | 1898 | i18n("Load!"), i18n("Cancel"), 0, |
1899 | 0, 1 ); | 1899 | 0, 1 ); |
1900 | if ( result != 0 ) { | 1900 | if ( result != 0 ) { |
1901 | loadbup = false; | 1901 | loadbup = false; |
1902 | } | 1902 | } |
1903 | } else { | 1903 | } else { |
1904 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1904 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1905 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 1905 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
1906 | 0, 1 ); | 1906 | 0, 1 ); |
1907 | 1907 | ||
1908 | return; | 1908 | return; |
1909 | } | 1909 | } |
1910 | if ( loadbup ) { | 1910 | if ( loadbup ) { |
1911 | mView->openCalendar( fn ); | 1911 | mView->openCalendar( fn ); |
1912 | KOPrefs::instance()->mLastLoadFile = fn; | 1912 | KOPrefs::instance()->mLastLoadFile = fn; |
1913 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 1913 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
1914 | setCaption(mess); | 1914 | setCaption(mess); |
1915 | } | 1915 | } |
1916 | 1916 | ||
1917 | } | 1917 | } |
1918 | void MainWindow::quickImportIcal() | 1918 | void MainWindow::quickImportIcal() |
1919 | { | 1919 | { |
1920 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 1920 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
1921 | } | 1921 | } |
1922 | void MainWindow::importFile( QString fn, bool quick ) | 1922 | void MainWindow::importFile( QString fn, bool quick ) |
1923 | { | 1923 | { |
1924 | QFileInfo info; | 1924 | QFileInfo info; |
1925 | info.setFile( fn ); | 1925 | info.setFile( fn ); |
1926 | QString mess; | 1926 | QString mess; |
1927 | bool loadbup = true; | 1927 | bool loadbup = true; |
1928 | if ( !info. exists() ) { | 1928 | if ( !info. exists() ) { |
1929 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 1929 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
1930 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1930 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1931 | mess ); | 1931 | mess ); |
1932 | return; | 1932 | return; |
1933 | } | 1933 | } |
1934 | int result = 0; | 1934 | int result = 0; |
1935 | if ( !quick ) { | 1935 | if ( !quick ) { |
1936 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1936 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1937 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1937 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1938 | mess, | 1938 | mess, |
1939 | "Import", "Cancel", 0, | 1939 | "Import", "Cancel", 0, |
1940 | 0, 1 ); | 1940 | 0, 1 ); |
1941 | } | 1941 | } |
1942 | if ( result == 0 ) { | 1942 | if ( result == 0 ) { |
1943 | if ( mView->openCalendar( fn, true )) { | 1943 | if ( mView->openCalendar( fn, true )) { |
1944 | KOPrefs::instance()->mLastImportFile = fn; | 1944 | KOPrefs::instance()->mLastImportFile = fn; |
1945 | setCaption(i18n("Imported file successfully")); | 1945 | setCaption(i18n("Imported file successfully")); |
1946 | } else { | 1946 | } else { |
1947 | setCaption(i18n("Error importing file")); | 1947 | setCaption(i18n("Error importing file")); |
1948 | } | 1948 | } |
1949 | } | 1949 | } |
1950 | } | 1950 | } |
1951 | 1951 | ||
1952 | void MainWindow::importIcal() | 1952 | void MainWindow::importIcal() |
1953 | { | 1953 | { |
1954 | 1954 | ||
1955 | QString fn =KOPrefs::instance()->mLastImportFile; | 1955 | QString fn =KOPrefs::instance()->mLastImportFile; |
1956 | 1956 | ||
1957 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 1957 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
1958 | if ( fn == "" ) | 1958 | if ( fn == "" ) |
1959 | return; | 1959 | return; |
1960 | importFile( fn, true ); | 1960 | importFile( fn, true ); |
1961 | 1961 | ||
1962 | } | 1962 | } |
1963 | 1963 | ||
1964 | void MainWindow::exportVCalendar() | 1964 | void MainWindow::exportVCalendar() |
1965 | { | 1965 | { |
1966 | QString fn = KOPrefs::instance()->mLastVcalFile; | 1966 | QString fn = KOPrefs::instance()->mLastVcalFile; |
1967 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 1967 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
1968 | if ( fn == "" ) | 1968 | if ( fn == "" ) |
1969 | return; | 1969 | return; |
1970 | QFileInfo info; | 1970 | QFileInfo info; |
1971 | info.setFile( fn ); | 1971 | info.setFile( fn ); |
1972 | QString mes; | 1972 | QString mes; |
1973 | bool createbup = true; | 1973 | bool createbup = true; |
1974 | if ( info. exists() ) { | 1974 | if ( info. exists() ) { |
1975 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 1975 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
1976 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1976 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1977 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1977 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1978 | 0, 1 ); | 1978 | 0, 1 ); |
1979 | if ( result != 0 ) { | 1979 | if ( result != 0 ) { |
1980 | createbup = false; | 1980 | createbup = false; |
1981 | } | 1981 | } |
1982 | } | 1982 | } |
1983 | if ( createbup ) { | 1983 | if ( createbup ) { |
1984 | if ( mView->exportVCalendar( fn ) ) { | 1984 | if ( mView->exportVCalendar( fn ) ) { |
1985 | KOPrefs::instance()->mLastVcalFile = fn; | 1985 | KOPrefs::instance()->mLastVcalFile = fn; |
1986 | if ( fn.length() > 20 ) | 1986 | if ( fn.length() > 20 ) |
1987 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 1987 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
1988 | else | 1988 | else |
1989 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 1989 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
1990 | setCaption(mes); | 1990 | setCaption(mes); |
1991 | } | 1991 | } |
1992 | } | 1992 | } |
1993 | 1993 | ||
1994 | } | 1994 | } |
1995 | 1995 | ||
1996 | void MainWindow::syncFileRequest() | 1996 | void MainWindow::syncFileRequest() |
1997 | { | 1997 | { |
1998 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 1998 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
1999 | mSyncManager->slotSyncMenu( 999 ); | 1999 | mSyncManager->slotSyncMenu( 999 ); |
2000 | } | 2000 | } |
2001 | save(); | 2001 | save(); |
2002 | } | 2002 | } |
2003 | void MainWindow::getFile( bool success ) | 2003 | void MainWindow::getFile( bool success ) |
2004 | { | 2004 | { |
2005 | if ( ! success ) { | 2005 | if ( ! success ) { |
2006 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2006 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2007 | return; | 2007 | return; |
2008 | } | 2008 | } |
2009 | mView->openCalendar( defaultFileName() ); | 2009 | mView->openCalendar( defaultFileName() ); |
2010 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2010 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
2011 | mSyncManager->slotSyncMenu( 999 ); | 2011 | mSyncManager->slotSyncMenu( 999 ); |
2012 | } | 2012 | } |
2013 | setCaption( i18n("Pi-Sync successful!") ); | 2013 | setCaption( i18n("Pi-Sync successful!") ); |
2014 | } | 2014 | } |
2015 | 2015 | ||
2016 | void MainWindow::printSel( ) | 2016 | void MainWindow::printSel( ) |
2017 | { | 2017 | { |
2018 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 2018 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
2019 | } | 2019 | } |
2020 | 2020 | ||
2021 | void MainWindow::printCal() | 2021 | void MainWindow::printCal() |
2022 | { | 2022 | { |
2023 | mView->print();//mCp->showDialog(); | 2023 | mView->print();//mCp->showDialog(); |
2024 | } | 2024 | } |
2025 | 2025 | ||
2026 | 2026 | ||
2027 | #include "libkdepim/kdatepicker.h" | 2027 | #include "libkdepim/kdatepicker.h" |
2028 | #include <kdatetbl.h> | 2028 | #include <kdatetbl.h> |
2029 | void MainWindow::weekAction() | 2029 | void MainWindow::weekAction() |
2030 | { | 2030 | { |
2031 | int month; | 2031 | int month; |
2032 | KPopupFrame* popup = new KPopupFrame(this); | 2032 | KPopupFrame* popup = new KPopupFrame(this); |
2033 | int size = 12; | 2033 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(10, popup); |
2034 | if ( QApplication::desktop()->width() >= 480 ) | ||
2035 | size = 18; | ||
2036 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(size, popup); | ||
2037 | // ----- | 2034 | // ----- |
2038 | picker->resize(picker->sizeHint()); | 2035 | picker->resize(picker->sizeHint()); |
2039 | popup->setMainWidget(picker); | 2036 | popup->setMainWidget(picker); |
2040 | picker->setFocus(); | 2037 | picker->setFocus(); |
2041 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 2038 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
2042 | if(popup->exec(iconToolBar->mapToGlobal(QPoint(0, iconToolBar->height())))) | 2039 | int x = 0; |
2040 | int y = iconToolBar->height(); | ||
2041 | int dX = 0; | ||
2042 | int dY = 0; | ||
2043 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | ||
2044 | if ( iconToolBar->y() > height()/2 ) { | ||
2045 | dY = iconToolBar->height()+picker->sizeHint().height(); | ||
2046 | y = 0; | ||
2047 | } | ||
2048 | } else { | ||
2049 | if ( iconToolBar->x() > width()/2 ) { // right side | ||
2050 | x=0; | ||
2051 | dX= iconToolBar->width()+picker->sizeHint().width(); | ||
2052 | y = 0; | ||
2053 | } else { | ||
2054 | x= iconToolBar->width(); | ||
2055 | y = 0; | ||
2056 | } | ||
2057 | } | ||
2058 | qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); | ||
2059 | if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) | ||
2043 | { | 2060 | { |
2044 | month = picker->getResult(); | 2061 | month = picker->getResult(); |
2045 | emit selectWeek ( month ); | 2062 | emit selectWeek ( month ); |
2046 | //qDebug("weekSelected %d ", month); | 2063 | //qDebug("weekSelected %d ", month); |
2047 | } | 2064 | } |
2048 | delete popup; | 2065 | delete popup; |
2049 | } | 2066 | } |
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp index f05e6f6..4a31c77 100644 --- a/korganizer/navigatorbar.cpp +++ b/korganizer/navigatorbar.cpp | |||
@@ -1,202 +1,203 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qstring.h> | 25 | #include <qstring.h> |
26 | #include <qtooltip.h> | 26 | #include <qtooltip.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qframe.h> | 29 | #include <qframe.h> |
30 | #include <qlabel.h> | 30 | #include <qlabel.h> |
31 | #include <qpopupmenu.h> | 31 | #include <qpopupmenu.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | 33 | ||
34 | #include <kdebug.h> | 34 | #include <kdebug.h> |
35 | #include <klocale.h> | 35 | #include <klocale.h> |
36 | #include <kglobal.h> | 36 | #include <kglobal.h> |
37 | #include <kiconloader.h> | 37 | #include <kiconloader.h> |
38 | #include "libkdepim/kdatepicker.h" | 38 | #include "libkdepim/kdatepicker.h" |
39 | #include <knotifyclient.h> | 39 | #include <knotifyclient.h> |
40 | #include "kdatetbl.h" | 40 | #include "kdatetbl.h" |
41 | 41 | ||
42 | #include "koglobals.h" | 42 | #include "koglobals.h" |
43 | #include <kglobalsettings.h> | ||
43 | #include "koprefs.h" | 44 | #include "koprefs.h" |
44 | #ifndef KORG_NOPLUGINS | 45 | #ifndef KORG_NOPLUGINS |
45 | #include "kocore.h" | 46 | #include "kocore.h" |
46 | #endif | 47 | #endif |
47 | 48 | ||
48 | #include <kcalendarsystem.h> | 49 | #include <kcalendarsystem.h> |
49 | 50 | ||
50 | #include "navigatorbar.h" | 51 | #include "navigatorbar.h" |
51 | 52 | ||
52 | NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name ) | 53 | NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name ) |
53 | : QWidget( parent, name ) | 54 | : QWidget( parent, name ) |
54 | { | 55 | { |
55 | QBoxLayout *topLayout = new QHBoxLayout( this ); | 56 | QBoxLayout *topLayout = new QHBoxLayout( this ); |
56 | 57 | ||
57 | // Set up the control buttons and date label | 58 | // Set up the control buttons and date label |
58 | mCtrlFrame = new QFrame( this ); | 59 | mCtrlFrame = new QFrame( this ); |
59 | mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); | 60 | mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); |
60 | mCtrlFrame->setLineWidth(1); | 61 | mCtrlFrame->setLineWidth(1); |
61 | 62 | ||
62 | topLayout->addWidget( mCtrlFrame ); | 63 | topLayout->addWidget( mCtrlFrame ); |
63 | 64 | ||
64 | QFont tfont = font(); | 65 | QFont tfont = KGlobalSettings::generalFont();//font(); |
65 | if ( QApplication::desktop()->width() >= 480 ) | 66 | if ( QApplication::desktop()->width() >= 480 ) |
66 | tfont.setPointSize(tfont.pointSize()+2); | 67 | tfont.setPointSize(tfont.pointSize()+2); |
67 | tfont.setBold(true); | 68 | tfont.setBold(true); |
68 | 69 | ||
69 | bool isRTL = KOGlobals::self()->reverseLayout(); | 70 | bool isRTL = KOGlobals::self()->reverseLayout(); |
70 | #ifndef DESKTOP_VERSION | 71 | #ifndef DESKTOP_VERSION |
71 | bool isDesktop = false; | 72 | bool isDesktop = false; |
72 | #else | 73 | #else |
73 | bool isDesktop = true; | 74 | bool isDesktop = true; |
74 | #endif | 75 | #endif |
75 | if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) | 76 | if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) |
76 | isDesktop = true; | 77 | isDesktop = true; |
77 | // Create backward navigation buttons | 78 | // Create backward navigation buttons |
78 | mPrevYear = new QPushButton( mCtrlFrame ); | 79 | mPrevYear = new QPushButton( mCtrlFrame ); |
79 | mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) ); | 80 | mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) ); |
80 | QToolTip::add( mPrevYear, i18n("Previous Year") ); | 81 | QToolTip::add( mPrevYear, i18n("Previous Year") ); |
81 | 82 | ||
82 | mPrevMonth = new QPushButton( mCtrlFrame ); | 83 | mPrevMonth = new QPushButton( mCtrlFrame ); |
83 | mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); | 84 | mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); |
84 | QToolTip::add( mPrevMonth, i18n("Previous Month") ); | 85 | QToolTip::add( mPrevMonth, i18n("Previous Month") ); |
85 | 86 | ||
86 | // Create forward navigation buttons | 87 | // Create forward navigation buttons |
87 | mNextMonth = new QPushButton( mCtrlFrame ); | 88 | mNextMonth = new QPushButton( mCtrlFrame ); |
88 | mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); | 89 | mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); |
89 | QToolTip::add( mNextMonth, i18n("Next Month") ); | 90 | QToolTip::add( mNextMonth, i18n("Next Month") ); |
90 | 91 | ||
91 | mNextYear = new QPushButton( mCtrlFrame ); | 92 | mNextYear = new QPushButton( mCtrlFrame ); |
92 | mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") ); | 93 | mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") ); |
93 | QToolTip::add( mNextYear, i18n("Next Year") ); | 94 | QToolTip::add( mNextYear, i18n("Next Year") ); |
94 | mSelectMonth = new QPushButton( mCtrlFrame ); | 95 | mSelectMonth = new QPushButton( mCtrlFrame ); |
95 | // Create month name label | 96 | // Create month name label |
96 | //selectMonth->setFont( tfont ); | 97 | //selectMonth->setFont( tfont ); |
97 | // selectMonth->setAlignment( AlignCenter ); | 98 | // selectMonth->setAlignment( AlignCenter ); |
98 | //mDateLabel = new QLabel( selectMonth ); | 99 | //mDateLabel = new QLabel( selectMonth ); |
99 | //mDateLabel->setFont( tfont ); | 100 | //mDateLabel->setFont( tfont ); |
100 | //mDateLabel->setAlignment( AlignCenter ); | 101 | //mDateLabel->setAlignment( AlignCenter ); |
101 | if ( QString ( name ) == QString("useBigPixmaps") ) { | 102 | if ( QString ( name ) == QString("useBigPixmaps") ) { |
102 | mNextMonth->setFlat( true); | 103 | mNextMonth->setFlat( true); |
103 | mNextYear->setFlat( true); | 104 | mNextYear->setFlat( true); |
104 | mSelectMonth->setFlat( true); | 105 | mSelectMonth->setFlat( true); |
105 | mPrevYear->setFlat( true); | 106 | mPrevYear->setFlat( true); |
106 | mPrevMonth->setFlat( true); | 107 | mPrevMonth->setFlat( true); |
107 | } | 108 | } |
108 | mSelectMonth->setFont( tfont ); | 109 | mSelectMonth->setFont( tfont ); |
109 | // Set minimum width to width of widest month name label | 110 | // Set minimum width to width of widest month name label |
110 | int i; | 111 | int i; |
111 | int maxwidth = 0; | 112 | int maxwidth = 0; |
112 | QFontMetrics fm ( mSelectMonth->font() ); | 113 | QFontMetrics fm ( mSelectMonth->font() ); |
113 | int width = fm.width("September '00" ); | 114 | int width = fm.width("September '00" ); |
114 | // for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date); | 115 | // for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date); |
115 | // ++i ) { | 116 | // ++i ) { |
116 | // //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i, | 117 | // //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i, |
117 | // // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" ); | 118 | // // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" ); |
118 | // int width = fm.width("September 2000" ); | 119 | // int width = fm.width("September 2000" ); |
119 | // if ( width > maxwidth ) maxwidth = width; | 120 | // if ( width > maxwidth ) maxwidth = width; |
120 | // } | 121 | // } |
121 | maxwidth = width+2; | 122 | maxwidth = width+2; |
122 | int size = fm.height()+2; | 123 | int size = fm.height()+2; |
123 | if ( QApplication::desktop()->width() >= 480 ) { | 124 | if ( QApplication::desktop()->width() >= 480 ) { |
124 | size += 6; | 125 | size += 6; |
125 | maxwidth+= 6; | 126 | maxwidth+= 6; |
126 | } | 127 | } |
127 | 128 | ||
128 | mSelectMonth->setFixedWidth( maxwidth ); | 129 | mSelectMonth->setFixedWidth( maxwidth ); |
129 | mSelectMonth->setFixedHeight( size ); | 130 | mSelectMonth->setFixedHeight( size ); |
130 | mPrevYear->setFixedHeight( size ); | 131 | mPrevYear->setFixedHeight( size ); |
131 | mPrevMonth->setFixedHeight( size ); | 132 | mPrevMonth->setFixedHeight( size ); |
132 | mNextMonth->setFixedHeight( size ); | 133 | mNextMonth->setFixedHeight( size ); |
133 | mNextYear->setFixedHeight ( size ); | 134 | mNextYear->setFixedHeight ( size ); |
134 | // set up control frame layout | 135 | // set up control frame layout |
135 | QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); | 136 | QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); |
136 | ctrlLayout->addWidget( mPrevYear, 3 ); | 137 | ctrlLayout->addWidget( mPrevYear, 3 ); |
137 | ctrlLayout->addWidget( mPrevMonth, 3 ); | 138 | ctrlLayout->addWidget( mPrevMonth, 3 ); |
138 | //ctrlLayout->addStretch( 1 ); | 139 | //ctrlLayout->addStretch( 1 ); |
139 | // ctrlLayout->addSpacing( 1 ); | 140 | // ctrlLayout->addSpacing( 1 ); |
140 | // ctrlLayout->addWidget( mDateLabel ); | 141 | // ctrlLayout->addWidget( mDateLabel ); |
141 | ctrlLayout->addWidget( mSelectMonth ); | 142 | ctrlLayout->addWidget( mSelectMonth ); |
142 | // ctrlLayout->addSpacing( 1 ); | 143 | // ctrlLayout->addSpacing( 1 ); |
143 | // ctrlLayout->addStretch( 1 ); | 144 | // ctrlLayout->addStretch( 1 ); |
144 | ctrlLayout->addWidget( mNextMonth, 3 ); | 145 | ctrlLayout->addWidget( mNextMonth, 3 ); |
145 | ctrlLayout->addWidget( mNextYear, 3 ); | 146 | ctrlLayout->addWidget( mNextYear, 3 ); |
146 | 147 | ||
147 | connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); | 148 | connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); |
148 | connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); | 149 | connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); |
149 | connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); | 150 | connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); |
150 | connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); | 151 | connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); |
151 | connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); | 152 | connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); |
152 | mPrevYear->setFocusPolicy(NoFocus); | 153 | mPrevYear->setFocusPolicy(NoFocus); |
153 | mPrevMonth->setFocusPolicy(NoFocus); | 154 | mPrevMonth->setFocusPolicy(NoFocus); |
154 | mNextMonth->setFocusPolicy(NoFocus); | 155 | mNextMonth->setFocusPolicy(NoFocus); |
155 | mNextYear->setFocusPolicy(NoFocus); | 156 | mNextYear->setFocusPolicy(NoFocus); |
156 | mSelectMonth->setFocusPolicy(NoFocus); | 157 | mSelectMonth->setFocusPolicy(NoFocus); |
157 | setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); | 158 | setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); |
158 | 159 | ||
159 | } | 160 | } |
160 | 161 | ||
161 | NavigatorBar::~NavigatorBar() | 162 | NavigatorBar::~NavigatorBar() |
162 | { | 163 | { |
163 | } | 164 | } |
164 | 165 | ||
165 | void NavigatorBar::selectMonth() | 166 | void NavigatorBar::selectMonth() |
166 | { | 167 | { |
167 | 168 | ||
168 | int month; | 169 | int month; |
169 | KPopupFrame* popup = new KPopupFrame(this); | 170 | KPopupFrame* popup = new KPopupFrame(this); |
170 | int size = 12; | 171 | int size = 12; |
171 | if ( QApplication::desktop()->width() >= 480 ) | 172 | if ( QApplication::desktop()->width() >= 480 ) |
172 | size = 18; | 173 | size = 18; |
173 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(size, popup); | 174 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(size, popup); |
174 | // ----- | 175 | // ----- |
175 | picker->resize(picker->sizeHint()); | 176 | picker->resize(picker->sizeHint()); |
176 | popup->setMainWidget(picker); | 177 | popup->setMainWidget(picker); |
177 | picker->setFocus(); | 178 | picker->setFocus(); |
178 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 179 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
179 | if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) | 180 | if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) |
180 | { | 181 | { |
181 | month = picker->getResult(); | 182 | month = picker->getResult(); |
182 | emit monthSelected ( month ); | 183 | emit monthSelected ( month ); |
183 | } else { | 184 | } else { |
184 | KNotifyClient::beep(); | 185 | KNotifyClient::beep(); |
185 | } | 186 | } |
186 | delete popup; | 187 | delete popup; |
187 | } | 188 | } |
188 | void NavigatorBar::selectDates( const KCal::DateList &dateList ) | 189 | void NavigatorBar::selectDates( const KCal::DateList &dateList ) |
189 | { | 190 | { |
190 | if (dateList.count() > 0) { | 191 | if (dateList.count() > 0) { |
191 | QDate date = dateList.first(); | 192 | QDate date = dateList.first(); |
192 | 193 | ||
193 | const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); | 194 | const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); |
194 | 195 | ||
195 | // compute the label at the top of the navigator | 196 | // compute the label at the top of the navigator |
196 | QString dtstr = i18n(calSys->monthName( date )) + " '" + | 197 | QString dtstr = i18n(calSys->monthName( date )) + " '" + |
197 | QString::number( calSys->year( date ) ).right(2); | 198 | QString::number( calSys->year( date ) ).right(2); |
198 | 199 | ||
199 | mSelectMonth->setText( dtstr ); | 200 | mSelectMonth->setText( dtstr ); |
200 | } | 201 | } |
201 | } | 202 | } |
202 | 203 | ||
diff --git a/libkdepim/kdatepicker.cpp b/libkdepim/kdatepicker.cpp index d8bc9f5..2be9c9e 100644 --- a/libkdepim/kdatepicker.cpp +++ b/libkdepim/kdatepicker.cpp | |||
@@ -1,475 +1,471 @@ | |||
1 | /* -*- C++ -*- | 1 | /* -*- C++ -*- |
2 | This file is part of the KDE libraries | 2 | This file is part of the KDE libraries |
3 | Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) | 3 | Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) |
4 | (C) 1998-2001 Mirko Boehm (mirko@kde.org) | 4 | (C) 1998-2001 Mirko Boehm (mirko@kde.org) |
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include "kdatepicker.h" | 21 | #include "kdatepicker.h" |
22 | #include <kglobal.h> | 22 | #include <kglobal.h> |
23 | #include <kapplication.h> | 23 | #include <kapplication.h> |
24 | #include <klocale.h> | 24 | #include <klocale.h> |
25 | #include <kiconloader.h> | 25 | #include <kiconloader.h> |
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qpainter.h> | 27 | #include <qpainter.h> |
28 | #include <qdialog.h> | 28 | #include <qdialog.h> |
29 | #include <qtoolbutton.h> | 29 | #include <qtoolbutton.h> |
30 | #include <qfont.h> | 30 | #include <qfont.h> |
31 | #include <qapplication.h> | 31 | #include <qapplication.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qvalidator.h> | 33 | #include <qvalidator.h> |
34 | #include <kdebug.h> | 34 | #include <kdebug.h> |
35 | #include <knotifyclient.h> | 35 | #include <knotifyclient.h> |
36 | #include <kglobalsettings.h> | ||
36 | #include "kdatetbl.h" | 37 | #include "kdatetbl.h" |
37 | #include "kdateedit.h" | 38 | #include "kdateedit.h" |
38 | //#include "kdatepicker.moc" | 39 | //#include "kdatepicker.moc" |
39 | 40 | ||
40 | 41 | ||
41 | KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name) | 42 | KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name) |
42 | : QFrame(parent,name), | 43 | : QFrame(parent,name), |
43 | yearForward(new QToolButton(this)), | 44 | yearForward(new QToolButton(this)), |
44 | yearBackward(new QToolButton(this)), | 45 | yearBackward(new QToolButton(this)), |
45 | monthForward(new QToolButton(this)), | 46 | monthForward(new QToolButton(this)), |
46 | monthBackward(new QToolButton(this)), | 47 | monthBackward(new QToolButton(this)), |
47 | selectMonth(new QToolButton(this)), | 48 | selectMonth(new QToolButton(this)), |
48 | selectYear(new QToolButton(this)), | 49 | selectYear(new QToolButton(this)), |
49 | //line(new QLineEdit(this)), | 50 | //line(new QLineEdit(this)), |
50 | val(new KDateValidator(this)) | 51 | val(new KDateValidator(this)) |
51 | //table(new KDateTable(this)), | 52 | //table(new KDateTable(this)), |
52 | //fontsize(1) | 53 | //fontsize(1) |
53 | { | 54 | { |
54 | // ----- | 55 | setFont ( KGlobalSettings::generalFont() ); |
55 | int size = 12; | ||
56 | if ( QApplication::desktop()->width() >= 480 ) | ||
57 | size = 18; | ||
58 | fontsize = size; | ||
59 | setFont ( QFont("helvetica",size) ); | ||
60 | table = new KDateTable(this); | 56 | table = new KDateTable(this); |
61 | setFontSize(size); | 57 | setFontSize(font().pointSize()+2); |
62 | //line->setValidator(val); | 58 | //line->setValidator(val); |
63 | lineDate = new KDateEdit( this, "dateediipicker", true ); | 59 | lineDate = new KDateEdit( this, "dateediipicker", true ); |
64 | yearForward->setPixmap(SmallIcon("2rightarrowB")); | 60 | yearForward->setPixmap(SmallIcon("2rightarrowB")); |
65 | yearBackward->setPixmap(SmallIcon("2leftarrowB")); | 61 | yearBackward->setPixmap(SmallIcon("2leftarrowB")); |
66 | monthForward->setPixmap(SmallIcon("1rightarrowB")); | 62 | monthForward->setPixmap(SmallIcon("1rightarrowB")); |
67 | monthBackward->setPixmap(SmallIcon("1leftarrowB")); | 63 | monthBackward->setPixmap(SmallIcon("1leftarrowB")); |
68 | setDate(dt); // set button texts | 64 | setDate(dt); // set button texts |
69 | connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate))); | 65 | connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate))); |
70 | connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot())); | 66 | connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot())); |
71 | connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked())); | 67 | connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked())); |
72 | connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked())); | 68 | connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked())); |
73 | connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked())); | 69 | connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked())); |
74 | connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked())); | 70 | connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked())); |
75 | connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked())); | 71 | connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked())); |
76 | connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked())); | 72 | connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked())); |
77 | //connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); | 73 | //connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); |
78 | connect(lineDate, SIGNAL(dateChanged(QDate)), SLOT(slotSetDate(QDate))); | 74 | connect(lineDate, SIGNAL(dateChanged(QDate)), SLOT(slotSetDate(QDate))); |
79 | connect(lineDate, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); | 75 | connect(lineDate, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); |
80 | table->setFocus(); | 76 | table->setFocus(); |
81 | 77 | ||
82 | } | 78 | } |
83 | 79 | ||
84 | KDatePicker::~KDatePicker() | 80 | KDatePicker::~KDatePicker() |
85 | { | 81 | { |
86 | } | 82 | } |
87 | 83 | ||
88 | void | 84 | void |
89 | KDatePicker::resizeEvent(QResizeEvent*) | 85 | KDatePicker::resizeEvent(QResizeEvent*) |
90 | { | 86 | { |
91 | QWidget *buttons[] = { | 87 | QWidget *buttons[] = { |
92 | yearBackward, | 88 | yearBackward, |
93 | monthBackward, | 89 | monthBackward, |
94 | selectMonth, | 90 | selectMonth, |
95 | selectYear, | 91 | selectYear, |
96 | monthForward, | 92 | monthForward, |
97 | yearForward }; | 93 | yearForward }; |
98 | const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); | 94 | const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); |
99 | QSize sizes[NoOfButtons]; | 95 | QSize sizes[NoOfButtons]; |
100 | int buttonHeight=0; | 96 | int buttonHeight=0; |
101 | int count; | 97 | int count; |
102 | int w; | 98 | int w; |
103 | int x=0; | 99 | int x=0; |
104 | // ----- calculate button row height: | 100 | // ----- calculate button row height: |
105 | for(count=0; count<NoOfButtons; ++count) { | 101 | for(count=0; count<NoOfButtons; ++count) { |
106 | int xS = buttons[count]->sizeHint().width(); | 102 | int xS = buttons[count]->sizeHint().width(); |
107 | int yS = buttons[count]->sizeHint().height(); | 103 | int yS = buttons[count]->sizeHint().height(); |
108 | if ( QApplication::desktop()->width() < 320 ) | 104 | if ( QApplication::desktop()->width() < 320 ) |
109 | sizes[count]=QSize ( xS+4, yS ); | 105 | sizes[count]=QSize ( xS+4, yS ); |
110 | else | 106 | else |
111 | sizes[count]=QSize ( xS+10, yS ); | 107 | sizes[count]=QSize ( xS+10, yS ); |
112 | 108 | ||
113 | buttonHeight=QMAX(buttonHeight, sizes[count].height()); | 109 | buttonHeight=QMAX(buttonHeight, sizes[count].height()); |
114 | } | 110 | } |
115 | buttonHeight += 10; | 111 | buttonHeight += 10; |
116 | // ----- calculate size of the month button: | 112 | // ----- calculate size of the month button: |
117 | w=0; | 113 | w=0; |
118 | for(count=0; count<NoOfButtons; ++count) { | 114 | for(count=0; count<NoOfButtons; ++count) { |
119 | if(buttons[count]!=selectMonth) | 115 | if(buttons[count]!=selectMonth) |
120 | { | 116 | { |
121 | w+=sizes[count].width(); | 117 | w+=sizes[count].width(); |
122 | } else { | 118 | } else { |
123 | x=count; | 119 | x=count; |
124 | } | 120 | } |
125 | } | 121 | } |
126 | sizes[x].setWidth(width()-w); // stretch the month button | 122 | sizes[x].setWidth(width()-w); // stretch the month button |
127 | // ----- place the buttons: | 123 | // ----- place the buttons: |
128 | x=0; | 124 | x=0; |
129 | for(count=0; count<NoOfButtons; ++count) | 125 | for(count=0; count<NoOfButtons; ++count) |
130 | { | 126 | { |
131 | w=sizes[count].width(); | 127 | w=sizes[count].width(); |
132 | buttons[count]->setGeometry(x, 0, w, buttonHeight); | 128 | buttons[count]->setGeometry(x, 0, w, buttonHeight); |
133 | x+=w; | 129 | x+=w; |
134 | } | 130 | } |
135 | // ----- place the line edit for direct input: | 131 | // ----- place the line edit for direct input: |
136 | sizes[0]=lineDate->sizeHint(); | 132 | sizes[0]=lineDate->sizeHint(); |
137 | //line->setGeometry(0, height()-sizes[0].height(), width(), sizes[0].height()); | 133 | //line->setGeometry(0, height()-sizes[0].height(), width(), sizes[0].height()); |
138 | lineDate->setGeometry(0, height()-sizes[0].height(), width(), sizes[0].height()); | 134 | lineDate->setGeometry(0, height()-sizes[0].height(), width(), sizes[0].height()); |
139 | // ----- adjust the table: | 135 | // ----- adjust the table: |
140 | table->setGeometry(0, buttonHeight, width(), | 136 | table->setGeometry(0, buttonHeight, width(), |
141 | height()-buttonHeight-sizes[0].height()); | 137 | height()-buttonHeight-sizes[0].height()); |
142 | } | 138 | } |
143 | 139 | ||
144 | void | 140 | void |
145 | KDatePicker::dateChangedSlot(QDate date) | 141 | KDatePicker::dateChangedSlot(QDate date) |
146 | { | 142 | { |
147 | lineDate->setDate( date );//(KGlobal::locale()->formatDate(date, true)); | 143 | lineDate->setDate( date );//(KGlobal::locale()->formatDate(date, true)); |
148 | //line->setText(KGlobal::locale()->formatDate(date, true)); | 144 | //line->setText(KGlobal::locale()->formatDate(date, true)); |
149 | emit(dateChanged(date)); | 145 | emit(dateChanged(date)); |
150 | } | 146 | } |
151 | 147 | ||
152 | void | 148 | void |
153 | KDatePicker::tableClickedSlot() | 149 | KDatePicker::tableClickedSlot() |
154 | { | 150 | { |
155 | 151 | ||
156 | emit(dateSelected(table->getDate())); | 152 | emit(dateSelected(table->getDate())); |
157 | emit(tableClicked()); | 153 | emit(tableClicked()); |
158 | } | 154 | } |
159 | 155 | ||
160 | const QDate& | 156 | const QDate& |
161 | KDatePicker::getDate() const | 157 | KDatePicker::getDate() const |
162 | { | 158 | { |
163 | return table->getDate(); | 159 | return table->getDate(); |
164 | } | 160 | } |
165 | 161 | ||
166 | const QDate & | 162 | const QDate & |
167 | KDatePicker::date() const | 163 | KDatePicker::date() const |
168 | { | 164 | { |
169 | return table->getDate(); | 165 | return table->getDate(); |
170 | } | 166 | } |
171 | 167 | ||
172 | void KDatePicker::slotSetDate( QDate date ) | 168 | void KDatePicker::slotSetDate( QDate date ) |
173 | { | 169 | { |
174 | 170 | ||
175 | if(date.isValid()) { | 171 | if(date.isValid()) { |
176 | QString temp; | 172 | QString temp; |
177 | // ----- | 173 | // ----- |
178 | table->setDate(date); | 174 | table->setDate(date); |
179 | selectMonth->setText(KGlobal::locale()->monthName(date.month(), false)); | 175 | selectMonth->setText(KGlobal::locale()->monthName(date.month(), false)); |
180 | temp.setNum(date.year()); | 176 | temp.setNum(date.year()); |
181 | selectYear->setText(temp); | 177 | selectYear->setText(temp); |
182 | //line->setText(KGlobal::locale()->formatDate(date, true)); | 178 | //line->setText(KGlobal::locale()->formatDate(date, true)); |
183 | lineDate->setDate( date ); | 179 | lineDate->setDate( date ); |
184 | } | 180 | } |
185 | 181 | ||
186 | } | 182 | } |
187 | bool | 183 | bool |
188 | KDatePicker::setDate(const QDate& date) | 184 | KDatePicker::setDate(const QDate& date) |
189 | { | 185 | { |
190 | table->setFocus(); | 186 | table->setFocus(); |
191 | if(date.isValid()) { | 187 | if(date.isValid()) { |
192 | QString temp; | 188 | QString temp; |
193 | // ----- | 189 | // ----- |
194 | table->setDate(date); | 190 | table->setDate(date); |
195 | selectMonth->setText(KGlobal::locale()->monthName(date.month(), false)); | 191 | selectMonth->setText(KGlobal::locale()->monthName(date.month(), false)); |
196 | temp.setNum(date.year()); | 192 | temp.setNum(date.year()); |
197 | selectYear->setText(temp); | 193 | selectYear->setText(temp); |
198 | //line->setText(KGlobal::locale()->formatDate(date, true)); | 194 | //line->setText(KGlobal::locale()->formatDate(date, true)); |
199 | lineDate->setDate( date ); | 195 | lineDate->setDate( date ); |
200 | return true; | 196 | return true; |
201 | } else { | 197 | } else { |
202 | 198 | ||
203 | return false; | 199 | return false; |
204 | } | 200 | } |
205 | 201 | ||
206 | 202 | ||
207 | } | 203 | } |
208 | 204 | ||
209 | void | 205 | void |
210 | KDatePicker::monthForwardClicked() | 206 | KDatePicker::monthForwardClicked() |
211 | { | 207 | { |
212 | QDate temp=table->getDate(); | 208 | QDate temp=table->getDate(); |
213 | int day=temp.day(); | 209 | int day=temp.day(); |
214 | // ----- | 210 | // ----- |
215 | if(temp.month()==12) { | 211 | if(temp.month()==12) { |
216 | temp.setYMD(temp.year()+1, 1, 1); | 212 | temp.setYMD(temp.year()+1, 1, 1); |
217 | } else { | 213 | } else { |
218 | temp.setYMD(temp.year(), temp.month()+1, 1); | 214 | temp.setYMD(temp.year(), temp.month()+1, 1); |
219 | } | 215 | } |
220 | if(temp.daysInMonth()<day) { | 216 | if(temp.daysInMonth()<day) { |
221 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); | 217 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); |
222 | } else { | 218 | } else { |
223 | temp.setYMD(temp.year(), temp.month(), day); | 219 | temp.setYMD(temp.year(), temp.month(), day); |
224 | } | 220 | } |
225 | // assert(temp.isValid()); | 221 | // assert(temp.isValid()); |
226 | setDate(temp); | 222 | setDate(temp); |
227 | } | 223 | } |
228 | 224 | ||
229 | void | 225 | void |
230 | KDatePicker::monthBackwardClicked() | 226 | KDatePicker::monthBackwardClicked() |
231 | { | 227 | { |
232 | QDate temp=table->getDate(); | 228 | QDate temp=table->getDate(); |
233 | int day=temp.day(); | 229 | int day=temp.day(); |
234 | // ----- | 230 | // ----- |
235 | if(temp.month()==1) | 231 | if(temp.month()==1) |
236 | { | 232 | { |
237 | temp.setYMD(temp.year()-1, 12, 1); | 233 | temp.setYMD(temp.year()-1, 12, 1); |
238 | } else { | 234 | } else { |
239 | temp.setYMD(temp.year(), temp.month()-1, 1); | 235 | temp.setYMD(temp.year(), temp.month()-1, 1); |
240 | } | 236 | } |
241 | if(temp.daysInMonth()<day) | 237 | if(temp.daysInMonth()<day) |
242 | { | 238 | { |
243 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); | 239 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); |
244 | } else { | 240 | } else { |
245 | temp.setYMD(temp.year(), temp.month(), day); | 241 | temp.setYMD(temp.year(), temp.month(), day); |
246 | } | 242 | } |
247 | // assert(temp.isValid()); | 243 | // assert(temp.isValid()); |
248 | setDate(temp); | 244 | setDate(temp); |
249 | } | 245 | } |
250 | 246 | ||
251 | void | 247 | void |
252 | KDatePicker::yearForwardClicked() | 248 | KDatePicker::yearForwardClicked() |
253 | { | 249 | { |
254 | QDate temp=table->getDate(); | 250 | QDate temp=table->getDate(); |
255 | int day=temp.day(); | 251 | int day=temp.day(); |
256 | // ----- | 252 | // ----- |
257 | temp.setYMD(temp.year()+1, temp.month(), 1); | 253 | temp.setYMD(temp.year()+1, temp.month(), 1); |
258 | if(temp.daysInMonth()<day) | 254 | if(temp.daysInMonth()<day) |
259 | { | 255 | { |
260 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); | 256 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); |
261 | } else { | 257 | } else { |
262 | temp.setYMD(temp.year(), temp.month(), day); | 258 | temp.setYMD(temp.year(), temp.month(), day); |
263 | } | 259 | } |
264 | // assert(temp.isValid()); | 260 | // assert(temp.isValid()); |
265 | setDate(temp); | 261 | setDate(temp); |
266 | } | 262 | } |
267 | 263 | ||
268 | void | 264 | void |
269 | KDatePicker::yearBackwardClicked() | 265 | KDatePicker::yearBackwardClicked() |
270 | { | 266 | { |
271 | QDate temp=table->getDate(); | 267 | QDate temp=table->getDate(); |
272 | int day=temp.day(); | 268 | int day=temp.day(); |
273 | // ----- | 269 | // ----- |
274 | temp.setYMD(temp.year()-1, temp.month(), 1); | 270 | temp.setYMD(temp.year()-1, temp.month(), 1); |
275 | if(temp.daysInMonth()<day) | 271 | if(temp.daysInMonth()<day) |
276 | { | 272 | { |
277 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); | 273 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); |
278 | } else { | 274 | } else { |
279 | temp.setYMD(temp.year(), temp.month(), day); | 275 | temp.setYMD(temp.year(), temp.month(), day); |
280 | } | 276 | } |
281 | // assert(temp.isValid()); | 277 | // assert(temp.isValid()); |
282 | setDate(temp); | 278 | setDate(temp); |
283 | } | 279 | } |
284 | 280 | ||
285 | void | 281 | void |
286 | KDatePicker::selectMonthClicked() | 282 | KDatePicker::selectMonthClicked() |
287 | { | 283 | { |
288 | int month; | 284 | int month; |
289 | KPopupFrame* popup = new KPopupFrame(this); | 285 | KPopupFrame* popup = new KPopupFrame(this); |
290 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(fontsize, popup); | 286 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(fontsize, popup); |
291 | // ----- | 287 | // ----- |
292 | picker->resize(picker->sizeHint()); | 288 | picker->resize(picker->sizeHint()); |
293 | popup->setMainWidget(picker); | 289 | popup->setMainWidget(picker); |
294 | picker->setFocus(); | 290 | picker->setFocus(); |
295 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 291 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
296 | if(popup->exec(selectMonth->mapToGlobal(QPoint(0, selectMonth->height())))) | 292 | if(popup->exec(selectMonth->mapToGlobal(QPoint(0, selectMonth->height())))) |
297 | { | 293 | { |
298 | QDate date; | 294 | QDate date; |
299 | int day; | 295 | int day; |
300 | // ----- | 296 | // ----- |
301 | month=picker->getResult(); | 297 | month=picker->getResult(); |
302 | date=table->getDate(); | 298 | date=table->getDate(); |
303 | day=date.day(); | 299 | day=date.day(); |
304 | // ----- construct a valid date in this month: | 300 | // ----- construct a valid date in this month: |
305 | date.setYMD(date.year(), month, 1); | 301 | date.setYMD(date.year(), month, 1); |
306 | date.setYMD(date.year(), month, QMIN(day, date.daysInMonth())); | 302 | date.setYMD(date.year(), month, QMIN(day, date.daysInMonth())); |
307 | // ----- set this month | 303 | // ----- set this month |
308 | setDate(date); | 304 | setDate(date); |
309 | } else { | 305 | } else { |
310 | KNotifyClient::beep(); | 306 | KNotifyClient::beep(); |
311 | } | 307 | } |
312 | delete popup; | 308 | delete popup; |
313 | } | 309 | } |
314 | 310 | ||
315 | void | 311 | void |
316 | KDatePicker::selectYearClicked() | 312 | KDatePicker::selectYearClicked() |
317 | { | 313 | { |
318 | int year; | 314 | int year; |
319 | KPopupFrame* popup = new KPopupFrame(this); | 315 | KPopupFrame* popup = new KPopupFrame(this); |
320 | KDateInternalYearSelector* picker = new KDateInternalYearSelector(fontsize, popup); | 316 | KDateInternalYearSelector* picker = new KDateInternalYearSelector(fontsize, popup); |
321 | // ----- | 317 | // ----- |
322 | picker->resize(picker->sizeHint()); | 318 | picker->resize(picker->sizeHint()); |
323 | popup->setMainWidget(picker); | 319 | popup->setMainWidget(picker); |
324 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 320 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
325 | picker->setFocus(); | 321 | picker->setFocus(); |
326 | if(popup->exec(selectYear->mapToGlobal(QPoint(0, selectMonth->height())))) | 322 | if(popup->exec(selectYear->mapToGlobal(QPoint(0, selectMonth->height())))) |
327 | { | 323 | { |
328 | QDate date; | 324 | QDate date; |
329 | int day; | 325 | int day; |
330 | // ----- | 326 | // ----- |
331 | year=picker->getYear(); | 327 | year=picker->getYear(); |
332 | date=table->getDate(); | 328 | date=table->getDate(); |
333 | day=date.day(); | 329 | day=date.day(); |
334 | // ----- construct a valid date in this month: | 330 | // ----- construct a valid date in this month: |
335 | date.setYMD(year, date.month(), 1); | 331 | date.setYMD(year, date.month(), 1); |
336 | date.setYMD(year, date.month(), QMIN(day, date.daysInMonth())); | 332 | date.setYMD(year, date.month(), QMIN(day, date.daysInMonth())); |
337 | // ----- set this month | 333 | // ----- set this month |
338 | setDate(date); | 334 | setDate(date); |
339 | } else { | 335 | } else { |
340 | KNotifyClient::beep(); | 336 | KNotifyClient::beep(); |
341 | } | 337 | } |
342 | delete popup; | 338 | delete popup; |
343 | } | 339 | } |
344 | 340 | ||
345 | void | 341 | void |
346 | KDatePicker::setEnabled(bool enable) | 342 | KDatePicker::setEnabled(bool enable) |
347 | { | 343 | { |
348 | QWidget *widgets[]= { | 344 | QWidget *widgets[]= { |
349 | yearForward, yearBackward, monthForward, monthBackward, | 345 | yearForward, yearBackward, monthForward, monthBackward, |
350 | selectMonth, selectYear, | 346 | selectMonth, selectYear, |
351 | lineDate, table }; | 347 | lineDate, table }; |
352 | const int Size=sizeof(widgets)/sizeof(widgets[0]); | 348 | const int Size=sizeof(widgets)/sizeof(widgets[0]); |
353 | int count; | 349 | int count; |
354 | // ----- | 350 | // ----- |
355 | for(count=0; count<Size; ++count) | 351 | for(count=0; count<Size; ++count) |
356 | { | 352 | { |
357 | widgets[count]->setEnabled(enable); | 353 | widgets[count]->setEnabled(enable); |
358 | } | 354 | } |
359 | } | 355 | } |
360 | 356 | ||
361 | void | 357 | void |
362 | KDatePicker::lineEnterPressed() | 358 | KDatePicker::lineEnterPressed() |
363 | { | 359 | { |
364 | QDate temp; | 360 | QDate temp; |
365 | // ----- | 361 | // ----- |
366 | temp = lineDate->date(); | 362 | temp = lineDate->date(); |
367 | //if(val->date(line->text(), temp)==QValidator::Acceptable) | 363 | //if(val->date(line->text(), temp)==QValidator::Acceptable) |
368 | //{ | 364 | //{ |
369 | emit(dateEntered(temp)); | 365 | emit(dateEntered(temp)); |
370 | setDate(temp); | 366 | setDate(temp); |
371 | // } else { | 367 | // } else { |
372 | // KNotifyClient::beep(); | 368 | // KNotifyClient::beep(); |
373 | // } | 369 | // } |
374 | } | 370 | } |
375 | 371 | ||
376 | QSize | 372 | QSize |
377 | KDatePicker::sizeHint() const | 373 | KDatePicker::sizeHint() const |
378 | { | 374 | { |
379 | QSize tableSize=table->sizeHint(); | 375 | QSize tableSize=table->sizeHint(); |
380 | QWidget *buttons[]={ | 376 | QWidget *buttons[]={ |
381 | yearBackward, | 377 | yearBackward, |
382 | monthBackward, | 378 | monthBackward, |
383 | selectMonth, | 379 | selectMonth, |
384 | selectYear, | 380 | selectYear, |
385 | monthForward, | 381 | monthForward, |
386 | yearForward }; | 382 | yearForward }; |
387 | const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); | 383 | const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); |
388 | QSize sizes[NoOfButtons]; | 384 | QSize sizes[NoOfButtons]; |
389 | int cx=0, cy=0, count; | 385 | int cx=0, cy=0, count; |
390 | // ----- store the size hints: | 386 | // ----- store the size hints: |
391 | for(count=0; count<NoOfButtons; ++count) | 387 | for(count=0; count<NoOfButtons; ++count) |
392 | { | 388 | { |
393 | sizes[count]=buttons[count]->sizeHint(); | 389 | sizes[count]=buttons[count]->sizeHint(); |
394 | if(buttons[count]==selectMonth) | 390 | if(buttons[count]==selectMonth) |
395 | { | 391 | { |
396 | cx+=maxMonthRect.width()+15; | 392 | cx+=maxMonthRect.width()+15; |
397 | } else { | 393 | } else { |
398 | cx+=sizes[count].width()+15; | 394 | cx+=sizes[count].width()+15; |
399 | } | 395 | } |
400 | cy=QMAX(sizes[count].height(), cy); | 396 | cy=QMAX(sizes[count].height(), cy); |
401 | } | 397 | } |
402 | // ----- calculate width hint: | 398 | // ----- calculate width hint: |
403 | cx=QMAX(cx, tableSize.width()); // line edit ignored | 399 | cx=QMAX(cx, tableSize.width()); // line edit ignored |
404 | if ( cx > QApplication::desktop()->width() -5 ) | 400 | if ( cx > QApplication::desktop()->width() -5 ) |
405 | cx = QApplication::desktop()->width() -5; | 401 | cx = QApplication::desktop()->width() -5; |
406 | // ----- calculate height hint: | 402 | // ----- calculate height hint: |
407 | cy+=tableSize.height()+lineDate->sizeHint().height(); | 403 | cy+=tableSize.height()+lineDate->sizeHint().height(); |
408 | 404 | ||
409 | return QSize(cx, cy); | 405 | return QSize(cx, cy); |
410 | } | 406 | } |
411 | 407 | ||
412 | void | 408 | void |
413 | KDatePicker::setFontSize(int s) | 409 | KDatePicker::setFontSize(int s) |
414 | { | 410 | { |
415 | QWidget *buttons[]= { | 411 | QWidget *buttons[]= { |
416 | // yearBackward, | 412 | // yearBackward, |
417 | // monthBackward, | 413 | // monthBackward, |
418 | selectMonth, | 414 | selectMonth, |
419 | selectYear, | 415 | selectYear, |
420 | // monthForward, | 416 | // monthForward, |
421 | // yearForward | 417 | // yearForward |
422 | }; | 418 | }; |
423 | const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); | 419 | const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); |
424 | int count; | 420 | int count; |
425 | QFont font; | 421 | QFont font; |
426 | QRect r; | 422 | QRect r; |
427 | // ----- | 423 | // ----- |
428 | fontsize=s; | 424 | fontsize=s; |
429 | for(count=0; count<NoOfButtons; ++count) | 425 | for(count=0; count<NoOfButtons; ++count) |
430 | { | 426 | { |
431 | font=buttons[count]->font(); | 427 | font=buttons[count]->font(); |
432 | font.setPointSize(s); | 428 | font.setPointSize(s); |
433 | buttons[count]->setFont(font); | 429 | buttons[count]->setFont(font); |
434 | } | 430 | } |
435 | QFontMetrics metrics(selectMonth->fontMetrics()); | 431 | QFontMetrics metrics(selectMonth->fontMetrics()); |
436 | for(int i=1; i <= 12; ++i) | 432 | for(int i=1; i <= 12; ++i) |
437 | { // maxMonthRect is used by sizeHint() | 433 | { // maxMonthRect is used by sizeHint() |
438 | r=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); | 434 | r=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); |
439 | maxMonthRect.setWidth(QMAX(r.width(), maxMonthRect.width())); | 435 | maxMonthRect.setWidth(QMAX(r.width(), maxMonthRect.width())); |
440 | maxMonthRect.setHeight(QMAX(r.height(), maxMonthRect.height())); | 436 | maxMonthRect.setHeight(QMAX(r.height(), maxMonthRect.height())); |
441 | } | 437 | } |
442 | table->setFontSize(s); | 438 | table->setFontSize(s); |
443 | } | 439 | } |
444 | 440 | ||
445 | void KDatePicker::virtual_hook( int id, void* data ) | 441 | void KDatePicker::virtual_hook( int id, void* data ) |
446 | { /*BASE::virtual_hook( id, data );*/ } | 442 | { /*BASE::virtual_hook( id, data );*/ } |
447 | 443 | ||
448 | void KDatePicker::keyPressEvent ( QKeyEvent * e ) | 444 | void KDatePicker::keyPressEvent ( QKeyEvent * e ) |
449 | { | 445 | { |
450 | switch ( e->key() ) { | 446 | switch ( e->key() ) { |
451 | case Qt::Key_Right: | 447 | case Qt::Key_Right: |
452 | monthForwardClicked(); | 448 | monthForwardClicked(); |
453 | break; | 449 | break; |
454 | case Qt::Key_Left: | 450 | case Qt::Key_Left: |
455 | monthBackwardClicked(); | 451 | monthBackwardClicked(); |
456 | break; | 452 | break; |
457 | 453 | ||
458 | case Qt::Key_Down: | 454 | case Qt::Key_Down: |
459 | yearForwardClicked(); | 455 | yearForwardClicked(); |
460 | 456 | ||
461 | break; | 457 | break; |
462 | 458 | ||
463 | case Qt::Key_Up: | 459 | case Qt::Key_Up: |
464 | yearBackwardClicked(); | 460 | yearBackwardClicked(); |
465 | break; | 461 | break; |
466 | 462 | ||
467 | case Qt::Key_Return: | 463 | case Qt::Key_Return: |
468 | tableClickedSlot(); | 464 | tableClickedSlot(); |
469 | break; | 465 | break; |
470 | 466 | ||
471 | default: | 467 | default: |
472 | break; | 468 | break; |
473 | } | 469 | } |
474 | 470 | ||
475 | } | 471 | } |
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp index fce0e5a..e827412 100644 --- a/microkde/kdatetbl.cpp +++ b/microkde/kdatetbl.cpp | |||
@@ -1,915 +1,929 @@ | |||
1 | /* -*- C++ -*- | 1 | /* -*- C++ -*- |
2 | This file is part of the KDE libraries | 2 | This file is part of the KDE libraries |
3 | Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) | 3 | Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) |
4 | (C) 1998-2001 Mirko Boehm (mirko@kde.org) | 4 | (C) 1998-2001 Mirko Boehm (mirko@kde.org) |
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /////////////////// KDateTable widget class ////////////////////// | 21 | /////////////////// KDateTable widget class ////////////////////// |
22 | // | 22 | // |
23 | // Copyright (C) 1997 Tim D. Gilman | 23 | // Copyright (C) 1997 Tim D. Gilman |
24 | // (C) 1998-2001 Mirko Boehm | 24 | // (C) 1998-2001 Mirko Boehm |
25 | // Written using Qt (http://www.troll.no) for the | 25 | // Written using Qt (http://www.troll.no) for the |
26 | // KDE project (http://www.kde.org) | 26 | // KDE project (http://www.kde.org) |
27 | // | 27 | // |
28 | // This is a support class for the KDatePicker class. It just | 28 | // This is a support class for the KDatePicker class. It just |
29 | // draws the calender table without titles, but could theoretically | 29 | // draws the calender table without titles, but could theoretically |
30 | // be used as a standalone. | 30 | // be used as a standalone. |
31 | // | 31 | // |
32 | // When a date is selected by the user, it emits a signal: | 32 | // When a date is selected by the user, it emits a signal: |
33 | // dateSelected(QDate) | 33 | // dateSelected(QDate) |
34 | 34 | ||
35 | #include <kglobal.h> | 35 | #include <kglobal.h> |
36 | #include <kglobalsettings.h> | 36 | #include <kglobalsettings.h> |
37 | #include <kapplication.h> | 37 | #include <kapplication.h> |
38 | #include <klocale.h> | 38 | #include <klocale.h> |
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <knotifyclient.h> | 40 | #include <knotifyclient.h> |
41 | #include "kdatetbl.h" | 41 | #include "kdatetbl.h" |
42 | #include <qdatetime.h> | 42 | #include <qdatetime.h> |
43 | #include <qstring.h> | 43 | #include <qstring.h> |
44 | #include <qpen.h> | 44 | #include <qpen.h> |
45 | #include <qpainter.h> | 45 | #include <qpainter.h> |
46 | #include <qdialog.h> | 46 | #include <qdialog.h> |
47 | #include <assert.h> | 47 | #include <assert.h> |
48 | #include <qapplication.h> | 48 | #include <qapplication.h> |
49 | 49 | ||
50 | KDateValidator::KDateValidator(QWidget* parent, const char* name) | 50 | KDateValidator::KDateValidator(QWidget* parent, const char* name) |
51 | : QValidator(parent, name) | 51 | : QValidator(parent, name) |
52 | { | 52 | { |
53 | } | 53 | } |
54 | 54 | ||
55 | QValidator::State | 55 | QValidator::State |
56 | KDateValidator::validate(QString& text, int&) const | 56 | KDateValidator::validate(QString& text, int&) const |
57 | { | 57 | { |
58 | QDate temp; | 58 | QDate temp; |
59 | // ----- everything is tested in date(): | 59 | // ----- everything is tested in date(): |
60 | return date(text, temp); | 60 | return date(text, temp); |
61 | } | 61 | } |
62 | 62 | ||
63 | QValidator::State | 63 | QValidator::State |
64 | KDateValidator::date(const QString& text, QDate& d) const | 64 | KDateValidator::date(const QString& text, QDate& d) const |
65 | { | 65 | { |
66 | QDate tmp = KGlobal::locale()->readDate(text); | 66 | QDate tmp = KGlobal::locale()->readDate(text); |
67 | if (!tmp.isNull()) | 67 | if (!tmp.isNull()) |
68 | { | 68 | { |
69 | d = tmp; | 69 | d = tmp; |
70 | return Acceptable; | 70 | return Acceptable; |
71 | } else | 71 | } else |
72 | return Valid; | 72 | return Valid; |
73 | } | 73 | } |
74 | 74 | ||
75 | void | 75 | void |
76 | KDateValidator::fixup( QString& ) const | 76 | KDateValidator::fixup( QString& ) const |
77 | { | 77 | { |
78 | 78 | ||
79 | } | 79 | } |
80 | 80 | ||
81 | KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, WFlags f) | 81 | KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, WFlags f) |
82 | : QGridView(parent, name, f) | 82 | : QGridView(parent, name, f) |
83 | { | 83 | { |
84 | setFontSize(10); | 84 | setFontSize(10); |
85 | if(!date_.isValid()) | 85 | if(!date_.isValid()) |
86 | { | 86 | { |
87 | date_=QDate::currentDate(); | 87 | date_=QDate::currentDate(); |
88 | } | 88 | } |
89 | setFocusPolicy( QWidget::StrongFocus ); | 89 | setFocusPolicy( QWidget::StrongFocus ); |
90 | setNumRows(7); // 6 weeks max + headline | 90 | setNumRows(7); // 6 weeks max + headline |
91 | setNumCols(7); // 7 days a week | 91 | setNumCols(7); // 7 days a week |
92 | setHScrollBarMode(AlwaysOff); | 92 | setHScrollBarMode(AlwaysOff); |
93 | setVScrollBarMode(AlwaysOff); | 93 | setVScrollBarMode(AlwaysOff); |
94 | viewport()->setBackgroundColor(QColor(220,245,255)); | 94 | viewport()->setBackgroundColor(QColor(220,245,255)); |
95 | #if 0 | 95 | #if 0 |
96 | viewport()->setEraseColor(lightGray); | 96 | viewport()->setEraseColor(lightGray); |
97 | #endif | 97 | #endif |
98 | mMarkCurrent = false; | 98 | mMarkCurrent = false; |
99 | setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth | 99 | setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth |
100 | } | 100 | } |
101 | 101 | ||
102 | void | 102 | void |
103 | KDateTable::paintCell(QPainter *painter, int row, int col) | 103 | KDateTable::paintCell(QPainter *painter, int row, int col) |
104 | { | 104 | { |
105 | QRect rect; | 105 | QRect rect; |
106 | QString text; | 106 | QString text; |
107 | QPen pen; | 107 | QPen pen; |
108 | int w=cellWidth(); | 108 | int w=cellWidth(); |
109 | int h=cellHeight(); | 109 | int h=cellHeight(); |
110 | int pos; | 110 | int pos; |
111 | QBrush brushBlue(blue); | 111 | QBrush brushBlue(blue); |
112 | QBrush brushLightblue(QColor(220,245,255)); | 112 | QBrush brushLightblue(QColor(220,245,255)); |
113 | QFont font=KGlobalSettings::generalFont(); | 113 | QFont font=KGlobalSettings::generalFont(); |
114 | // ----- | 114 | // ----- |
115 | font.setPointSize(fontsize); | 115 | font.setPointSize(fontsize); |
116 | if(row==0) | 116 | if(row==0) |
117 | { // we are drawing the headline | 117 | { // we are drawing the headline |
118 | font.setBold(true); | 118 | font.setBold(true); |
119 | painter->setFont(font); | 119 | painter->setFont(font); |
120 | bool normalday = true; | 120 | bool normalday = true; |
121 | QString daystr; | 121 | QString daystr; |
122 | if (KGlobal::locale()->weekStartsMonday()) | 122 | if (KGlobal::locale()->weekStartsMonday()) |
123 | { | 123 | { |
124 | daystr = KGlobal::locale()->weekDayName(col+1, true); | 124 | daystr = KGlobal::locale()->weekDayName(col+1, true); |
125 | if (col == 5 || col == 6) | 125 | if (col == 5 || col == 6) |
126 | normalday = false; | 126 | normalday = false; |
127 | } else { | 127 | } else { |
128 | daystr = KGlobal::locale()->weekDayName(col==0? 7 : col, true); | 128 | daystr = KGlobal::locale()->weekDayName(col==0? 7 : col, true); |
129 | if (col == 0 || col == 6) | 129 | if (col == 0 || col == 6) |
130 | normalday = false; | 130 | normalday = false; |
131 | } | 131 | } |
132 | if (!normalday) | 132 | if (!normalday) |
133 | { | 133 | { |
134 | painter->setPen(QColor(220,245,255)); | 134 | painter->setPen(QColor(220,245,255)); |
135 | painter->setBrush(brushLightblue); | 135 | painter->setBrush(brushLightblue); |
136 | painter->drawRect(0, 0, w, h); | 136 | painter->drawRect(0, 0, w, h); |
137 | painter->setPen(blue); | 137 | painter->setPen(blue); |
138 | } else { | 138 | } else { |
139 | painter->setPen(blue); | 139 | painter->setPen(blue); |
140 | painter->setBrush(brushBlue); | 140 | painter->setBrush(brushBlue); |
141 | painter->drawRect(0, 0, w, h); | 141 | painter->drawRect(0, 0, w, h); |
142 | painter->setPen(white); | 142 | painter->setPen(white); |
143 | } | 143 | } |
144 | painter->drawText(0, 0, w, h-1, AlignCenter, | 144 | painter->drawText(0, 0, w, h-1, AlignCenter, |
145 | daystr, -1, &rect); | 145 | daystr, -1, &rect); |
146 | painter->setPen(black); | 146 | painter->setPen(black); |
147 | painter->moveTo(0, h-1); | 147 | painter->moveTo(0, h-1); |
148 | painter->lineTo(w-1, h-1); | 148 | painter->lineTo(w-1, h-1); |
149 | // ----- draw the weekday: | 149 | // ----- draw the weekday: |
150 | } else { | 150 | } else { |
151 | painter->setFont(font); | 151 | painter->setFont(font); |
152 | pos=7*(row-1)+col; | 152 | pos=7*(row-1)+col; |
153 | if (KGlobal::locale()->weekStartsMonday()) | 153 | if (KGlobal::locale()->weekStartsMonday()) |
154 | pos++; | 154 | pos++; |
155 | if(pos<firstday || (firstday+numdays<=pos)) | 155 | if(pos<firstday || (firstday+numdays<=pos)) |
156 | { // we are either | 156 | { // we are either |
157 | // ° painting a day of the previous month or | 157 | // ° painting a day of the previous month or |
158 | // ° painting a day of the following month | 158 | // ° painting a day of the following month |
159 | if(pos<firstday) | 159 | if(pos<firstday) |
160 | { // previous month | 160 | { // previous month |
161 | text.setNum(numDaysPrevMonth+pos-firstday+1); | 161 | text.setNum(numDaysPrevMonth+pos-firstday+1); |
162 | } else { // following month | 162 | } else { // following month |
163 | text.setNum(pos-firstday-numdays+1); | 163 | text.setNum(pos-firstday-numdays+1); |
164 | } | 164 | } |
165 | painter->setPen(gray); | 165 | painter->setPen(gray); |
166 | } else { // paint a day of the current month | 166 | } else { // paint a day of the current month |
167 | text.setNum(pos-firstday+1); | 167 | text.setNum(pos-firstday+1); |
168 | painter->setPen(black); | 168 | painter->setPen(black); |
169 | } | 169 | } |
170 | 170 | ||
171 | pen=painter->pen(); | 171 | pen=painter->pen(); |
172 | if(firstday+date.day()-1==pos) | 172 | if(firstday+date.day()-1==pos) |
173 | { | 173 | { |
174 | if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) | 174 | if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) |
175 | painter->setPen(green); | 175 | painter->setPen(green); |
176 | else | 176 | else |
177 | painter->setPen(red); | 177 | painter->setPen(red); |
178 | if(hasFocus()) | 178 | if(hasFocus()) |
179 | { | 179 | { |
180 | painter->setBrush(darkRed); | 180 | painter->setBrush(darkRed); |
181 | pen=white; | 181 | pen=white; |
182 | } else { | 182 | } else { |
183 | painter->setBrush(darkGray); | 183 | painter->setBrush(darkGray); |
184 | pen=white; | 184 | pen=white; |
185 | } | 185 | } |
186 | } else { | 186 | } else { |
187 | if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) | 187 | if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) |
188 | { | 188 | { |
189 | painter->setPen(green); | 189 | painter->setPen(green); |
190 | painter->setBrush(darkGreen); | 190 | painter->setBrush(darkGreen); |
191 | pen=white; | 191 | pen=white; |
192 | } else { | 192 | } else { |
193 | painter->setBrush(QColor(220,245,255)); | 193 | painter->setBrush(QColor(220,245,255)); |
194 | painter->setPen(QColor(220,245,255)); | 194 | painter->setPen(QColor(220,245,255)); |
195 | } | 195 | } |
196 | } | 196 | } |
197 | painter->drawRect(0, 0, w, h); | 197 | painter->drawRect(0, 0, w, h); |
198 | painter->setPen(pen); | 198 | painter->setPen(pen); |
199 | painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect); | 199 | painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect); |
200 | } | 200 | } |
201 | if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width()); | 201 | /* |
202 | if(rect.height()>maxCell.height()) maxCell.setHeight(rect.height()); | 202 | if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width()); |
203 | if(rect.height()>maxCell.height()) { | ||
204 | maxCell.setHeight(rect.height()); | ||
205 | } | ||
206 | */ | ||
203 | } | 207 | } |
204 | 208 | ||
205 | void | 209 | void |
206 | KDateTable::keyPressEvent( QKeyEvent *e ) | 210 | KDateTable::keyPressEvent( QKeyEvent *e ) |
207 | { | 211 | { |
208 | /* | 212 | /* |
209 | // not working properly | 213 | // not working properly |
210 | if ( e->key() == Qt::Key_Prior ) { | 214 | if ( e->key() == Qt::Key_Prior ) { |
211 | if ( date.month() == 1 ) { | 215 | if ( date.month() == 1 ) { |
212 | KNotifyClient::beep(); | 216 | KNotifyClient::beep(); |
213 | return; | 217 | return; |
214 | } | 218 | } |
215 | int day = date.day(); | 219 | int day = date.day(); |
216 | if ( day > 27 ) | 220 | if ( day > 27 ) |
217 | while ( !QDate::isValid( date.year(), date.month()-1, day ) ) | 221 | while ( !QDate::isValid( date.year(), date.month()-1, day ) ) |
218 | day--; | 222 | day--; |
219 | setDate(QDate(date.year(), date.month()-1, day)); | 223 | setDate(QDate(date.year(), date.month()-1, day)); |
220 | return; | 224 | return; |
221 | } | 225 | } |
222 | if ( e->key() == Qt::Key_Next ) { | 226 | if ( e->key() == Qt::Key_Next ) { |
223 | if ( date.month() == 12 ) { | 227 | if ( date.month() == 12 ) { |
224 | KNotifyClient::beep(); | 228 | KNotifyClient::beep(); |
225 | return; | 229 | return; |
226 | } | 230 | } |
227 | int day = date.day(); | 231 | int day = date.day(); |
228 | if ( day > 27 ) | 232 | if ( day > 27 ) |
229 | while ( !QDate::isValid( date.year(), date.month()+1, day ) ) | 233 | while ( !QDate::isValid( date.year(), date.month()+1, day ) ) |
230 | day--; | 234 | day--; |
231 | setDate(QDate(date.year(), date.month()+1, day)); | 235 | setDate(QDate(date.year(), date.month()+1, day)); |
232 | return; | 236 | return; |
233 | } | 237 | } |
234 | */ | 238 | */ |
235 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; | 239 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; |
236 | 240 | ||
237 | int temp=firstday+date.day()-dayoff; | 241 | int temp=firstday+date.day()-dayoff; |
238 | int pos = temp; | 242 | int pos = temp; |
239 | bool irgnore = true; | 243 | bool irgnore = true; |
240 | if ( e->state() != Qt::ControlButton ) { | 244 | if ( e->state() != Qt::ControlButton ) { |
241 | if ( e->key() == Qt::Key_Up ) { | 245 | if ( e->key() == Qt::Key_Up ) { |
242 | pos -= 7; | 246 | pos -= 7; |
243 | irgnore = false; | 247 | irgnore = false; |
244 | } | 248 | } |
245 | if ( e->key() == Qt::Key_Down ) { | 249 | if ( e->key() == Qt::Key_Down ) { |
246 | pos += 7; | 250 | pos += 7; |
247 | irgnore = false; | 251 | irgnore = false; |
248 | } | 252 | } |
249 | if ( e->key() == Qt::Key_Left ) { | 253 | if ( e->key() == Qt::Key_Left ) { |
250 | pos--; | 254 | pos--; |
251 | irgnore = false; | 255 | irgnore = false; |
252 | } | 256 | } |
253 | if ( e->key() == Qt::Key_Right ) { | 257 | if ( e->key() == Qt::Key_Right ) { |
254 | pos++; | 258 | pos++; |
255 | irgnore = false; | 259 | irgnore = false; |
256 | } | 260 | } |
257 | } | 261 | } |
258 | if ( irgnore ) | 262 | if ( irgnore ) |
259 | e->ignore(); | 263 | e->ignore(); |
260 | 264 | ||
261 | if(pos+dayoff<=firstday) | 265 | if(pos+dayoff<=firstday) |
262 | { // this day is in the previous month | 266 | { // this day is in the previous month |
263 | KNotifyClient::beep(); | 267 | KNotifyClient::beep(); |
264 | return; | 268 | return; |
265 | } | 269 | } |
266 | if(firstday+numdays<pos+dayoff) | 270 | if(firstday+numdays<pos+dayoff) |
267 | { // this date is in the next month | 271 | { // this date is in the next month |
268 | KNotifyClient::beep(i18n( "Month not long enough" )); | 272 | KNotifyClient::beep(i18n( "Month not long enough" )); |
269 | return; | 273 | return; |
270 | } | 274 | } |
271 | 275 | ||
272 | if ( pos == temp ) | 276 | if ( pos == temp ) |
273 | return; | 277 | return; |
274 | 278 | ||
275 | setDate(QDate(date.year(), date.month(), pos-firstday+dayoff)); | 279 | setDate(QDate(date.year(), date.month(), pos-firstday+dayoff)); |
276 | updateCell(temp/7+1, temp%7); // Update the previously selected cell | 280 | updateCell(temp/7+1, temp%7); // Update the previously selected cell |
277 | updateCell(pos/7+1, pos%7); // Update the selected cell | 281 | updateCell(pos/7+1, pos%7); // Update the selected cell |
278 | assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); | 282 | assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); |
279 | 283 | ||
280 | 284 | ||
281 | } | 285 | } |
282 | 286 | ||
283 | void | 287 | void |
284 | KDateTable::viewportResizeEvent(QResizeEvent * e) | 288 | KDateTable::viewportResizeEvent(QResizeEvent * e) |
285 | { | 289 | { |
286 | QGridView::viewportResizeEvent(e); | 290 | QGridView::viewportResizeEvent(e); |
287 | 291 | ||
288 | setCellWidth(viewport()->width()/7); | 292 | setCellWidth(viewport()->width()/7); |
289 | setCellHeight(viewport()->height()/7); | 293 | setCellHeight(viewport()->height()/7); |
290 | } | 294 | } |
291 | 295 | ||
292 | void | 296 | void |
293 | KDateTable::setFontSize(int size) | 297 | KDateTable::setFontSize(int size) |
294 | { | 298 | { |
295 | int count; | 299 | int count; |
296 | QRect rect; | 300 | QRect rect; |
297 | // ----- store rectangles: | 301 | // ----- store rectangles: |
298 | fontsize=size; | 302 | fontsize=size; |
299 | QFont font = KGlobalSettings::generalFont(); | 303 | QFont font = KGlobalSettings::generalFont(); |
300 | font.setPointSize(fontsize); | 304 | font.setPointSize(fontsize); |
301 | font.setBold( true ); | 305 | font.setBold( true ); |
302 | QFontMetrics metrics(font); | 306 | QFontMetrics metrics(font); |
303 | 307 | ||
304 | // ----- find largest day name: | 308 | // ----- find largest day name: |
305 | maxCell.setWidth(0); | 309 | maxCell.setWidth(0); |
306 | maxCell.setHeight(0); | 310 | maxCell.setHeight(0); |
307 | for(count=0; count<7; ++count) | 311 | for(count=0; count<7; ++count) |
308 | { | 312 | { |
309 | rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true)); | 313 | rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true)); |
310 | maxCell.setWidth(QMAX(maxCell.width(), rect.width())); | 314 | maxCell.setWidth(QMAX(maxCell.width(), rect.width())); |
311 | maxCell.setHeight(QMAX(maxCell.height(), rect.height())); | 315 | maxCell.setHeight(QMAX(maxCell.height(), rect.height())); |
312 | } | 316 | } |
313 | // ----- compare with a real wide number and add some space: | 317 | // ----- compare with a real wide number and add some space: |
314 | rect=metrics.boundingRect(QString::fromLatin1("88")); | 318 | rect=metrics.boundingRect(QString::fromLatin1("88")); |
315 | maxCell.setWidth(QMAX(maxCell.width()+2, rect.width())); | 319 | maxCell.setWidth(QMAX(maxCell.width()+2, rect.width())); |
320 | #ifdef DESKTOP_VERSION | ||
321 | maxCell.setHeight(QMAX(maxCell.height()+8, rect.height())); | ||
322 | #else | ||
316 | maxCell.setHeight(QMAX(maxCell.height()+4, rect.height())); | 323 | maxCell.setHeight(QMAX(maxCell.height()+4, rect.height())); |
317 | if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) | 324 | #endif |
325 | if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) { | ||
318 | maxCell.setHeight(maxCell.width() * 1000 / 1900 ); | 326 | maxCell.setHeight(maxCell.width() * 1000 / 1900 ); |
327 | qDebug("setmax "); | ||
328 | } | ||
319 | } | 329 | } |
320 | 330 | ||
321 | void | 331 | void |
322 | KDateTable::contentsMousePressEvent(QMouseEvent *e) | 332 | KDateTable::contentsMousePressEvent(QMouseEvent *e) |
323 | { | 333 | { |
324 | if(e->type()!=QEvent::MouseButtonPress) | 334 | if(e->type()!=QEvent::MouseButtonPress) |
325 | { // the KDatePicker only reacts on mouse press events: | 335 | { // the KDatePicker only reacts on mouse press events: |
326 | return; | 336 | return; |
327 | } | 337 | } |
328 | if(!isEnabled()) | 338 | if(!isEnabled()) |
329 | { | 339 | { |
330 | KNotifyClient::beep(); | 340 | KNotifyClient::beep(); |
331 | return; | 341 | return; |
332 | } | 342 | } |
333 | 343 | ||
334 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; | 344 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; |
335 | // ----- | 345 | // ----- |
336 | int row, col, pos, temp; | 346 | int row, col, pos, temp; |
337 | QPoint mouseCoord; | 347 | QPoint mouseCoord; |
338 | // ----- | 348 | // ----- |
339 | mouseCoord = e->pos(); | 349 | mouseCoord = e->pos(); |
340 | row=rowAt(mouseCoord.y()); | 350 | row=rowAt(mouseCoord.y()); |
341 | col=columnAt(mouseCoord.x()); | 351 | col=columnAt(mouseCoord.x()); |
342 | if(row<0 || col<0) | 352 | if(row<0 || col<0) |
343 | { // the user clicked on the frame of the table | 353 | { // the user clicked on the frame of the table |
344 | return; | 354 | return; |
345 | } | 355 | } |
346 | pos=7*(row-1)+col+1; | 356 | pos=7*(row-1)+col+1; |
347 | #if 0 | 357 | #if 0 |
348 | if(pos+dayoff<=firstday) | 358 | if(pos+dayoff<=firstday) |
349 | { // this day is in the previous month | 359 | { // this day is in the previous month |
350 | KNotifyClient::beep(); | 360 | KNotifyClient::beep(); |
351 | return; | 361 | return; |
352 | } | 362 | } |
353 | if(firstday+numdays<pos+dayoff) | 363 | if(firstday+numdays<pos+dayoff) |
354 | { // this date is in the next month | 364 | { // this date is in the next month |
355 | KNotifyClient::beep(); | 365 | KNotifyClient::beep(); |
356 | return; | 366 | return; |
357 | } | 367 | } |
358 | #endif | 368 | #endif |
359 | temp=firstday+date.day()-dayoff-1; | 369 | temp=firstday+date.day()-dayoff-1; |
360 | QDate da = QDate(date.year(), date.month(),1); | 370 | QDate da = QDate(date.year(), date.month(),1); |
361 | setDate(da.addDays( pos-firstday+dayoff-1)); | 371 | setDate(da.addDays( pos-firstday+dayoff-1)); |
362 | updateCell(temp/7+1, temp%7); // Update the previously selected cell | 372 | updateCell(temp/7+1, temp%7); // Update the previously selected cell |
363 | updateCell(row, col); // Update the selected cell | 373 | updateCell(row, col); // Update the selected cell |
364 | // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); | 374 | // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); |
365 | emit(tableClicked()); | 375 | emit(tableClicked()); |
366 | } | 376 | } |
367 | 377 | ||
368 | bool | 378 | bool |
369 | KDateTable::setDate(const QDate& date_) | 379 | KDateTable::setDate(const QDate& date_) |
370 | { | 380 | { |
371 | bool changed=false; | 381 | bool changed=false; |
372 | QDate temp; | 382 | QDate temp; |
373 | mMarkCurrent = false; | 383 | mMarkCurrent = false; |
374 | // ----- | 384 | // ----- |
375 | if(!date_.isValid()) | 385 | if(!date_.isValid()) |
376 | { | 386 | { |
377 | kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl; | 387 | kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl; |
378 | return false; | 388 | return false; |
379 | } | 389 | } |
380 | if(date!=date_) | 390 | if(date!=date_) |
381 | { | 391 | { |
382 | date=date_; | 392 | date=date_; |
383 | changed=true; | 393 | changed=true; |
384 | } | 394 | } |
385 | mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() ); | 395 | mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() ); |
386 | temp.setYMD(date.year(), date.month(), 1); | 396 | temp.setYMD(date.year(), date.month(), 1); |
387 | firstday=temp.dayOfWeek(); | 397 | firstday=temp.dayOfWeek(); |
388 | if(firstday==1) firstday=8; | 398 | if(firstday==1) firstday=8; |
389 | numdays=date.daysInMonth(); | 399 | numdays=date.daysInMonth(); |
390 | if(date.month()==1) | 400 | if(date.month()==1) |
391 | { // set to december of previous year | 401 | { // set to december of previous year |
392 | temp.setYMD(date.year()-1, 12, 1); | 402 | temp.setYMD(date.year()-1, 12, 1); |
393 | } else { // set to previous month | 403 | } else { // set to previous month |
394 | temp.setYMD(date.year(), date.month()-1, 1); | 404 | temp.setYMD(date.year(), date.month()-1, 1); |
395 | } | 405 | } |
396 | numDaysPrevMonth=temp.daysInMonth(); | 406 | numDaysPrevMonth=temp.daysInMonth(); |
397 | if(changed) | 407 | if(changed) |
398 | { | 408 | { |
399 | repaintContents(false); | 409 | repaintContents(false); |
400 | } | 410 | } |
401 | emit(dateChanged(date)); | 411 | emit(dateChanged(date)); |
402 | return true; | 412 | return true; |
403 | } | 413 | } |
404 | 414 | ||
405 | const QDate& | 415 | const QDate& |
406 | KDateTable::getDate() const | 416 | KDateTable::getDate() const |
407 | { | 417 | { |
408 | return date; | 418 | return date; |
409 | } | 419 | } |
410 | 420 | ||
411 | void KDateTable::focusInEvent( QFocusEvent *e ) | 421 | void KDateTable::focusInEvent( QFocusEvent *e ) |
412 | { | 422 | { |
413 | repaintContents(false); | 423 | repaintContents(false); |
414 | QGridView::focusInEvent( e ); | 424 | QGridView::focusInEvent( e ); |
415 | } | 425 | } |
416 | 426 | ||
417 | void KDateTable::focusOutEvent( QFocusEvent *e ) | 427 | void KDateTable::focusOutEvent( QFocusEvent *e ) |
418 | { | 428 | { |
419 | repaintContents(false); | 429 | repaintContents(false); |
420 | QGridView::focusOutEvent( e ); | 430 | QGridView::focusOutEvent( e ); |
421 | } | 431 | } |
422 | 432 | ||
423 | QSize | 433 | QSize |
424 | KDateTable::sizeHint() const | 434 | KDateTable::sizeHint() const |
425 | { | 435 | { |
426 | if(maxCell.height()>0 && maxCell.width()>0) | 436 | if(maxCell.height()>0 && maxCell.width()>0) |
427 | { | 437 | { |
428 | return QSize((maxCell.width()+2)*numCols()+2*frameWidth(), | 438 | return QSize((maxCell.width()+2)*numCols()+2*frameWidth(), |
429 | (maxCell.height()+4)*numRows()+2*frameWidth()); | 439 | (maxCell.height()+4)*numRows()+2*frameWidth()); |
430 | } else { | 440 | } else { |
431 | return QSize(-1, -1); | 441 | return QSize(-1, -1); |
432 | } | 442 | } |
433 | } | 443 | } |
434 | 444 | ||
435 | KDateInternalMonthPicker::KDateInternalMonthPicker | 445 | KDateInternalMonthPicker::KDateInternalMonthPicker |
436 | (int fontsize, QWidget* parent, const char* name) | 446 | (int fontsize, QWidget* parent, const char* name) |
437 | : QGridView(parent, name), | 447 | : QGridView(parent, name), |
438 | result(0) // invalid | 448 | result(0) // invalid |
439 | { | 449 | { |
440 | QRect rect; | 450 | QRect rect; |
441 | QFont font; | 451 | QFont font; |
442 | // ----- | 452 | // ----- |
443 | activeCol = -1; | 453 | activeCol = -1; |
444 | activeRow = -1; | 454 | activeRow = -1; |
445 | font=KGlobalSettings::generalFont(); | 455 | font=KGlobalSettings::generalFont(); |
446 | font.setPointSize(fontsize); | 456 | //font.setPointSize(fontsize); |
447 | setFont(font); | 457 | setFont(font); |
448 | setHScrollBarMode(AlwaysOff); | 458 | setHScrollBarMode(AlwaysOff); |
449 | setVScrollBarMode(AlwaysOff); | 459 | setVScrollBarMode(AlwaysOff); |
450 | setFrameStyle(QFrame::NoFrame); | 460 | setFrameStyle(QFrame::NoFrame); |
451 | setNumRows(4); | 461 | setNumRows(4); |
452 | setNumCols(3); | 462 | setNumCols(3); |
453 | // enable to find drawing failures: | 463 | // enable to find drawing failures: |
454 | // setTableFlags(Tbl_clipCellPainting); | 464 | // setTableFlags(Tbl_clipCellPainting); |
455 | #if 0 | 465 | #if 0 |
456 | viewport()->setEraseColor(lightGray); // for consistency with the datepicker | 466 | viewport()->setEraseColor(lightGray); // for consistency with the datepicker |
457 | #endif | 467 | #endif |
458 | // ----- find the preferred size | 468 | // ----- find the preferred size |
459 | // (this is slow, possibly, but unfortunatly it is needed here): | 469 | // (this is slow, possibly, but unfortunatly it is needed here): |
460 | QFontMetrics metrics(font); | 470 | QFontMetrics metrics(font); |
461 | for(int i=1; i <= 12; ++i) | 471 | for(int i=1; i <= 12; ++i) |
462 | { | 472 | { |
463 | rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); | 473 | rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); |
464 | if(max.width()<rect.width()) max.setWidth(rect.width()); | 474 | if(max.width()<rect.width()) max.setWidth(rect.width()); |
465 | if(max.height()<rect.height()) max.setHeight(rect.height()); | 475 | if(max.height()<rect.height()) max.setHeight(rect.height()); |
466 | } | 476 | } |
467 | 477 | ||
468 | } | 478 | } |
469 | 479 | ||
470 | QSize | 480 | QSize |
471 | KDateInternalMonthPicker::sizeHint() const | 481 | KDateInternalMonthPicker::sizeHint() const |
472 | { | 482 | { |
473 | return QSize((max.width()+6)*numCols()+2*frameWidth(), | 483 | return QSize((max.width()+6)*numCols()+2*frameWidth(), |
474 | (max.height()+6)*numRows()+2*frameWidth()); | 484 | (max.height()+6)*numRows()+2*frameWidth()); |
475 | } | 485 | } |
476 | 486 | ||
477 | int | 487 | int |
478 | KDateInternalMonthPicker::getResult() const | 488 | KDateInternalMonthPicker::getResult() const |
479 | { | 489 | { |
480 | return result; | 490 | return result; |
481 | } | 491 | } |
482 | 492 | ||
483 | void | 493 | void |
484 | KDateInternalMonthPicker::setupPainter(QPainter *p) | 494 | KDateInternalMonthPicker::setupPainter(QPainter *p) |
485 | { | 495 | { |
486 | p->setPen(black); | 496 | p->setPen(black); |
487 | } | 497 | } |
488 | 498 | ||
489 | void | 499 | void |
490 | KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*) | 500 | KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*) |
491 | { | 501 | { |
492 | setCellWidth(width()/3); | 502 | setCellWidth(width()/3); |
493 | setCellHeight(height()/4); | 503 | setCellHeight(height()/4); |
494 | } | 504 | } |
495 | 505 | ||
496 | void | 506 | void |
497 | KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col) | 507 | KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col) |
498 | { | 508 | { |
499 | int index; | 509 | int index; |
500 | QString text; | 510 | QString text; |
501 | // ----- find the number of the cell: | 511 | // ----- find the number of the cell: |
502 | index=3*row+col+1; | 512 | index=3*row+col+1; |
503 | text=KGlobal::locale()->monthName(index, false); | 513 | text=KGlobal::locale()->monthName(index, false); |
504 | painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); | 514 | painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); |
505 | if ( activeCol == col && activeRow == row ) | 515 | if ( activeCol == col && activeRow == row ) |
506 | painter->drawRect( 0, 0, cellWidth(), cellHeight() ); | 516 | painter->drawRect( 0, 0, cellWidth(), cellHeight() ); |
507 | } | 517 | } |
508 | 518 | ||
509 | void | 519 | void |
510 | KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) | 520 | KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) |
511 | { | 521 | { |
512 | if(!isEnabled() || e->button() != LeftButton) | 522 | if(!isEnabled() || e->button() != LeftButton) |
513 | { | 523 | { |
514 | KNotifyClient::beep(); | 524 | KNotifyClient::beep(); |
515 | return; | 525 | return; |
516 | } | 526 | } |
517 | // ----- | 527 | // ----- |
518 | int row, col; | 528 | int row, col; |
519 | QPoint mouseCoord; | 529 | QPoint mouseCoord; |
520 | // ----- | 530 | // ----- |
521 | mouseCoord = e->pos(); | 531 | mouseCoord = e->pos(); |
522 | row=rowAt(mouseCoord.y()); | 532 | row=rowAt(mouseCoord.y()); |
523 | col=columnAt(mouseCoord.x()); | 533 | col=columnAt(mouseCoord.x()); |
524 | 534 | ||
525 | if(row<0 || col<0) | 535 | if(row<0 || col<0) |
526 | { // the user clicked on the frame of the table | 536 | { // the user clicked on the frame of the table |
527 | activeCol = -1; | 537 | activeCol = -1; |
528 | activeRow = -1; | 538 | activeRow = -1; |
529 | } else { | 539 | } else { |
530 | activeCol = col; | 540 | activeCol = col; |
531 | activeRow = row; | 541 | activeRow = row; |
532 | updateCell( row, col /*, false */ ); | 542 | updateCell( row, col /*, false */ ); |
533 | } | 543 | } |
534 | } | 544 | } |
535 | 545 | ||
536 | void | 546 | void |
537 | KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e) | 547 | KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e) |
538 | { | 548 | { |
539 | if (e->state() & LeftButton) | 549 | if (e->state() & LeftButton) |
540 | { | 550 | { |
541 | int row, col; | 551 | int row, col; |
542 | QPoint mouseCoord; | 552 | QPoint mouseCoord; |
543 | // ----- | 553 | // ----- |
544 | mouseCoord = e->pos(); | 554 | mouseCoord = e->pos(); |
545 | row=rowAt(mouseCoord.y()); | 555 | row=rowAt(mouseCoord.y()); |
546 | col=columnAt(mouseCoord.x()); | 556 | col=columnAt(mouseCoord.x()); |
547 | int tmpRow = -1, tmpCol = -1; | 557 | int tmpRow = -1, tmpCol = -1; |
548 | if(row<0 || col<0) | 558 | if(row<0 || col<0) |
549 | { // the user clicked on the frame of the table | 559 | { // the user clicked on the frame of the table |
550 | if ( activeCol > -1 ) | 560 | if ( activeCol > -1 ) |
551 | { | 561 | { |
552 | tmpRow = activeRow; | 562 | tmpRow = activeRow; |
553 | tmpCol = activeCol; | 563 | tmpCol = activeCol; |
554 | } | 564 | } |
555 | activeCol = -1; | 565 | activeCol = -1; |
556 | activeRow = -1; | 566 | activeRow = -1; |
557 | } else { | 567 | } else { |
558 | bool differentCell = (activeRow != row || activeCol != col); | 568 | bool differentCell = (activeRow != row || activeCol != col); |
559 | if ( activeCol > -1 && differentCell) | 569 | if ( activeCol > -1 && differentCell) |
560 | { | 570 | { |
561 | tmpRow = activeRow; | 571 | tmpRow = activeRow; |
562 | tmpCol = activeCol; | 572 | tmpCol = activeCol; |
563 | } | 573 | } |
564 | if ( differentCell) | 574 | if ( differentCell) |
565 | { | 575 | { |
566 | activeRow = row; | 576 | activeRow = row; |
567 | activeCol = col; | 577 | activeCol = col; |
568 | updateCell( row, col /*, false */ ); // mark the new active cell | 578 | updateCell( row, col /*, false */ ); // mark the new active cell |
569 | } | 579 | } |
570 | } | 580 | } |
571 | if ( tmpRow > -1 ) // repaint the former active cell | 581 | if ( tmpRow > -1 ) // repaint the former active cell |
572 | updateCell( tmpRow, tmpCol /*, true */ ); | 582 | updateCell( tmpRow, tmpCol /*, true */ ); |
573 | } | 583 | } |
574 | } | 584 | } |
575 | 585 | ||
576 | void | 586 | void |
577 | KDateInternalMonthPicker::contentsMouseReleaseEvent(QMouseEvent *e) | 587 | KDateInternalMonthPicker::contentsMouseReleaseEvent(QMouseEvent *e) |
578 | { | 588 | { |
579 | if(!isEnabled()) | 589 | if(!isEnabled()) |
580 | { | 590 | { |
581 | return; | 591 | return; |
582 | } | 592 | } |
583 | // ----- | 593 | // ----- |
584 | int row, col, pos; | 594 | int row, col, pos; |
585 | QPoint mouseCoord; | 595 | QPoint mouseCoord; |
586 | // ----- | 596 | // ----- |
587 | mouseCoord = e->pos(); | 597 | mouseCoord = e->pos(); |
588 | row=rowAt(mouseCoord.y()); | 598 | row=rowAt(mouseCoord.y()); |
589 | col=columnAt(mouseCoord.x()); | 599 | col=columnAt(mouseCoord.x()); |
590 | if(row<0 || col<0) | 600 | if(row<0 || col<0) |
591 | { // the user clicked on the frame of the table | 601 | { // the user clicked on the frame of the table |
592 | emit(closeMe(0)); | 602 | emit(closeMe(0)); |
593 | } | 603 | } |
594 | pos=3*row+col+1; | 604 | pos=3*row+col+1; |
595 | result=pos; | 605 | result=pos; |
596 | emit(closeMe(1)); | 606 | emit(closeMe(1)); |
597 | } | 607 | } |
598 | 608 | ||
599 | 609 | ||
600 | 610 | ||
601 | KDateInternalYearSelector::KDateInternalYearSelector | 611 | KDateInternalYearSelector::KDateInternalYearSelector |
602 | (int fontsize, QWidget* parent, const char* name) | 612 | (int fontsize, QWidget* parent, const char* name) |
603 | : QLineEdit(parent, name), | 613 | : QLineEdit(parent, name), |
604 | val(new QIntValidator(this)), | 614 | val(new QIntValidator(this)), |
605 | result(0) | 615 | result(0) |
606 | { | 616 | { |
607 | QFont font; | 617 | QFont font; |
608 | // ----- | 618 | // ----- |
609 | font=KGlobalSettings::generalFont(); | 619 | font=KGlobalSettings::generalFont(); |
610 | font.setPointSize(fontsize); | 620 | font.setPointSize(fontsize); |
611 | setFont(font); | 621 | setFont(font); |
612 | #if 0 | 622 | #if 0 |
613 | setFrameStyle(QFrame::NoFrame); | 623 | setFrameStyle(QFrame::NoFrame); |
614 | #endif | 624 | #endif |
615 | // we have to respect the limits of QDate here, I fear: | 625 | // we have to respect the limits of QDate here, I fear: |
616 | val->setRange(0, 8000); | 626 | val->setRange(0, 8000); |
617 | setValidator(val); | 627 | setValidator(val); |
618 | connect(this, SIGNAL(returnPressed()), SLOT(yearEnteredSlot())); | 628 | connect(this, SIGNAL(returnPressed()), SLOT(yearEnteredSlot())); |
619 | } | 629 | } |
620 | 630 | ||
621 | void | 631 | void |
622 | KDateInternalYearSelector::yearEnteredSlot() | 632 | KDateInternalYearSelector::yearEnteredSlot() |
623 | { | 633 | { |
624 | bool ok; | 634 | bool ok; |
625 | int year; | 635 | int year; |
626 | QDate date; | 636 | QDate date; |
627 | // ----- check if this is a valid year: | 637 | // ----- check if this is a valid year: |
628 | year=text().toInt(&ok); | 638 | year=text().toInt(&ok); |
629 | if(!ok) | 639 | if(!ok) |
630 | { | 640 | { |
631 | KNotifyClient::beep(); | 641 | KNotifyClient::beep(); |
632 | return; | 642 | return; |
633 | } | 643 | } |
634 | date.setYMD(year, 1, 1); | 644 | date.setYMD(year, 1, 1); |
635 | if(!date.isValid()) | 645 | if(!date.isValid()) |
636 | { | 646 | { |
637 | KNotifyClient::beep(); | 647 | KNotifyClient::beep(); |
638 | return; | 648 | return; |
639 | } | 649 | } |
640 | result=year; | 650 | result=year; |
641 | emit(closeMe(1)); | 651 | emit(closeMe(1)); |
642 | } | 652 | } |
643 | 653 | ||
644 | int | 654 | int |
645 | KDateInternalYearSelector::getYear() | 655 | KDateInternalYearSelector::getYear() |
646 | { | 656 | { |
647 | return result; | 657 | return result; |
648 | } | 658 | } |
649 | 659 | ||
650 | void | 660 | void |
651 | KDateInternalYearSelector::setYear(int year) | 661 | KDateInternalYearSelector::setYear(int year) |
652 | { | 662 | { |
653 | QString temp; | 663 | QString temp; |
654 | // ----- | 664 | // ----- |
655 | temp.setNum(year); | 665 | temp.setNum(year); |
656 | setText(temp); | 666 | setText(temp); |
657 | } | 667 | } |
658 | 668 | ||
659 | KPopupFrame::KPopupFrame(QWidget* parent, const char* name) | 669 | KPopupFrame::KPopupFrame(QWidget* parent, const char* name) |
660 | : QFrame(parent, name, WType_Popup), | 670 | : QFrame(parent, name, WType_Popup), |
661 | result(0), // rejected | 671 | result(0), // rejected |
662 | main(0) | 672 | main(0) |
663 | { | 673 | { |
664 | setFrameStyle(QFrame::Box|QFrame::Raised); | 674 | setFrameStyle(QFrame::Box|QFrame::Raised); |
665 | setMidLineWidth(2); | 675 | setMidLineWidth(2); |
666 | } | 676 | } |
667 | 677 | ||
668 | void | 678 | void |
669 | KPopupFrame::keyPressEvent(QKeyEvent* e) | 679 | KPopupFrame::keyPressEvent(QKeyEvent* e) |
670 | { | 680 | { |
671 | if(e->key()==Key_Escape) | 681 | if(e->key()==Key_Escape) |
672 | { | 682 | { |
673 | result=0; // rejected | 683 | result=0; // rejected |
674 | qApp->exit_loop(); | 684 | qApp->exit_loop(); |
675 | } | 685 | } |
676 | } | 686 | } |
677 | 687 | ||
678 | void | 688 | void |
679 | KPopupFrame::close(int r) | 689 | KPopupFrame::close(int r) |
680 | { | 690 | { |
681 | result=r; | 691 | result=r; |
682 | qApp->exit_loop(); | 692 | qApp->exit_loop(); |
683 | } | 693 | } |
684 | 694 | ||
685 | void | 695 | void |
686 | KPopupFrame::setMainWidget(QWidget* m) | 696 | KPopupFrame::setMainWidget(QWidget* m) |
687 | { | 697 | { |
688 | main=m; | 698 | main=m; |
689 | if(main!=0) | 699 | if(main!=0) |
690 | { | 700 | { |
691 | resize(main->width()+2*frameWidth(), main->height()+2*frameWidth()); | 701 | resize(main->width()+2*frameWidth(), main->height()+2*frameWidth()); |
692 | } | 702 | } |
693 | } | 703 | } |
694 | 704 | ||
695 | void | 705 | void |
696 | KPopupFrame::resizeEvent(QResizeEvent*) | 706 | KPopupFrame::resizeEvent(QResizeEvent*) |
697 | { | 707 | { |
698 | if(main!=0) | 708 | if(main!=0) |
699 | { | 709 | { |
700 | main->setGeometry(frameWidth(), frameWidth(), | 710 | main->setGeometry(frameWidth(), frameWidth(), |
701 | width()-2*frameWidth(), height()-2*frameWidth()); | 711 | width()-2*frameWidth(), height()-2*frameWidth()); |
702 | } | 712 | } |
703 | } | 713 | } |
704 | 714 | ||
705 | void | 715 | void |
706 | KPopupFrame::popup(const QPoint &pos) | 716 | KPopupFrame::popup(const QPoint &pos) |
707 | { | 717 | { |
708 | // Make sure the whole popup is visible. | 718 | // Make sure the whole popup is visible. |
709 | QRect d = QApplication::desktop()->frameGeometry(); | 719 | QRect d = QApplication::desktop()->frameGeometry(); |
710 | int x = pos.x(); | 720 | int x = pos.x(); |
711 | int y = pos.y(); | 721 | int y = pos.y(); |
712 | int w = width(); | 722 | int w = width(); |
713 | int h = height(); | 723 | int h = height(); |
714 | if (x+w > d.x()+d.width()) | 724 | if (x+w > d.x()+d.width()) |
715 | x = d.width() - w; | 725 | x = d.width() - w; |
716 | if (y+h > d.y()+d.height()) | 726 | if (y+h > d.y()+d.height()) |
717 | y = d.height() - h; | 727 | y = d.height() - h; |
718 | if (x < d.x()) | 728 | if (x < d.x()) |
719 | x = 0; | 729 | x = 0; |
720 | if (y < d.y()) | 730 | if (y < d.y()) |
721 | y = 0; | 731 | y = 0; |
722 | 732 | ||
723 | // Pop the thingy up. | 733 | // Pop the thingy up. |
724 | move(x, y); | 734 | move(x, y); |
725 | show(); | 735 | show(); |
726 | } | 736 | } |
727 | 737 | ||
728 | int | 738 | int |
729 | KPopupFrame::exec(QPoint pos) | 739 | KPopupFrame::exec(QPoint pos) |
730 | { | 740 | { |
731 | popup(pos); | 741 | popup(pos); |
732 | repaint(); | 742 | repaint(); |
733 | qApp->enter_loop(); | 743 | qApp->enter_loop(); |
734 | hide(); | 744 | hide(); |
735 | return result; | 745 | return result; |
736 | } | 746 | } |
737 | 747 | ||
738 | int | 748 | int |
739 | KPopupFrame::exec(int x, int y) | 749 | KPopupFrame::exec(int x, int y) |
740 | { | 750 | { |
741 | return exec(QPoint(x, y)); | 751 | return exec(QPoint(x, y)); |
742 | } | 752 | } |
743 | 753 | ||
744 | void KPopupFrame::virtual_hook( int, void* ) | 754 | void KPopupFrame::virtual_hook( int, void* ) |
745 | { /*BASE::virtual_hook( id, data );*/ } | 755 | { /*BASE::virtual_hook( id, data );*/ } |
746 | 756 | ||
747 | void KDateTable::virtual_hook( int, void* ) | 757 | void KDateTable::virtual_hook( int, void* ) |
748 | { /*BASE::virtual_hook( id, data );*/ } | 758 | { /*BASE::virtual_hook( id, data );*/ } |
749 | 759 | ||
750 | //#include "kdatetbl.moc" | 760 | //#include "kdatetbl.moc" |
751 | 761 | ||
752 | 762 | ||
753 | KDateInternalWeekPicker::KDateInternalWeekPicker | 763 | KDateInternalWeekPicker::KDateInternalWeekPicker |
754 | (int fontsize, QWidget* parent, const char* name) | 764 | (int fontsize, QWidget* parent, const char* name) |
755 | : QGridView(parent, name), | 765 | : QGridView(parent, name), |
756 | result(0) // invalid | 766 | result(0) // invalid |
757 | { | 767 | { |
758 | QRect rect; | 768 | QRect rect; |
759 | QFont font; | 769 | QFont font; |
760 | // ----- | 770 | // ----- |
761 | activeCol = -1; | 771 | activeCol = -1; |
762 | activeRow = -1; | 772 | activeRow = -1; |
763 | font=KGlobalSettings::generalFont(); | 773 | font=KGlobalSettings::generalFont(); |
764 | font.setPointSize(fontsize); | 774 | //font.setPointSize(fontsize); |
765 | setFont(font); | 775 | setFont(font); |
766 | setHScrollBarMode(AlwaysOff); | 776 | setHScrollBarMode(AlwaysOff); |
767 | setVScrollBarMode(AlwaysOff); | 777 | setVScrollBarMode(AlwaysOff); |
768 | setFrameStyle(QFrame::NoFrame); | 778 | setFrameStyle(QFrame::NoFrame); |
769 | setNumRows(13); | 779 | setNumRows(13); |
770 | setNumCols(4); | 780 | setNumCols(4); |
771 | // enable to find drawing failures: | 781 | // enable to find drawing failures: |
772 | // setTableFlags(Tbl_clipCellPainting); | 782 | // setTableFlags(Tbl_clipCellPainting); |
773 | #if 0 | 783 | #if 0 |
774 | viewport()->setEraseColor(lightGray); // for consistency with the datepicker | 784 | viewport()->setEraseColor(lightGray); // for consistency with the datepicker |
775 | #endif | 785 | #endif |
776 | // ----- find the preferred size | 786 | // ----- find the preferred size |
777 | // (this is slow, possibly, but unfortunatly it is needed here): | 787 | // (this is slow, possibly, but unfortunatly it is needed here): |
778 | QFontMetrics metrics(font); | 788 | QFontMetrics metrics(font); |
779 | for(int i=1; i <= 52; ++i) | 789 | for(int i=1; i <= 52; ++i) |
780 | { | 790 | { |
781 | rect=metrics.boundingRect(QString::number( i )); | 791 | rect=metrics.boundingRect(QString::number( i )); |
782 | if(max.width()<rect.width()) max.setWidth(rect.width()); | 792 | if(max.width()<rect.width()) max.setWidth(rect.width()); |
783 | if(max.height()<rect.height()) max.setHeight(rect.height()); | 793 | if(max.height()<rect.height()) max.setHeight(rect.height()); |
784 | } | 794 | } |
785 | 795 | if ( QApplication::desktop()->width() > 640 ) { | |
796 | |||
797 | max.setWidth(max.width()+6); | ||
798 | max.setHeight(max.height()+8); | ||
799 | } | ||
786 | } | 800 | } |
787 | 801 | ||
788 | QSize | 802 | QSize |
789 | KDateInternalWeekPicker::sizeHint() const | 803 | KDateInternalWeekPicker::sizeHint() const |
790 | { | 804 | { |
791 | return QSize((max.width()+6)*numCols()+2*frameWidth(), | 805 | return QSize((max.width()+6)*numCols()+2*frameWidth(), |
792 | (max.height()+6)*numRows()+2*frameWidth()); | 806 | (max.height()+6)*numRows()+2*frameWidth()); |
793 | } | 807 | } |
794 | 808 | ||
795 | int | 809 | int |
796 | KDateInternalWeekPicker::getResult() const | 810 | KDateInternalWeekPicker::getResult() const |
797 | { | 811 | { |
798 | return result; | 812 | return result; |
799 | } | 813 | } |
800 | 814 | ||
801 | void | 815 | void |
802 | KDateInternalWeekPicker::setupPainter(QPainter *p) | 816 | KDateInternalWeekPicker::setupPainter(QPainter *p) |
803 | { | 817 | { |
804 | p->setPen(black); | 818 | p->setPen(black); |
805 | } | 819 | } |
806 | 820 | ||
807 | void | 821 | void |
808 | KDateInternalWeekPicker::viewportResizeEvent(QResizeEvent*) | 822 | KDateInternalWeekPicker::viewportResizeEvent(QResizeEvent*) |
809 | { | 823 | { |
810 | setCellWidth(width()/4); | 824 | setCellWidth(width()/4); |
811 | setCellHeight(height()/13); | 825 | setCellHeight(height()/13); |
812 | } | 826 | } |
813 | 827 | ||
814 | void | 828 | void |
815 | KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col) | 829 | KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col) |
816 | { | 830 | { |
817 | int index; | 831 | int index; |
818 | QString text; | 832 | QString text; |
819 | // ----- find the number of the cell: | 833 | // ----- find the number of the cell: |
820 | index=4*row+col+1; | 834 | index=4*row+col+1; |
821 | text=QString::number( index ); | 835 | text=QString::number( index ); |
822 | painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); | 836 | painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); |
823 | if ( activeCol == col && activeRow == row ) | 837 | if ( activeCol == col && activeRow == row ) |
824 | painter->drawRect( 0, 0, cellWidth(), cellHeight() ); | 838 | painter->drawRect( 0, 0, cellWidth(), cellHeight() ); |
825 | } | 839 | } |
826 | 840 | ||
827 | void | 841 | void |
828 | KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e) | 842 | KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e) |
829 | { | 843 | { |
830 | if(!isEnabled() || e->button() != LeftButton) | 844 | if(!isEnabled() || e->button() != LeftButton) |
831 | { | 845 | { |
832 | KNotifyClient::beep(); | 846 | KNotifyClient::beep(); |
833 | return; | 847 | return; |
834 | } | 848 | } |
835 | // ----- | 849 | // ----- |
836 | int row, col; | 850 | int row, col; |
837 | QPoint mouseCoord; | 851 | QPoint mouseCoord; |
838 | // ----- | 852 | // ----- |
839 | mouseCoord = e->pos(); | 853 | mouseCoord = e->pos(); |
840 | row=rowAt(mouseCoord.y()); | 854 | row=rowAt(mouseCoord.y()); |
841 | col=columnAt(mouseCoord.x()); | 855 | col=columnAt(mouseCoord.x()); |
842 | 856 | ||
843 | if(row<0 || col<0) | 857 | if(row<0 || col<0) |
844 | { // the user clicked on the frame of the table | 858 | { // the user clicked on the frame of the table |
845 | activeCol = -1; | 859 | activeCol = -1; |
846 | activeRow = -1; | 860 | activeRow = -1; |
847 | } else { | 861 | } else { |
848 | activeCol = col; | 862 | activeCol = col; |
849 | activeRow = row; | 863 | activeRow = row; |
850 | updateCell( row, col /*, false */ ); | 864 | updateCell( row, col /*, false */ ); |
851 | } | 865 | } |
852 | } | 866 | } |
853 | 867 | ||
854 | void | 868 | void |
855 | KDateInternalWeekPicker::contentsMouseMoveEvent(QMouseEvent *e) | 869 | KDateInternalWeekPicker::contentsMouseMoveEvent(QMouseEvent *e) |
856 | { | 870 | { |
857 | if (e->state() & LeftButton) | 871 | if (e->state() & LeftButton) |
858 | { | 872 | { |
859 | int row, col; | 873 | int row, col; |
860 | QPoint mouseCoord; | 874 | QPoint mouseCoord; |
861 | // ----- | 875 | // ----- |
862 | mouseCoord = e->pos(); | 876 | mouseCoord = e->pos(); |
863 | row=rowAt(mouseCoord.y()); | 877 | row=rowAt(mouseCoord.y()); |
864 | col=columnAt(mouseCoord.x()); | 878 | col=columnAt(mouseCoord.x()); |
865 | int tmpRow = -1, tmpCol = -1; | 879 | int tmpRow = -1, tmpCol = -1; |
866 | if(row<0 || col<0) | 880 | if(row<0 || col<0) |
867 | { // the user clicked on the frame of the table | 881 | { // the user clicked on the frame of the table |
868 | if ( activeCol > -1 ) | 882 | if ( activeCol > -1 ) |
869 | { | 883 | { |
870 | tmpRow = activeRow; | 884 | tmpRow = activeRow; |
871 | tmpCol = activeCol; | 885 | tmpCol = activeCol; |
872 | } | 886 | } |
873 | activeCol = -1; | 887 | activeCol = -1; |
874 | activeRow = -1; | 888 | activeRow = -1; |
875 | } else { | 889 | } else { |
876 | bool differentCell = (activeRow != row || activeCol != col); | 890 | bool differentCell = (activeRow != row || activeCol != col); |
877 | if ( activeCol > -1 && differentCell) | 891 | if ( activeCol > -1 && differentCell) |
878 | { | 892 | { |
879 | tmpRow = activeRow; | 893 | tmpRow = activeRow; |
880 | tmpCol = activeCol; | 894 | tmpCol = activeCol; |
881 | } | 895 | } |
882 | if ( differentCell) | 896 | if ( differentCell) |
883 | { | 897 | { |
884 | activeRow = row; | 898 | activeRow = row; |
885 | activeCol = col; | 899 | activeCol = col; |
886 | updateCell( row, col /*, false */ ); // mark the new active cell | 900 | updateCell( row, col /*, false */ ); // mark the new active cell |
887 | } | 901 | } |
888 | } | 902 | } |
889 | if ( tmpRow > -1 ) // repaint the former active cell | 903 | if ( tmpRow > -1 ) // repaint the former active cell |
890 | updateCell( tmpRow, tmpCol /*, true */ ); | 904 | updateCell( tmpRow, tmpCol /*, true */ ); |
891 | } | 905 | } |
892 | } | 906 | } |
893 | 907 | ||
894 | void | 908 | void |
895 | KDateInternalWeekPicker::contentsMouseReleaseEvent(QMouseEvent *e) | 909 | KDateInternalWeekPicker::contentsMouseReleaseEvent(QMouseEvent *e) |
896 | { | 910 | { |
897 | if(!isEnabled()) | 911 | if(!isEnabled()) |
898 | { | 912 | { |
899 | return; | 913 | return; |
900 | } | 914 | } |
901 | // ----- | 915 | // ----- |
902 | int row, col, pos; | 916 | int row, col, pos; |
903 | QPoint mouseCoord; | 917 | QPoint mouseCoord; |
904 | // ----- | 918 | // ----- |
905 | mouseCoord = e->pos(); | 919 | mouseCoord = e->pos(); |
906 | row=rowAt(mouseCoord.y()); | 920 | row=rowAt(mouseCoord.y()); |
907 | col=columnAt(mouseCoord.x()); | 921 | col=columnAt(mouseCoord.x()); |
908 | if(row<0 || col<0) | 922 | if(row<0 || col<0) |
909 | { // the user clicked on the frame of the table | 923 | { // the user clicked on the frame of the table |
910 | emit(closeMe(0)); | 924 | emit(closeMe(0)); |
911 | } | 925 | } |
912 | pos=4*row+col+1; | 926 | pos=4*row+col+1; |
913 | result=pos; | 927 | result=pos; |
914 | emit(closeMe(1)); | 928 | emit(closeMe(1)); |
915 | } | 929 | } |
diff --git a/microkde/kglobalsettings.cpp b/microkde/kglobalsettings.cpp index 2fff8fc..30e793f 100644 --- a/microkde/kglobalsettings.cpp +++ b/microkde/kglobalsettings.cpp | |||
@@ -1,41 +1,43 @@ | |||
1 | #include "kglobalsettings.h" | 1 | #include "kglobalsettings.h" |
2 | #include "kconfig.h" | 2 | #include "kconfig.h" |
3 | #include "kglobal.h" | 3 | #include "kglobal.h" |
4 | #include "kconfigbase.h" | 4 | #include "kconfigbase.h" |
5 | 5 | ||
6 | #include <qapplication.h> | 6 | #include <qapplication.h> |
7 | 7 | ||
8 | QFont KGlobalSettings::generalFont() | 8 | QFont KGlobalSettings::generalFont() |
9 | { | 9 | { |
10 | int size = 12; | 10 | int size = 12; |
11 | if (QApplication::desktop()->width() < 480 ) | 11 | if (QApplication::desktop()->width() < 480 ) |
12 | size = 10; | 12 | size = 10; |
13 | return QFont("helvetica",size); | 13 | QFont f = QApplication::font(); |
14 | f.setPointSize( size ); | ||
15 | return f; | ||
14 | } | 16 | } |
15 | QFont KGlobalSettings::toolBarFont() | 17 | QFont KGlobalSettings::toolBarFont() |
16 | { | 18 | { |
17 | return QFont("helevetica",12); | 19 | return QApplication::font(); |
18 | } | 20 | } |
19 | 21 | ||
20 | QColor KGlobalSettings::toolBarHighlightColor() | 22 | QColor KGlobalSettings::toolBarHighlightColor() |
21 | { | 23 | { |
22 | return QColor("black"); | 24 | return QColor( "black" ); |
23 | } | 25 | } |
24 | 26 | ||
25 | QRect KGlobalSettings::desktopGeometry( QWidget * ) | 27 | QRect KGlobalSettings::desktopGeometry( QWidget * ) |
26 | { | 28 | { |
27 | return QApplication::desktop()->rect(); | 29 | return QApplication::desktop()->rect(); |
28 | } | 30 | } |
29 | 31 | ||
30 | /** | 32 | /** |
31 | * Returns whether KDE runs in single (default) or double click | 33 | * Returns whether KDE runs in single (default) or double click |
32 | * mode. | 34 | * mode. |
33 | * see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html | 35 | * see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html |
34 | * @return true if single click mode, or false if double click mode. | 36 | * @return true if single click mode, or false if double click mode. |
35 | **/ | 37 | **/ |
36 | bool KGlobalSettings::singleClick() | 38 | bool KGlobalSettings::singleClick() |
37 | { | 39 | { |
38 | KConfig *c = KGlobal::config(); | 40 | KConfig *c = KGlobal::config(); |
39 | KConfigGroupSaver cgs( c, "KDE" ); | 41 | KConfigGroupSaver cgs( c, "KDE" ); |
40 | return c->readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK); | 42 | return c->readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK); |
41 | } | 43 | } |