author | zautrix <zautrix> | 2005-08-23 12:55:50 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-08-23 12:55:50 (UTC) |
commit | 72d600e2c3b3405e5f37615a56560811c0cf9a78 (patch) (unidiff) | |
tree | 0f3eeb3ae34822149ba8b6d62990725e59a29187 /korganizer | |
parent | e34e096c0e1b799904643c753591833f3ff2ab95 (diff) | |
download | kdepimpi-72d600e2c3b3405e5f37615a56560811c0cf9a78.zip kdepimpi-72d600e2c3b3405e5f37615a56560811c0cf9a78.tar.gz kdepimpi-72d600e2c3b3405e5f37615a56560811c0cf9a78.tar.bz2 |
kopi load change
-rw-r--r-- | korganizer/calendarview.cpp | 4 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 5 | ||||
-rw-r--r-- | korganizer/main.cpp | 4 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 64 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 6 |
5 files changed, 61 insertions, 22 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index e3b62de..9928b48 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1882,1026 +1882,1026 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1882 | dt = cur.addSecs( 62 ); | 1882 | dt = cur.addSecs( 62 ); |
1883 | } | 1883 | } |
1884 | else if (inR->typeID() == eventID ) { | 1884 | else if (inR->typeID() == eventID ) { |
1885 | bool ok; | 1885 | bool ok; |
1886 | dt = inR->getNextOccurence( cur, &ok ); | 1886 | dt = inR->getNextOccurence( cur, &ok ); |
1887 | if ( !ok ) | 1887 | if ( !ok ) |
1888 | dt = cur.addSecs( -62 ); | 1888 | dt = cur.addSecs( -62 ); |
1889 | } | 1889 | } |
1890 | else | 1890 | else |
1891 | dt = inR->dtStart(); | 1891 | dt = inR->dtStart(); |
1892 | if ( dt < cur || dt > end ) { | 1892 | if ( dt < cur || dt > end ) { |
1893 | remote->deleteIncidence( inR ); | 1893 | remote->deleteIncidence( inR ); |
1894 | ++delFut; | 1894 | ++delFut; |
1895 | } | 1895 | } |
1896 | inR = er.next(); | 1896 | inR = er.next(); |
1897 | } | 1897 | } |
1898 | } | 1898 | } |
1899 | bar.hide(); | 1899 | bar.hide(); |
1900 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1900 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1901 | eventLSync->setReadOnly( false ); | 1901 | eventLSync->setReadOnly( false ); |
1902 | eventLSync->setDtStart( mLastCalendarSync ); | 1902 | eventLSync->setDtStart( mLastCalendarSync ); |
1903 | eventRSync->setDtStart( mLastCalendarSync ); | 1903 | eventRSync->setDtStart( mLastCalendarSync ); |
1904 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1904 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1905 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1905 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1906 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1906 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1907 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1907 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1908 | eventLSync->setReadOnly( true ); | 1908 | eventLSync->setReadOnly( true ); |
1909 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1909 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1910 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1910 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1911 | remote->addEvent( eventRSync ); | 1911 | remote->addEvent( eventRSync ); |
1912 | else | 1912 | else |
1913 | delete eventRSync; | 1913 | delete eventRSync; |
1914 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1914 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1915 | QString mes; | 1915 | QString mes; |
1916 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1916 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1917 | QString delmess; | 1917 | QString delmess; |
1918 | if ( delFut ) { | 1918 | if ( delFut ) { |
1919 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1919 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1920 | mes += delmess; | 1920 | mes += delmess; |
1921 | } | 1921 | } |
1922 | mes = i18n("Local calendar changed!\n") +mes; | 1922 | mes = i18n("Local calendar changed!\n") +mes; |
1923 | mCalendar->checkAlarmForIncidence( 0, true ); | 1923 | mCalendar->checkAlarmForIncidence( 0, true ); |
1924 | qDebug( mes ); | 1924 | qDebug( mes ); |
1925 | if ( mSyncManager->mShowSyncSummary ) { | 1925 | if ( mSyncManager->mShowSyncSummary ) { |
1926 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1926 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1927 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1927 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1928 | qDebug("KO: WB cancelled "); | 1928 | qDebug("KO: WB cancelled "); |
1929 | mSyncManager->mWriteBackFile = false; | 1929 | mSyncManager->mWriteBackFile = false; |
1930 | return syncOK; | 1930 | return syncOK; |
1931 | } | 1931 | } |
1932 | } | 1932 | } |
1933 | return syncOK; | 1933 | return syncOK; |
1934 | } | 1934 | } |
1935 | 1935 | ||
1936 | void CalendarView::setSyncDevice( QString s ) | 1936 | void CalendarView::setSyncDevice( QString s ) |
1937 | { | 1937 | { |
1938 | mCurrentSyncDevice= s; | 1938 | mCurrentSyncDevice= s; |
1939 | } | 1939 | } |
1940 | void CalendarView::setSyncName( QString s ) | 1940 | void CalendarView::setSyncName( QString s ) |
1941 | { | 1941 | { |
1942 | mCurrentSyncName= s; | 1942 | mCurrentSyncName= s; |
1943 | } | 1943 | } |
1944 | bool CalendarView::syncCalendar(QString filename, int mode) | 1944 | bool CalendarView::syncCalendar(QString filename, int mode) |
1945 | { | 1945 | { |
1946 | //qDebug("syncCalendar %s ", filename.latin1()); | 1946 | //qDebug("syncCalendar %s ", filename.latin1()); |
1947 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1947 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1948 | CalendarLocal* calendar = new CalendarLocal(); | 1948 | CalendarLocal* calendar = new CalendarLocal(); |
1949 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1949 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1950 | FileStorage* storage = new FileStorage( calendar ); | 1950 | FileStorage* storage = new FileStorage( calendar ); |
1951 | bool syncOK = false; | 1951 | bool syncOK = false; |
1952 | storage->setFileName( filename ); | 1952 | storage->setFileName( filename ); |
1953 | // qDebug("loading ... "); | 1953 | // qDebug("loading ... "); |
1954 | if ( storage->load() ) { | 1954 | if ( storage->load() ) { |
1955 | getEventViewerDialog()->setSyncMode( true ); | 1955 | getEventViewerDialog()->setSyncMode( true ); |
1956 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1956 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1957 | getEventViewerDialog()->setSyncMode( false ); | 1957 | getEventViewerDialog()->setSyncMode( false ); |
1958 | if ( syncOK ) { | 1958 | if ( syncOK ) { |
1959 | if ( mSyncManager->mWriteBackFile ) | 1959 | if ( mSyncManager->mWriteBackFile ) |
1960 | { | 1960 | { |
1961 | storage->setSaveFormat( new ICalFormat() ); | 1961 | storage->setSaveFormat( new ICalFormat() ); |
1962 | storage->save(); | 1962 | storage->save(); |
1963 | } | 1963 | } |
1964 | } | 1964 | } |
1965 | setModified( true ); | 1965 | setModified( true ); |
1966 | } | 1966 | } |
1967 | delete storage; | 1967 | delete storage; |
1968 | delete calendar; | 1968 | delete calendar; |
1969 | if ( syncOK ) | 1969 | if ( syncOK ) |
1970 | updateView(); | 1970 | updateView(); |
1971 | return syncOK; | 1971 | return syncOK; |
1972 | } | 1972 | } |
1973 | 1973 | ||
1974 | void CalendarView::syncExternal( int mode ) | 1974 | void CalendarView::syncExternal( int mode ) |
1975 | { | 1975 | { |
1976 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1976 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1977 | 1977 | ||
1978 | qApp->processEvents(); | 1978 | qApp->processEvents(); |
1979 | CalendarLocal* calendar = new CalendarLocal(); | 1979 | CalendarLocal* calendar = new CalendarLocal(); |
1980 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1980 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1981 | bool syncOK = false; | 1981 | bool syncOK = false; |
1982 | bool loadSuccess = false; | 1982 | bool loadSuccess = false; |
1983 | PhoneFormat* phoneFormat = 0; | 1983 | PhoneFormat* phoneFormat = 0; |
1984 | emit tempDisableBR(true); | 1984 | emit tempDisableBR(true); |
1985 | #ifndef DESKTOP_VERSION | 1985 | #ifndef DESKTOP_VERSION |
1986 | SharpFormat* sharpFormat = 0; | 1986 | SharpFormat* sharpFormat = 0; |
1987 | if ( mode == 0 ) { // sharp | 1987 | if ( mode == 0 ) { // sharp |
1988 | sharpFormat = new SharpFormat () ; | 1988 | sharpFormat = new SharpFormat () ; |
1989 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1989 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1990 | 1990 | ||
1991 | } else | 1991 | } else |
1992 | #endif | 1992 | #endif |
1993 | if ( mode == 1 ) { // phone | 1993 | if ( mode == 1 ) { // phone |
1994 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1994 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1995 | mSyncManager->mPhoneDevice, | 1995 | mSyncManager->mPhoneDevice, |
1996 | mSyncManager->mPhoneConnection, | 1996 | mSyncManager->mPhoneConnection, |
1997 | mSyncManager->mPhoneModel); | 1997 | mSyncManager->mPhoneModel); |
1998 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1998 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1999 | 1999 | ||
2000 | } else { | 2000 | } else { |
2001 | emit tempDisableBR(false); | 2001 | emit tempDisableBR(false); |
2002 | return; | 2002 | return; |
2003 | } | 2003 | } |
2004 | if ( loadSuccess ) { | 2004 | if ( loadSuccess ) { |
2005 | getEventViewerDialog()->setSyncMode( true ); | 2005 | getEventViewerDialog()->setSyncMode( true ); |
2006 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2006 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2007 | getEventViewerDialog()->setSyncMode( false ); | 2007 | getEventViewerDialog()->setSyncMode( false ); |
2008 | qApp->processEvents(); | 2008 | qApp->processEvents(); |
2009 | if ( syncOK ) { | 2009 | if ( syncOK ) { |
2010 | if ( mSyncManager->mWriteBackFile ) | 2010 | if ( mSyncManager->mWriteBackFile ) |
2011 | { | 2011 | { |
2012 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 2012 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
2013 | Incidence* inc = iL.first(); | 2013 | Incidence* inc = iL.first(); |
2014 | if ( phoneFormat ) { | 2014 | if ( phoneFormat ) { |
2015 | while ( inc ) { | 2015 | while ( inc ) { |
2016 | inc->removeID(mCurrentSyncDevice); | 2016 | inc->removeID(mCurrentSyncDevice); |
2017 | inc = iL.next(); | 2017 | inc = iL.next(); |
2018 | } | 2018 | } |
2019 | } | 2019 | } |
2020 | #ifndef DESKTOP_VERSION | 2020 | #ifndef DESKTOP_VERSION |
2021 | if ( sharpFormat ) | 2021 | if ( sharpFormat ) |
2022 | sharpFormat->save(calendar); | 2022 | sharpFormat->save(calendar); |
2023 | #endif | 2023 | #endif |
2024 | if ( phoneFormat ) | 2024 | if ( phoneFormat ) |
2025 | phoneFormat->save(calendar); | 2025 | phoneFormat->save(calendar); |
2026 | iL = calendar->rawIncidences(); | 2026 | iL = calendar->rawIncidences(); |
2027 | inc = iL.first(); | 2027 | inc = iL.first(); |
2028 | Incidence* loc; | 2028 | Incidence* loc; |
2029 | while ( inc ) { | 2029 | while ( inc ) { |
2030 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 2030 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
2031 | loc = mCalendar->incidence(inc->uid() ); | 2031 | loc = mCalendar->incidence(inc->uid() ); |
2032 | if ( loc ) { | 2032 | if ( loc ) { |
2033 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 2033 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
2034 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 2034 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
2035 | } | 2035 | } |
2036 | } | 2036 | } |
2037 | inc = iL.next(); | 2037 | inc = iL.next(); |
2038 | } | 2038 | } |
2039 | Incidence* lse = getLastSyncEvent(); | 2039 | Incidence* lse = getLastSyncEvent(); |
2040 | if ( lse ) { | 2040 | if ( lse ) { |
2041 | lse->setReadOnly( false ); | 2041 | lse->setReadOnly( false ); |
2042 | lse->setDescription( "" ); | 2042 | lse->setDescription( "" ); |
2043 | lse->setReadOnly( true ); | 2043 | lse->setReadOnly( true ); |
2044 | } | 2044 | } |
2045 | } | 2045 | } |
2046 | } else { | 2046 | } else { |
2047 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 2047 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
2048 | } | 2048 | } |
2049 | setModified( true ); | 2049 | setModified( true ); |
2050 | } else { | 2050 | } else { |
2051 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 2051 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
2052 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 2052 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
2053 | question, i18n("Ok")) ; | 2053 | question, i18n("Ok")) ; |
2054 | 2054 | ||
2055 | } | 2055 | } |
2056 | delete calendar; | 2056 | delete calendar; |
2057 | updateView(); | 2057 | updateView(); |
2058 | emit tempDisableBR(false); | 2058 | emit tempDisableBR(false); |
2059 | return ;//syncOK; | 2059 | return ;//syncOK; |
2060 | 2060 | ||
2061 | } | 2061 | } |
2062 | 2062 | ||
2063 | bool CalendarView::importBday() | 2063 | bool CalendarView::importBday() |
2064 | { | 2064 | { |
2065 | #ifndef KORG_NOKABC | 2065 | #ifndef KORG_NOKABC |
2066 | 2066 | ||
2067 | #ifdef DESKTOP_VERSION | 2067 | #ifdef DESKTOP_VERSION |
2068 | int curCal = mCalendar->defaultCalendar(); | 2068 | int curCal = mCalendar->defaultCalendar(); |
2069 | int bd = mCalEditView->getBirtdayID(); | 2069 | int bd = mCalEditView->getBirtdayID(); |
2070 | if ( bd == 0 ) | 2070 | if ( bd == 0 ) |
2071 | return false; | 2071 | return false; |
2072 | mCalendar->setDefaultCalendar( bd ); | 2072 | mCalendar->setDefaultCalendar( bd ); |
2073 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 2073 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
2074 | KABC::AddressBook::Iterator it; | 2074 | KABC::AddressBook::Iterator it; |
2075 | int count = 0; | 2075 | int count = 0; |
2076 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 2076 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
2077 | ++count; | 2077 | ++count; |
2078 | } | 2078 | } |
2079 | QProgressBar bar(count,0 ); | 2079 | QProgressBar bar(count,0 ); |
2080 | int w = 300; | 2080 | int w = 300; |
2081 | if ( QApplication::desktop()->width() < 320 ) | 2081 | if ( QApplication::desktop()->width() < 320 ) |
2082 | w = 220; | 2082 | w = 220; |
2083 | int h = bar.sizeHint().height() ; | 2083 | int h = bar.sizeHint().height() ; |
2084 | int dw = QApplication::desktop()->width(); | 2084 | int dw = QApplication::desktop()->width(); |
2085 | int dh = QApplication::desktop()->height(); | 2085 | int dh = QApplication::desktop()->height(); |
2086 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2086 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2087 | bar.show(); | 2087 | bar.show(); |
2088 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 2088 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
2089 | qApp->processEvents(); | 2089 | qApp->processEvents(); |
2090 | count = 0; | 2090 | count = 0; |
2091 | int addCount = 0; | 2091 | int addCount = 0; |
2092 | KCal::Attendee* a = 0; | 2092 | KCal::Attendee* a = 0; |
2093 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 2093 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
2094 | if ( ! bar.isVisible() ) | 2094 | if ( ! bar.isVisible() ) |
2095 | return false; | 2095 | return false; |
2096 | bar.setProgress( count++ ); | 2096 | bar.setProgress( count++ ); |
2097 | qApp->processEvents(); | 2097 | qApp->processEvents(); |
2098 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 2098 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
2099 | if ( (*it).birthday().date().isValid() ){ | 2099 | if ( (*it).birthday().date().isValid() ){ |
2100 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 2100 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
2101 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 2101 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
2102 | ++addCount; | 2102 | ++addCount; |
2103 | } | 2103 | } |
2104 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 2104 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
2105 | if ( anni.isValid() ){ | 2105 | if ( anni.isValid() ){ |
2106 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 2106 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
2107 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 2107 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
2108 | ++addCount; | 2108 | ++addCount; |
2109 | } | 2109 | } |
2110 | } | 2110 | } |
2111 | mCalendar->setDefaultCalendar( curCal ); | 2111 | mCalendar->setDefaultCalendar( curCal ); |
2112 | updateView(); | 2112 | updateView(); |
2113 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 2113 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
2114 | #else //DESKTOP_VERSION | 2114 | #else //DESKTOP_VERSION |
2115 | 2115 | ||
2116 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 2116 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
2117 | // the result should now arrive through method insertBirthdays | 2117 | // the result should now arrive through method insertBirthdays |
2118 | 2118 | ||
2119 | #endif //DESKTOP_VERSION | 2119 | #endif //DESKTOP_VERSION |
2120 | 2120 | ||
2121 | #endif //KORG_NOKABC | 2121 | #endif //KORG_NOKABC |
2122 | 2122 | ||
2123 | 2123 | ||
2124 | return true; | 2124 | return true; |
2125 | } | 2125 | } |
2126 | 2126 | ||
2127 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 2127 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
2128 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 2128 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
2129 | const QStringList& anniversaryList, const QStringList& realNameList, | 2129 | const QStringList& anniversaryList, const QStringList& realNameList, |
2130 | const QStringList& emailList, const QStringList& assembledNameList, | 2130 | const QStringList& emailList, const QStringList& assembledNameList, |
2131 | const QStringList& uidList) | 2131 | const QStringList& uidList) |
2132 | { | 2132 | { |
2133 | 2133 | ||
2134 | //qDebug("KO::CalendarView::insertBirthdays"); | 2134 | //qDebug("KO::CalendarView::insertBirthdays"); |
2135 | if (uid == this->name()) | 2135 | if (uid == this->name()) |
2136 | { | 2136 | { |
2137 | int curCal = mCalendar->defaultCalendar(); | 2137 | int curCal = mCalendar->defaultCalendar(); |
2138 | int bd = mCalEditView->getBirtdayID(); | 2138 | int bd = mCalEditView->getBirtdayID(); |
2139 | if ( bd == 0 ) | 2139 | if ( bd == 0 ) |
2140 | return; | 2140 | return; |
2141 | mCalendar->setDefaultCalendar( bd ); | 2141 | mCalendar->setDefaultCalendar( bd ); |
2142 | 2142 | ||
2143 | 2143 | ||
2144 | int count = birthdayList.count(); | 2144 | int count = birthdayList.count(); |
2145 | int addCount = 0; | 2145 | int addCount = 0; |
2146 | KCal::Attendee* a = 0; | 2146 | KCal::Attendee* a = 0; |
2147 | 2147 | ||
2148 | //qDebug("CalView 1 %i", count); | 2148 | //qDebug("CalView 1 %i", count); |
2149 | 2149 | ||
2150 | QProgressBar bar(count,0 ); | 2150 | QProgressBar bar(count,0 ); |
2151 | int w = 300; | 2151 | int w = 300; |
2152 | if ( QApplication::desktop()->width() < 320 ) | 2152 | if ( QApplication::desktop()->width() < 320 ) |
2153 | w = 220; | 2153 | w = 220; |
2154 | int h = bar.sizeHint().height() ; | 2154 | int h = bar.sizeHint().height() ; |
2155 | int dw = QApplication::desktop()->width(); | 2155 | int dw = QApplication::desktop()->width(); |
2156 | int dh = QApplication::desktop()->height(); | 2156 | int dh = QApplication::desktop()->height(); |
2157 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2157 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2158 | bar.show(); | 2158 | bar.show(); |
2159 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 2159 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
2160 | qApp->processEvents(); | 2160 | qApp->processEvents(); |
2161 | 2161 | ||
2162 | QDate birthday; | 2162 | QDate birthday; |
2163 | QDate anniversary; | 2163 | QDate anniversary; |
2164 | QString realName; | 2164 | QString realName; |
2165 | QString email; | 2165 | QString email; |
2166 | QString assembledName; | 2166 | QString assembledName; |
2167 | QString uid; | 2167 | QString uid; |
2168 | bool ok = true; | 2168 | bool ok = true; |
2169 | for ( int i = 0; i < count; i++) | 2169 | for ( int i = 0; i < count; i++) |
2170 | { | 2170 | { |
2171 | if ( ! bar.isVisible() ) | 2171 | if ( ! bar.isVisible() ) |
2172 | return; | 2172 | return; |
2173 | bar.setProgress( i ); | 2173 | bar.setProgress( i ); |
2174 | qApp->processEvents(); | 2174 | qApp->processEvents(); |
2175 | 2175 | ||
2176 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 2176 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
2177 | if (!ok) { | 2177 | if (!ok) { |
2178 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 2178 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
2179 | } | 2179 | } |
2180 | 2180 | ||
2181 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 2181 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
2182 | if (!ok) { | 2182 | if (!ok) { |
2183 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 2183 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
2184 | } | 2184 | } |
2185 | realName = realNameList[i]; | 2185 | realName = realNameList[i]; |
2186 | email = emailList[i]; | 2186 | email = emailList[i]; |
2187 | assembledName = assembledNameList[i]; | 2187 | assembledName = assembledNameList[i]; |
2188 | uid = uidList[i]; | 2188 | uid = uidList[i]; |
2189 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 2189 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
2190 | 2190 | ||
2191 | if ( birthday.isValid() ){ | 2191 | if ( birthday.isValid() ){ |
2192 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 2192 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
2193 | KCal::Attendee::ReqParticipant,uid) ; | 2193 | KCal::Attendee::ReqParticipant,uid) ; |
2194 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 2194 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
2195 | ++addCount; | 2195 | ++addCount; |
2196 | } | 2196 | } |
2197 | 2197 | ||
2198 | if ( anniversary.isValid() ){ | 2198 | if ( anniversary.isValid() ){ |
2199 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 2199 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
2200 | KCal::Attendee::ReqParticipant,uid) ; | 2200 | KCal::Attendee::ReqParticipant,uid) ; |
2201 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 2201 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
2202 | ++addCount; | 2202 | ++addCount; |
2203 | } | 2203 | } |
2204 | } | 2204 | } |
2205 | 2205 | ||
2206 | mCalendar->setDefaultCalendar( curCal ); | 2206 | mCalendar->setDefaultCalendar( curCal ); |
2207 | updateView(); | 2207 | updateView(); |
2208 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 2208 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
2209 | 2209 | ||
2210 | } | 2210 | } |
2211 | 2211 | ||
2212 | } | 2212 | } |
2213 | 2213 | ||
2214 | 2214 | ||
2215 | 2215 | ||
2216 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 2216 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
2217 | { | 2217 | { |
2218 | //qDebug("addAnni "); | 2218 | //qDebug("addAnni "); |
2219 | Event * ev = new Event(); | 2219 | Event * ev = new Event(); |
2220 | ev->setOrganizer(KOPrefs::instance()->email()); | 2220 | ev->setOrganizer(KOPrefs::instance()->email()); |
2221 | if ( a ) { | 2221 | if ( a ) { |
2222 | ev->addAttendee( a ); | 2222 | ev->addAttendee( a ); |
2223 | } | 2223 | } |
2224 | QString kind; | 2224 | QString kind; |
2225 | if ( birthday ) { | 2225 | if ( birthday ) { |
2226 | kind = i18n( "Birthday" ); | 2226 | kind = i18n( "Birthday" ); |
2227 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 2227 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
2228 | } | 2228 | } |
2229 | else { | 2229 | else { |
2230 | kind = i18n( "Anniversary" ); | 2230 | kind = i18n( "Anniversary" ); |
2231 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 2231 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
2232 | } | 2232 | } |
2233 | ev->setCategories( kind ); | 2233 | ev->setCategories( kind ); |
2234 | ev->setDtStart( QDateTime(date) ); | 2234 | ev->setDtStart( QDateTime(date) ); |
2235 | ev->setDtEnd( QDateTime(date) ); | 2235 | ev->setDtEnd( QDateTime(date) ); |
2236 | ev->setFloats( true ); | 2236 | ev->setFloats( true ); |
2237 | Recurrence * rec = ev->recurrence(); | 2237 | Recurrence * rec = ev->recurrence(); |
2238 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 2238 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
2239 | rec->addYearlyNum( date.month() ); | 2239 | rec->addYearlyNum( date.month() ); |
2240 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 2240 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
2241 | delete ev; | 2241 | delete ev; |
2242 | return false; | 2242 | return false; |
2243 | } | 2243 | } |
2244 | return true; | 2244 | return true; |
2245 | 2245 | ||
2246 | } | 2246 | } |
2247 | bool CalendarView::importQtopia( const QString &categories, | 2247 | bool CalendarView::importQtopia( const QString &categories, |
2248 | const QString &datebook, | 2248 | const QString &datebook, |
2249 | const QString &todolist ) | 2249 | const QString &todolist ) |
2250 | { | 2250 | { |
2251 | 2251 | ||
2252 | QtopiaFormat qtopiaFormat; | 2252 | QtopiaFormat qtopiaFormat; |
2253 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2253 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2254 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 2254 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
2255 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 2255 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
2256 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 2256 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
2257 | 2257 | ||
2258 | updateView(); | 2258 | updateView(); |
2259 | return true; | 2259 | return true; |
2260 | 2260 | ||
2261 | #if 0 | 2261 | #if 0 |
2262 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 2262 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
2263 | mCurrentSyncDevice = "qtopia-XML"; | 2263 | mCurrentSyncDevice = "qtopia-XML"; |
2264 | if ( mSyncManager->mAskForPreferences ) | 2264 | if ( mSyncManager->mAskForPreferences ) |
2265 | edit_sync_options(); | 2265 | edit_sync_options(); |
2266 | qApp->processEvents(); | 2266 | qApp->processEvents(); |
2267 | CalendarLocal* calendar = new CalendarLocal(); | 2267 | CalendarLocal* calendar = new CalendarLocal(); |
2268 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2268 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2269 | bool syncOK = false; | 2269 | bool syncOK = false; |
2270 | QtopiaFormat qtopiaFormat; | 2270 | QtopiaFormat qtopiaFormat; |
2271 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2271 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2272 | bool loadOk = true; | 2272 | bool loadOk = true; |
2273 | if ( !categories.isEmpty() ) | 2273 | if ( !categories.isEmpty() ) |
2274 | loadOk = qtopiaFormat.load( calendar, categories ); | 2274 | loadOk = qtopiaFormat.load( calendar, categories ); |
2275 | if ( loadOk && !datebook.isEmpty() ) | 2275 | if ( loadOk && !datebook.isEmpty() ) |
2276 | loadOk = qtopiaFormat.load( calendar, datebook ); | 2276 | loadOk = qtopiaFormat.load( calendar, datebook ); |
2277 | if ( loadOk && !todolist.isEmpty() ) | 2277 | if ( loadOk && !todolist.isEmpty() ) |
2278 | loadOk = qtopiaFormat.load( calendar, todolist ); | 2278 | loadOk = qtopiaFormat.load( calendar, todolist ); |
2279 | 2279 | ||
2280 | if ( loadOk ) { | 2280 | if ( loadOk ) { |
2281 | getEventViewerDialog()->setSyncMode( true ); | 2281 | getEventViewerDialog()->setSyncMode( true ); |
2282 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2282 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2283 | getEventViewerDialog()->setSyncMode( false ); | 2283 | getEventViewerDialog()->setSyncMode( false ); |
2284 | qApp->processEvents(); | 2284 | qApp->processEvents(); |
2285 | if ( syncOK ) { | 2285 | if ( syncOK ) { |
2286 | if ( mSyncManager->mWriteBackFile ) | 2286 | if ( mSyncManager->mWriteBackFile ) |
2287 | { | 2287 | { |
2288 | // write back XML file | 2288 | // write back XML file |
2289 | 2289 | ||
2290 | } | 2290 | } |
2291 | setModified( true ); | 2291 | setModified( true ); |
2292 | } | 2292 | } |
2293 | } else { | 2293 | } else { |
2294 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 2294 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
2295 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 2295 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
2296 | question, i18n("Ok")) ; | 2296 | question, i18n("Ok")) ; |
2297 | } | 2297 | } |
2298 | delete calendar; | 2298 | delete calendar; |
2299 | updateView(); | 2299 | updateView(); |
2300 | return syncOK; | 2300 | return syncOK; |
2301 | 2301 | ||
2302 | 2302 | ||
2303 | #endif | 2303 | #endif |
2304 | 2304 | ||
2305 | } | 2305 | } |
2306 | 2306 | ||
2307 | void CalendarView::setSyncEventsReadOnly() | 2307 | void CalendarView::setSyncEventsReadOnly() |
2308 | { | 2308 | { |
2309 | mCalendar->setSyncEventsReadOnly(); | 2309 | mCalendar->setSyncEventsReadOnly(); |
2310 | } | 2310 | } |
2311 | 2311 | ||
2312 | bool CalendarView::loadCalendars() | 2312 | bool CalendarView::loadCalendars() |
2313 | { | 2313 | { |
2314 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2314 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2315 | KopiCalendarFile * cal = calendars.first(); | 2315 | KopiCalendarFile * cal = calendars.first(); |
2316 | mCalendar->setDefaultCalendar( 1 ); | 2316 | mCalendar->setDefaultCalendar( 1 ); |
2317 | openCalendar( MainWindow::defaultFileName(), false ); | 2317 | openCalendar( MainWindow::defaultFileName(), false ); |
2318 | cal = calendars.next(); | 2318 | cal = calendars.next(); |
2319 | while ( cal ) { | 2319 | while ( cal ) { |
2320 | addCalendar( cal ); | 2320 | addCalendar( cal ); |
2321 | cal = calendars.next(); | 2321 | cal = calendars.next(); |
2322 | } | 2322 | } |
2323 | restoreCalendarSettings(); | 2323 | restoreCalendarSettings(); |
2324 | return true; | 2324 | return true; |
2325 | } | 2325 | } |
2326 | bool CalendarView::restoreCalendarSettings() | 2326 | bool CalendarView::restoreCalendarSettings() |
2327 | { | 2327 | { |
2328 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2328 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2329 | KopiCalendarFile * cal = calendars.first(); | 2329 | KopiCalendarFile * cal = calendars.first(); |
2330 | while ( cal ) { | 2330 | while ( cal ) { |
2331 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 2331 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
2332 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 2332 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
2333 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 2333 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
2334 | if ( cal->isStandard ) | 2334 | if ( cal->isStandard ) |
2335 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2335 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2336 | cal = calendars.next(); | 2336 | cal = calendars.next(); |
2337 | } | 2337 | } |
2338 | setSyncEventsReadOnly(); | 2338 | setSyncEventsReadOnly(); |
2339 | mCalendar->reInitAlarmSettings(); | 2339 | mCalendar->reInitAlarmSettings(); |
2340 | updateUnmanagedViews(); | 2340 | updateUnmanagedViews(); |
2341 | updateView(); | 2341 | updateView(); |
2342 | return true; | 2342 | return true; |
2343 | } | 2343 | } |
2344 | void CalendarView::addCalendarId( int id ) | 2344 | void CalendarView::addCalendarId( int id ) |
2345 | { | 2345 | { |
2346 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 2346 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
2347 | if ( cal ) | 2347 | if ( cal ) |
2348 | addCalendar( cal ); | 2348 | addCalendar( cal ); |
2349 | } | 2349 | } |
2350 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 2350 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
2351 | { | 2351 | { |
2352 | cal->mErrorOnLoad = false; | 2352 | cal->mErrorOnLoad = false; |
2353 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 2353 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
2354 | cal->mLoadDt = QDateTime::currentDateTime(); | 2354 | cal->mLoadDt = QDateTime::currentDateTime(); |
2355 | return true; | 2355 | return true; |
2356 | } | 2356 | } |
2357 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); | 2357 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); |
2358 | cal->mErrorOnLoad = true; | 2358 | cal->mErrorOnLoad = true; |
2359 | return false; | 2359 | return false; |
2360 | } | 2360 | } |
2361 | bool CalendarView::openCalendar(QString filename, bool merge) | 2361 | bool CalendarView::openCalendar(QString filename, bool merge) |
2362 | { | 2362 | { |
2363 | 2363 | ||
2364 | if (filename.isEmpty()) { | 2364 | if (filename.isEmpty()) { |
2365 | return false; | 2365 | return false; |
2366 | } | 2366 | } |
2367 | 2367 | ||
2368 | if (!QFile::exists(filename)) { | 2368 | if (!QFile::exists(filename)) { |
2369 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 2369 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
2370 | return false; | 2370 | return false; |
2371 | } | 2371 | } |
2372 | 2372 | ||
2373 | globalFlagBlockAgenda = 1; | 2373 | globalFlagBlockAgenda = 1; |
2374 | clearAllViews(); | 2374 | clearAllViews(); |
2375 | if (!merge) { | 2375 | if (!merge) { |
2376 | mViewManager->setDocumentId( filename ); | 2376 | mViewManager->setDocumentId( filename ); |
2377 | mCalendar->close(); | 2377 | mCalendar->close(); |
2378 | } | 2378 | } |
2379 | mStorage->setFileName( filename ); | 2379 | mStorage->setFileName( filename ); |
2380 | 2380 | ||
2381 | if ( mStorage->load() ) { | 2381 | if ( mStorage->load() ) { |
2382 | if ( merge ) ;//setModified( true ); | 2382 | if ( merge ) ;//setModified( true ); |
2383 | else { | 2383 | else { |
2384 | //setModified( true ); | 2384 | //setModified( true ); |
2385 | mViewManager->setDocumentId( filename ); | 2385 | mViewManager->setDocumentId( filename ); |
2386 | mDialogManager->setDocumentId( filename ); | 2386 | mDialogManager->setDocumentId( filename ); |
2387 | mTodoList->setDocumentId( filename ); | 2387 | mTodoList->setDocumentId( filename ); |
2388 | } | 2388 | } |
2389 | globalFlagBlockAgenda = 2; | 2389 | globalFlagBlockAgenda = 2; |
2390 | // if ( getLastSyncEvent() ) | 2390 | // if ( getLastSyncEvent() ) |
2391 | // getLastSyncEvent()->setReadOnly( true ); | 2391 | // getLastSyncEvent()->setReadOnly( true ); |
2392 | mCalendar->reInitAlarmSettings(); | 2392 | mCalendar->reInitAlarmSettings(); |
2393 | setSyncEventsReadOnly(); | 2393 | setSyncEventsReadOnly(); |
2394 | updateUnmanagedViews(); | 2394 | //updateUnmanagedViews(); |
2395 | updateView(); | 2395 | //updateView(); |
2396 | if ( filename != MainWindow::defaultFileName() ) { | 2396 | if ( filename != MainWindow::defaultFileName() ) { |
2397 | saveCalendar( MainWindow::defaultFileName() ); | 2397 | saveCalendar( MainWindow::defaultFileName() ); |
2398 | } else { | 2398 | } else { |
2399 | QFileInfo finf ( MainWindow::defaultFileName()); | 2399 | QFileInfo finf ( MainWindow::defaultFileName()); |
2400 | if ( finf.exists() ) { | 2400 | if ( finf.exists() ) { |
2401 | setLoadedFileVersion( finf.lastModified () ); | 2401 | setLoadedFileVersion( finf.lastModified () ); |
2402 | } | 2402 | } |
2403 | } | 2403 | } |
2404 | return true; | 2404 | return true; |
2405 | } else { | 2405 | } else { |
2406 | // while failing to load, the calendar object could | 2406 | // while failing to load, the calendar object could |
2407 | // have become partially populated. Clear it out. | 2407 | // have become partially populated. Clear it out. |
2408 | if ( !merge ) { | 2408 | if ( !merge ) { |
2409 | mCalendar->close(); | 2409 | mCalendar->close(); |
2410 | mViewManager->setDocumentId( filename ); | 2410 | mViewManager->setDocumentId( filename ); |
2411 | mDialogManager->setDocumentId( filename ); | 2411 | mDialogManager->setDocumentId( filename ); |
2412 | mTodoList->setDocumentId( filename ); | 2412 | mTodoList->setDocumentId( filename ); |
2413 | } | 2413 | } |
2414 | 2414 | ||
2415 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 2415 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
2416 | 2416 | ||
2417 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 2417 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
2418 | globalFlagBlockAgenda = 2; | 2418 | globalFlagBlockAgenda = 2; |
2419 | mCalendar->reInitAlarmSettings(); | 2419 | mCalendar->reInitAlarmSettings(); |
2420 | setSyncEventsReadOnly(); | 2420 | setSyncEventsReadOnly(); |
2421 | updateUnmanagedViews(); | 2421 | updateUnmanagedViews(); |
2422 | updateView(); | 2422 | updateView(); |
2423 | } | 2423 | } |
2424 | return false; | 2424 | return false; |
2425 | } | 2425 | } |
2426 | void CalendarView::mergeFile( QString fn ) | 2426 | void CalendarView::mergeFile( QString fn ) |
2427 | { | 2427 | { |
2428 | clearAllViews(); | 2428 | clearAllViews(); |
2429 | mCalendar->mergeCalendarFile( fn ); | 2429 | mCalendar->mergeCalendarFile( fn ); |
2430 | mCalendar->reInitAlarmSettings(); | 2430 | mCalendar->reInitAlarmSettings(); |
2431 | setSyncEventsReadOnly(); | 2431 | setSyncEventsReadOnly(); |
2432 | updateUnmanagedViews(); | 2432 | updateUnmanagedViews(); |
2433 | updateView(); | 2433 | updateView(); |
2434 | } | 2434 | } |
2435 | void CalendarView::showOpenError() | 2435 | void CalendarView::showOpenError() |
2436 | { | 2436 | { |
2437 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2437 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2438 | } | 2438 | } |
2439 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2439 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2440 | { | 2440 | { |
2441 | loadedFileVersion = dt; | 2441 | loadedFileVersion = dt; |
2442 | } | 2442 | } |
2443 | bool CalendarView::checkFileChanged(QString fn) | 2443 | bool CalendarView::checkFileChanged(QString fn) |
2444 | { | 2444 | { |
2445 | QFileInfo finf ( fn ); | 2445 | QFileInfo finf ( fn ); |
2446 | if ( !finf.exists() ) | 2446 | if ( !finf.exists() ) |
2447 | return true; | 2447 | return true; |
2448 | QDateTime dt = finf.lastModified (); | 2448 | QDateTime dt = finf.lastModified (); |
2449 | if ( dt <= loadedFileVersion ) | 2449 | if ( dt <= loadedFileVersion ) |
2450 | return false; | 2450 | return false; |
2451 | return true; | 2451 | return true; |
2452 | 2452 | ||
2453 | } | 2453 | } |
2454 | void CalendarView::watchSavedFile() | 2454 | void CalendarView::watchSavedFile() |
2455 | { | 2455 | { |
2456 | QFileInfo finf ( MainWindow::defaultFileName()); | 2456 | QFileInfo finf ( MainWindow::defaultFileName()); |
2457 | if ( !finf.exists() ) | 2457 | if ( !finf.exists() ) |
2458 | return; | 2458 | return; |
2459 | QDateTime dt = finf.lastModified (); | 2459 | QDateTime dt = finf.lastModified (); |
2460 | if ( dt < loadedFileVersion ) { | 2460 | if ( dt < loadedFileVersion ) { |
2461 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2461 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2462 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2462 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2463 | return; | 2463 | return; |
2464 | } | 2464 | } |
2465 | loadedFileVersion = dt; | 2465 | loadedFileVersion = dt; |
2466 | } | 2466 | } |
2467 | bool CalendarView::checkAllFileVersions() | 2467 | bool CalendarView::checkAllFileVersions() |
2468 | { | 2468 | { |
2469 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2469 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2470 | KopiCalendarFile * cal = calendars.first(); | 2470 | KopiCalendarFile * cal = calendars.first(); |
2471 | mCalendar->setDefaultCalendar( 1 ); | 2471 | mCalendar->setDefaultCalendar( 1 ); |
2472 | mCalendar->setDefaultCalendarEnabledOnly(); | 2472 | mCalendar->setDefaultCalendarEnabledOnly(); |
2473 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2473 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2474 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2474 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2475 | restoreCalendarSettings(); | 2475 | restoreCalendarSettings(); |
2476 | return false; | 2476 | return false; |
2477 | } | 2477 | } |
2478 | } | 2478 | } |
2479 | cal = calendars.next(); | 2479 | cal = calendars.next(); |
2480 | QDateTime storeTemp = loadedFileVersion; | 2480 | QDateTime storeTemp = loadedFileVersion; |
2481 | while ( cal ) { | 2481 | while ( cal ) { |
2482 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2482 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2483 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2483 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2484 | mCalendar->setDefaultCalendarEnabledOnly(); | 2484 | mCalendar->setDefaultCalendarEnabledOnly(); |
2485 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2485 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2486 | if ( !checkFileVersion(cal->mFileName )) { | 2486 | if ( !checkFileVersion(cal->mFileName )) { |
2487 | loadedFileVersion = storeTemp; | 2487 | loadedFileVersion = storeTemp; |
2488 | restoreCalendarSettings(); | 2488 | restoreCalendarSettings(); |
2489 | return false; | 2489 | return false; |
2490 | } | 2490 | } |
2491 | } | 2491 | } |
2492 | cal = calendars.next(); | 2492 | cal = calendars.next(); |
2493 | } | 2493 | } |
2494 | loadedFileVersion = storeTemp; | 2494 | loadedFileVersion = storeTemp; |
2495 | return true; | 2495 | return true; |
2496 | } | 2496 | } |
2497 | bool CalendarView::checkFileVersion(QString fn) | 2497 | bool CalendarView::checkFileVersion(QString fn) |
2498 | { | 2498 | { |
2499 | QFileInfo finf ( fn ); | 2499 | QFileInfo finf ( fn ); |
2500 | if ( !finf.exists() ) | 2500 | if ( !finf.exists() ) |
2501 | return true; | 2501 | return true; |
2502 | QDateTime dt = finf.lastModified (); | 2502 | QDateTime dt = finf.lastModified (); |
2503 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2503 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2504 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2504 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2505 | if ( dt <= loadedFileVersion ) | 2505 | if ( dt <= loadedFileVersion ) |
2506 | return true; | 2506 | return true; |
2507 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 2507 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
2508 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2508 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2509 | i18n("Sync+save")); | 2509 | i18n("Sync+save")); |
2510 | 2510 | ||
2511 | if ( km == KMessageBox::Cancel ) | 2511 | if ( km == KMessageBox::Cancel ) |
2512 | return false; | 2512 | return false; |
2513 | if ( km == KMessageBox::Yes ) | 2513 | if ( km == KMessageBox::Yes ) |
2514 | return true; | 2514 | return true; |
2515 | 2515 | ||
2516 | setSyncDevice("deleteaftersync" ); | 2516 | setSyncDevice("deleteaftersync" ); |
2517 | mSyncManager->mAskForPreferences = true; | 2517 | mSyncManager->mAskForPreferences = true; |
2518 | mSyncManager->mSyncAlgoPrefs = 3; | 2518 | mSyncManager->mSyncAlgoPrefs = 3; |
2519 | mSyncManager->mWriteBackFile = false; | 2519 | mSyncManager->mWriteBackFile = false; |
2520 | mSyncManager->mWriteBackExistingOnly = false; | 2520 | mSyncManager->mWriteBackExistingOnly = false; |
2521 | mSyncManager->mShowSyncSummary = false; | 2521 | mSyncManager->mShowSyncSummary = false; |
2522 | syncCalendar( fn, 3 ); | 2522 | syncCalendar( fn, 3 ); |
2523 | Event * e = getLastSyncEvent(); | 2523 | Event * e = getLastSyncEvent(); |
2524 | if ( e ) | 2524 | if ( e ) |
2525 | mCalendar->deleteEvent( e ); | 2525 | mCalendar->deleteEvent( e ); |
2526 | return true; | 2526 | return true; |
2527 | } | 2527 | } |
2528 | bool CalendarView::saveCalendars() | 2528 | bool CalendarView::saveCalendars() |
2529 | { | 2529 | { |
2530 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2530 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2531 | KopiCalendarFile * cal = calendars.first(); | 2531 | KopiCalendarFile * cal = calendars.first(); |
2532 | mCalendar->setDefaultCalendar( 1 ); | 2532 | mCalendar->setDefaultCalendar( 1 ); |
2533 | mCalendar->setDefaultCalendarEnabledOnly(); | 2533 | mCalendar->setDefaultCalendarEnabledOnly(); |
2534 | QString saveError; | 2534 | QString saveError; |
2535 | if ( !saveCalendar( MainWindow::defaultFileName() ) ) | 2535 | if ( !saveCalendar( MainWindow::defaultFileName() ) ) |
2536 | saveError = cal->mName +"\n"; | 2536 | saveError = cal->mName +"\n"; |
2537 | cal = calendars.next(); | 2537 | cal = calendars.next(); |
2538 | while ( cal ) { | 2538 | while ( cal ) { |
2539 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2539 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2540 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2540 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2541 | mCalendar->setDefaultCalendarEnabledOnly(); | 2541 | mCalendar->setDefaultCalendarEnabledOnly(); |
2542 | if ( saveCalendar( cal->mFileName ) ) | 2542 | if ( saveCalendar( cal->mFileName ) ) |
2543 | cal->mLoadDt = QDateTime::currentDateTime(); | 2543 | cal->mLoadDt = QDateTime::currentDateTime(); |
2544 | else | 2544 | else |
2545 | saveError += cal->mName + "\n"; | 2545 | saveError += cal->mName + "\n"; |
2546 | } | 2546 | } |
2547 | cal = calendars.next(); | 2547 | cal = calendars.next(); |
2548 | } | 2548 | } |
2549 | restoreCalendarSettings(); | 2549 | restoreCalendarSettings(); |
2550 | if ( !saveError.isEmpty() ) { | 2550 | if ( !saveError.isEmpty() ) { |
2551 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; | 2551 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; |
2552 | KMessageBox::error(this, saveError, i18n("Error saving data")); | 2552 | KMessageBox::error(this, saveError, i18n("Error saving data")); |
2553 | return false; | 2553 | return false; |
2554 | } | 2554 | } |
2555 | return true; | 2555 | return true; |
2556 | } | 2556 | } |
2557 | bool CalendarView::saveCalendar( QString filename ) | 2557 | bool CalendarView::saveCalendar( QString filename ) |
2558 | { | 2558 | { |
2559 | 2559 | ||
2560 | // Store back all unsaved data into calendar object | 2560 | // Store back all unsaved data into calendar object |
2561 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2561 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2562 | if ( mViewManager->currentView() ) | 2562 | if ( mViewManager->currentView() ) |
2563 | mViewManager->currentView()->flushView(); | 2563 | mViewManager->currentView()->flushView(); |
2564 | 2564 | ||
2565 | 2565 | ||
2566 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2566 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2567 | mStorage->setSaveFormat( new ICalFormat() ); | 2567 | mStorage->setSaveFormat( new ICalFormat() ); |
2568 | mStorage->setFileName( filename ); | 2568 | mStorage->setFileName( filename ); |
2569 | bool success; | 2569 | bool success; |
2570 | success = mStorage->save(); | 2570 | success = mStorage->save(); |
2571 | if ( !success ) { | 2571 | if ( !success ) { |
2572 | return false; | 2572 | return false; |
2573 | } | 2573 | } |
2574 | if ( filename == MainWindow::defaultFileName() ) { | 2574 | if ( filename == MainWindow::defaultFileName() ) { |
2575 | setLoadedFileVersion( lfv ); | 2575 | setLoadedFileVersion( lfv ); |
2576 | watchSavedFile(); | 2576 | watchSavedFile(); |
2577 | } | 2577 | } |
2578 | return true; | 2578 | return true; |
2579 | } | 2579 | } |
2580 | 2580 | ||
2581 | void CalendarView::closeCalendar() | 2581 | void CalendarView::closeCalendar() |
2582 | { | 2582 | { |
2583 | 2583 | ||
2584 | // child windows no longer valid | 2584 | // child windows no longer valid |
2585 | clearAllViews(); | 2585 | clearAllViews(); |
2586 | emit closingDown(); | 2586 | emit closingDown(); |
2587 | 2587 | ||
2588 | mCalendar->close(); | 2588 | mCalendar->close(); |
2589 | setModified(false); | 2589 | setModified(false); |
2590 | updateView(); | 2590 | updateView(); |
2591 | } | 2591 | } |
2592 | 2592 | ||
2593 | void CalendarView::archiveCalendar() | 2593 | void CalendarView::archiveCalendar() |
2594 | { | 2594 | { |
2595 | mDialogManager->showArchiveDialog(); | 2595 | mDialogManager->showArchiveDialog(); |
2596 | } | 2596 | } |
2597 | 2597 | ||
2598 | 2598 | ||
2599 | void CalendarView::readSettings() | 2599 | void CalendarView::readSettings() |
2600 | { | 2600 | { |
2601 | 2601 | ||
2602 | 2602 | ||
2603 | // mViewManager->showAgendaView(); | 2603 | // mViewManager->showAgendaView(); |
2604 | QString str; | 2604 | QString str; |
2605 | //qDebug("CalendarView::readSettings() "); | 2605 | //qDebug("CalendarView::readSettings() "); |
2606 | // read settings from the KConfig, supplying reasonable | 2606 | // read settings from the KConfig, supplying reasonable |
2607 | // defaults where none are to be found | 2607 | // defaults where none are to be found |
2608 | KConfig *config = KOGlobals::config(); | 2608 | KConfig *config = KOGlobals::config(); |
2609 | #ifndef KORG_NOSPLITTER | 2609 | #ifndef KORG_NOSPLITTER |
2610 | config->setGroup("KOrganizer Geometry"); | 2610 | config->setGroup("KOrganizer Geometry"); |
2611 | 2611 | ||
2612 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2612 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2613 | if (sizes.count() != 2) { | 2613 | if (sizes.count() != 2) { |
2614 | sizes << mDateNavigator->minimumSizeHint().width(); | 2614 | sizes << mDateNavigator->minimumSizeHint().width(); |
2615 | sizes << 300; | 2615 | sizes << 300; |
2616 | } | 2616 | } |
2617 | mPanner->setSizes(sizes); | 2617 | mPanner->setSizes(sizes); |
2618 | 2618 | ||
2619 | sizes = config->readIntListEntry("Separator2"); | 2619 | sizes = config->readIntListEntry("Separator2"); |
2620 | if ( ( mResourceView && sizes.count() == 4 ) || | 2620 | if ( ( mResourceView && sizes.count() == 4 ) || |
2621 | ( !mResourceView && sizes.count() == 3 ) ) { | 2621 | ( !mResourceView && sizes.count() == 3 ) ) { |
2622 | mLeftSplitter->setSizes(sizes); | 2622 | mLeftSplitter->setSizes(sizes); |
2623 | } | 2623 | } |
2624 | #endif | 2624 | #endif |
2625 | globalFlagBlockAgenda = 1; | 2625 | globalFlagBlockAgenda = 1; |
2626 | mViewManager->showAgendaView(); | 2626 | mViewManager->showAgendaView(); |
2627 | //mViewManager->readSettings( config ); | 2627 | //mViewManager->readSettings( config ); |
2628 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2628 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2629 | readFilterSettings(config); | 2629 | readFilterSettings(config); |
2630 | 2630 | ||
2631 | #ifdef DESKTOP_VERSION | 2631 | #ifdef DESKTOP_VERSION |
2632 | config->setGroup("WidgetLayout"); | 2632 | config->setGroup("WidgetLayout"); |
2633 | QStringList list; | 2633 | QStringList list; |
2634 | list = config->readListEntry("MainLayout"); | 2634 | list = config->readListEntry("MainLayout"); |
2635 | int x,y,w,h; | 2635 | int x,y,w,h; |
2636 | if ( ! list.isEmpty() ) { | 2636 | if ( ! list.isEmpty() ) { |
2637 | x = list[0].toInt(); | 2637 | x = list[0].toInt(); |
2638 | y = list[1].toInt(); | 2638 | y = list[1].toInt(); |
2639 | w = list[2].toInt(); | 2639 | w = list[2].toInt(); |
2640 | h = list[3].toInt(); | 2640 | h = list[3].toInt(); |
2641 | KApplication::testCoords( &x,&y,&w,&h ); | 2641 | KApplication::testCoords( &x,&y,&w,&h ); |
2642 | topLevelWidget()->setGeometry(x,y,w,h); | 2642 | topLevelWidget()->setGeometry(x,y,w,h); |
2643 | 2643 | ||
2644 | } else { | 2644 | } else { |
2645 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2645 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2646 | } | 2646 | } |
2647 | list = config->readListEntry("EditEventLayout"); | 2647 | list = config->readListEntry("EditEventLayout"); |
2648 | if ( ! list.isEmpty() ) { | 2648 | if ( ! list.isEmpty() ) { |
2649 | x = list[0].toInt(); | 2649 | x = list[0].toInt(); |
2650 | y = list[1].toInt(); | 2650 | y = list[1].toInt(); |
2651 | w = list[2].toInt(); | 2651 | w = list[2].toInt(); |
2652 | h = list[3].toInt(); | 2652 | h = list[3].toInt(); |
2653 | KApplication::testCoords( &x,&y,&w,&h ); | 2653 | KApplication::testCoords( &x,&y,&w,&h ); |
2654 | mEventEditor->setGeometry(x,y,w,h); | 2654 | mEventEditor->setGeometry(x,y,w,h); |
2655 | 2655 | ||
2656 | } | 2656 | } |
2657 | list = config->readListEntry("EditTodoLayout"); | 2657 | list = config->readListEntry("EditTodoLayout"); |
2658 | if ( ! list.isEmpty() ) { | 2658 | if ( ! list.isEmpty() ) { |
2659 | x = list[0].toInt(); | 2659 | x = list[0].toInt(); |
2660 | y = list[1].toInt(); | 2660 | y = list[1].toInt(); |
2661 | w = list[2].toInt(); | 2661 | w = list[2].toInt(); |
2662 | h = list[3].toInt(); | 2662 | h = list[3].toInt(); |
2663 | KApplication::testCoords( &x,&y,&w,&h ); | 2663 | KApplication::testCoords( &x,&y,&w,&h ); |
2664 | mTodoEditor->setGeometry(x,y,w,h); | 2664 | mTodoEditor->setGeometry(x,y,w,h); |
2665 | 2665 | ||
2666 | } | 2666 | } |
2667 | list = config->readListEntry("ViewerLayout"); | 2667 | list = config->readListEntry("ViewerLayout"); |
2668 | if ( ! list.isEmpty() ) { | 2668 | if ( ! list.isEmpty() ) { |
2669 | x = list[0].toInt(); | 2669 | x = list[0].toInt(); |
2670 | y = list[1].toInt(); | 2670 | y = list[1].toInt(); |
2671 | w = list[2].toInt(); | 2671 | w = list[2].toInt(); |
2672 | h = list[3].toInt(); | 2672 | h = list[3].toInt(); |
2673 | KApplication::testCoords( &x,&y,&w,&h ); | 2673 | KApplication::testCoords( &x,&y,&w,&h ); |
2674 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2674 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2675 | } | 2675 | } |
2676 | #endif | 2676 | #endif |
2677 | config->setGroup( "Views" ); | 2677 | config->setGroup( "Views" ); |
2678 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2678 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2679 | 2679 | ||
2680 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2680 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2681 | 2681 | ||
2682 | int resetval = 0; | 2682 | int resetval = 0; |
2683 | int maxVal = 0; | 2683 | int maxVal = 0; |
2684 | if (sizes.count() != 3) { | 2684 | if (sizes.count() != 3) { |
2685 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2685 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2686 | resetval = mDateNavigator->sizeHint().width()+2; | 2686 | resetval = mDateNavigator->sizeHint().width()+2; |
2687 | } else { | 2687 | } else { |
2688 | resetval = mDateNavigator->sizeHint().height()+2; | 2688 | resetval = mDateNavigator->sizeHint().height()+2; |
2689 | } | 2689 | } |
2690 | } | 2690 | } |
2691 | if ( resetval ) { | 2691 | if ( resetval ) { |
2692 | sizes.clear(); | 2692 | sizes.clear(); |
2693 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2693 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2694 | maxVal = QApplication::desktop()->width() -10; | 2694 | maxVal = QApplication::desktop()->width() -10; |
2695 | } else { | 2695 | } else { |
2696 | maxVal = QApplication::desktop()->height()-10; | 2696 | maxVal = QApplication::desktop()->height()-10; |
2697 | } | 2697 | } |
2698 | sizes << resetval; | 2698 | sizes << resetval; |
2699 | if ( maxVal < resetval + resetval) | 2699 | if ( maxVal < resetval + resetval) |
2700 | resetval = maxVal - resetval; | 2700 | resetval = maxVal - resetval; |
2701 | sizes << resetval; | 2701 | sizes << resetval; |
2702 | sizes << 100; | 2702 | sizes << 100; |
2703 | } | 2703 | } |
2704 | mLeftFrame->setSizes(sizes); | 2704 | mLeftFrame->setSizes(sizes); |
2705 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2705 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2706 | resetval = 0; | 2706 | resetval = 0; |
2707 | maxVal = 0; | 2707 | maxVal = 0; |
2708 | if (sizes.count() != 2) { | 2708 | if (sizes.count() != 2) { |
2709 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2709 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2710 | resetval = mDateNavigator->sizeHint().width()+2; | 2710 | resetval = mDateNavigator->sizeHint().width()+2; |
2711 | } else { | 2711 | } else { |
2712 | resetval = mDateNavigator->sizeHint().height()+2; | 2712 | resetval = mDateNavigator->sizeHint().height()+2; |
2713 | } | 2713 | } |
2714 | } | 2714 | } |
2715 | if ( resetval ) { | 2715 | if ( resetval ) { |
2716 | sizes.clear(); | 2716 | sizes.clear(); |
2717 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2717 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2718 | maxVal = QApplication::desktop()->width() -10; | 2718 | maxVal = QApplication::desktop()->width() -10; |
2719 | } else { | 2719 | } else { |
2720 | maxVal = QApplication::desktop()->height()-10; | 2720 | maxVal = QApplication::desktop()->height()-10; |
2721 | } | 2721 | } |
2722 | sizes << resetval; | 2722 | sizes << resetval; |
2723 | if ( maxVal < resetval + resetval) | 2723 | if ( maxVal < resetval + resetval) |
2724 | resetval = maxVal - resetval; | 2724 | resetval = maxVal - resetval; |
2725 | sizes << resetval; | 2725 | sizes << resetval; |
2726 | } | 2726 | } |
2727 | mMainFrame->setSizes(sizes); | 2727 | mMainFrame->setSizes(sizes); |
2728 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2728 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2729 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2729 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2730 | else mNavigator->selectDates( dateCount ); | 2730 | else mNavigator->selectDates( dateCount ); |
2731 | // mViewManager->readSettings( config ); | 2731 | // mViewManager->readSettings( config ); |
2732 | updateConfig(); | 2732 | updateConfig(); |
2733 | globalFlagBlockAgenda = 2; | 2733 | globalFlagBlockAgenda = 2; |
2734 | mViewManager->readSettings( config ); | 2734 | mViewManager->readSettings( config ); |
2735 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2735 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2736 | } | 2736 | } |
2737 | 2737 | ||
2738 | void CalendarView::checkSuspendAlarm() | 2738 | void CalendarView::checkSuspendAlarm() |
2739 | { | 2739 | { |
2740 | if ( mSuspendTimer->isActive() ) { | 2740 | if ( mSuspendTimer->isActive() ) { |
2741 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); | 2741 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); |
2742 | } | 2742 | } |
2743 | } | 2743 | } |
2744 | void CalendarView::writeSettings() | 2744 | void CalendarView::writeSettings() |
2745 | { | 2745 | { |
2746 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2746 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2747 | 2747 | ||
2748 | KConfig *config = KOGlobals::config(); | 2748 | KConfig *config = KOGlobals::config(); |
2749 | 2749 | ||
2750 | mViewManager->writeSettings( config ); | 2750 | mViewManager->writeSettings( config ); |
2751 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2751 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2752 | mDialogManager->writeSettings( config ); | 2752 | mDialogManager->writeSettings( config ); |
2753 | //KOPrefs::instance()->usrWriteConfig(); | 2753 | //KOPrefs::instance()->usrWriteConfig(); |
2754 | KOPrefs::instance()->writeConfig(); | 2754 | KOPrefs::instance()->writeConfig(); |
2755 | 2755 | ||
2756 | writeFilterSettings(config); | 2756 | writeFilterSettings(config); |
2757 | config->setGroup( "AppRun" ); | 2757 | config->setGroup( "AppRun" ); |
2758 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2758 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2759 | int days = dt.daysTo( QDate::currentDate() ); | 2759 | int days = dt.daysTo( QDate::currentDate() ); |
2760 | dt = dt.addDays( days ); | 2760 | dt = dt.addDays( days ); |
2761 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2761 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2762 | config->writeEntry( "LatestProgramStopDays", days ); | 2762 | config->writeEntry( "LatestProgramStopDays", days ); |
2763 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2763 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2764 | //qDebug("KO: Writing stop time: %d ", secs); | 2764 | //qDebug("KO: Writing stop time: %d ", secs); |
2765 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2765 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2766 | //QDateTime latest = dt.addSecs ( secs ); | 2766 | //QDateTime latest = dt.addSecs ( secs ); |
2767 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2767 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2768 | config->setGroup( "Views" ); | 2768 | config->setGroup( "Views" ); |
2769 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2769 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2770 | 2770 | ||
2771 | #if 0 | 2771 | #if 0 |
2772 | qDebug("********************* "); | 2772 | qDebug("********************* "); |
2773 | qDebug("Testcode secsto "); | 2773 | qDebug("Testcode secsto "); |
2774 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2774 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2775 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2775 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2776 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2776 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2777 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2777 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2778 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2778 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2779 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2779 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2780 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2780 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2781 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2781 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2782 | qDebug("********************* testcode end"); | 2782 | qDebug("********************* testcode end"); |
2783 | 2783 | ||
2784 | #endif | 2784 | #endif |
2785 | 2785 | ||
2786 | QValueList<int> listINT = mLeftFrame->sizes(); | 2786 | QValueList<int> listINT = mLeftFrame->sizes(); |
2787 | config->writeEntry("Left Splitter Frame",listINT); | 2787 | config->writeEntry("Left Splitter Frame",listINT); |
2788 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2788 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2789 | config->writeEntry("Main Splitter Frame",listINT2); | 2789 | config->writeEntry("Main Splitter Frame",listINT2); |
2790 | #ifdef DESKTOP_VERSION | 2790 | #ifdef DESKTOP_VERSION |
2791 | config->setGroup("WidgetLayout"); | 2791 | config->setGroup("WidgetLayout"); |
2792 | QStringList list ;//= config->readListEntry("MainLayout"); | 2792 | QStringList list ;//= config->readListEntry("MainLayout"); |
2793 | int x,y,w,h; | 2793 | int x,y,w,h; |
2794 | QWidget* wid; | 2794 | QWidget* wid; |
2795 | wid = topLevelWidget(); | 2795 | wid = topLevelWidget(); |
2796 | x = wid->geometry().x(); | 2796 | x = wid->geometry().x(); |
2797 | y = wid->geometry().y(); | 2797 | y = wid->geometry().y(); |
2798 | w = wid->width(); | 2798 | w = wid->width(); |
2799 | h = wid->height(); | 2799 | h = wid->height(); |
2800 | list.clear(); | 2800 | list.clear(); |
2801 | list << QString::number( x ); | 2801 | list << QString::number( x ); |
2802 | list << QString::number( y ); | 2802 | list << QString::number( y ); |
2803 | list << QString::number( w ); | 2803 | list << QString::number( w ); |
2804 | list << QString::number( h ); | 2804 | list << QString::number( h ); |
2805 | config->writeEntry("MainLayout",list ); | 2805 | config->writeEntry("MainLayout",list ); |
2806 | 2806 | ||
2807 | wid = mEventEditor; | 2807 | wid = mEventEditor; |
2808 | x = wid->geometry().x(); | 2808 | x = wid->geometry().x(); |
2809 | y = wid->geometry().y(); | 2809 | y = wid->geometry().y(); |
2810 | w = wid->width(); | 2810 | w = wid->width(); |
2811 | h = wid->height(); | 2811 | h = wid->height(); |
2812 | list.clear(); | 2812 | list.clear(); |
2813 | list << QString::number( x ); | 2813 | list << QString::number( x ); |
2814 | list << QString::number( y ); | 2814 | list << QString::number( y ); |
2815 | list << QString::number( w ); | 2815 | list << QString::number( w ); |
2816 | list << QString::number( h ); | 2816 | list << QString::number( h ); |
2817 | config->writeEntry("EditEventLayout",list ); | 2817 | config->writeEntry("EditEventLayout",list ); |
2818 | 2818 | ||
2819 | wid = mTodoEditor; | 2819 | wid = mTodoEditor; |
2820 | x = wid->geometry().x(); | 2820 | x = wid->geometry().x(); |
2821 | y = wid->geometry().y(); | 2821 | y = wid->geometry().y(); |
2822 | w = wid->width(); | 2822 | w = wid->width(); |
2823 | h = wid->height(); | 2823 | h = wid->height(); |
2824 | list.clear(); | 2824 | list.clear(); |
2825 | list << QString::number( x ); | 2825 | list << QString::number( x ); |
2826 | list << QString::number( y ); | 2826 | list << QString::number( y ); |
2827 | list << QString::number( w ); | 2827 | list << QString::number( w ); |
2828 | list << QString::number( h ); | 2828 | list << QString::number( h ); |
2829 | config->writeEntry("EditTodoLayout",list ); | 2829 | config->writeEntry("EditTodoLayout",list ); |
2830 | wid = getEventViewerDialog(); | 2830 | wid = getEventViewerDialog(); |
2831 | x = wid->geometry().x(); | 2831 | x = wid->geometry().x(); |
2832 | y = wid->geometry().y(); | 2832 | y = wid->geometry().y(); |
2833 | w = wid->width(); | 2833 | w = wid->width(); |
2834 | h = wid->height(); | 2834 | h = wid->height(); |
2835 | list.clear(); | 2835 | list.clear(); |
2836 | list << QString::number( x ); | 2836 | list << QString::number( x ); |
2837 | list << QString::number( y ); | 2837 | list << QString::number( y ); |
2838 | list << QString::number( w ); | 2838 | list << QString::number( w ); |
2839 | list << QString::number( h ); | 2839 | list << QString::number( h ); |
2840 | config->writeEntry("ViewerLayout",list ); | 2840 | config->writeEntry("ViewerLayout",list ); |
2841 | wid = mDialogManager->getSearchDialog(); | 2841 | wid = mDialogManager->getSearchDialog(); |
2842 | if ( wid ) { | 2842 | if ( wid ) { |
2843 | x = wid->geometry().x(); | 2843 | x = wid->geometry().x(); |
2844 | y = wid->geometry().y(); | 2844 | y = wid->geometry().y(); |
2845 | w = wid->width(); | 2845 | w = wid->width(); |
2846 | h = wid->height(); | 2846 | h = wid->height(); |
2847 | list.clear(); | 2847 | list.clear(); |
2848 | list << QString::number( x ); | 2848 | list << QString::number( x ); |
2849 | list << QString::number( y ); | 2849 | list << QString::number( y ); |
2850 | list << QString::number( w ); | 2850 | list << QString::number( w ); |
2851 | list << QString::number( h ); | 2851 | list << QString::number( h ); |
2852 | config->writeEntry("SearchLayout",list ); | 2852 | config->writeEntry("SearchLayout",list ); |
2853 | } | 2853 | } |
2854 | #endif | 2854 | #endif |
2855 | 2855 | ||
2856 | 2856 | ||
2857 | config->sync(); | 2857 | config->sync(); |
2858 | } | 2858 | } |
2859 | 2859 | ||
2860 | void CalendarView::readFilterSettings(KConfig *config) | 2860 | void CalendarView::readFilterSettings(KConfig *config) |
2861 | { | 2861 | { |
2862 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2862 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2863 | 2863 | ||
2864 | mFilters.clear(); | 2864 | mFilters.clear(); |
2865 | 2865 | ||
2866 | config->setGroup("General"); | 2866 | config->setGroup("General"); |
2867 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2867 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2868 | 2868 | ||
2869 | QStringList::ConstIterator it = filterList.begin(); | 2869 | QStringList::ConstIterator it = filterList.begin(); |
2870 | QStringList::ConstIterator end = filterList.end(); | 2870 | QStringList::ConstIterator end = filterList.end(); |
2871 | while(it != end) { | 2871 | while(it != end) { |
2872 | // kdDebug() << " filter: " << (*it) << endl; | 2872 | // kdDebug() << " filter: " << (*it) << endl; |
2873 | 2873 | ||
2874 | CalFilter *filter; | 2874 | CalFilter *filter; |
2875 | filter = new CalFilter(*it); | 2875 | filter = new CalFilter(*it); |
2876 | config->setGroup("Filter_" + (*it).utf8()); | 2876 | config->setGroup("Filter_" + (*it).utf8()); |
2877 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2877 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2878 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2878 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2879 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2879 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2880 | mFilters.append(filter); | 2880 | mFilters.append(filter); |
2881 | 2881 | ||
2882 | ++it; | 2882 | ++it; |
2883 | } | 2883 | } |
2884 | 2884 | ||
2885 | if (mFilters.count() == 0) { | 2885 | if (mFilters.count() == 0) { |
2886 | CalFilter *filter = new CalFilter(i18n("Default")); | 2886 | CalFilter *filter = new CalFilter(i18n("Default")); |
2887 | mFilters.append(filter); | 2887 | mFilters.append(filter); |
2888 | } | 2888 | } |
2889 | mFilterView->updateFilters(); | 2889 | mFilterView->updateFilters(); |
2890 | config->setGroup("FilterView"); | 2890 | config->setGroup("FilterView"); |
2891 | 2891 | ||
2892 | mFilterView->blockSignals(true); | 2892 | mFilterView->blockSignals(true); |
2893 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2893 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2894 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2894 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2895 | mFilterView->blockSignals(false); | 2895 | mFilterView->blockSignals(false); |
2896 | // We do it manually to avoid it being done twice by the above calls | 2896 | // We do it manually to avoid it being done twice by the above calls |
2897 | updateFilter(); | 2897 | updateFilter(); |
2898 | } | 2898 | } |
2899 | 2899 | ||
2900 | void CalendarView::writeFilterSettings(KConfig *config) | 2900 | void CalendarView::writeFilterSettings(KConfig *config) |
2901 | { | 2901 | { |
2902 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2902 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2903 | 2903 | ||
2904 | QStringList filterList; | 2904 | QStringList filterList; |
2905 | 2905 | ||
2906 | CalFilter *filter = mFilters.first(); | 2906 | CalFilter *filter = mFilters.first(); |
2907 | while(filter) { | 2907 | while(filter) { |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 17248dc..07bfdbf 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -1,1018 +1,1023 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,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 <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qheader.h> | 25 | #include <qheader.h> |
26 | #include <qcursor.h> | 26 | #include <qcursor.h> |
27 | #include <qwhatsthis.h> | 27 | #include <qwhatsthis.h> |
28 | #include <qdialog.h> | 28 | #include <qdialog.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | 31 | ||
32 | #include <qinputdialog.h> | 32 | #include <qinputdialog.h> |
33 | 33 | ||
34 | #include <qvbox.h> | 34 | #include <qvbox.h> |
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include "koprefs.h" | 36 | #include "koprefs.h" |
37 | #include <klocale.h> | 37 | #include <klocale.h> |
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kdateedit.h> | 39 | #include <kdateedit.h> |
40 | #include "ktimeedit.h" | 40 | #include "ktimeedit.h" |
41 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
42 | #include <kmessagebox.h> | 42 | #include <kmessagebox.h> |
43 | 43 | ||
44 | #include <libkcal/icaldrag.h> | 44 | #include <libkcal/icaldrag.h> |
45 | #include <libkcal/vcaldrag.h> | 45 | #include <libkcal/vcaldrag.h> |
46 | #include <libkcal/calfilter.h> | 46 | #include <libkcal/calfilter.h> |
47 | #include <libkcal/dndfactory.h> | 47 | #include <libkcal/dndfactory.h> |
48 | #include <libkcal/calendarresources.h> | 48 | #include <libkcal/calendarresources.h> |
49 | #include <libkcal/resourcecalendar.h> | 49 | #include <libkcal/resourcecalendar.h> |
50 | #include <kresources/resourceselectdialog.h> | 50 | #include <kresources/resourceselectdialog.h> |
51 | #include <libkcal/kincidenceformatter.h> | 51 | #include <libkcal/kincidenceformatter.h> |
52 | #ifndef DESKTOP_VERSION | 52 | #ifndef DESKTOP_VERSION |
53 | #include <qpe/qpeapplication.h> | 53 | #include <qpe/qpeapplication.h> |
54 | #else | 54 | #else |
55 | #include <qapplication.h> | 55 | #include <qapplication.h> |
56 | #endif | 56 | #endif |
57 | #ifndef KORG_NOPRINTER | 57 | #ifndef KORG_NOPRINTER |
58 | #include "calprinter.h" | 58 | #include "calprinter.h" |
59 | #endif | 59 | #endif |
60 | #include "docprefs.h" | 60 | #include "docprefs.h" |
61 | 61 | ||
62 | #include "kotodoview.h" | 62 | #include "kotodoview.h" |
63 | using namespace KOrg; | 63 | using namespace KOrg; |
64 | 64 | ||
65 | 65 | ||
66 | KOStartTodoPrefs::KOStartTodoPrefs( QString sum, QWidget *parent, const char *name ) : | 66 | KOStartTodoPrefs::KOStartTodoPrefs( QString sum, QWidget *parent, const char *name ) : |
67 | QDialog( parent, name, true ) | 67 | QDialog( parent, name, true ) |
68 | { | 68 | { |
69 | mStopAll = true; | 69 | mStopAll = true; |
70 | setCaption( i18n("Start todo") ); | 70 | setCaption( i18n("Start todo") ); |
71 | QVBoxLayout* lay = new QVBoxLayout( this ); | 71 | QVBoxLayout* lay = new QVBoxLayout( this ); |
72 | lay->setSpacing( 3 ); | 72 | lay->setSpacing( 3 ); |
73 | lay->setMargin( 3 ); | 73 | lay->setMargin( 3 ); |
74 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( sum ), this ); | 74 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( sum ), this ); |
75 | lay->addWidget( lab ); | 75 | lay->addWidget( lab ); |
76 | lab->setAlignment( AlignCenter ); | 76 | lab->setAlignment( AlignCenter ); |
77 | 77 | ||
78 | QPushButton * ok = new QPushButton( i18n("Start this todo\nand stop all running"), this ); | 78 | QPushButton * ok = new QPushButton( i18n("Start this todo\nand stop all running"), this ); |
79 | lay->addWidget( ok ); | 79 | lay->addWidget( ok ); |
80 | ok->setDefault( true ); | 80 | ok->setDefault( true ); |
81 | QPushButton * start = new QPushButton( i18n("Start todo"), this ); | 81 | QPushButton * start = new QPushButton( i18n("Start todo"), this ); |
82 | lay->addWidget( start ); | 82 | lay->addWidget( start ); |
83 | QPushButton * cancel = new QPushButton( i18n("Cancel - do not start"), this ); | 83 | QPushButton * cancel = new QPushButton( i18n("Cancel - do not start"), this ); |
84 | lay->addWidget( cancel ); | 84 | lay->addWidget( cancel ); |
85 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 85 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
86 | connect ( start,SIGNAL(clicked() ),this , SLOT ( doStop() ) ); | 86 | connect ( start,SIGNAL(clicked() ),this , SLOT ( doStop() ) ); |
87 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 87 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
88 | resize( sizeHint() ); | 88 | resize( sizeHint() ); |
89 | 89 | ||
90 | } | 90 | } |
91 | void KOStartTodoPrefs::doStop() | 91 | void KOStartTodoPrefs::doStop() |
92 | { | 92 | { |
93 | mStopAll = false; | 93 | mStopAll = false; |
94 | accept(); | 94 | accept(); |
95 | } | 95 | } |
96 | KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : | 96 | KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : |
97 | QDialog( parent, name, true ) | 97 | QDialog( parent, name, true ) |
98 | { | 98 | { |
99 | mTodo = todo; | 99 | mTodo = todo; |
100 | setCaption( i18n("Stop todo") ); | 100 | setCaption( i18n("Stop todo") ); |
101 | QVBoxLayout* lay = new QVBoxLayout( this ); | 101 | QVBoxLayout* lay = new QVBoxLayout( this ); |
102 | lay->setSpacing( 3 ); | 102 | lay->setSpacing( 3 ); |
103 | lay->setMargin( 3 ); | 103 | lay->setMargin( 3 ); |
104 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this ); | 104 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this ); |
105 | lay->addWidget( lab ); | 105 | lay->addWidget( lab ); |
106 | lab->setAlignment( AlignHCenter ); | 106 | lab->setAlignment( AlignHCenter ); |
107 | lab = new QLabel( i18n("Additional Comment:"), this ); | 107 | lab = new QLabel( i18n("Additional Comment:"), this ); |
108 | lay->addWidget( lab ); | 108 | lay->addWidget( lab ); |
109 | mComment = new QLineEdit( this ); | 109 | mComment = new QLineEdit( this ); |
110 | lay->addWidget( mComment ); | 110 | lay->addWidget( mComment ); |
111 | QHBox * start = new QHBox ( this ); | 111 | QHBox * start = new QHBox ( this ); |
112 | lay->addWidget( start ); | 112 | lay->addWidget( start ); |
113 | lab = new QLabel( i18n("Start:"), start ); | 113 | lab = new QLabel( i18n("Start:"), start ); |
114 | QHBox * end = new QHBox ( this ); | 114 | QHBox * end = new QHBox ( this ); |
115 | lay->addWidget( end ); | 115 | lay->addWidget( end ); |
116 | lab = new QLabel( i18n("End:"), end ); | 116 | lab = new QLabel( i18n("End:"), end ); |
117 | sde = new KDateEdit( start ); | 117 | sde = new KDateEdit( start ); |
118 | ste = new KOTimeEdit( start ); | 118 | ste = new KOTimeEdit( start ); |
119 | connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) ); | 119 | connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) ); |
120 | ede = new KDateEdit( end ); | 120 | ede = new KDateEdit( end ); |
121 | ete = new KOTimeEdit(end ); | 121 | ete = new KOTimeEdit(end ); |
122 | connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) ); | 122 | connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) ); |
123 | sde->setDate( mTodo->runStart().date() ); | 123 | sde->setDate( mTodo->runStart().date() ); |
124 | ste->setTime( mTodo->runStart().time() ); | 124 | ste->setTime( mTodo->runStart().time() ); |
125 | ede->setDate( QDate::currentDate()); | 125 | ede->setDate( QDate::currentDate()); |
126 | ete->setTime( QTime::currentTime() ); | 126 | ete->setTime( QTime::currentTime() ); |
127 | QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); | 127 | QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); |
128 | lay->addWidget( ok ); | 128 | lay->addWidget( ok ); |
129 | ok->setDefault( true ); | 129 | ok->setDefault( true ); |
130 | QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); | 130 | QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); |
131 | lay->addWidget( cancel ); | 131 | lay->addWidget( cancel ); |
132 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 132 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
133 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 133 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
134 | ok = new QPushButton( i18n("Stop - do not save"), this ); | 134 | ok = new QPushButton( i18n("Stop - do not save"), this ); |
135 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); | 135 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); |
136 | lay->addWidget( ok ); | 136 | lay->addWidget( ok ); |
137 | if (QApplication::desktop()->width() < 320 ) | 137 | if (QApplication::desktop()->width() < 320 ) |
138 | resize( 240, sizeHint().height() ); | 138 | resize( 240, sizeHint().height() ); |
139 | else | 139 | else |
140 | resize( 320, sizeHint().height() ); | 140 | resize( 320, sizeHint().height() ); |
141 | 141 | ||
142 | } | 142 | } |
143 | 143 | ||
144 | void KOStopTodoPrefs::accept() | 144 | void KOStopTodoPrefs::accept() |
145 | { | 145 | { |
146 | QDateTime start = QDateTime( sde->date(), ste->getTime() ); | 146 | QDateTime start = QDateTime( sde->date(), ste->getTime() ); |
147 | QDateTime stop = QDateTime( ede->date(), ete->getTime() ); | 147 | QDateTime stop = QDateTime( ede->date(), ete->getTime() ); |
148 | if ( start > stop ) { | 148 | if ( start > stop ) { |
149 | KMessageBox::sorry(this, | 149 | KMessageBox::sorry(this, |
150 | i18n("The start time is\nafter the end time!"), | 150 | i18n("The start time is\nafter the end time!"), |
151 | i18n("Time mismatch!")); | 151 | i18n("Time mismatch!")); |
152 | return; | 152 | return; |
153 | } | 153 | } |
154 | mTodo->saveRunningInfo( mComment->text(), start, stop ); | 154 | mTodo->saveRunningInfo( mComment->text(), start, stop ); |
155 | QDialog::accept(); | 155 | QDialog::accept(); |
156 | } | 156 | } |
157 | void KOStopTodoPrefs::doNotSave() | 157 | void KOStopTodoPrefs::doNotSave() |
158 | { | 158 | { |
159 | int result = KMessageBox::warningContinueCancel(this, | 159 | int result = KMessageBox::warningContinueCancel(this, |
160 | i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") ); | 160 | i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") ); |
161 | if (result != KMessageBox::Continue) return; | 161 | if (result != KMessageBox::Continue) return; |
162 | mTodo->stopRunning(); | 162 | mTodo->stopRunning(); |
163 | QDialog::accept(); | 163 | QDialog::accept(); |
164 | } | 164 | } |
165 | 165 | ||
166 | 166 | ||
167 | class KOTodoViewWhatsThis :public QWhatsThis | 167 | class KOTodoViewWhatsThis :public QWhatsThis |
168 | { | 168 | { |
169 | public: | 169 | public: |
170 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; | 170 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; |
171 | 171 | ||
172 | protected: | 172 | protected: |
173 | virtual QString text( const QPoint& p) | 173 | virtual QString text( const QPoint& p) |
174 | { | 174 | { |
175 | return _view->getWhatsThisText(p) ; | 175 | return _view->getWhatsThisText(p) ; |
176 | } | 176 | } |
177 | private: | 177 | private: |
178 | QWidget* _wid; | 178 | QWidget* _wid; |
179 | KOTodoView * _view; | 179 | KOTodoView * _view; |
180 | }; | 180 | }; |
181 | 181 | ||
182 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, | 182 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, |
183 | const char *name) : | 183 | const char *name) : |
184 | KListView(parent,name) | 184 | KListView(parent,name) |
185 | { | 185 | { |
186 | mName = QString ( name ); | 186 | mName = QString ( name ); |
187 | mCalendar = calendar; | 187 | mCalendar = calendar; |
188 | #ifndef DESKTOP_VERSION | 188 | #ifndef DESKTOP_VERSION |
189 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 189 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
190 | #endif | 190 | #endif |
191 | mOldCurrent = 0; | 191 | mOldCurrent = 0; |
192 | mMousePressed = false; | 192 | mMousePressed = false; |
193 | 193 | ||
194 | setAcceptDrops(true); | 194 | setAcceptDrops(true); |
195 | viewport()->setAcceptDrops(true); | 195 | viewport()->setAcceptDrops(true); |
196 | int size = 16; | 196 | int size = 16; |
197 | if (qApp->desktop()->width() < 300 ) | 197 | if (qApp->desktop()->width() < 300 ) |
198 | size = 12; | 198 | size = 12; |
199 | setTreeStepSize( size + 6 ); | 199 | setTreeStepSize( size + 6 ); |
200 | 200 | ||
201 | } | 201 | } |
202 | 202 | ||
203 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) | 203 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) |
204 | { | 204 | { |
205 | #ifndef KORG_NODND | 205 | #ifndef KORG_NODND |
206 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; | 206 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; |
207 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 207 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
208 | !QTextDrag::canDecode( e ) ) { | 208 | !QTextDrag::canDecode( e ) ) { |
209 | e->ignore(); | 209 | e->ignore(); |
210 | return; | 210 | return; |
211 | } | 211 | } |
212 | 212 | ||
213 | mOldCurrent = currentItem(); | 213 | mOldCurrent = currentItem(); |
214 | #endif | 214 | #endif |
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
218 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) | 218 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) |
219 | { | 219 | { |
220 | #ifndef KORG_NODND | 220 | #ifndef KORG_NODND |
221 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; | 221 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; |
222 | 222 | ||
223 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 223 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
224 | !QTextDrag::canDecode( e ) ) { | 224 | !QTextDrag::canDecode( e ) ) { |
225 | e->ignore(); | 225 | e->ignore(); |
226 | return; | 226 | return; |
227 | } | 227 | } |
228 | 228 | ||
229 | e->accept(); | 229 | e->accept(); |
230 | #endif | 230 | #endif |
231 | } | 231 | } |
232 | 232 | ||
233 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) | 233 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) |
234 | { | 234 | { |
235 | #ifndef KORG_NODND | 235 | #ifndef KORG_NODND |
236 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; | 236 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; |
237 | 237 | ||
238 | setCurrentItem(mOldCurrent); | 238 | setCurrentItem(mOldCurrent); |
239 | setSelected(mOldCurrent,true); | 239 | setSelected(mOldCurrent,true); |
240 | #endif | 240 | #endif |
241 | } | 241 | } |
242 | 242 | ||
243 | void KOTodoListView::contentsDropEvent(QDropEvent *e) | 243 | void KOTodoListView::contentsDropEvent(QDropEvent *e) |
244 | { | 244 | { |
245 | #ifndef KORG_NODND | 245 | #ifndef KORG_NODND |
246 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; | 246 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; |
247 | 247 | ||
248 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 248 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
249 | !QTextDrag::canDecode( e ) ) { | 249 | !QTextDrag::canDecode( e ) ) { |
250 | e->ignore(); | 250 | e->ignore(); |
251 | return; | 251 | return; |
252 | } | 252 | } |
253 | 253 | ||
254 | DndFactory factory( mCalendar ); | 254 | DndFactory factory( mCalendar ); |
255 | Todo *todo = factory.createDropTodo(e); | 255 | Todo *todo = factory.createDropTodo(e); |
256 | 256 | ||
257 | if (todo) { | 257 | if (todo) { |
258 | e->acceptAction(); | 258 | e->acceptAction(); |
259 | 259 | ||
260 | KOTodoViewItem *destination = | 260 | KOTodoViewItem *destination = |
261 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); | 261 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); |
262 | Todo *destinationEvent = 0; | 262 | Todo *destinationEvent = 0; |
263 | if (destination) destinationEvent = destination->todo(); | 263 | if (destination) destinationEvent = destination->todo(); |
264 | 264 | ||
265 | Todo *existingTodo = mCalendar->todo(todo->uid()); | 265 | Todo *existingTodo = mCalendar->todo(todo->uid()); |
266 | 266 | ||
267 | if(existingTodo) { | 267 | if(existingTodo) { |
268 | Incidence *to = destinationEvent; | 268 | Incidence *to = destinationEvent; |
269 | while(to) { | 269 | while(to) { |
270 | if (to->uid() == todo->uid()) { | 270 | if (to->uid() == todo->uid()) { |
271 | KMessageBox::sorry(this, | 271 | KMessageBox::sorry(this, |
272 | i18n("Cannot move Todo to itself\nor a child of itself"), | 272 | i18n("Cannot move Todo to itself\nor a child of itself"), |
273 | i18n("Drop Todo")); | 273 | i18n("Drop Todo")); |
274 | delete todo; | 274 | delete todo; |
275 | return; | 275 | return; |
276 | } | 276 | } |
277 | to = to->relatedTo(); | 277 | to = to->relatedTo(); |
278 | } | 278 | } |
279 | internalDrop = true; | 279 | internalDrop = true; |
280 | if ( destinationEvent ) | 280 | if ( destinationEvent ) |
281 | reparentTodoSignal( destinationEvent, existingTodo ); | 281 | reparentTodoSignal( destinationEvent, existingTodo ); |
282 | else | 282 | else |
283 | unparentTodoSignal(existingTodo); | 283 | unparentTodoSignal(existingTodo); |
284 | delete todo; | 284 | delete todo; |
285 | } else { | 285 | } else { |
286 | mCalendar->addTodo(todo); | 286 | mCalendar->addTodo(todo); |
287 | emit todoDropped(todo, KOGlobals::EVENTADDED); | 287 | emit todoDropped(todo, KOGlobals::EVENTADDED); |
288 | if ( destinationEvent ) | 288 | if ( destinationEvent ) |
289 | reparentTodoSignal( destinationEvent, todo ); | 289 | reparentTodoSignal( destinationEvent, todo ); |
290 | } | 290 | } |
291 | } | 291 | } |
292 | else { | 292 | else { |
293 | QString text; | 293 | QString text; |
294 | if (QTextDrag::decode(e,text)) { | 294 | if (QTextDrag::decode(e,text)) { |
295 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 295 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
296 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 296 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
297 | qDebug("Dropped : " + text); | 297 | qDebug("Dropped : " + text); |
298 | QStringList emails = QStringList::split(",",text); | 298 | QStringList emails = QStringList::split(",",text); |
299 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 299 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
300 | int pos = (*it).find("<"); | 300 | int pos = (*it).find("<"); |
301 | QString name = (*it).left(pos); | 301 | QString name = (*it).left(pos); |
302 | QString email = (*it).mid(pos); | 302 | QString email = (*it).mid(pos); |
303 | if (!email.isEmpty() && todoi) { | 303 | if (!email.isEmpty() && todoi) { |
304 | todoi->todo()->addAttendee(new Attendee(name,email)); | 304 | todoi->todo()->addAttendee(new Attendee(name,email)); |
305 | } | 305 | } |
306 | } | 306 | } |
307 | } | 307 | } |
308 | else { | 308 | else { |
309 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); | 309 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); |
310 | e->ignore(); | 310 | e->ignore(); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | #endif | 313 | #endif |
314 | } | 314 | } |
315 | void KOTodoListView::wheelEvent (QWheelEvent *e) | 315 | void KOTodoListView::wheelEvent (QWheelEvent *e) |
316 | { | 316 | { |
317 | QListView::wheelEvent (e); | 317 | QListView::wheelEvent (e); |
318 | } | 318 | } |
319 | 319 | ||
320 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 320 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
321 | { | 321 | { |
322 | 322 | ||
323 | QPoint p(contentsToViewport(e->pos())); | 323 | QPoint p(contentsToViewport(e->pos())); |
324 | QListViewItem *i = itemAt(p); | 324 | QListViewItem *i = itemAt(p); |
325 | bool rootClicked = true; | 325 | bool rootClicked = true; |
326 | if (i) { | 326 | if (i) { |
327 | // if the user clicked into the root decoration of the item, don't | 327 | // if the user clicked into the root decoration of the item, don't |
328 | // try to start a drag! | 328 | // try to start a drag! |
329 | int X = p.x(); | 329 | int X = p.x(); |
330 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); | 330 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); |
331 | if (X > header()->sectionPos(0) + | 331 | if (X > header()->sectionPos(0) + |
332 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 332 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
333 | itemMargin() +i->height()|| | 333 | itemMargin() +i->height()|| |
334 | X < header()->sectionPos(0)) { | 334 | X < header()->sectionPos(0)) { |
335 | rootClicked = false; | 335 | rootClicked = false; |
336 | } | 336 | } |
337 | } else { | 337 | } else { |
338 | rootClicked = false; | 338 | rootClicked = false; |
339 | } | 339 | } |
340 | #ifndef KORG_NODND | 340 | #ifndef KORG_NODND |
341 | mMousePressed = false; | 341 | mMousePressed = false; |
342 | if (! rootClicked && !( e->button() == RightButton) ) { | 342 | if (! rootClicked && !( e->button() == RightButton) ) { |
343 | mPressPos = e->pos(); | 343 | mPressPos = e->pos(); |
344 | mMousePressed = true; | 344 | mMousePressed = true; |
345 | } else { | 345 | } else { |
346 | mMousePressed = false; | 346 | mMousePressed = false; |
347 | } | 347 | } |
348 | #endif | 348 | #endif |
349 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); | 349 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); |
350 | #ifndef DESKTOP_VERSION | 350 | #ifndef DESKTOP_VERSION |
351 | if (!( e->button() == RightButton && rootClicked) ) | 351 | if (!( e->button() == RightButton && rootClicked) ) |
352 | QListView::contentsMousePressEvent(e); | 352 | QListView::contentsMousePressEvent(e); |
353 | #else | 353 | #else |
354 | QListView::contentsMousePressEvent(e); | 354 | QListView::contentsMousePressEvent(e); |
355 | #endif | 355 | #endif |
356 | } | 356 | } |
357 | void KOTodoListView::paintEvent(QPaintEvent* e) | 357 | void KOTodoListView::paintEvent(QPaintEvent* e) |
358 | { | 358 | { |
359 | emit paintNeeded(); | 359 | emit paintNeeded(); |
360 | QListView::paintEvent( e); | 360 | QListView::paintEvent( e); |
361 | } | 361 | } |
362 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 362 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
363 | { | 363 | { |
364 | 364 | ||
365 | #ifndef KORG_NODND | 365 | #ifndef KORG_NODND |
366 | //QListView::contentsMouseMoveEvent(e); | 366 | //QListView::contentsMouseMoveEvent(e); |
367 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 367 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
368 | QApplication::startDragDistance()*3) { | 368 | QApplication::startDragDistance()*3) { |
369 | mMousePressed = false; | 369 | mMousePressed = false; |
370 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 370 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
371 | if (item) { | 371 | if (item) { |
372 | DndFactory factory( mCalendar ); | 372 | DndFactory factory( mCalendar ); |
373 | ICalDrag *vd = factory.createDrag( | 373 | ICalDrag *vd = factory.createDrag( |
374 | ((KOTodoViewItem *)item)->todo(),viewport()); | 374 | ((KOTodoViewItem *)item)->todo(),viewport()); |
375 | internalDrop = false; | 375 | internalDrop = false; |
376 | // we cannot do any senseful here, because the DnD is still broken in Qt | 376 | // we cannot do any senseful here, because the DnD is still broken in Qt |
377 | if (vd->drag()) { | 377 | if (vd->drag()) { |
378 | if ( !internalDrop ) { | 378 | if ( !internalDrop ) { |
379 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | 379 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); |
380 | qDebug("Dnd: External move: Delete drag source "); | 380 | qDebug("Dnd: External move: Delete drag source "); |
381 | } else | 381 | } else |
382 | qDebug("Dnd: Internal move "); | 382 | qDebug("Dnd: Internal move "); |
383 | 383 | ||
384 | } else { | 384 | } else { |
385 | if ( !internalDrop ) { | 385 | if ( !internalDrop ) { |
386 | qDebug("Dnd: External Copy"); | 386 | qDebug("Dnd: External Copy"); |
387 | } else | 387 | } else |
388 | qDebug("DnD: Internal copy: Copy pending"); | 388 | qDebug("DnD: Internal copy: Copy pending"); |
389 | } | 389 | } |
390 | } | 390 | } |
391 | } | 391 | } |
392 | #endif | 392 | #endif |
393 | } | 393 | } |
394 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) | 394 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) |
395 | { | 395 | { |
396 | if ( !e->isAutoRepeat() ) { | 396 | if ( !e->isAutoRepeat() ) { |
397 | mFlagKeyPressed = false; | 397 | mFlagKeyPressed = false; |
398 | } | 398 | } |
399 | } | 399 | } |
400 | 400 | ||
401 | 401 | ||
402 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 402 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
403 | { | 403 | { |
404 | qApp->processEvents(); | 404 | qApp->processEvents(); |
405 | if ( !isVisible() ) { | 405 | if ( !isVisible() ) { |
406 | e->ignore(); | 406 | e->ignore(); |
407 | return; | 407 | return; |
408 | } | 408 | } |
409 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 409 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
410 | e->ignore(); | 410 | e->ignore(); |
411 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 411 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
412 | return; | 412 | return; |
413 | } | 413 | } |
414 | if (! e->isAutoRepeat() ) | 414 | if (! e->isAutoRepeat() ) |
415 | mFlagKeyPressed = true; | 415 | mFlagKeyPressed = true; |
416 | QListViewItem* cn; | 416 | QListViewItem* cn; |
417 | if ( (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) && mName != "todolistsmall") { | 417 | if ( (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) && mName != "todolistsmall") { |
418 | cn = currentItem(); | 418 | cn = currentItem(); |
419 | if ( cn ) { | 419 | if ( cn ) { |
420 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 420 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
421 | if ( ci ){ | 421 | if ( ci ){ |
422 | if ( e->state() == ShiftButton ) | 422 | if ( e->state() == ShiftButton ) |
423 | ci->setOn( false ); | 423 | ci->setOn( false ); |
424 | else | 424 | else |
425 | ci->setOn( true ); | 425 | ci->setOn( true ); |
426 | cn = cn->itemBelow(); | 426 | cn = cn->itemBelow(); |
427 | if ( cn ) { | 427 | if ( cn ) { |
428 | setCurrentItem ( cn ); | 428 | setCurrentItem ( cn ); |
429 | ensureItemVisible ( cn ); | 429 | ensureItemVisible ( cn ); |
430 | } | 430 | } |
431 | 431 | ||
432 | } | 432 | } |
433 | } | 433 | } |
434 | 434 | ||
435 | e->accept(); | 435 | e->accept(); |
436 | return; | 436 | return; |
437 | } | 437 | } |
438 | 438 | ||
439 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 439 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
440 | switch ( e->key() ) { | 440 | switch ( e->key() ) { |
441 | case Qt::Key_Down: | 441 | case Qt::Key_Down: |
442 | case Qt::Key_Up: | 442 | case Qt::Key_Up: |
443 | QListView::keyPressEvent ( e ); | 443 | QListView::keyPressEvent ( e ); |
444 | e->accept(); | 444 | e->accept(); |
445 | break; | 445 | break; |
446 | case Qt::Key_Left: | 446 | case Qt::Key_Left: |
447 | case Qt::Key_Right: | 447 | case Qt::Key_Right: |
448 | QListView::keyPressEvent ( e ); | 448 | QListView::keyPressEvent ( e ); |
449 | e->accept(); | 449 | e->accept(); |
450 | return; | 450 | return; |
451 | break; | 451 | break; |
452 | default: | 452 | default: |
453 | e->ignore(); | 453 | e->ignore(); |
454 | break; | 454 | break; |
455 | } | 455 | } |
456 | return; | 456 | return; |
457 | } | 457 | } |
458 | e->ignore(); | 458 | e->ignore(); |
459 | } | 459 | } |
460 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 460 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
461 | { | 461 | { |
462 | QListView::contentsMouseReleaseEvent(e); | 462 | QListView::contentsMouseReleaseEvent(e); |
463 | mMousePressed = false; | 463 | mMousePressed = false; |
464 | } | 464 | } |
465 | 465 | ||
466 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 466 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
467 | { | 467 | { |
468 | if (!e) return; | 468 | if (!e) return; |
469 | 469 | ||
470 | QPoint vp = contentsToViewport(e->pos()); | 470 | QPoint vp = contentsToViewport(e->pos()); |
471 | 471 | ||
472 | QListViewItem *item = itemAt(vp); | 472 | QListViewItem *item = itemAt(vp); |
473 | 473 | ||
474 | emit double_Clicked(item); | 474 | emit double_Clicked(item); |
475 | if (!item) return; | 475 | if (!item) return; |
476 | 476 | ||
477 | emit doubleClicked(item,vp,0); | 477 | emit doubleClicked(item,vp,0); |
478 | } | 478 | } |
479 | 479 | ||
480 | ///////////////////////////////////////////////////////////////////////////// | 480 | ///////////////////////////////////////////////////////////////////////////// |
481 | 481 | ||
482 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 482 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
483 | QLineEdit(parent) | 483 | QLineEdit(parent) |
484 | { | 484 | { |
485 | setText(i18n("Click to add new Todo")); | 485 | setText(i18n("Click to add new Todo")); |
486 | setFocusPolicy ( QWidget::ClickFocus ); | 486 | setFocusPolicy ( QWidget::ClickFocus ); |
487 | } | 487 | } |
488 | 488 | ||
489 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 489 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
490 | { | 490 | { |
491 | if ( text()==i18n("Click to add new Todo") ) | 491 | if ( text()==i18n("Click to add new Todo") ) |
492 | setText(""); | 492 | setText(""); |
493 | QLineEdit::focusInEvent(ev); | 493 | QLineEdit::focusInEvent(ev); |
494 | } | 494 | } |
495 | 495 | ||
496 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 496 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
497 | { | 497 | { |
498 | setText(i18n("Click to add new Todo")); | 498 | setText(i18n("Click to add new Todo")); |
499 | QLineEdit::focusOutEvent(ev); | 499 | QLineEdit::focusOutEvent(ev); |
500 | } | 500 | } |
501 | 501 | ||
502 | ///////////////////////////////////////////////////////////////////////////// | 502 | ///////////////////////////////////////////////////////////////////////////// |
503 | 503 | ||
504 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 504 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
505 | KOrg::BaseView(calendar,parent,name) | 505 | KOrg::BaseView(calendar,parent,name) |
506 | { | 506 | { |
507 | |||
508 | mCurItem = 0; | ||
509 | mCurItemRootParent = 0; | ||
510 | mCurItemParent = 0; | ||
511 | mCurItemAbove = 0; | ||
507 | mActiveItem = 0; | 512 | mActiveItem = 0; |
508 | mCategoryPopupMenu = 0; | 513 | mCategoryPopupMenu = 0; |
509 | mPendingUpdateBeforeRepaint = false; | 514 | mPendingUpdateBeforeRepaint = false; |
510 | isFlatDisplay = false; | 515 | isFlatDisplay = false; |
511 | mNavigator = 0; | 516 | mNavigator = 0; |
512 | QBoxLayout *topLayout = new QVBoxLayout(this); | 517 | QBoxLayout *topLayout = new QVBoxLayout(this); |
513 | mName = QString ( name ); | 518 | mName = QString ( name ); |
514 | mBlockUpdate = false; | 519 | mBlockUpdate = false; |
515 | mQuickBar = new QWidget( this ); | 520 | mQuickBar = new QWidget( this ); |
516 | topLayout->addWidget(mQuickBar); | 521 | topLayout->addWidget(mQuickBar); |
517 | 522 | ||
518 | mQuickAdd = new KOQuickTodo(mQuickBar); | 523 | mQuickAdd = new KOQuickTodo(mQuickBar); |
519 | QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); | 524 | QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); |
520 | quickLayout->addWidget( mQuickAdd ); | 525 | quickLayout->addWidget( mQuickAdd ); |
521 | mNewSubBut = new QPushButton( "sub",mQuickBar ); | 526 | mNewSubBut = new QPushButton( "sub",mQuickBar ); |
522 | QPushButton * s_done = new QPushButton( "D",mQuickBar ); | 527 | QPushButton * s_done = new QPushButton( "D",mQuickBar ); |
523 | QPushButton * s_run = new QPushButton( "R",mQuickBar ); | 528 | QPushButton * s_run = new QPushButton( "R",mQuickBar ); |
524 | QPushButton * allopen = new QPushButton( "O",mQuickBar ); | 529 | QPushButton * allopen = new QPushButton( "O",mQuickBar ); |
525 | QPushButton * allclose = new QPushButton( "C",mQuickBar ); | 530 | QPushButton * allclose = new QPushButton( "C",mQuickBar ); |
526 | QPushButton * flat = new QPushButton( "F",mQuickBar ); | 531 | QPushButton * flat = new QPushButton( "F",mQuickBar ); |
527 | 532 | ||
528 | int fixwid = mQuickAdd->sizeHint().height(); | 533 | int fixwid = mQuickAdd->sizeHint().height(); |
529 | int fixhei = fixwid; | 534 | int fixhei = fixwid; |
530 | if ( QApplication::desktop()->width() > 800 ) | 535 | if ( QApplication::desktop()->width() > 800 ) |
531 | fixwid = (fixwid*3)/2; | 536 | fixwid = (fixwid*3)/2; |
532 | connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); | 537 | connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); |
533 | connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); | 538 | connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); |
534 | connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); | 539 | connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); |
535 | s_done->setPixmap( SmallIcon("greenhook16")); | 540 | s_done->setPixmap( SmallIcon("greenhook16")); |
536 | connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); | 541 | connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); |
537 | s_run->setPixmap( SmallIcon("ko16old")); | 542 | s_run->setPixmap( SmallIcon("ko16old")); |
538 | connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); | 543 | connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); |
539 | 544 | ||
540 | connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); | 545 | connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); |
541 | 546 | ||
542 | mNewSubBut->setFixedWidth(mNewSubBut->sizeHint().width() ); | 547 | mNewSubBut->setFixedWidth(mNewSubBut->sizeHint().width() ); |
543 | mNewSubBut->setEnabled( false ); | 548 | mNewSubBut->setEnabled( false ); |
544 | flat->setFixedWidth( fixwid ); | 549 | flat->setFixedWidth( fixwid ); |
545 | s_done->setFixedWidth( fixwid ); | 550 | s_done->setFixedWidth( fixwid ); |
546 | allopen->setFixedWidth( fixwid ); | 551 | allopen->setFixedWidth( fixwid ); |
547 | allclose->setFixedWidth( fixwid ); | 552 | allclose->setFixedWidth( fixwid ); |
548 | s_run->setFixedWidth( fixwid ); | 553 | s_run->setFixedWidth( fixwid ); |
549 | 554 | ||
550 | flat->setFixedHeight(fixhei ); | 555 | flat->setFixedHeight(fixhei ); |
551 | s_done->setFixedHeight(fixhei ); | 556 | s_done->setFixedHeight(fixhei ); |
552 | allopen->setFixedHeight(fixhei ); | 557 | allopen->setFixedHeight(fixhei ); |
553 | allclose->setFixedHeight(fixhei ); | 558 | allclose->setFixedHeight(fixhei ); |
554 | s_run->setFixedHeight(fixhei ); | 559 | s_run->setFixedHeight(fixhei ); |
555 | mNewSubBut->setFixedHeight(fixhei ); | 560 | mNewSubBut->setFixedHeight(fixhei ); |
556 | 561 | ||
557 | flat->setFocusPolicy( NoFocus ); | 562 | flat->setFocusPolicy( NoFocus ); |
558 | s_done->setFocusPolicy( NoFocus ); | 563 | s_done->setFocusPolicy( NoFocus ); |
559 | allopen->setFocusPolicy( NoFocus ); | 564 | allopen->setFocusPolicy( NoFocus ); |
560 | allclose->setFocusPolicy( NoFocus ); | 565 | allclose->setFocusPolicy( NoFocus ); |
561 | s_run->setFocusPolicy( NoFocus ); | 566 | s_run->setFocusPolicy( NoFocus ); |
562 | mNewSubBut->setFocusPolicy( NoFocus ); | 567 | mNewSubBut->setFocusPolicy( NoFocus ); |
563 | 568 | ||
564 | QWhatsThis::add( flat, i18n("Click this button to display all todos in a <b>flat</b> hierarchy" ) ); | 569 | QWhatsThis::add( flat, i18n("Click this button to display all todos in a <b>flat</b> hierarchy" ) ); |
565 | QWhatsThis::add( allopen, i18n("Click this button to display all todos <b>openend</b>" ) ); | 570 | QWhatsThis::add( allopen, i18n("Click this button to display all todos <b>openend</b>" ) ); |
566 | QWhatsThis::add( allclose, i18n("Click this button to display all todos <b>closed</b>" ) ); | 571 | QWhatsThis::add( allclose, i18n("Click this button to display all todos <b>closed</b>" ) ); |
567 | QWhatsThis::add( s_run, i18n("Click this button to toggle show/hide <b>running</b> todos" ) ); | 572 | QWhatsThis::add( s_run, i18n("Click this button to toggle show/hide <b>running</b> todos" ) ); |
568 | QWhatsThis::add( mNewSubBut, i18n("Click this button to add a new subtodo to the currently selected todo" ) ); | 573 | QWhatsThis::add( mNewSubBut, i18n("Click this button to add a new subtodo to the currently selected todo" ) ); |
569 | QWhatsThis::add( s_done, i18n("Click this button to toggle show/hide <b>completed</b> todos" ) ); | 574 | QWhatsThis::add( s_done, i18n("Click this button to toggle show/hide <b>completed</b> todos" ) ); |
570 | 575 | ||
571 | quickLayout->addWidget( mNewSubBut ); | 576 | quickLayout->addWidget( mNewSubBut ); |
572 | quickLayout->addWidget( s_done ); | 577 | quickLayout->addWidget( s_done ); |
573 | quickLayout->addWidget( s_run ); | 578 | quickLayout->addWidget( s_run ); |
574 | quickLayout->addWidget( allopen ); | 579 | quickLayout->addWidget( allopen ); |
575 | quickLayout->addWidget( allclose ); | 580 | quickLayout->addWidget( allclose ); |
576 | quickLayout->addWidget( flat ); | 581 | quickLayout->addWidget( flat ); |
577 | 582 | ||
578 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide(); | 583 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide(); |
579 | 584 | ||
580 | mTodoListView = new KOTodoListView(calendar,this, name ); | 585 | mTodoListView = new KOTodoListView(calendar,this, name ); |
581 | topLayout->addWidget(mTodoListView); | 586 | topLayout->addWidget(mTodoListView); |
582 | //mTodoListView->header()->setMaximumHeight(30); | 587 | //mTodoListView->header()->setMaximumHeight(30); |
583 | mTodoListView->setRootIsDecorated(true); | 588 | mTodoListView->setRootIsDecorated(true); |
584 | mTodoListView->setAllColumnsShowFocus(true); | 589 | mTodoListView->setAllColumnsShowFocus(true); |
585 | 590 | ||
586 | mTodoListView->setShowSortIndicator(true); | 591 | mTodoListView->setShowSortIndicator(true); |
587 | 592 | ||
588 | mTodoListView->addColumn(i18n("Todo")); | 593 | mTodoListView->addColumn(i18n("Todo")); |
589 | mTodoListView->addColumn(i18n("Prio")); | 594 | mTodoListView->addColumn(i18n("Prio")); |
590 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 595 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
591 | mTodoListView->addColumn(i18n("Complete")); | 596 | mTodoListView->addColumn(i18n("Complete")); |
592 | mTodoListView->setColumnAlignment(2,AlignCenter); | 597 | mTodoListView->setColumnAlignment(2,AlignCenter); |
593 | 598 | ||
594 | mTodoListView->addColumn(i18n("Due Date")); | 599 | mTodoListView->addColumn(i18n("Due Date")); |
595 | mTodoListView->setColumnAlignment(3,AlignLeft); | 600 | mTodoListView->setColumnAlignment(3,AlignLeft); |
596 | mTodoListView->addColumn(i18n("Due Time")); | 601 | mTodoListView->addColumn(i18n("Due Time")); |
597 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 602 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
598 | 603 | ||
599 | mTodoListView->addColumn(i18n("Start Date")); | 604 | mTodoListView->addColumn(i18n("Start Date")); |
600 | mTodoListView->setColumnAlignment(5,AlignLeft); | 605 | mTodoListView->setColumnAlignment(5,AlignLeft); |
601 | mTodoListView->addColumn(i18n("Start Time")); | 606 | mTodoListView->addColumn(i18n("Start Time")); |
602 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 607 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
603 | 608 | ||
604 | //mTodoListView->addColumn(i18n("Cancelled")); | 609 | //mTodoListView->addColumn(i18n("Cancelled")); |
605 | mTodoListView->addColumn(i18n("Categories")); | 610 | mTodoListView->addColumn(i18n("Categories")); |
606 | mTodoListView->addColumn(i18n("Calendar")); | 611 | mTodoListView->addColumn(i18n("Calendar")); |
607 | mTodoListView->addColumn(i18n("Last Modified")); | 612 | mTodoListView->addColumn(i18n("Last Modified")); |
608 | mTodoListView->addColumn(i18n("Created")); | 613 | mTodoListView->addColumn(i18n("Created")); |
609 | mTodoListView->addColumn(i18n("Last Modified Sub")); | 614 | mTodoListView->addColumn(i18n("Last Modified Sub")); |
610 | #if 0 | 615 | #if 0 |
611 | mTodoListView->addColumn(i18n("Sort Id")); | 616 | mTodoListView->addColumn(i18n("Sort Id")); |
612 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 617 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
613 | #endif | 618 | #endif |
614 | 619 | ||
615 | mTodoListView->setMinimumHeight( 60 ); | 620 | mTodoListView->setMinimumHeight( 60 ); |
616 | mTodoListView->setItemsRenameable( true ); | 621 | mTodoListView->setItemsRenameable( true ); |
617 | mTodoListView->setRenameable( 0 ); | 622 | mTodoListView->setRenameable( 0 ); |
618 | mTodoListView->setColumnWidth( 0, 120 ); | 623 | mTodoListView->setColumnWidth( 0, 120 ); |
619 | int iii = 0; | 624 | int iii = 0; |
620 | for ( iii = 0; iii< 12 ; ++iii ) | 625 | for ( iii = 0; iii< 12 ; ++iii ) |
621 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); | 626 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); |
622 | 627 | ||
623 | 628 | ||
624 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); | 629 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); |
625 | 630 | ||
626 | mPriorityPopupMenu = new QPopupMenu(this); | 631 | mPriorityPopupMenu = new QPopupMenu(this); |
627 | for (int i = 1; i <= 5; i++) { | 632 | for (int i = 1; i <= 5; i++) { |
628 | QString label = QString ("%1").arg (i); | 633 | QString label = QString ("%1").arg (i); |
629 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 634 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
630 | } | 635 | } |
631 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 636 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
632 | 637 | ||
633 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 638 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
634 | for (int i = 0; i <= 100; i+=20) { | 639 | for (int i = 0; i <= 100; i+=20) { |
635 | QString label = QString ("%1 %").arg (i); | 640 | QString label = QString ("%1 %").arg (i); |
636 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 641 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
637 | } | 642 | } |
638 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 643 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
639 | 644 | ||
640 | 645 | ||
641 | mCategoryPopupMenu = new QPopupMenu (this); | 646 | mCategoryPopupMenu = new QPopupMenu (this); |
642 | mCategoryPopupMenu->setCheckable (true); | 647 | mCategoryPopupMenu->setCheckable (true); |
643 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 648 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
644 | connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); | 649 | connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); |
645 | 650 | ||
646 | mCalPopupMenu = new QPopupMenu (this); | 651 | mCalPopupMenu = new QPopupMenu (this); |
647 | mCalPopupMenu->setCheckable (true); | 652 | mCalPopupMenu->setCheckable (true); |
648 | connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); | 653 | connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); |
649 | connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); | 654 | connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); |
650 | 655 | ||
651 | 656 | ||
652 | 657 | ||
653 | 658 | ||
654 | mItemPopupMenu = new QPopupMenu(this); | 659 | mItemPopupMenu = new QPopupMenu(this); |
655 | mItemPopupMenu->insertItem(i18n("Show"), this, | 660 | mItemPopupMenu->insertItem(i18n("Show"), this, |
656 | SLOT (showTodo())); | 661 | SLOT (showTodo())); |
657 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 662 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
658 | SLOT (editTodo())); | 663 | SLOT (editTodo())); |
659 | mItemPopupMenu->insertItem( i18n("Delete..."), this, | 664 | mItemPopupMenu->insertItem( i18n("Delete..."), this, |
660 | SLOT (deleteTodo())); | 665 | SLOT (deleteTodo())); |
661 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 666 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
662 | SLOT (cloneTodo())); | 667 | SLOT (cloneTodo())); |
663 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 668 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
664 | SLOT (moveTodo())); | 669 | SLOT (moveTodo())); |
665 | #ifndef DESKTOP_VERSION | 670 | #ifndef DESKTOP_VERSION |
666 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 671 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
667 | SLOT (beamTodo())); | 672 | SLOT (beamTodo())); |
668 | #endif | 673 | #endif |
669 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 674 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
670 | SLOT (cancelTodo())); | 675 | SLOT (cancelTodo())); |
671 | mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); | 676 | mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); |
672 | mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); | 677 | mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); |
673 | mItemPopupMenu->insertSeparator(); | 678 | mItemPopupMenu->insertSeparator(); |
674 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, | 679 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, |
675 | SLOT (toggleRunningItem())); | 680 | SLOT (toggleRunningItem())); |
676 | mItemPopupMenu->insertSeparator(); | 681 | mItemPopupMenu->insertSeparator(); |
677 | /* | 682 | /* |
678 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 683 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
679 | SLOT (newTodo())); | 684 | SLOT (newTodo())); |
680 | */ | 685 | */ |
681 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 686 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
682 | SLOT (newSubTodo())); | 687 | SLOT (newSubTodo())); |
683 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 688 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
684 | SLOT (unparentTodo()),0,21); | 689 | SLOT (unparentTodo()),0,21); |
685 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 690 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
686 | SLOT (reparentTodo()),0,22); | 691 | SLOT (reparentTodo()),0,22); |
687 | mItemPopupMenu->insertSeparator(); | 692 | mItemPopupMenu->insertSeparator(); |
688 | #if 0 | 693 | #if 0 |
689 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), | 694 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), |
690 | this, SLOT( purgeCompleted() ) ); | 695 | this, SLOT( purgeCompleted() ) ); |
691 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 696 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
692 | this, SLOT( toggleCompleted() ),0, 33 ); | 697 | this, SLOT( toggleCompleted() ),0, 33 ); |
693 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 698 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
694 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 699 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
695 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 700 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
696 | this, SLOT( toggleRunning() ),0, 35 ); | 701 | this, SLOT( toggleRunning() ),0, 35 ); |
697 | 702 | ||
698 | #endif | 703 | #endif |
699 | mPopupMenu = new QPopupMenu(this); | 704 | mPopupMenu = new QPopupMenu(this); |
700 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 705 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
701 | SLOT (newTodo()),0,1); | 706 | SLOT (newTodo()),0,1); |
702 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), | 707 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), |
703 | this, SLOT(purgeCompleted()),0,2); | 708 | this, SLOT(purgeCompleted()),0,2); |
704 | mPopupMenu->insertItem(i18n("Show Completed"), | 709 | mPopupMenu->insertItem(i18n("Show Completed"), |
705 | this, SLOT( toggleCompleted() ),0,3 ); | 710 | this, SLOT( toggleCompleted() ),0,3 ); |
706 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 711 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
707 | this, SLOT( toggleRunning() ),0,5 ); | 712 | this, SLOT( toggleRunning() ),0,5 ); |
708 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 713 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
709 | this, SLOT( setAllOpen() ),0,6 ); | 714 | this, SLOT( setAllOpen() ),0,6 ); |
710 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 715 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
711 | this, SLOT( setAllClose() ),0,7 ); | 716 | this, SLOT( setAllClose() ),0,7 ); |
712 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 717 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
713 | this, SLOT( setAllFlat() ),0,8 ); | 718 | this, SLOT( setAllFlat() ),0,8 ); |
714 | mPopupMenu->insertSeparator(); | 719 | mPopupMenu->insertSeparator(); |
715 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 720 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
716 | this, SLOT( toggleQuickTodo() ),0,4 ); | 721 | this, SLOT( toggleQuickTodo() ),0,4 ); |
717 | mDocPrefs = new DocPrefs( name ); | 722 | mDocPrefs = new DocPrefs( name ); |
718 | 723 | ||
719 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 724 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
720 | mPopupMenu->setCheckable( true ); | 725 | mPopupMenu->setCheckable( true ); |
721 | mItemPopupMenu->setCheckable( true ); | 726 | mItemPopupMenu->setCheckable( true ); |
722 | 727 | ||
723 | 728 | ||
724 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 729 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
725 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 730 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
726 | 731 | ||
727 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 732 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
728 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 733 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
729 | 734 | ||
730 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 735 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
731 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 736 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
732 | 737 | ||
733 | 738 | ||
734 | // Double clicking conflicts with opening/closing the subtree | 739 | // Double clicking conflicts with opening/closing the subtree |
735 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 740 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
736 | SLOT( editItem( QListViewItem *) ) ); | 741 | SLOT( editItem( QListViewItem *) ) ); |
737 | /* | 742 | /* |
738 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 743 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
739 | const QPoint &,int ) ), | 744 | const QPoint &,int ) ), |
740 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 745 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
741 | */ | 746 | */ |
742 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 747 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
743 | const QPoint &,int ) ), | 748 | const QPoint &,int ) ), |
744 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 749 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
745 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 750 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
746 | SLOT( itemClicked( QListViewItem * ) ) ); | 751 | SLOT( itemClicked( QListViewItem * ) ) ); |
747 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 752 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
748 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 753 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
749 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 754 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
750 | SLOT( updateView() ) ); | 755 | SLOT( updateView() ) ); |
751 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 756 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
752 | SLOT( todoModified(Todo *, int) ) ); | 757 | SLOT( todoModified(Todo *, int) ) ); |
753 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 758 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
754 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 759 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
755 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 760 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
756 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 761 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
757 | connect( mTodoListView, SIGNAL( paintNeeded() ), | 762 | connect( mTodoListView, SIGNAL( paintNeeded() ), |
758 | SLOT( paintNeeded()) ); | 763 | SLOT( paintNeeded()) ); |
759 | 764 | ||
760 | #if 0 | 765 | #if 0 |
761 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 766 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
762 | SLOT(selectionChanged(QListViewItem *))); | 767 | SLOT(selectionChanged(QListViewItem *))); |
763 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 768 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
764 | SLOT(selectionChanged(QListViewItem *))); | 769 | SLOT(selectionChanged(QListViewItem *))); |
765 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 770 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
766 | SLOT(selectionChanged(QListViewItem *))); | 771 | SLOT(selectionChanged(QListViewItem *))); |
767 | #endif | 772 | #endif |
768 | 773 | ||
769 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | 774 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); |
770 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | 775 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); |
771 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | 776 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); |
772 | 777 | ||
773 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 778 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
774 | SLOT( processSelectionChange() ) ); | 779 | SLOT( processSelectionChange() ) ); |
775 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 780 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
776 | SLOT( addQuickTodo() ) ); | 781 | SLOT( addQuickTodo() ) ); |
777 | 782 | ||
778 | } | 783 | } |
779 | 784 | ||
780 | KOTodoView::~KOTodoView() | 785 | KOTodoView::~KOTodoView() |
781 | { | 786 | { |
782 | 787 | ||
783 | #if QT_VERSION >= 0x030000 | 788 | #if QT_VERSION >= 0x030000 |
784 | 789 | ||
785 | #else | 790 | #else |
786 | delete mKOTodoViewWhatsThis; | 791 | delete mKOTodoViewWhatsThis; |
787 | #endif | 792 | #endif |
788 | 793 | ||
789 | delete mDocPrefs; | 794 | delete mDocPrefs; |
790 | } | 795 | } |
791 | QString KOTodoView::getWhatsThisText(QPoint p) | 796 | QString KOTodoView::getWhatsThisText(QPoint p) |
792 | { | 797 | { |
793 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); | 798 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); |
794 | if ( item ) | 799 | if ( item ) |
795 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), | 800 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), |
796 | KOPrefs::instance()->mWTshowDetails, | 801 | KOPrefs::instance()->mWTshowDetails, |
797 | KOPrefs::instance()->mWTshowCreated, | 802 | KOPrefs::instance()->mWTshowCreated, |
798 | KOPrefs::instance()->mWTshowChanged); | 803 | KOPrefs::instance()->mWTshowChanged); |
799 | return i18n("That is the todo view" ); | 804 | return i18n("That is the todo view" ); |
800 | 805 | ||
801 | } | 806 | } |
802 | 807 | ||
803 | void KOTodoView::jumpToDate () | 808 | void KOTodoView::jumpToDate () |
804 | { | 809 | { |
805 | // if (mActiveItem) { | 810 | // if (mActiveItem) { |
806 | // mActiveItem->todo()); | 811 | // mActiveItem->todo()); |
807 | // if ( mActiveItem->todo()->hasDueDate() ) | 812 | // if ( mActiveItem->todo()->hasDueDate() ) |
808 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 813 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
809 | } | 814 | } |
810 | void KOTodoView::paintNeeded() | 815 | void KOTodoView::paintNeeded() |
811 | { | 816 | { |
812 | if ( mPendingUpdateBeforeRepaint ) { | 817 | if ( mPendingUpdateBeforeRepaint ) { |
813 | updateView(); | 818 | updateView(); |
814 | mPendingUpdateBeforeRepaint = false; | 819 | mPendingUpdateBeforeRepaint = false; |
815 | } | 820 | } |
816 | } | 821 | } |
817 | void KOTodoView::paintEvent(QPaintEvent * pevent) | 822 | void KOTodoView::paintEvent(QPaintEvent * pevent) |
818 | { | 823 | { |
819 | if ( mPendingUpdateBeforeRepaint ) { | 824 | if ( mPendingUpdateBeforeRepaint ) { |
820 | updateView(); | 825 | updateView(); |
821 | mPendingUpdateBeforeRepaint = false; | 826 | mPendingUpdateBeforeRepaint = false; |
822 | } | 827 | } |
823 | KOrg::BaseView::paintEvent( pevent); | 828 | KOrg::BaseView::paintEvent( pevent); |
824 | } | 829 | } |
825 | 830 | ||
826 | void KOTodoView::clearList( bool saveCurrentItem ) // default true | 831 | void KOTodoView::clearList( bool saveCurrentItem ) // default true |
827 | { | 832 | { |
828 | if ( mTodoListView->childCount() ) { | 833 | if ( mTodoListView->childCount() ) { |
829 | if ( saveCurrentItem ) | 834 | if ( saveCurrentItem ) |
830 | storeCurrentItem(); | 835 | storeCurrentItem(); |
831 | mTodoListView->clear(); | 836 | mTodoListView->clear(); |
832 | mTodoMap.clear(); | 837 | mTodoMap.clear(); |
833 | } | 838 | } |
834 | } | 839 | } |
835 | void KOTodoView::updateView() | 840 | void KOTodoView::updateView() |
836 | { | 841 | { |
837 | mActiveItem = 0; | 842 | mActiveItem = 0; |
838 | pendingSubtodo = 0; | 843 | pendingSubtodo = 0; |
839 | if ( mBlockUpdate ) { | 844 | if ( mBlockUpdate ) { |
840 | return; | 845 | return; |
841 | } | 846 | } |
842 | if ( !isVisible() ) { | 847 | if ( !isVisible() ) { |
843 | clearList (); | 848 | clearList (); |
844 | mPendingUpdateBeforeRepaint = true; | 849 | mPendingUpdateBeforeRepaint = true; |
845 | return; | 850 | return; |
846 | } | 851 | } |
847 | //qDebug("KOTodoView::updateView() %x", this); | 852 | //qDebug("KOTodoView::updateView() %x", this); |
848 | if ( isFlatDisplay ) { | 853 | if ( isFlatDisplay ) { |
849 | displayAllFlat(); | 854 | displayAllFlat(); |
850 | return; | 855 | return; |
851 | } | 856 | } |
852 | //qDebug("update "); | 857 | //qDebug("update "); |
853 | // kdDebug() << "KOTodoView::updateView()" << endl; | 858 | // kdDebug() << "KOTodoView::updateView()" << endl; |
854 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 859 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
855 | 860 | ||
856 | clearList (); | 861 | clearList (); |
857 | 862 | ||
858 | if ( mName == "todolistsmall" ) { | 863 | if ( mName == "todolistsmall" ) { |
859 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 864 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
860 | int ps = fo.pointSize() -2; | 865 | int ps = fo.pointSize() -2; |
861 | if ( ps > 12 ) | 866 | if ( ps > 12 ) |
862 | ps -= 2; | 867 | ps -= 2; |
863 | fo.setPointSize( ps ); | 868 | fo.setPointSize( ps ); |
864 | } | 869 | } |
865 | } | 870 | } |
866 | 871 | ||
867 | mTodoListView->setFont( fo ); | 872 | mTodoListView->setFont( fo ); |
868 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 873 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
869 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 874 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
870 | QPtrList<Todo> todoList = calendar()->todos(); | 875 | QPtrList<Todo> todoList = calendar()->todos(); |
871 | 876 | ||
872 | /* | 877 | /* |
873 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 878 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
874 | Event *t; | 879 | Event *t; |
875 | for(t = todoList.first(); t; t = todoList.next()) { | 880 | for(t = todoList.first(); t; t = todoList.next()) { |
876 | kdDebug() << " " << t->getSummary() << endl; | 881 | kdDebug() << " " << t->getSummary() << endl; |
877 | 882 | ||
878 | if (t->getRelatedTo()) { | 883 | if (t->getRelatedTo()) { |
879 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 884 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
880 | } | 885 | } |
881 | 886 | ||
882 | QPtrList<Event> l = t->getRelations(); | 887 | QPtrList<Event> l = t->getRelations(); |
883 | Event *c; | 888 | Event *c; |
884 | for(c=l.first();c;c=l.next()) { | 889 | for(c=l.first();c;c=l.next()) { |
885 | kdDebug() << " - relation: " << c->getSummary() << endl; | 890 | kdDebug() << " - relation: " << c->getSummary() << endl; |
886 | } | 891 | } |
887 | } | 892 | } |
888 | */ | 893 | */ |
889 | 894 | ||
890 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 895 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
891 | // specific order of events. That means that we have to generate parent items | 896 | // specific order of events. That means that we have to generate parent items |
892 | // recursively for proper hierarchical display of Todos. | 897 | // recursively for proper hierarchical display of Todos. |
893 | Todo *todo; | 898 | Todo *todo; |
894 | todo = todoList.first();// todo; todo = todoList.next()) { | 899 | todo = todoList.first();// todo; todo = todoList.next()) { |
895 | while ( todo ) { | 900 | while ( todo ) { |
896 | bool next = true; | 901 | bool next = true; |
897 | // qDebug("todo %s ", todo->summary().latin1()); | 902 | // qDebug("todo %s ", todo->summary().latin1()); |
898 | Incidence *incidence = todo->relatedTo(); | 903 | Incidence *incidence = todo->relatedTo(); |
899 | while ( incidence ) { | 904 | while ( incidence ) { |
900 | if ( incidence->typeID() == todoID ) { | 905 | if ( incidence->typeID() == todoID ) { |
901 | //qDebug("related %s ",incidence->summary().latin1() ); | 906 | //qDebug("related %s ",incidence->summary().latin1() ); |
902 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { | 907 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { |
903 | //qDebug("related not found "); | 908 | //qDebug("related not found "); |
904 | todoList.remove( ); | 909 | todoList.remove( ); |
905 | todo = todoList.current(); | 910 | todo = todoList.current(); |
906 | next = false; | 911 | next = false; |
907 | incidence = 0; | 912 | incidence = 0; |
908 | 913 | ||
909 | } else { | 914 | } else { |
910 | //qDebug("related found "); | 915 | //qDebug("related found "); |
911 | incidence = incidence->relatedTo(); | 916 | incidence = incidence->relatedTo(); |
912 | } | 917 | } |
913 | } else | 918 | } else |
914 | incidence = 0; | 919 | incidence = 0; |
915 | } | 920 | } |
916 | if ( next ) | 921 | if ( next ) |
917 | todo = todoList.next(); | 922 | todo = todoList.next(); |
918 | } | 923 | } |
919 | 924 | ||
920 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 925 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
921 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 926 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
922 | { | 927 | { |
923 | insertTodoItem(todo); | 928 | insertTodoItem(todo); |
924 | } | 929 | } |
925 | } | 930 | } |
926 | // Restore opened/closed state | 931 | // Restore opened/closed state |
927 | mTodoListView->blockSignals( true ); | 932 | mTodoListView->blockSignals( true ); |
928 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 933 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
929 | mTodoListView->blockSignals( false ); | 934 | mTodoListView->blockSignals( false ); |
930 | resetCurrentItem(); | 935 | resetCurrentItem(); |
931 | } | 936 | } |
932 | 937 | ||
933 | void KOTodoView::storeCurrentItem() | 938 | void KOTodoView::storeCurrentItem() |
934 | { | 939 | { |
935 | mCurItem = 0; | 940 | mCurItem = 0; |
936 | mCurItemRootParent = 0; | 941 | mCurItemRootParent = 0; |
937 | mCurItemParent = 0; | 942 | mCurItemParent = 0; |
938 | mCurItemAbove = 0; | 943 | mCurItemAbove = 0; |
939 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 944 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
940 | if (mActiveItem) { | 945 | if (mActiveItem) { |
941 | mCurItem = mActiveItem->todo(); | 946 | mCurItem = mActiveItem->todo(); |
942 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); | 947 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); |
943 | if ( activeItemAbove ) | 948 | if ( activeItemAbove ) |
944 | mCurItemAbove = activeItemAbove->todo(); | 949 | mCurItemAbove = activeItemAbove->todo(); |
945 | mCurItemRootParent = mCurItem; | 950 | mCurItemRootParent = mCurItem; |
946 | mCurItemParent = mCurItemRootParent->relatedTo(); | 951 | mCurItemParent = mCurItemRootParent->relatedTo(); |
947 | while ( mCurItemRootParent->relatedTo() != 0 ) | 952 | while ( mCurItemRootParent->relatedTo() != 0 ) |
948 | mCurItemRootParent = mCurItemRootParent->relatedTo(); | 953 | mCurItemRootParent = mCurItemRootParent->relatedTo(); |
949 | } | 954 | } |
950 | mActiveItem = 0; | 955 | mActiveItem = 0; |
951 | } | 956 | } |
952 | 957 | ||
953 | void KOTodoView::resetCurrentItem() | 958 | void KOTodoView::resetCurrentItem() |
954 | { | 959 | { |
955 | //mTodoListView->setFocus(); | 960 | //mTodoListView->setFocus(); |
956 | KOTodoViewItem* foundItem = 0; | 961 | KOTodoViewItem* foundItem = 0; |
957 | KOTodoViewItem* foundItemRoot = 0; | 962 | KOTodoViewItem* foundItemRoot = 0; |
958 | KOTodoViewItem* foundItemParent = 0; | 963 | KOTodoViewItem* foundItemParent = 0; |
959 | KOTodoViewItem* foundItemAbove = 0; | 964 | KOTodoViewItem* foundItemAbove = 0; |
960 | if ( mTodoListView->firstChild () ) { | 965 | if ( mTodoListView->firstChild () ) { |
961 | if ( mCurItem ) { | 966 | if ( mCurItem ) { |
962 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); | 967 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); |
963 | while ( item ) { | 968 | while ( item ) { |
964 | if ( item->todo() == mCurItem ) { | 969 | if ( item->todo() == mCurItem ) { |
965 | foundItem = item; | 970 | foundItem = item; |
966 | break; | 971 | break; |
967 | } else if ( item->todo() == mCurItemAbove ) { | 972 | } else if ( item->todo() == mCurItemAbove ) { |
968 | foundItemAbove = item; | 973 | foundItemAbove = item; |
969 | 974 | ||
970 | } | 975 | } |
971 | if ( item->todo() == mCurItemRootParent ) { | 976 | if ( item->todo() == mCurItemRootParent ) { |
972 | foundItemRoot = item; | 977 | foundItemRoot = item; |
973 | } | 978 | } |
974 | if ( item->todo() == mCurItemParent ) { | 979 | if ( item->todo() == mCurItemParent ) { |
975 | foundItemParent = item; | 980 | foundItemParent = item; |
976 | } | 981 | } |
977 | item = (KOTodoViewItem*)item->itemBelow(); | 982 | item = (KOTodoViewItem*)item->itemBelow(); |
978 | } | 983 | } |
979 | if ( ! foundItem ) { | 984 | if ( ! foundItem ) { |
980 | if ( foundItemParent ) { | 985 | if ( foundItemParent ) { |
981 | foundItem = foundItemParent; | 986 | foundItem = foundItemParent; |
982 | } else { | 987 | } else { |
983 | if ( foundItemRoot ) | 988 | if ( foundItemRoot ) |
984 | foundItem = foundItemRoot; | 989 | foundItem = foundItemRoot; |
985 | else | 990 | else |
986 | foundItem = foundItemAbove; | 991 | foundItem = foundItemAbove; |
987 | } | 992 | } |
988 | } | 993 | } |
989 | } | 994 | } |
990 | if ( foundItem ) { | 995 | if ( foundItem ) { |
991 | mTodoListView->setSelected ( foundItem, true ); | 996 | mTodoListView->setSelected ( foundItem, true ); |
992 | mTodoListView->setCurrentItem( foundItem ); | 997 | mTodoListView->setCurrentItem( foundItem ); |
993 | mTodoListView->ensureItemVisible( foundItem ); | 998 | mTodoListView->ensureItemVisible( foundItem ); |
994 | } else { | 999 | } else { |
995 | if ( mTodoListView->firstChild () ) { | 1000 | if ( mTodoListView->firstChild () ) { |
996 | mTodoListView->setSelected ( mTodoListView->firstChild (), true ); | 1001 | mTodoListView->setSelected ( mTodoListView->firstChild (), true ); |
997 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | 1002 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); |
998 | } | 1003 | } |
999 | } | 1004 | } |
1000 | } | 1005 | } |
1001 | processSelectionChange(); | 1006 | processSelectionChange(); |
1002 | if ( mName != "todolistsmall" ) | 1007 | if ( mName != "todolistsmall" ) |
1003 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); | 1008 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); |
1004 | } | 1009 | } |
1005 | void KOTodoView::resetFocusToList() | 1010 | void KOTodoView::resetFocusToList() |
1006 | { | 1011 | { |
1007 | topLevelWidget()->setActiveWindow(); | 1012 | topLevelWidget()->setActiveWindow(); |
1008 | mTodoListView->setFocus(); | 1013 | mTodoListView->setFocus(); |
1009 | } | 1014 | } |
1010 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; | 1015 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; |
1011 | bool KOTodoView::checkTodo( Todo * todo ) | 1016 | bool KOTodoView::checkTodo( Todo * todo ) |
1012 | { | 1017 | { |
1013 | 1018 | ||
1014 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 1019 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
1015 | return false; | 1020 | return false; |
1016 | if ( !todo->isCompleted() ) { | 1021 | if ( !todo->isCompleted() ) { |
1017 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) | 1022 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) |
1018 | return true; | 1023 | return true; |
diff --git a/korganizer/main.cpp b/korganizer/main.cpp index c9d1345..6339370 100644 --- a/korganizer/main.cpp +++ b/korganizer/main.cpp | |||
@@ -1,115 +1,115 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #ifndef DESKTOP_VERSION | 3 | #ifndef DESKTOP_VERSION |
4 | #include <qpe/qpeapplication.h> | 4 | #include <qpe/qpeapplication.h> |
5 | #include <qcopchannel_qws.h> | 5 | #include <qcopchannel_qws.h> |
6 | #include <qpe/global.h> | 6 | #include <qpe/global.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #else | 8 | #else |
9 | #include <qapplication.h> | 9 | #include <qapplication.h> |
10 | #include <qstring.h> | 10 | #include <qstring.h> |
11 | #include <qwindowsstyle.h> | 11 | #include <qwindowsstyle.h> |
12 | #include <qplatinumstyle.h> | 12 | #include <qplatinumstyle.h> |
13 | #include <qsgistyle.h> | 13 | #include <qsgistyle.h> |
14 | #include <stdlib.h> | 14 | #include <stdlib.h> |
15 | #endif | 15 | #endif |
16 | #include <qtextcodec.h> | 16 | #include <qtextcodec.h> |
17 | 17 | ||
18 | #include <qdir.h> | 18 | #include <qdir.h> |
19 | #include <kstandarddirs.h> | 19 | #include <kstandarddirs.h> |
20 | #include <kglobal.h> | 20 | #include <kglobal.h> |
21 | #include <stdio.h> | 21 | #include <stdio.h> |
22 | #include "mainwindow.h" | 22 | #include "mainwindow.h" |
23 | #include <libkdepim/kpimglobalprefs.h> | 23 | #include <libkdepim/kpimglobalprefs.h> |
24 | void dumpMissing(); | 24 | void dumpMissing(); |
25 | 25 | ||
26 | 26 | ||
27 | int main( int argc, char **argv ) | 27 | int main( int argc, char **argv ) |
28 | { | 28 | { |
29 | #ifndef DESKTOP_VERSION | 29 | #ifndef DESKTOP_VERSION |
30 | QPEApplication a( argc, argv ); | 30 | QPEApplication a( argc, argv ); |
31 | a.setKeepRunning (); | 31 | a.setKeepRunning (); |
32 | #else | 32 | #else |
33 | QApplication a( argc, argv ); | 33 | QApplication a( argc, argv ); |
34 | QApplication::setStyle( new QPlatinumStyle ()); | 34 | QApplication::setStyle( new QPlatinumStyle ()); |
35 | #ifdef _WIN32_ | 35 | #ifdef _WIN32_ |
36 | QString hdir ( getenv( "HOME") ); | 36 | QString hdir ( getenv( "HOME") ); |
37 | if ( hdir.isEmpty() ) { | 37 | if ( hdir.isEmpty() ) { |
38 | QString hd ("C:/" ); | 38 | QString hd ("C:/" ); |
39 | //QMessageBox::information(0,"hh",QDir::homeDirPath()+" xx" +hd ); | 39 | //QMessageBox::information(0,"hh",QDir::homeDirPath()+" xx" +hd ); |
40 | if ( QDir::homeDirPath().lower() == hd.lower() ) { | 40 | if ( QDir::homeDirPath().lower() == hd.lower() ) { |
41 | _putenv( "HOME=C:"); | 41 | _putenv( "HOME=C:"); |
42 | //QMessageBox::information(0,"hh",QString ( getenv( "HOME") ) ); | 42 | //QMessageBox::information(0,"hh",QString ( getenv( "HOME") ) ); |
43 | } | 43 | } |
44 | } else { | 44 | } else { |
45 | QDir app_dir; | 45 | QDir app_dir; |
46 | if ( !app_dir.exists(hdir) ) | 46 | if ( !app_dir.exists(hdir) ) |
47 | app_dir.mkdir (hdir); | 47 | app_dir.mkdir (hdir); |
48 | } | 48 | } |
49 | #endif | 49 | #endif |
50 | #endif | 50 | #endif |
51 | bool exitHelp = false; | 51 | bool exitHelp = false; |
52 | if ( argc > 1 ) { | 52 | if ( argc > 1 ) { |
53 | QString command = argv[1]; | 53 | QString command = argv[1]; |
54 | if ( command == "-help" ){ | 54 | if ( command == "-help" ){ |
55 | printf("KO/Pi command line commands:\n"); | 55 | printf("KO/Pi command line commands:\n"); |
56 | printf(" no command: Start KO/Pi in usual way\n"); | 56 | printf(" no command: Start KO/Pi in usual way\n"); |
57 | printf(" -help: This output\n"); | 57 | printf(" -help: This output\n"); |
58 | printf("Next Option: Open or Show after start:\n"); | 58 | printf("Next Option: Open or Show after start:\n"); |
59 | printf(" -newTodo: New Todo dialog\n"); | 59 | printf(" -newTodo: New Todo dialog\n"); |
60 | printf(" -newEvent: New Event dialog\n"); | 60 | printf(" -newEvent: New Event dialog\n"); |
61 | printf(" -showList: List view\n"); | 61 | printf(" -showList: List view\n"); |
62 | printf(" -showDay: Day view\n"); | 62 | printf(" -showDay: Day view\n"); |
63 | printf(" -showWWeek: Work Week view\n"); | 63 | printf(" -showWWeek: Work Week view\n"); |
64 | printf(" -showWeek: Week view\n"); | 64 | printf(" -showWeek: Week view\n"); |
65 | printf(" -showTodo: Todo view\n"); | 65 | printf(" -showTodo: Todo view\n"); |
66 | printf(" -showJournal: Journal view\n"); | 66 | printf(" -showJournal: Journal view\n"); |
67 | printf(" -showKO: Next Days view\n"); | 67 | printf(" -showKO: Next Days view\n"); |
68 | printf(" -showWNext: What's Next view\n"); | 68 | printf(" -showWNext: What's Next view\n"); |
69 | printf(" -showNextXView: Next X View\n"); | 69 | printf(" -showNextXView: Next X View\n"); |
70 | printf(" -new[Y] and -show[X] may be used togehther\n"); | 70 | printf(" -new[Y] and -show[X] may be used togehther\n"); |
71 | printf(" KO/Pi is exiting now. Bye!\n"); | 71 | printf(" KO/Pi is exiting now. Bye!\n"); |
72 | exitHelp = true; | 72 | exitHelp = true; |
73 | } | 73 | } |
74 | } | 74 | } |
75 | if ( ! exitHelp ) { | 75 | if ( ! exitHelp ) { |
76 | KGlobal::setAppName( "korganizer" ); | 76 | KGlobal::setAppName( "korganizer" ); |
77 | QString fileName ; | 77 | QString fileName ; |
78 | #ifndef DESKTOP_VERSION | 78 | #ifndef DESKTOP_VERSION |
79 | fileName = getenv("QPEDIR"); | 79 | fileName = getenv("QPEDIR"); |
80 | KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/"); | 80 | KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/"); |
81 | #else | 81 | #else |
82 | fileName = qApp->applicationDirPath () + "/kdepim/korganizer/"; | 82 | fileName = qApp->applicationDirPath () + "/kdepim/korganizer/"; |
83 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); | 83 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); |
84 | #endif | 84 | #endif |
85 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "korganizer"))); | 85 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "korganizer"))); |
86 | 86 | ||
87 | QApplication::setFont( KPimGlobalPrefs::instance()->mApplicationFont ); | 87 | QApplication::setFont( KPimGlobalPrefs::instance()->mApplicationFont ); |
88 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 88 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
89 | MainWindow m; | 89 | MainWindow m; |
90 | #ifndef DESKTOP_VERSION | 90 | #ifndef DESKTOP_VERSION |
91 | 91 | ||
92 | QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); | 92 | QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(receiveStart( const QCString&, const QByteArray& ))); |
93 | a.showMainWidget(&m ); | 93 | a.showMainWidget(&m ); |
94 | #else | 94 | #else |
95 | a.setMainWidget(&m ); | 95 | a.setMainWidget(&m ); |
96 | m.show(); | 96 | m.show(); |
97 | //m.resize( 800, 600 ); | 97 | //m.resize( 800, 600 ); |
98 | QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); | 98 | //QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); |
99 | #endif | 99 | #endif |
100 | if ( argc > 1 ) { | 100 | if ( argc > 1 ) { |
101 | QCString command = argv[1]; | 101 | QCString command = argv[1]; |
102 | if ( argc > 2 ) | 102 | if ( argc > 2 ) |
103 | command += argv[2]; | 103 | command += argv[2]; |
104 | qApp->processEvents(); | 104 | qApp->processEvents(); |
105 | m.recieve(command, QByteArray() ); | 105 | m.recieve(command, QByteArray() ); |
106 | 106 | ||
107 | } | 107 | } |
108 | 108 | ||
109 | a.exec(); | 109 | a.exec(); |
110 | dumpMissing(); | 110 | dumpMissing(); |
111 | 111 | ||
112 | KPimGlobalPrefs::instance()->writeConfig(); | 112 | KPimGlobalPrefs::instance()->writeConfig(); |
113 | } | 113 | } |
114 | qDebug("KO: Bye! "); | 114 | qDebug("KO: Bye! "); |
115 | } | 115 | } |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 9ae393d..8c72d89 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,1055 +1,1082 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qpopupmenu.h> | 4 | #include <qpopupmenu.h> |
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | #include <qwhatsthis.h> | 6 | #include <qwhatsthis.h> |
7 | #include <qpushbutton.h> | 7 | #include <qpushbutton.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qtextcodec.h> | 10 | #include <qtextcodec.h> |
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qdir.h> | 12 | #include <qdir.h> |
13 | #include <qapp.h> | 13 | #include <qapp.h> |
14 | #include <qfileinfo.h> | 14 | #include <qfileinfo.h> |
15 | #include <qlabel.h> | 15 | #include <qlabel.h> |
16 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
17 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
18 | #include <qmap.h> | 18 | #include <qmap.h> |
19 | #include <qwmatrix.h> | 19 | #include <qwmatrix.h> |
20 | #include <qtextbrowser.h> | 20 | #include <qtextbrowser.h> |
21 | #include <qtextstream.h> | 21 | #include <qtextstream.h> |
22 | #ifndef DESKTOP_VERSION | 22 | #ifndef DESKTOP_VERSION |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/qpetoolbar.h> | 24 | #include <qpe/qpetoolbar.h> |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | #include <qtopia/alarmserver.h> | 27 | #include <qtopia/alarmserver.h> |
28 | #include <qtopia/qcopenvelope_qws.h> | 28 | #include <qtopia/qcopenvelope_qws.h> |
29 | #include <unistd.h> // for sleep | 29 | #include <unistd.h> // for sleep |
30 | #else | 30 | #else |
31 | #include <qtoolbar.h> | 31 | #include <qtoolbar.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | //#include <resource.h> | 33 | //#include <resource.h> |
34 | 34 | ||
35 | #endif | 35 | #endif |
36 | #include <libkcal/calendarlocal.h> | 36 | #include <libkcal/calendarlocal.h> |
37 | #include <libkcal/todo.h> | 37 | #include <libkcal/todo.h> |
38 | #include <libkcal/phoneformat.h> | 38 | #include <libkcal/phoneformat.h> |
39 | #include <libkdepim/ksyncprofile.h> | 39 | #include <libkdepim/ksyncprofile.h> |
40 | #include <libkdepim/phoneaccess.h> | 40 | #include <libkdepim/phoneaccess.h> |
41 | #include <libkcal/kincidenceformatter.h> | 41 | #include <libkcal/kincidenceformatter.h> |
42 | #include <libkdepim/kpimglobalprefs.h> | 42 | #include <libkdepim/kpimglobalprefs.h> |
43 | 43 | ||
44 | #include "calendarview.h" | 44 | #include "calendarview.h" |
45 | #include "koviewmanager.h" | 45 | #include "koviewmanager.h" |
46 | #include "datenavigator.h" | 46 | #include "datenavigator.h" |
47 | #include "koagendaview.h" | 47 | #include "koagendaview.h" |
48 | #include "kojournalview.h" | 48 | #include "kojournalview.h" |
49 | #include "koagenda.h" | 49 | #include "koagenda.h" |
50 | #include "kodialogmanager.h" | 50 | #include "kodialogmanager.h" |
51 | #include "kdialogbase.h" | 51 | #include "kdialogbase.h" |
52 | #include "kapplication.h" | 52 | #include "kapplication.h" |
53 | #include "kofilterview.h" | 53 | #include "kofilterview.h" |
54 | #include "kstandarddirs.h" | 54 | #include "kstandarddirs.h" |
55 | #include "koprefs.h" | 55 | #include "koprefs.h" |
56 | #include "kfiledialog.h" | 56 | #include "kfiledialog.h" |
57 | #include "koglobals.h" | 57 | #include "koglobals.h" |
58 | #include "kglobal.h" | 58 | #include "kglobal.h" |
59 | #include "ktoolbar.h" | 59 | #include "ktoolbar.h" |
60 | #include "klocale.h" | 60 | #include "klocale.h" |
61 | #include "kconfig.h" | 61 | #include "kconfig.h" |
62 | #include "externalapphandler.h" | 62 | #include "externalapphandler.h" |
63 | #include <kglobalsettings.h> | 63 | #include <kglobalsettings.h> |
64 | 64 | ||
65 | using namespace KCal; | 65 | using namespace KCal; |
66 | #ifndef _WIN32_ | 66 | #ifndef _WIN32_ |
67 | #include <unistd.h> | 67 | #include <unistd.h> |
68 | #else | 68 | #else |
69 | #ifdef _OL_IMPORT_ | 69 | #ifdef _OL_IMPORT_ |
70 | #include "koimportoldialog.h" | 70 | #include "koimportoldialog.h" |
71 | #endif | 71 | #endif |
72 | #endif | 72 | #endif |
73 | #include "mainwindow.h" | 73 | #include "mainwindow.h" |
74 | 74 | ||
75 | 75 | ||
76 | class KOex2phonePrefs : public QDialog | 76 | class KOex2phonePrefs : public QDialog |
77 | { | 77 | { |
78 | public: | 78 | public: |
79 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 79 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
80 | QDialog( parent, name, true ) | 80 | QDialog( parent, name, true ) |
81 | { | 81 | { |
82 | setCaption( i18n("Export to phone options") ); | 82 | setCaption( i18n("Export to phone options") ); |
83 | QVBoxLayout* lay = new QVBoxLayout( this ); | 83 | QVBoxLayout* lay = new QVBoxLayout( this ); |
84 | lay->setSpacing( 3 ); | 84 | lay->setSpacing( 3 ); |
85 | lay->setMargin( 3 ); | 85 | lay->setMargin( 3 ); |
86 | QLabel *lab; | 86 | QLabel *lab; |
87 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 87 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
88 | lab->setAlignment (AlignHCenter ); | 88 | lab->setAlignment (AlignHCenter ); |
89 | QHBox* temphb; | 89 | QHBox* temphb; |
90 | temphb = new QHBox( this ); | 90 | temphb = new QHBox( this ); |
91 | new QLabel( i18n("I/O device: "), temphb ); | 91 | new QLabel( i18n("I/O device: "), temphb ); |
92 | mPhoneDevice = new QLineEdit( temphb); | 92 | mPhoneDevice = new QLineEdit( temphb); |
93 | lay->addWidget( temphb ); | 93 | lay->addWidget( temphb ); |
94 | temphb = new QHBox( this ); | 94 | temphb = new QHBox( this ); |
95 | new QLabel( i18n("Connection: "), temphb ); | 95 | new QLabel( i18n("Connection: "), temphb ); |
96 | mPhoneConnection = new QLineEdit( temphb); | 96 | mPhoneConnection = new QLineEdit( temphb); |
97 | lay->addWidget( temphb ); | 97 | lay->addWidget( temphb ); |
98 | temphb = new QHBox( this ); | 98 | temphb = new QHBox( this ); |
99 | new QLabel( i18n("Model(opt.): "), temphb ); | 99 | new QLabel( i18n("Model(opt.): "), temphb ); |
100 | mPhoneModel = new QLineEdit( temphb); | 100 | mPhoneModel = new QLineEdit( temphb); |
101 | lay->addWidget( temphb ); | 101 | lay->addWidget( temphb ); |
102 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); | 102 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); |
103 | mWriteBackFuture->setChecked( true ); | 103 | mWriteBackFuture->setChecked( true ); |
104 | lay->addWidget( mWriteBackFuture ); | 104 | lay->addWidget( mWriteBackFuture ); |
105 | temphb = new QHBox( this ); | 105 | temphb = new QHBox( this ); |
106 | new QLabel( i18n("Max. weeks in future: ") , temphb ); | 106 | new QLabel( i18n("Max. weeks in future: ") , temphb ); |
107 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); | 107 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); |
108 | mWriteBackFutureWeeks->setValue( 8 ); | 108 | mWriteBackFutureWeeks->setValue( 8 ); |
109 | lay->addWidget( temphb ); | 109 | lay->addWidget( temphb ); |
110 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); | 110 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); |
111 | lab->setAlignment (AlignHCenter ); | 111 | lab->setAlignment (AlignHCenter ); |
112 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 112 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
113 | lay->addWidget( ok ); | 113 | lay->addWidget( ok ); |
114 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 114 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
115 | lay->addWidget( cancel ); | 115 | lay->addWidget( cancel ); |
116 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 116 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
117 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 117 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
118 | resize( 220, 240 ); | 118 | resize( 220, 240 ); |
119 | qApp->processEvents(); | 119 | qApp->processEvents(); |
120 | int dw = QApplication::desktop()->width(); | 120 | int dw = QApplication::desktop()->width(); |
121 | int dh = QApplication::desktop()->height(); | 121 | int dh = QApplication::desktop()->height(); |
122 | move( (dw-width())/2, (dh - height() )/2 ); | 122 | move( (dw-width())/2, (dh - height() )/2 ); |
123 | } | 123 | } |
124 | 124 | ||
125 | public: | 125 | public: |
126 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 126 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
127 | QCheckBox* mWriteBackFuture; | 127 | QCheckBox* mWriteBackFuture; |
128 | QSpinBox* mWriteBackFutureWeeks; | 128 | QSpinBox* mWriteBackFutureWeeks; |
129 | }; | 129 | }; |
130 | 130 | ||
131 | QPixmap* sgListViewCompletedPix[6]; | 131 | QPixmap* sgListViewCompletedPix[6]; |
132 | QPixmap* sgListViewJournalPix; | 132 | QPixmap* sgListViewJournalPix; |
133 | 133 | ||
134 | 134 | ||
135 | int globalFlagBlockStartup; | 135 | int globalFlagBlockStartup; |
136 | MainWindow::MainWindow( QWidget *parent, const char *name ) : | 136 | MainWindow::MainWindow( QWidget *parent, const char *name ) : |
137 | QMainWindow( parent, name ) | 137 | QMainWindow( parent, name ) |
138 | { | 138 | { |
139 | sgListViewCompletedPix[5] = &listviewPix; | 139 | sgListViewCompletedPix[5] = &listviewPix; |
140 | sgListViewCompletedPix[0] = &listviewPix0; | 140 | sgListViewCompletedPix[0] = &listviewPix0; |
141 | sgListViewCompletedPix[1] = &listviewPix20; | 141 | sgListViewCompletedPix[1] = &listviewPix20; |
142 | sgListViewCompletedPix[2] = &listviewPix40; | 142 | sgListViewCompletedPix[2] = &listviewPix40; |
143 | sgListViewCompletedPix[3] = &listviewPix60; | 143 | sgListViewCompletedPix[3] = &listviewPix60; |
144 | sgListViewCompletedPix[4] = &listviewPix80; | 144 | sgListViewCompletedPix[4] = &listviewPix80; |
145 | //int size = 12; | 145 | //int size = 12; |
146 | { | 146 | { |
147 | sgListViewCompletedPix[5]->resize( 11, 11 ); | 147 | sgListViewCompletedPix[5]->resize( 11, 11 ); |
148 | sgListViewCompletedPix[5]->fill( Qt::white ); | 148 | sgListViewCompletedPix[5]->fill( Qt::white ); |
149 | QPainter p ( sgListViewCompletedPix[5] ); | 149 | QPainter p ( sgListViewCompletedPix[5] ); |
150 | p.drawRect( 0,0,11,11); | 150 | p.drawRect( 0,0,11,11); |
151 | p.drawLine ( 2, 5, 4 , 7 ) ; | 151 | p.drawLine ( 2, 5, 4 , 7 ) ; |
152 | p.drawLine ( 4 , 7 , 8, 3) ; | 152 | p.drawLine ( 4 , 7 , 8, 3) ; |
153 | int iii = 0; | 153 | int iii = 0; |
154 | for ( iii = 0; iii < 5; ++iii ) { | 154 | for ( iii = 0; iii < 5; ++iii ) { |
155 | sgListViewCompletedPix[iii]->resize( 11, 11 ); | 155 | sgListViewCompletedPix[iii]->resize( 11, 11 ); |
156 | sgListViewCompletedPix[iii]->fill( Qt::white ); | 156 | sgListViewCompletedPix[iii]->fill( Qt::white ); |
157 | QPainter p ( sgListViewCompletedPix[iii] ); | 157 | QPainter p ( sgListViewCompletedPix[iii] ); |
158 | p.drawRect( 0,0,11,11); | 158 | p.drawRect( 0,0,11,11); |
159 | if ( iii ) | 159 | if ( iii ) |
160 | p.fillRect( 1,1,iii*2,9,Qt::gray ); | 160 | p.fillRect( 1,1,iii*2,9,Qt::gray ); |
161 | } | 161 | } |
162 | sgListViewJournalPix = &journalPix; | 162 | sgListViewJournalPix = &journalPix; |
163 | sgListViewJournalPix->resize( 11, 11 ); | 163 | sgListViewJournalPix->resize( 11, 11 ); |
164 | sgListViewJournalPix->fill( Qt::white ); | 164 | sgListViewJournalPix->fill( Qt::white ); |
165 | { | 165 | { |
166 | QPainter p ( sgListViewJournalPix ); | 166 | QPainter p ( sgListViewJournalPix ); |
167 | p.drawRect( 0,0,11,11); | 167 | p.drawRect( 0,0,11,11); |
168 | p.drawLine( 2,3,5,3); | 168 | p.drawLine( 2,3,5,3); |
169 | p.drawLine( 2,5,8,5); | 169 | p.drawLine( 2,5,8,5); |
170 | p.drawLine( 2,7,6,7); | 170 | p.drawLine( 2,7,6,7); |
171 | } | 171 | } |
172 | } | 172 | } |
173 | mClosed = false; | 173 | mClosed = false; |
174 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 174 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
175 | QString confFile = locateLocal("config","korganizerrc"); | 175 | QString confFile = locateLocal("config","korganizerrc"); |
176 | QFileInfo finf ( confFile ); | 176 | QFileInfo finf ( confFile ); |
177 | bool showWarning = !finf.exists(); | 177 | bool showWarning = !finf.exists(); |
178 | setIcon(SmallIcon( "ko24" ) ); | 178 | setIcon(SmallIcon( "ko24" ) ); |
179 | mBlockAtStartup = true; | 179 | mBlockAtStartup = true; |
180 | mFlagKeyPressed = false; | 180 | mFlagKeyPressed = false; |
181 | setCaption("KO/Pi"); | 181 | setCaption("KO/Pi"); |
182 | KOPrefs *p = KOPrefs::instance(); | 182 | KOPrefs *p = KOPrefs::instance(); |
183 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 183 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
184 | p->mCurrentDisplayedView = 0; | 184 | p->mCurrentDisplayedView = 0; |
185 | if ( p->mHourSize > 22 ) | 185 | if ( p->mHourSize > 22 ) |
186 | p->mHourSize = 22; | 186 | p->mHourSize = 22; |
187 | QMainWindow::ToolBarDock tbd; | 187 | QMainWindow::ToolBarDock tbd; |
188 | if ( p->mToolBarHor ) { | 188 | if ( p->mToolBarHor ) { |
189 | if ( p->mToolBarUp ) | 189 | if ( p->mToolBarUp ) |
190 | tbd = Bottom; | 190 | tbd = Bottom; |
191 | else | 191 | else |
192 | tbd = Top; | 192 | tbd = Top; |
193 | } | 193 | } |
194 | else { | 194 | else { |
195 | if ( p->mToolBarUp ) | 195 | if ( p->mToolBarUp ) |
196 | tbd = Right; | 196 | tbd = Right; |
197 | else | 197 | else |
198 | tbd = Left; | 198 | tbd = Left; |
199 | } | 199 | } |
200 | if ( KOPrefs::instance()->mUseAppColors ) | 200 | if ( KOPrefs::instance()->mUseAppColors ) |
201 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 201 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
202 | globalFlagBlockStartup = 1; | 202 | globalFlagBlockStartup = 1; |
203 | iconToolBar = new QPEToolBar( this ); | 203 | iconToolBar = new QPEToolBar( this ); |
204 | addToolBar (iconToolBar , tbd ); | 204 | addToolBar (iconToolBar , tbd ); |
205 | 205 | ||
206 | #ifdef DESKTOP_VERSION | 206 | #ifdef DESKTOP_VERSION |
207 | if ( KOPrefs::instance()->mShowIconFilter ) | 207 | if ( KOPrefs::instance()->mShowIconFilter ) |
208 | #else | 208 | #else |
209 | if ( KOPrefs::instance()->mShowIconFilter || ( !p->mShowIconOnetoolbar &&!p->mShowIconFilterview ) ) | 209 | if ( KOPrefs::instance()->mShowIconFilter || ( !p->mShowIconOnetoolbar &&!p->mShowIconFilterview ) ) |
210 | #endif | 210 | #endif |
211 | 211 | ||
212 | { | 212 | { |
213 | if ( p->mToolBarHorF ) { | 213 | if ( p->mToolBarHorF ) { |
214 | if ( p->mToolBarUpF ) | 214 | if ( p->mToolBarUpF ) |
215 | tbd = Bottom; | 215 | tbd = Bottom; |
216 | else | 216 | else |
217 | tbd = Top; | 217 | tbd = Top; |
218 | } | 218 | } |
219 | else { | 219 | else { |
220 | if ( p->mToolBarUpF ) | 220 | if ( p->mToolBarUpF ) |
221 | tbd = Right; | 221 | tbd = Right; |
222 | else | 222 | else |
223 | tbd = Left; | 223 | tbd = Left; |
224 | } | 224 | } |
225 | filterToolBar = new QPEToolBar ( this ); | 225 | filterToolBar = new QPEToolBar ( this ); |
226 | filterMenubar = new KMenuBar( 0 ); | 226 | filterMenubar = new KMenuBar( 0 ); |
227 | QFontMetrics fm ( filterMenubar->font() ); | 227 | QFontMetrics fm ( filterMenubar->font() ); |
228 | #ifndef DESKTOP_VERSION | 228 | #ifndef DESKTOP_VERSION |
229 | filterToolBar->setFocusPolicy( NoFocus ); | 229 | filterToolBar->setFocusPolicy( NoFocus ); |
230 | filterMenubar->setFocusPolicy( NoFocus ); | 230 | filterMenubar->setFocusPolicy( NoFocus ); |
231 | #endif | 231 | #endif |
232 | filterPopupMenu = new QPopupMenu( this ); | 232 | filterPopupMenu = new QPopupMenu( this ); |
233 | filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); | 233 | filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); |
234 | QString addTest = "A"; | 234 | QString addTest = "A"; |
235 | filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); | 235 | filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); |
236 | #ifdef DESKTOP_VERSION | 236 | #ifdef DESKTOP_VERSION |
237 | addTest = "AAAAAABBBCCCx"; | 237 | addTest = "AAAAAABBBCCCx"; |
238 | #else | 238 | #else |
239 | addTest = "AAAAAx"; | 239 | addTest = "AAAAAx"; |
240 | #endif | 240 | #endif |
241 | filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); | 241 | filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); |
242 | addToolBar (filterToolBar , tbd ); | 242 | addToolBar (filterToolBar , tbd ); |
243 | connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); | 243 | connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); |
244 | connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); | 244 | connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); |
245 | if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) | 245 | if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) |
246 | filterToolBar->hide(); | 246 | filterToolBar->hide(); |
247 | } else { | 247 | } else { |
248 | filterToolBar = 0; | 248 | filterToolBar = 0; |
249 | filterMenubar = 0; | 249 | filterMenubar = 0; |
250 | filterPopupMenu = 0; | 250 | filterPopupMenu = 0; |
251 | } | 251 | } |
252 | if ( p->mShowIconOnetoolbar ) { | 252 | if ( p->mShowIconOnetoolbar ) { |
253 | viewToolBar = iconToolBar ; | 253 | viewToolBar = iconToolBar ; |
254 | navigatorToolBar = iconToolBar ; | 254 | navigatorToolBar = iconToolBar ; |
255 | } else { | 255 | } else { |
256 | #ifndef DESKTOP_VERSION | 256 | #ifndef DESKTOP_VERSION |
257 | setToolBarsMovable( false ); | 257 | setToolBarsMovable( false ); |
258 | #endif | 258 | #endif |
259 | if ( p->mToolBarHorV ) { | 259 | if ( p->mToolBarHorV ) { |
260 | if ( p->mToolBarUpV ) | 260 | if ( p->mToolBarUpV ) |
261 | tbd = Bottom; | 261 | tbd = Bottom; |
262 | else | 262 | else |
263 | tbd = Top; | 263 | tbd = Top; |
264 | } | 264 | } |
265 | else { | 265 | else { |
266 | if ( p->mToolBarUpV ) | 266 | if ( p->mToolBarUpV ) |
267 | tbd = Right; | 267 | tbd = Right; |
268 | else | 268 | else |
269 | tbd = Left; | 269 | tbd = Left; |
270 | } | 270 | } |
271 | viewToolBar = new QPEToolBar( this ); | 271 | viewToolBar = new QPEToolBar( this ); |
272 | addToolBar (viewToolBar , tbd ); | 272 | addToolBar (viewToolBar , tbd ); |
273 | if ( p->mToolBarHorN ) { | 273 | if ( p->mToolBarHorN ) { |
274 | if ( p->mToolBarUpN ) | 274 | if ( p->mToolBarUpN ) |
275 | tbd = Bottom; | 275 | tbd = Bottom; |
276 | else | 276 | else |
277 | tbd = Top; | 277 | tbd = Top; |
278 | } | 278 | } |
279 | else { | 279 | else { |
280 | if ( p->mToolBarUpN ) | 280 | if ( p->mToolBarUpN ) |
281 | tbd = Right; | 281 | tbd = Right; |
282 | else | 282 | else |
283 | tbd = Left; | 283 | tbd = Left; |
284 | } | 284 | } |
285 | navigatorToolBar = new QPEToolBar( this ); | 285 | navigatorToolBar = new QPEToolBar( this ); |
286 | addToolBar (navigatorToolBar , tbd ); | 286 | addToolBar (navigatorToolBar , tbd ); |
287 | } | 287 | } |
288 | 288 | ||
289 | 289 | ||
290 | 290 | ||
291 | mCalendarModifiedFlag = false; | 291 | mCalendarModifiedFlag = false; |
292 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 292 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
293 | splash->setAlignment ( AlignCenter ); | 293 | splash->setAlignment ( AlignCenter ); |
294 | setCentralWidget( splash ); | 294 | setCentralWidget( splash ); |
295 | #ifndef DESKTOP_VERSION | 295 | #ifndef DESKTOP_VERSION |
296 | showMaximized(); | 296 | showMaximized(); |
297 | #endif | 297 | #endif |
298 | 298 | ||
299 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | 299 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); |
300 | setDefaultPreferences(); | 300 | setDefaultPreferences(); |
301 | mCalendar = new CalendarLocal(); | 301 | mCalendar = new CalendarLocal(); |
302 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | 302 | mView = new CalendarView( mCalendar, this,"mCalendar " ); |
303 | mView->hide(); | 303 | mView->hide(); |
304 | //mView->resize(splash->size() ); | 304 | //mView->resize(splash->size() ); |
305 | initActions(); | 305 | initActions(); |
306 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); | 306 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); |
307 | mSyncManager->setBlockSave(false); | 307 | mSyncManager->setBlockSave(false); |
308 | mView->setSyncManager(mSyncManager); | 308 | mView->setSyncManager(mSyncManager); |
309 | #ifndef DESKTOP_VERSION | 309 | #ifndef DESKTOP_VERSION |
310 | iconToolBar->show(); | 310 | iconToolBar->show(); |
311 | qApp->processEvents(); | 311 | qApp->processEvents(); |
312 | #endif | 312 | #endif |
313 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | 313 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); |
314 | int vh = height() ; | 314 | int vh = height() ; |
315 | int vw = width(); | 315 | int vw = width(); |
316 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); | 316 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); |
317 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 317 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
318 | vh -= iconToolBar->height(); | 318 | vh -= iconToolBar->height(); |
319 | } else { | 319 | } else { |
320 | vw -= iconToolBar->height(); | 320 | vw -= iconToolBar->height(); |
321 | } | 321 | } |
322 | //mView->setMaximumSize( splash->size() ); | 322 | //mView->setMaximumSize( splash->size() ); |
323 | //mView->resize( splash->size() ); | 323 | //mView->resize( splash->size() ); |
324 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 324 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
325 | mView->readSettings(); | 325 | mView->readSettings(); |
326 | bool newFile = false; | 326 | bool newFile = false; |
327 | if( !QFile::exists( defaultFileName() ) ) { | 327 | if( !QFile::exists( defaultFileName() ) ) { |
328 | QFileInfo finfo ( defaultFileName() ); | 328 | QFileInfo finfo ( defaultFileName() ); |
329 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | 329 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); |
330 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; | 330 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; |
331 | finfo.setFile( oldFile ); | 331 | finfo.setFile( oldFile ); |
332 | if (finfo.exists() ) { | 332 | if (finfo.exists() ) { |
333 | KMessageBox::information( this, message); | 333 | KMessageBox::information( this, message); |
334 | mView->openCalendar( oldFile ); | 334 | mView->openCalendar( oldFile ); |
335 | qApp->processEvents(); | 335 | qApp->processEvents(); |
336 | } else { | 336 | } else { |
337 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 337 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
338 | finfo.setFile( oldFile ); | 338 | finfo.setFile( oldFile ); |
339 | if (finfo.exists() ) { | 339 | if (finfo.exists() ) { |
340 | KMessageBox::information( this, message); | 340 | KMessageBox::information( this, message); |
341 | mView->openCalendar( oldFile ); | 341 | mView->openCalendar( oldFile ); |
342 | qApp->processEvents(); | 342 | qApp->processEvents(); |
343 | } | 343 | } |
344 | } | 344 | } |
345 | mView->saveCalendar( defaultFileName() ); | 345 | mView->saveCalendar( defaultFileName() ); |
346 | newFile = true; | 346 | newFile = true; |
347 | } | 347 | } |
348 | 348 | ||
349 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 349 | //QTime neededSaveTime = QDateTime::currentDateTime().time(); |
350 | mView->loadCalendars(); | 350 | //mView->loadCalendars(); |
351 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 351 | //int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
352 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 352 | //qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
353 | 353 | ||
354 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { | 354 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { |
355 | KOPrefs::instance()->setAllDefaults(); | 355 | KOPrefs::instance()->setAllDefaults(); |
356 | } | 356 | } |
357 | processIncidenceSelection( 0 ); | ||
358 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | ||
359 | SLOT( processIncidenceSelection( Incidence * ) ) ); | ||
360 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | ||
361 | SLOT( slotModifiedChanged( bool ) ) ); | ||
362 | 357 | ||
363 | 358 | ||
364 | connect( mView, SIGNAL( tempDisableBR(bool) ), | 359 | connect( mView, SIGNAL( tempDisableBR(bool) ), |
365 | SLOT( disableBR(bool) ) ); | 360 | SLOT( disableBR(bool) ) ); |
366 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 361 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
367 | mView->setModified( false ); | ||
368 | mBlockAtStartup = false; | ||
369 | mView->setModified( false ); | ||
370 | setCentralWidget( mView ); | 362 | setCentralWidget( mView ); |
371 | globalFlagBlockStartup = 0; | 363 | globalFlagBlockStartup = 0; |
372 | mView->show(); | 364 | mView->show(); |
373 | delete splash; | 365 | delete splash; |
374 | if ( newFile ) | 366 | if ( newFile ) |
375 | mView->updateConfig(); | 367 | mView->updateConfig(); |
376 | // qApp->processEvents(); | 368 | // qApp->processEvents(); |
377 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 369 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
378 | //fillSyncMenu(); | 370 | //fillSyncMenu(); |
379 | 371 | ||
380 | 372 | ||
381 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | 373 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); |
382 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); | ||
383 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); | 374 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); |
384 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 375 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
385 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 376 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
386 | mSyncManager->setDefaultFileName( sentSyncFile()); | 377 | mSyncManager->setDefaultFileName( sentSyncFile()); |
387 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); | 378 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); |
388 | mSyncManager->fillSyncMenu(); | 379 | mSyncManager->fillSyncMenu(); |
389 | 380 | ||
390 | 381 | ||
391 | 382 | ||
392 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 383 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
393 | if ( showWarning ) { | 384 | if ( showWarning ) { |
394 | KMessageBox::information( this, | 385 | KMessageBox::information( this, |
395 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); | 386 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); |
396 | qApp->processEvents(); | 387 | qApp->processEvents(); |
397 | mView->dialogManager()->showSyncOptions(); | 388 | mView->dialogManager()->showSyncOptions(); |
398 | } | 389 | } |
399 | 390 | ||
400 | //US listen for result adressed from Ka/Pi | 391 | //US listen for result adressed from Ka/Pi |
401 | #ifndef DESKTOP_VERSION | 392 | |
402 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | ||
403 | #endif | ||
404 | #ifndef DESKTOP_VERSION | 393 | #ifndef DESKTOP_VERSION |
405 | infrared = 0; | 394 | infrared = 0; |
406 | #endif | 395 | #endif |
407 | updateFilterToolbar(); | 396 | updateFilterToolbar(); |
408 | updateWeek( mView->startDate() ); | 397 | updateWeek( mView->startDate() ); |
409 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), | 398 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), |
410 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); | 399 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); |
411 | mBRdisabled = false; | 400 | mBRdisabled = false; |
412 | //toggleBeamReceive(); | 401 | //toggleBeamReceive(); |
413 | 402 | ||
414 | QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); | 403 | setCaption(i18n("Loading calendar files ... please wait" )); |
404 | QTimer::singleShot( 10, this, SLOT ( loadDataAfterStart() )); | ||
415 | } | 405 | } |
416 | MainWindow::~MainWindow() | 406 | MainWindow::~MainWindow() |
417 | { | 407 | { |
418 | //qDebug("MainWindow::~MainWindow() "); | 408 | //qDebug("MainWindow::~MainWindow() "); |
419 | //save toolbar location | 409 | //save toolbar location |
420 | delete mCalendar; | 410 | delete mCalendar; |
421 | delete mSyncManager; | 411 | delete mSyncManager; |
422 | #ifndef DESKTOP_VERSION | 412 | #ifndef DESKTOP_VERSION |
423 | if ( infrared ) | 413 | if ( infrared ) |
424 | delete infrared; | 414 | delete infrared; |
425 | #endif | 415 | #endif |
426 | 416 | ||
427 | 417 | ||
428 | } | 418 | } |
419 | |||
420 | void MainWindow::loadDataAfterStart() | ||
421 | { | ||
422 | |||
423 | qDebug("KO: Start loading files..." ); | ||
424 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | ||
425 | mView->loadCalendars(); | ||
426 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | ||
427 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | ||
428 | //QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); | ||
429 | mView->setModified( false ); | ||
430 | mBlockAtStartup = false; | ||
431 | mView->setModified( false ); | ||
432 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); | ||
433 | processIncidenceSelection( 0 ); | ||
434 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | ||
435 | SLOT( processIncidenceSelection( Incidence * ) ) ); | ||
436 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | ||
437 | SLOT( slotModifiedChanged( bool ) ) ); | ||
438 | |||
439 | #ifndef DESKTOP_VERSION | ||
440 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | ||
441 | connect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(recieve( const QCString&, const QByteArray& ))); | ||
442 | disconnect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(receiveStart( const QCString&, const QByteArray& ))); | ||
443 | if ( !mCStringMess.isEmpty() ) | ||
444 | recieve( mCStringMess, mByteData ); | ||
445 | #endif | ||
446 | |||
447 | |||
448 | QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); | ||
449 | } | ||
450 | |||
429 | void MainWindow::slotResetFocus() | 451 | void MainWindow::slotResetFocus() |
430 | { | 452 | { |
431 | //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar); | 453 | //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar); |
432 | mFocusLoop = 3; | 454 | mFocusLoop = 3; |
433 | QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); | 455 | QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); |
434 | } | 456 | } |
435 | void MainWindow::slotResetFocusLoop() | 457 | void MainWindow::slotResetFocusLoop() |
436 | { | 458 | { |
437 | --mFocusLoop; | 459 | --mFocusLoop; |
438 | QWidget* fw = mView->viewManager()->currentView(); | 460 | QWidget* fw = mView->viewManager()->currentView(); |
439 | if ( fw ) { | 461 | if ( fw ) { |
440 | //qDebug("loop "); | 462 | //qDebug("loop "); |
441 | fw->setFocus(); | 463 | fw->setFocus(); |
442 | if ( qApp->focusWidget() != fw && mFocusLoop > 0 ) | 464 | if ( qApp->focusWidget() != fw && mFocusLoop > 0 ) |
443 | QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); | 465 | QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); |
444 | } | 466 | } |
445 | 467 | ||
446 | } | 468 | } |
447 | void MainWindow::disableBR(bool b) | 469 | void MainWindow::disableBR(bool b) |
448 | { | 470 | { |
449 | #ifndef DESKTOP_VERSION | 471 | #ifndef DESKTOP_VERSION |
450 | if ( b ) { | 472 | if ( b ) { |
451 | if ( infrared ) { | 473 | if ( infrared ) { |
452 | toggleBeamReceive(); | 474 | toggleBeamReceive(); |
453 | mBRdisabled = true; | 475 | mBRdisabled = true; |
454 | } | 476 | } |
455 | mBRdisabled = true; | 477 | mBRdisabled = true; |
456 | } else { | 478 | } else { |
457 | if ( mBRdisabled ) { | 479 | if ( mBRdisabled ) { |
458 | mBRdisabled = false; | 480 | mBRdisabled = false; |
459 | //makes no sense,because other cal ap is probably running | 481 | //makes no sense,because other cal ap is probably running |
460 | // toggleBeamReceive(); | 482 | // toggleBeamReceive(); |
461 | } | 483 | } |
462 | } | 484 | } |
463 | #endif | 485 | #endif |
464 | 486 | ||
465 | } | 487 | } |
466 | bool MainWindow::beamReceiveEnabled() | 488 | bool MainWindow::beamReceiveEnabled() |
467 | { | 489 | { |
468 | #ifndef DESKTOP_VERSION | 490 | #ifndef DESKTOP_VERSION |
469 | return ( infrared != 0 ); | 491 | return ( infrared != 0 ); |
470 | #endif | 492 | #endif |
471 | return false; | 493 | return false; |
472 | } | 494 | } |
473 | 495 | ||
474 | void MainWindow::toggleBeamReceive() | 496 | void MainWindow::toggleBeamReceive() |
475 | { | 497 | { |
476 | if ( mBRdisabled ) | 498 | if ( mBRdisabled ) |
477 | return; | 499 | return; |
478 | #ifndef DESKTOP_VERSION | 500 | #ifndef DESKTOP_VERSION |
479 | if ( infrared ) { | 501 | if ( infrared ) { |
480 | qDebug("KO: Disable BeamReceive "); | 502 | qDebug("KO: Disable BeamReceive "); |
481 | delete infrared; | 503 | delete infrared; |
482 | infrared = 0; | 504 | infrared = 0; |
483 | brAction->setOn(false); | 505 | brAction->setOn(false); |
484 | return; | 506 | return; |
485 | } | 507 | } |
486 | qDebug("KO: Enable BeamReceive "); | 508 | qDebug("KO: Enable BeamReceive "); |
487 | brAction->setOn(true); | 509 | brAction->setOn(true); |
488 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; | 510 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; |
489 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); | 511 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); |
490 | #endif | 512 | #endif |
491 | } | 513 | } |
492 | void MainWindow::showMaximized () | 514 | void MainWindow::showMaximized () |
493 | { | 515 | { |
494 | #ifndef DESKTOP_VERSION | 516 | #ifndef DESKTOP_VERSION |
495 | if ( ! globalFlagBlockStartup ) | 517 | if ( ! globalFlagBlockStartup ) |
496 | if ( mClosed ) | 518 | if ( mClosed ) |
497 | mView->goToday(); | 519 | mView->goToday(); |
498 | #endif | 520 | #endif |
499 | QWidget::showMaximized () ; | 521 | QWidget::showMaximized () ; |
500 | mClosed = false; | 522 | mClosed = false; |
501 | } | 523 | } |
502 | void MainWindow::closeEvent( QCloseEvent* ce ) | 524 | void MainWindow::closeEvent( QCloseEvent* ce ) |
503 | { | 525 | { |
504 | 526 | ||
505 | 527 | ||
506 | 528 | ||
507 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 529 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
508 | saveOnClose(); | 530 | saveOnClose(); |
509 | if ( mCalendarModifiedFlag ) { | 531 | if ( mCalendarModifiedFlag ) { |
510 | ce->ignore(); | 532 | ce->ignore(); |
511 | return; | 533 | return; |
512 | } | 534 | } |
513 | mClosed = true; | 535 | mClosed = true; |
514 | ce->accept(); | 536 | ce->accept(); |
515 | return; | 537 | return; |
516 | 538 | ||
517 | } | 539 | } |
518 | 540 | ||
519 | switch( QMessageBox::information( this, "KO/Pi", | 541 | switch( QMessageBox::information( this, "KO/Pi", |
520 | i18n("Do you really want\nto close KO/Pi?"), | 542 | i18n("Do you really want\nto close KO/Pi?"), |
521 | i18n("Close"), i18n("No"), | 543 | i18n("Close"), i18n("No"), |
522 | 0, 0 ) ) { | 544 | 0, 0 ) ) { |
523 | case 0: | 545 | case 0: |
524 | saveOnClose(); | 546 | saveOnClose(); |
525 | if ( mCalendarModifiedFlag ) { | 547 | if ( mCalendarModifiedFlag ) { |
526 | ce->ignore(); | 548 | ce->ignore(); |
527 | return; | 549 | return; |
528 | } | 550 | } |
529 | mClosed = true; | 551 | mClosed = true; |
530 | ce->accept(); | 552 | ce->accept(); |
531 | break; | 553 | break; |
532 | case 1: | 554 | case 1: |
533 | ce->ignore(); | 555 | ce->ignore(); |
534 | break; | 556 | break; |
535 | case 2: | 557 | case 2: |
536 | 558 | ||
537 | default: | 559 | default: |
538 | break; | 560 | break; |
539 | } | 561 | } |
540 | 562 | ||
541 | 563 | ||
542 | } | 564 | } |
543 | 565 | void MainWindow::receiveStart( const QCString& cmsg, const QByteArray& data ) | |
566 | { | ||
567 | qDebug("KO: QCOP start message received: %s ", cmsg.data() ); | ||
568 | mCStringMess = cmsg; | ||
569 | mByteData = data; | ||
570 | } | ||
544 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 571 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
545 | { | 572 | { |
546 | QDataStream stream( data, IO_ReadOnly ); | 573 | QDataStream stream( data, IO_ReadOnly ); |
547 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 574 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
548 | //QString datamess; | 575 | //QString datamess; |
549 | //qDebug("message "); | 576 | //qDebug("message "); |
550 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 577 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
551 | 578 | ||
552 | if ( cmsg == "setDocument(QString)" ) { | 579 | if ( cmsg == "setDocument(QString)" ) { |
553 | QDataStream stream( data, IO_ReadOnly ); | 580 | QDataStream stream( data, IO_ReadOnly ); |
554 | QString fileName; | 581 | QString fileName; |
555 | stream >> fileName; | 582 | stream >> fileName; |
556 | //qDebug("filename %s ", fileName.latin1()); | 583 | //qDebug("filename %s ", fileName.latin1()); |
557 | showMaximized(); | 584 | showMaximized(); |
558 | raise(); | 585 | raise(); |
559 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; | 586 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; |
560 | mSyncManager->slotSyncMenu( 1002 ); | 587 | mSyncManager->slotSyncMenu( 1002 ); |
561 | return; | 588 | return; |
562 | } | 589 | } |
563 | 590 | ||
564 | if ( cmsg == "-writeFile" ) { | 591 | if ( cmsg == "-writeFile" ) { |
565 | // I made from the "-writeFile" an "-writeAlarm" | 592 | // I made from the "-writeFile" an "-writeAlarm" |
566 | mView->viewManager()->showWhatsNextView(); | 593 | mView->viewManager()->showWhatsNextView(); |
567 | mCalendar->checkAlarmForIncidence( 0, true); | 594 | mCalendar->checkAlarmForIncidence( 0, true); |
568 | showMaximized(); | 595 | showMaximized(); |
569 | raise(); | 596 | raise(); |
570 | return; | 597 | return; |
571 | 598 | ||
572 | } | 599 | } |
573 | if ( cmsg == "-writeFileSilent" ) { | 600 | if ( cmsg == "-writeFileSilent" ) { |
574 | // I made from the "-writeFile" an "-writeAlarm" | 601 | // I made from the "-writeFile" an "-writeAlarm" |
575 | // mView->viewManager()->showWhatsNextView(); | 602 | // mView->viewManager()->showWhatsNextView(); |
576 | mCalendar->checkAlarmForIncidence( 0, true); | 603 | mCalendar->checkAlarmForIncidence( 0, true); |
577 | //showMaximized(); | 604 | //showMaximized(); |
578 | //raise(); | 605 | //raise(); |
579 | hide(); | 606 | hide(); |
580 | return; | 607 | return; |
581 | } | 608 | } |
582 | if ( cmsg == "-newCountdown" ) { | 609 | if ( cmsg == "-newCountdown" ) { |
583 | qDebug("newCountdown "); | 610 | qDebug("newCountdown "); |
584 | 611 | ||
585 | } | 612 | } |
586 | QString msg ; | 613 | QString msg ; |
587 | QString allmsg = cmsg; | 614 | QString allmsg = cmsg; |
588 | while ( allmsg.length() > 0 ) { | 615 | while ( allmsg.length() > 0 ) { |
589 | int nextC = allmsg.find( "-", 1 ); | 616 | int nextC = allmsg.find( "-", 1 ); |
590 | if ( nextC == -1 ) { | 617 | if ( nextC == -1 ) { |
591 | msg = allmsg; | 618 | msg = allmsg; |
592 | allmsg = ""; | 619 | allmsg = ""; |
593 | } else{ | 620 | } else{ |
594 | msg = allmsg.left( nextC ); | 621 | msg = allmsg.left( nextC ); |
595 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 622 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
596 | } | 623 | } |
597 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 624 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
598 | if ( msg == "-newEvent" ) { | 625 | if ( msg == "-newEvent" ) { |
599 | QTimer::singleShot( 0, mView, SLOT ( newEvent())); | 626 | QTimer::singleShot( 0, mView, SLOT ( newEvent())); |
600 | } | 627 | } |
601 | if ( msg == "-newTodo" ) { | 628 | if ( msg == "-newTodo" ) { |
602 | QTimer::singleShot( 0, mView, SLOT ( newTodo())); | 629 | QTimer::singleShot( 0, mView, SLOT ( newTodo())); |
603 | } | 630 | } |
604 | if ( msg == "-showWN" ) { | 631 | if ( msg == "-showWN" ) { |
605 | mView->viewManager()->showWhatsNextView(); | 632 | mView->viewManager()->showWhatsNextView(); |
606 | } | 633 | } |
607 | if ( msg == "-showTodo" ) { | 634 | if ( msg == "-showTodo" ) { |
608 | mView->viewManager()->showTodoView(); | 635 | mView->viewManager()->showTodoView(); |
609 | } | 636 | } |
610 | if ( msg == "-showList" ) { | 637 | if ( msg == "-showList" ) { |
611 | mView->viewManager()->showListView(); | 638 | mView->viewManager()->showListView(); |
612 | } | 639 | } |
613 | else if ( msg == "-showDay" ) { | 640 | else if ( msg == "-showDay" ) { |
614 | mView->viewManager()->showDayView(); | 641 | mView->viewManager()->showDayView(); |
615 | } | 642 | } |
616 | else if ( msg == "-showWWeek" ) { | 643 | else if ( msg == "-showWWeek" ) { |
617 | mView->viewManager()->showWorkWeekView(); | 644 | mView->viewManager()->showWorkWeekView(); |
618 | } | 645 | } |
619 | else if ( msg == "-ringSync" ) { | 646 | else if ( msg == "-ringSync" ) { |
620 | QTimer::singleShot( 0, this, SLOT (startMultiSync())); | 647 | QTimer::singleShot( 0, this, SLOT (startMultiSync())); |
621 | } | 648 | } |
622 | else if ( msg == "-showWeek" ) { | 649 | else if ( msg == "-showWeek" ) { |
623 | mView->viewManager()->showWeekView(); | 650 | mView->viewManager()->showWeekView(); |
624 | } | 651 | } |
625 | else if ( msg == "-showTodo" ) { | 652 | else if ( msg == "-showTodo" ) { |
626 | mView->viewManager()->showTodoView(); | 653 | mView->viewManager()->showTodoView(); |
627 | } | 654 | } |
628 | else if ( msg == "-showJournal" ) { | 655 | else if ( msg == "-showJournal" ) { |
629 | mView->dateNavigator()->selectDates( 1 ); | 656 | mView->dateNavigator()->selectDates( 1 ); |
630 | mView->dateNavigator()->selectToday(); | 657 | mView->dateNavigator()->selectToday(); |
631 | mView->viewManager()->showJournalView(); | 658 | mView->viewManager()->showJournalView(); |
632 | } | 659 | } |
633 | else if ( msg == "-showKO" ) { | 660 | else if ( msg == "-showKO" ) { |
634 | mView->viewManager()->showNextXView(); | 661 | mView->viewManager()->showNextXView(); |
635 | } | 662 | } |
636 | else if ( msg == "-showWNext" ) { | 663 | else if ( msg == "-showWNext" ) { |
637 | mView->viewManager()->showWhatsNextView(); | 664 | mView->viewManager()->showWhatsNextView(); |
638 | } | 665 | } |
639 | else if ( msg == "nextView()" ) { | 666 | else if ( msg == "nextView()" ) { |
640 | mView->viewManager()->showNextView(); | 667 | mView->viewManager()->showNextView(); |
641 | } | 668 | } |
642 | else if ( msg == "-showNextXView" ) { | 669 | else if ( msg == "-showNextXView" ) { |
643 | mView->viewManager()->showNextXView(); | 670 | mView->viewManager()->showNextXView(); |
644 | } | 671 | } |
645 | 672 | ||
646 | 673 | ||
647 | } | 674 | } |
648 | 675 | ||
649 | showMaximized(); | 676 | showMaximized(); |
650 | raise(); | 677 | raise(); |
651 | } | 678 | } |
652 | void MainWindow::startMultiSync() | 679 | void MainWindow::startMultiSync() |
653 | { | 680 | { |
654 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 681 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
655 | if ( QMessageBox::information( this, i18n("KDE-Pim Sync"), | 682 | if ( QMessageBox::information( this, i18n("KDE-Pim Sync"), |
656 | question, | 683 | question, |
657 | i18n("Yes"), i18n("No"), | 684 | i18n("Yes"), i18n("No"), |
658 | 0, 0 ) != 0 ) { | 685 | 0, 0 ) != 0 ) { |
659 | setCaption(i18n("Aborted! Nothing synced!")); | 686 | setCaption(i18n("Aborted! Nothing synced!")); |
660 | return; | 687 | return; |
661 | } | 688 | } |
662 | mSyncManager->multiSync( false ); | 689 | mSyncManager->multiSync( false ); |
663 | #ifndef DESKTOP_VERSION | 690 | #ifndef DESKTOP_VERSION |
664 | QCopEnvelope e("QPE/Application/kapi", "doRingSync"); | 691 | QCopEnvelope e("QPE/Application/kapi", "doRingSync"); |
665 | #endif | 692 | #endif |
666 | } | 693 | } |
667 | QPixmap MainWindow::loadPixmap( QString name ) | 694 | QPixmap MainWindow::loadPixmap( QString name ) |
668 | { | 695 | { |
669 | return SmallIcon( name ); | 696 | return SmallIcon( name ); |
670 | 697 | ||
671 | } | 698 | } |
672 | void MainWindow::setUsesBigPixmaps ( bool b ) | 699 | void MainWindow::setUsesBigPixmaps ( bool b ) |
673 | { | 700 | { |
674 | qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); | 701 | qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); |
675 | if ( b ) | 702 | if ( b ) |
676 | qDebug("KO: BigPixmaps are not supported "); | 703 | qDebug("KO: BigPixmaps are not supported "); |
677 | } | 704 | } |
678 | void MainWindow::initActions() | 705 | void MainWindow::initActions() |
679 | { | 706 | { |
680 | //KOPrefs::instance()->mShowFullMenu | 707 | //KOPrefs::instance()->mShowFullMenu |
681 | iconToolBar->clear(); | 708 | iconToolBar->clear(); |
682 | KOPrefs *p = KOPrefs::instance(); | 709 | KOPrefs *p = KOPrefs::instance(); |
683 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 710 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
684 | 711 | ||
685 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 712 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
686 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 713 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
687 | mCurrentItemMenu = new QPopupMenu ( this ); | 714 | mCurrentItemMenu = new QPopupMenu ( this ); |
688 | QPopupMenu *nextConflictMenu = new QPopupMenu ( this ); | 715 | QPopupMenu *nextConflictMenu = new QPopupMenu ( this ); |
689 | QPopupMenu *importMenu = new QPopupMenu( this ); | 716 | QPopupMenu *importMenu = new QPopupMenu( this ); |
690 | QPopupMenu *importMenu_X = new QPopupMenu( this ); | 717 | QPopupMenu *importMenu_X = new QPopupMenu( this ); |
691 | QPopupMenu *exportMenu_X = new QPopupMenu( this ); | 718 | QPopupMenu *exportMenu_X = new QPopupMenu( this ); |
692 | QPopupMenu *beamMenu_X = new QPopupMenu( this ); | 719 | QPopupMenu *beamMenu_X = new QPopupMenu( this ); |
693 | selectFilterMenu = new QPopupMenu( this ); | 720 | selectFilterMenu = new QPopupMenu( this ); |
694 | selectFilterMenu->setCheckable( true ); | 721 | selectFilterMenu->setCheckable( true ); |
695 | syncMenu = new QPopupMenu( this ); | 722 | syncMenu = new QPopupMenu( this ); |
696 | configureAgendaMenu = new QPopupMenu( this ); | 723 | configureAgendaMenu = new QPopupMenu( this ); |
697 | configureToolBarMenu = new QPopupMenu( this ); | 724 | configureToolBarMenu = new QPopupMenu( this ); |
698 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 725 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
699 | QIconSet icon; | 726 | QIconSet icon; |
700 | int pixWid = 22, pixHei = 22; | 727 | int pixWid = 22, pixHei = 22; |
701 | QString pathString = ""; | 728 | QString pathString = ""; |
702 | if ( !p->mToolBarMiniIcons ) { | 729 | if ( !p->mToolBarMiniIcons ) { |
703 | if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) { | 730 | if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) { |
704 | pathString += "icons16/"; | 731 | pathString += "icons16/"; |
705 | pixWid = 18; pixHei = 16; | 732 | pixWid = 18; pixHei = 16; |
706 | } | 733 | } |
707 | } else { | 734 | } else { |
708 | pathString += "iconsmini/"; | 735 | pathString += "iconsmini/"; |
709 | pixWid = 18; pixHei = 16; | 736 | pixWid = 18; pixHei = 16; |
710 | } | 737 | } |
711 | 738 | ||
712 | if ( KOPrefs::instance()->mShowFullMenu ) { | 739 | if ( KOPrefs::instance()->mShowFullMenu ) { |
713 | menuBar1 = new KMenuBar( this );//menuBar(); | 740 | menuBar1 = new KMenuBar( this );//menuBar(); |
714 | //setMenuBar( menuBar1 ); | 741 | //setMenuBar( menuBar1 ); |
715 | menuBar1->show(); | 742 | menuBar1->show(); |
716 | menuBar1->insertItem( i18n("File"), importMenu ); | 743 | menuBar1->insertItem( i18n("File"), importMenu ); |
717 | menuBar1->insertItem( i18n("View"), viewMenu ); | 744 | menuBar1->insertItem( i18n("View"), viewMenu ); |
718 | menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu ); | 745 | menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu ); |
719 | menuBar1->insertItem( i18n("Action"), actionMenu ); | 746 | menuBar1->insertItem( i18n("Action"), actionMenu ); |
720 | #ifdef DESKTOP_VERSION | 747 | #ifdef DESKTOP_VERSION |
721 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | 748 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); |
722 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 749 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
723 | #else | 750 | #else |
724 | menuBar1->insertItem( i18n("Sync"), syncMenu ); | 751 | menuBar1->insertItem( i18n("Sync"), syncMenu ); |
725 | menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); | 752 | menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); |
726 | #endif | 753 | #endif |
727 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 754 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
728 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); | 755 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); |
729 | menuBar1->insertItem( i18n("Help"), helpMenu ); | 756 | menuBar1->insertItem( i18n("Help"), helpMenu ); |
730 | } else { | 757 | } else { |
731 | menuBar1 = new KMenuBar( iconToolBar ); | 758 | menuBar1 = new KMenuBar( iconToolBar ); |
732 | QPopupMenu *menuBar = new QPopupMenu( this ); | 759 | QPopupMenu *menuBar = new QPopupMenu( this ); |
733 | icon = loadPixmap( pathString + "z_menu" ); | 760 | icon = loadPixmap( pathString + "z_menu" ); |
734 | menuBar1->insertItem( icon.pixmap(), menuBar); | 761 | menuBar1->insertItem( icon.pixmap(), menuBar); |
735 | //menuBar1->insertItem( i18n("ME"), menuBar); | 762 | //menuBar1->insertItem( i18n("ME"), menuBar); |
736 | menuBar->insertItem( i18n("File"), importMenu ); | 763 | menuBar->insertItem( i18n("File"), importMenu ); |
737 | menuBar->insertItem( i18n("View"), viewMenu ); | 764 | menuBar->insertItem( i18n("View"), viewMenu ); |
738 | menuBar->insertItem( i18n("Edit"), mCurrentItemMenu ); | 765 | menuBar->insertItem( i18n("Edit"), mCurrentItemMenu ); |
739 | menuBar->insertItem( i18n("Action"), actionMenu ); | 766 | menuBar->insertItem( i18n("Action"), actionMenu ); |
740 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); | 767 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); |
741 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 768 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
742 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 769 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
743 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); | 770 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); |
744 | menuBar->insertItem( i18n("Help"), helpMenu ); | 771 | menuBar->insertItem( i18n("Help"), helpMenu ); |
745 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | 772 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); |
746 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | 773 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); |
747 | connect ( menuBar, SIGNAL( aboutToHide () ), this, SLOT ( slotResetFocus() ) ); | 774 | connect ( menuBar, SIGNAL( aboutToHide () ), this, SLOT ( slotResetFocus() ) ); |
748 | } | 775 | } |
749 | connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); | 776 | connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); |
750 | //connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); | 777 | //connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); |
751 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 778 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
752 | connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); | 779 | connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); |
753 | 780 | ||
754 | 781 | ||
755 | mWeekBgColor = iconToolBar->backgroundColor(); | 782 | mWeekBgColor = iconToolBar->backgroundColor(); |
756 | mWeekPixmap.resize( pixWid , pixHei ); | 783 | mWeekPixmap.resize( pixWid , pixHei ); |
757 | mWeekPixmap.fill( mWeekBgColor ); | 784 | mWeekPixmap.fill( mWeekBgColor ); |
758 | icon = mWeekPixmap; | 785 | icon = mWeekPixmap; |
759 | mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); | 786 | mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); |
760 | if ( p-> mShowIconWeekNum ) | 787 | if ( p-> mShowIconWeekNum ) |
761 | mWeekAction->addTo( iconToolBar ); | 788 | mWeekAction->addTo( iconToolBar ); |
762 | mWeekFont = font(); | 789 | mWeekFont = font(); |
763 | 790 | ||
764 | int fontPoint = mWeekFont.pointSize(); | 791 | int fontPoint = mWeekFont.pointSize(); |
765 | QFontMetrics f( mWeekFont ); | 792 | QFontMetrics f( mWeekFont ); |
766 | int fontWid = f.width( "30" ); | 793 | int fontWid = f.width( "30" ); |
767 | while ( fontWid > pixWid ) { | 794 | while ( fontWid > pixWid ) { |
768 | --fontPoint; | 795 | --fontPoint; |
769 | mWeekFont.setPointSize( fontPoint ); | 796 | mWeekFont.setPointSize( fontPoint ); |
770 | QFontMetrics f( mWeekFont ); | 797 | QFontMetrics f( mWeekFont ); |
771 | fontWid = f.width( "30" ); | 798 | fontWid = f.width( "30" ); |
772 | //qDebug("dec-- "); | 799 | //qDebug("dec-- "); |
773 | } | 800 | } |
774 | 801 | ||
775 | connect( mWeekAction, SIGNAL( activated() ), | 802 | connect( mWeekAction, SIGNAL( activated() ), |
776 | this, SLOT( weekAction() ) ); | 803 | this, SLOT( weekAction() ) ); |
777 | 804 | ||
778 | connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); | 805 | connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); |
779 | if ( p->mShowIconFilterview ) { | 806 | if ( p->mShowIconFilterview ) { |
780 | icon = loadPixmap( pathString + "filter" ); | 807 | icon = loadPixmap( pathString + "filter" ); |
781 | actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); | 808 | actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); |
782 | connect( actionFilterMenuTB, SIGNAL( activated() ), | 809 | connect( actionFilterMenuTB, SIGNAL( activated() ), |
783 | this, SLOT( fillFilterMenuTB() ) ); | 810 | this, SLOT( fillFilterMenuTB() ) ); |
784 | actionFilterMenuTB->addTo( iconToolBar ); | 811 | actionFilterMenuTB->addTo( iconToolBar ); |
785 | selectFilterMenuTB = new QPopupMenu( this ); | 812 | selectFilterMenuTB = new QPopupMenu( this ); |
786 | selectFilterMenuTB->setCheckable( true ); | 813 | selectFilterMenuTB->setCheckable( true ); |
787 | connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 814 | connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
788 | } | 815 | } |
789 | 816 | ||
790 | //#endif | 817 | //#endif |
791 | // ****************** | 818 | // ****************** |
792 | QAction *action; | 819 | QAction *action; |
793 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | 820 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); |
794 | configureToolBarMenu->setCheckable( true ); | 821 | configureToolBarMenu->setCheckable( true ); |
795 | 822 | ||
796 | 823 | ||
797 | configureAgendaMenu->setCheckable( true ); | 824 | configureAgendaMenu->setCheckable( true ); |
798 | int iii ; | 825 | int iii ; |
799 | for ( iii = 1;iii<= 10 ;++iii ){ | 826 | for ( iii = 1;iii<= 10 ;++iii ){ |
800 | configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); | 827 | configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); |
801 | } | 828 | } |
802 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | 829 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); |
803 | 830 | ||
804 | connect( configureAgendaMenu, SIGNAL( aboutToShow()), | 831 | connect( configureAgendaMenu, SIGNAL( aboutToShow()), |
805 | this, SLOT( showConfigureAgenda( ) ) ); | 832 | this, SLOT( showConfigureAgenda( ) ) ); |
806 | icon = loadPixmap( pathString + "today" ); | 833 | icon = loadPixmap( pathString + "today" ); |
807 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | 834 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); |
808 | today_action->addTo( actionMenu ); | 835 | today_action->addTo( actionMenu ); |
809 | connect( today_action, SIGNAL( activated() ), | 836 | connect( today_action, SIGNAL( activated() ), |
810 | mView, SLOT( goToday() ) ); | 837 | mView, SLOT( goToday() ) ); |
811 | 838 | ||
812 | icon = loadPixmap( pathString + "picker" ); | 839 | icon = loadPixmap( pathString + "picker" ); |
813 | QAction* dPickerAction = new QAction( i18n("Select Date..."), icon, i18n("Select Date..."), 0, this ); | 840 | QAction* dPickerAction = new QAction( i18n("Select Date..."), icon, i18n("Select Date..."), 0, this ); |
814 | dPickerAction->addTo( actionMenu ); | 841 | dPickerAction->addTo( actionMenu ); |
815 | connect( dPickerAction, SIGNAL( activated() ), | 842 | connect( dPickerAction, SIGNAL( activated() ), |
816 | mView, SLOT( showDatePicker() ) ); | 843 | mView, SLOT( showDatePicker() ) ); |
817 | 844 | ||
818 | icon = loadPixmap( pathString + "search" ); | 845 | icon = loadPixmap( pathString + "search" ); |
819 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | 846 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); |
820 | search_action->addTo( actionMenu ); | 847 | search_action->addTo( actionMenu ); |
821 | connect( search_action, SIGNAL( activated() ), | 848 | connect( search_action, SIGNAL( activated() ), |
822 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | 849 | mView->dialogManager(), SLOT( showSearchDialog() ) ); |
823 | actionMenu->insertItem( i18n("Show next conflict for"), nextConflictMenu ); | 850 | actionMenu->insertItem( i18n("Show next conflict for"), nextConflictMenu ); |
824 | 851 | ||
825 | action = new QAction( "Undo Delete", i18n("All events"), 0, this ); | 852 | action = new QAction( "Undo Delete", i18n("All events"), 0, this ); |
826 | action->addTo( nextConflictMenu ); | 853 | action->addTo( nextConflictMenu ); |
827 | connect( action, SIGNAL( activated() ), | 854 | connect( action, SIGNAL( activated() ), |
828 | mView, SLOT( conflictAll() ) ); | 855 | mView, SLOT( conflictAll() ) ); |
829 | 856 | ||
830 | action = new QAction( "Undo Delete", i18n("Allday events"), 0, this ); | 857 | action = new QAction( "Undo Delete", i18n("Allday events"), 0, this ); |
831 | action->addTo( nextConflictMenu ); | 858 | action->addTo( nextConflictMenu ); |
832 | connect( action, SIGNAL( activated() ), | 859 | connect( action, SIGNAL( activated() ), |
833 | mView, SLOT( conflictAllday() ) ); | 860 | mView, SLOT( conflictAllday() ) ); |
834 | 861 | ||
835 | action = new QAction( "Undo Delete", i18n("Events with time"), 0, this ); | 862 | action = new QAction( "Undo Delete", i18n("Events with time"), 0, this ); |
836 | action->addTo( nextConflictMenu ); | 863 | action->addTo( nextConflictMenu ); |
837 | connect( action, SIGNAL( activated() ), | 864 | connect( action, SIGNAL( activated() ), |
838 | mView, SLOT( conflictNotAll() ) ); | 865 | mView, SLOT( conflictNotAll() ) ); |
839 | 866 | ||
840 | actionMenu->insertSeparator(); | 867 | actionMenu->insertSeparator(); |
841 | 868 | ||
842 | icon = loadPixmap( pathString + "newevent" ); | 869 | icon = loadPixmap( pathString + "newevent" ); |
843 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | 870 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); |
844 | ne_action->addTo( mCurrentItemMenu ); | 871 | ne_action->addTo( mCurrentItemMenu ); |
845 | connect( ne_action, SIGNAL( activated() ), | 872 | connect( ne_action, SIGNAL( activated() ), |
846 | mView, SLOT( newEvent() ) ); | 873 | mView, SLOT( newEvent() ) ); |
847 | icon = loadPixmap( pathString + "newtodo" ); | 874 | icon = loadPixmap( pathString + "newtodo" ); |
848 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | 875 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); |
849 | nt_action->addTo( mCurrentItemMenu ); | 876 | nt_action->addTo( mCurrentItemMenu ); |
850 | connect( nt_action, SIGNAL( activated() ), | 877 | connect( nt_action, SIGNAL( activated() ), |
851 | mView, SLOT( newTodo() ) ); | 878 | mView, SLOT( newTodo() ) ); |
852 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | 879 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, |
853 | this ); | 880 | this ); |
854 | mNewSubTodoAction->addTo( mCurrentItemMenu ); | 881 | mNewSubTodoAction->addTo( mCurrentItemMenu ); |
855 | connect( mNewSubTodoAction, SIGNAL( activated() ), | 882 | connect( mNewSubTodoAction, SIGNAL( activated() ), |
856 | mView, SLOT( newSubTodo() ) ); | 883 | mView, SLOT( newSubTodo() ) ); |
857 | 884 | ||
858 | mCurrentItemMenu->insertSeparator(); | 885 | mCurrentItemMenu->insertSeparator(); |
859 | icon = loadPixmap( pathString + "newevent" ); | 886 | icon = loadPixmap( pathString + "newevent" ); |
860 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | 887 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); |
861 | configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); | 888 | configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); |
862 | configureToolBarMenu->insertSeparator(); | 889 | configureToolBarMenu->insertSeparator(); |
863 | configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); | 890 | configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); |
864 | configureToolBarMenu->insertSeparator(); | 891 | configureToolBarMenu->insertSeparator(); |
865 | configureToolBarMenu->insertItem(i18n("Week Number"), 400); | 892 | configureToolBarMenu->insertItem(i18n("Week Number"), 400); |
866 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | 893 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); |
867 | icon = loadPixmap( pathString + "newtodo" ); | 894 | icon = loadPixmap( pathString + "newtodo" ); |
868 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | 895 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); |
869 | 896 | ||
870 | //actionMenu->insertItem ( i18n("Selected Item"), mCurrentItemMenu); | 897 | //actionMenu->insertItem ( i18n("Selected Item"), mCurrentItemMenu); |
871 | mShowAction = new QAction( "show_incidence", i18n("Show"), 0, this ); | 898 | mShowAction = new QAction( "show_incidence", i18n("Show"), 0, this ); |
872 | mShowAction->addTo( mCurrentItemMenu ); | 899 | mShowAction->addTo( mCurrentItemMenu ); |
873 | connect( mShowAction, SIGNAL( activated() ), | 900 | connect( mShowAction, SIGNAL( activated() ), |
874 | mView, SLOT( showIncidence() ) ); | 901 | mView, SLOT( showIncidence() ) ); |
875 | 902 | ||
876 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | 903 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); |
877 | mEditAction->addTo( mCurrentItemMenu ); | 904 | mEditAction->addTo( mCurrentItemMenu ); |
878 | connect( mEditAction, SIGNAL( activated() ), | 905 | connect( mEditAction, SIGNAL( activated() ), |
879 | mView, SLOT( editIncidence() ) ); | 906 | mView, SLOT( editIncidence() ) ); |
880 | 907 | ||
881 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | 908 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); |
882 | mDeleteAction->addTo( mCurrentItemMenu ); | 909 | mDeleteAction->addTo( mCurrentItemMenu ); |
883 | connect( mDeleteAction, SIGNAL( activated() ), | 910 | connect( mDeleteAction, SIGNAL( activated() ), |
884 | mView, SLOT( deleteIncidence() ) ); | 911 | mView, SLOT( deleteIncidence() ) ); |
885 | 912 | ||
886 | 913 | ||
887 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); | 914 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); |
888 | mCloneAction->addTo( mCurrentItemMenu ); | 915 | mCloneAction->addTo( mCurrentItemMenu ); |
889 | connect( mCloneAction, SIGNAL( activated() ), | 916 | connect( mCloneAction, SIGNAL( activated() ), |
890 | mView, SLOT( cloneIncidence() ) ); | 917 | mView, SLOT( cloneIncidence() ) ); |
891 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); | 918 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); |
892 | mMoveAction->addTo( mCurrentItemMenu ); | 919 | mMoveAction->addTo( mCurrentItemMenu ); |
893 | connect( mMoveAction, SIGNAL( activated() ), | 920 | connect( mMoveAction, SIGNAL( activated() ), |
894 | mView, SLOT( moveIncidence() ) ); | 921 | mView, SLOT( moveIncidence() ) ); |
895 | #ifndef DESKTOP_VERSION | 922 | #ifndef DESKTOP_VERSION |
896 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); | 923 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); |
897 | mBeamAction->addTo(mCurrentItemMenu ); | 924 | mBeamAction->addTo(mCurrentItemMenu ); |
898 | connect( mBeamAction, SIGNAL( activated() ), | 925 | connect( mBeamAction, SIGNAL( activated() ), |
899 | mView, SLOT( beamIncidence() ) ); | 926 | mView, SLOT( beamIncidence() ) ); |
900 | #endif | 927 | #endif |
901 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); | 928 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); |
902 | mCancelAction->addTo( mCurrentItemMenu ); | 929 | mCancelAction->addTo( mCurrentItemMenu ); |
903 | connect( mCancelAction, SIGNAL( activated() ), | 930 | connect( mCancelAction, SIGNAL( activated() ), |
904 | mView, SLOT( toggleCancelIncidence() ) ); | 931 | mView, SLOT( toggleCancelIncidence() ) ); |
905 | 932 | ||
906 | 933 | ||
907 | mCurrentItemMenu->insertSeparator(); | 934 | mCurrentItemMenu->insertSeparator(); |
908 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); | 935 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); |
909 | action->addTo( mCurrentItemMenu ); | 936 | action->addTo( mCurrentItemMenu ); |
910 | connect( action, SIGNAL( activated() ), | 937 | connect( action, SIGNAL( activated() ), |
911 | mView, SLOT( undo_delete() ) ); | 938 | mView, SLOT( undo_delete() ) ); |
912 | 939 | ||
913 | // *********************** | 940 | // *********************** |
914 | if ( KOPrefs::instance()->mVerticalScreen ) { | 941 | if ( KOPrefs::instance()->mVerticalScreen ) { |
915 | icon = SmallIcon( "1updownarrow" ); | 942 | icon = SmallIcon( "1updownarrow" ); |
916 | } else { | 943 | } else { |
917 | icon = SmallIcon("1leftrightarrow" ); | 944 | icon = SmallIcon("1leftrightarrow" ); |
918 | } | 945 | } |
919 | configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); | 946 | configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); |
920 | QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); | 947 | QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); |
921 | FSaction->addTo( viewMenu ); | 948 | FSaction->addTo( viewMenu ); |
922 | connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); | 949 | connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); |
923 | 950 | ||
924 | 951 | ||
925 | icon = loadPixmap( pathString + "filter" ); | 952 | icon = loadPixmap( pathString + "filter" ); |
926 | configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); | 953 | configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); |
927 | icon = loadPixmap( pathString + "configure" ); | 954 | icon = loadPixmap( pathString + "configure" ); |
928 | action = new QAction( i18n("Toggle Resource View"), icon, i18n("Toggle Resource View"), 0, this ); | 955 | action = new QAction( i18n("Toggle Resource View"), icon, i18n("Toggle Resource View"), 0, this ); |
929 | action->addTo( viewMenu ); | 956 | action->addTo( viewMenu ); |
930 | connect( action, SIGNAL( activated() ), | 957 | connect( action, SIGNAL( activated() ), |
931 | mView, SLOT( toggleFilter() ) ); | 958 | mView, SLOT( toggleFilter() ) ); |
932 | mToggleFilter = action; | 959 | mToggleFilter = action; |
933 | icon = loadPixmap( pathString + "navi" ); | 960 | icon = loadPixmap( pathString + "navi" ); |
934 | configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); | 961 | configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); |
935 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | 962 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); |
936 | action->addTo( viewMenu ); | 963 | action->addTo( viewMenu ); |
937 | connect( action, SIGNAL( activated() ), | 964 | connect( action, SIGNAL( activated() ), |
938 | mView, SLOT( toggleDateNavigatorWidget() ) ); | 965 | mView, SLOT( toggleDateNavigatorWidget() ) ); |
939 | mToggleNav = action ; | 966 | mToggleNav = action ; |
940 | icon = loadPixmap( pathString + "allday" ); | 967 | icon = loadPixmap( pathString + "allday" ); |
941 | configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); | 968 | configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); |
942 | action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); | 969 | action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); |
943 | action->addTo( viewMenu ); | 970 | action->addTo( viewMenu ); |
944 | connect( action, SIGNAL( activated() ), | 971 | connect( action, SIGNAL( activated() ), |
945 | mView, SLOT( toggleAllDaySize() ) ); | 972 | mView, SLOT( toggleAllDaySize() ) ); |
946 | mToggleAllday = action; | 973 | mToggleAllday = action; |
947 | 974 | ||
948 | 975 | ||
949 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), | 976 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), |
950 | mToggleNav, SLOT( setEnabled ( bool ) ) ); | 977 | mToggleNav, SLOT( setEnabled ( bool ) ) ); |
951 | //connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), | 978 | //connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), |
952 | // mToggleFilter, SLOT( setEnabled ( bool ) ) ); | 979 | // mToggleFilter, SLOT( setEnabled ( bool ) ) ); |
953 | connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), | 980 | connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), |
954 | mToggleAllday, SLOT( setEnabled ( bool ) ) ); | 981 | mToggleAllday, SLOT( setEnabled ( bool ) ) ); |
955 | // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), | 982 | // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), |
956 | // configureAgendaMenu, SLOT( setEnabled ( bool ) ) ); | 983 | // configureAgendaMenu, SLOT( setEnabled ( bool ) ) ); |
957 | 984 | ||
958 | 985 | ||
959 | dPickerAction->addTo( iconToolBar ); | 986 | dPickerAction->addTo( iconToolBar ); |
960 | viewMenu->insertSeparator(); | 987 | viewMenu->insertSeparator(); |
961 | 988 | ||
962 | if ( p-> mShowIconToggleFull ) | 989 | if ( p-> mShowIconToggleFull ) |
963 | FSaction->addTo( iconToolBar ); | 990 | FSaction->addTo( iconToolBar ); |
964 | if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); | 991 | if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); |
965 | 992 | ||
966 | //******************** | 993 | //******************** |
967 | if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); | 994 | if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); |
968 | 995 | ||
969 | 996 | ||
970 | icon = loadPixmap( pathString + "whatsnext" ); | 997 | icon = loadPixmap( pathString + "whatsnext" ); |
971 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); | 998 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); |
972 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); | 999 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); |
973 | whatsnext_action->addTo( viewMenu ); | 1000 | whatsnext_action->addTo( viewMenu ); |
974 | connect( whatsnext_action, SIGNAL( activated() ), | 1001 | connect( whatsnext_action, SIGNAL( activated() ), |
975 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | 1002 | mView->viewManager(), SLOT( showWhatsNextView() ) ); |
976 | 1003 | ||
977 | icon = loadPixmap( pathString + "xdays" ); | 1004 | icon = loadPixmap( pathString + "xdays" ); |
978 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); | 1005 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); |
979 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); | 1006 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); |
980 | xdays_action->addTo( viewMenu ); | 1007 | xdays_action->addTo( viewMenu ); |
981 | connect( xdays_action, SIGNAL( activated() ), | 1008 | connect( xdays_action, SIGNAL( activated() ), |
982 | mView->viewManager(), SLOT( showNextXView() ) ); | 1009 | mView->viewManager(), SLOT( showNextXView() ) ); |
983 | 1010 | ||
984 | 1011 | ||
985 | icon = loadPixmap( pathString + "journal" ); | 1012 | icon = loadPixmap( pathString + "journal" ); |
986 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); | 1013 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); |
987 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); | 1014 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); |
988 | viewjournal_action->addTo( viewMenu ); | 1015 | viewjournal_action->addTo( viewMenu ); |
989 | connect( viewjournal_action, SIGNAL( activated() ), | 1016 | connect( viewjournal_action, SIGNAL( activated() ), |
990 | mView->viewManager(), SLOT( showJournalView() ) ); | 1017 | mView->viewManager(), SLOT( showJournalView() ) ); |
991 | 1018 | ||
992 | 1019 | ||
993 | icon = loadPixmap( pathString + "day" ); | 1020 | icon = loadPixmap( pathString + "day" ); |
994 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); | 1021 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); |
995 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); | 1022 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); |
996 | day1_action->addTo( viewMenu ); | 1023 | day1_action->addTo( viewMenu ); |
997 | // action->addTo( toolBar ); | 1024 | // action->addTo( toolBar ); |
998 | connect( day1_action, SIGNAL( activated() ), | 1025 | connect( day1_action, SIGNAL( activated() ), |
999 | mView->viewManager(), SLOT( showDayView() ) ); | 1026 | mView->viewManager(), SLOT( showDayView() ) ); |
1000 | 1027 | ||
1001 | icon = loadPixmap( pathString + "workweek" ); | 1028 | icon = loadPixmap( pathString + "workweek" ); |
1002 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); | 1029 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); |
1003 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); | 1030 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); |
1004 | day5_action->addTo( viewMenu ); | 1031 | day5_action->addTo( viewMenu ); |
1005 | connect( day5_action, SIGNAL( activated() ), | 1032 | connect( day5_action, SIGNAL( activated() ), |
1006 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | 1033 | mView->viewManager(), SLOT( showWorkWeekView() ) ); |
1007 | 1034 | ||
1008 | icon = loadPixmap( pathString + "week" ); | 1035 | icon = loadPixmap( pathString + "week" ); |
1009 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); | 1036 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); |
1010 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); | 1037 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); |
1011 | day7_action->addTo( viewMenu ); | 1038 | day7_action->addTo( viewMenu ); |
1012 | connect( day7_action, SIGNAL( activated() ), | 1039 | connect( day7_action, SIGNAL( activated() ), |
1013 | mView->viewManager(), SLOT( showWeekView() ) ); | 1040 | mView->viewManager(), SLOT( showWeekView() ) ); |
1014 | 1041 | ||
1015 | icon = loadPixmap( pathString + "workweek2" ); | 1042 | icon = loadPixmap( pathString + "workweek2" ); |
1016 | configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); | 1043 | configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); |
1017 | QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); | 1044 | QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); |
1018 | day6_action->addTo( viewMenu ); | 1045 | day6_action->addTo( viewMenu ); |
1019 | connect( day6_action, SIGNAL( activated() ), | 1046 | connect( day6_action, SIGNAL( activated() ), |
1020 | mView->viewManager(), SLOT( showMonthViewWeek() ) ); | 1047 | mView->viewManager(), SLOT( showMonthViewWeek() ) ); |
1021 | 1048 | ||
1022 | icon = loadPixmap( pathString + "month" ); | 1049 | icon = loadPixmap( pathString + "month" ); |
1023 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); | 1050 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); |
1024 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); | 1051 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); |
1025 | month_action->addTo( viewMenu ); | 1052 | month_action->addTo( viewMenu ); |
1026 | connect( month_action, SIGNAL( activated() ), | 1053 | connect( month_action, SIGNAL( activated() ), |
1027 | mView->viewManager(), SLOT( showMonthView() ) ); | 1054 | mView->viewManager(), SLOT( showMonthView() ) ); |
1028 | 1055 | ||
1029 | icon = loadPixmap( pathString + "list" ); | 1056 | icon = loadPixmap( pathString + "list" ); |
1030 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); | 1057 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); |
1031 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); | 1058 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); |
1032 | showlist_action->addTo( viewMenu ); | 1059 | showlist_action->addTo( viewMenu ); |
1033 | connect( showlist_action, SIGNAL( activated() ), | 1060 | connect( showlist_action, SIGNAL( activated() ), |
1034 | mView->viewManager(), SLOT( showListView() ) ); | 1061 | mView->viewManager(), SLOT( showListView() ) ); |
1035 | 1062 | ||
1036 | icon = loadPixmap( pathString + "todo" ); | 1063 | icon = loadPixmap( pathString + "todo" ); |
1037 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); | 1064 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); |
1038 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); | 1065 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); |
1039 | todoview_action->addTo( viewMenu ); | 1066 | todoview_action->addTo( viewMenu ); |
1040 | connect( todoview_action, SIGNAL( activated() ), | 1067 | connect( todoview_action, SIGNAL( activated() ), |
1041 | mView->viewManager(), SLOT( showTodoView() ) ); | 1068 | mView->viewManager(), SLOT( showTodoView() ) ); |
1042 | 1069 | ||
1043 | 1070 | ||
1044 | 1071 | ||
1045 | #if 0 | 1072 | #if 0 |
1046 | action = new QAction( "view_timespan", "Time Span", 0, this ); | 1073 | action = new QAction( "view_timespan", "Time Span", 0, this ); |
1047 | action->addTo( viewMenu ); | 1074 | action->addTo( viewMenu ); |
1048 | connect( action, SIGNAL( activated() ), | 1075 | connect( action, SIGNAL( activated() ), |
1049 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | 1076 | mView->viewManager(), SLOT( showTimeSpanView() ) ); |
1050 | #endif | 1077 | #endif |
1051 | 1078 | ||
1052 | 1079 | ||
1053 | 1080 | ||
1054 | action = new QAction( "purge_completed", i18n("Purge Completed..."), 0, | 1081 | action = new QAction( "purge_completed", i18n("Purge Completed..."), 0, |
1055 | this ); | 1082 | this ); |
@@ -2007,682 +2034,683 @@ void MainWindow::save() | |||
2007 | ; // KPimGlobalPrefs::instance()->mLastBackupDate | 2034 | ; // KPimGlobalPrefs::instance()->mLastBackupDate |
2008 | } | 2035 | } |
2009 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 2036 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
2010 | if ( !isMinimized () ) | 2037 | if ( !isMinimized () ) |
2011 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 2038 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
2012 | qDebug("KO: Start saving data to file!"); | 2039 | qDebug("KO: Start saving data to file!"); |
2013 | if ( mView->saveCalendars() ) | 2040 | if ( mView->saveCalendars() ) |
2014 | mCalendarModifiedFlag = false; | 2041 | mCalendarModifiedFlag = false; |
2015 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 2042 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
2016 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 2043 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
2017 | QString savemes; | 2044 | QString savemes; |
2018 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 2045 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
2019 | if ( !isMinimized () ) | 2046 | if ( !isMinimized () ) |
2020 | setCaption(savemes); | 2047 | setCaption(savemes); |
2021 | else | 2048 | else |
2022 | qDebug(savemes); | 2049 | qDebug(savemes); |
2023 | } else { | 2050 | } else { |
2024 | setCaption(i18n("Saving cancelled!")); | 2051 | setCaption(i18n("Saving cancelled!")); |
2025 | mCalendarModifiedFlag = false; | 2052 | mCalendarModifiedFlag = false; |
2026 | slotModifiedChanged( true ); | 2053 | slotModifiedChanged( true ); |
2027 | } | 2054 | } |
2028 | mSyncManager->setBlockSave( false ); | 2055 | mSyncManager->setBlockSave( false ); |
2029 | } | 2056 | } |
2030 | 2057 | ||
2031 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 2058 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
2032 | { | 2059 | { |
2033 | if ( !e->isAutoRepeat() ) { | 2060 | if ( !e->isAutoRepeat() ) { |
2034 | mFlagKeyPressed = false; | 2061 | mFlagKeyPressed = false; |
2035 | } | 2062 | } |
2036 | } | 2063 | } |
2037 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 2064 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
2038 | { | 2065 | { |
2039 | qApp->processEvents(); | 2066 | qApp->processEvents(); |
2040 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 2067 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
2041 | e->ignore(); | 2068 | e->ignore(); |
2042 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 2069 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
2043 | return; | 2070 | return; |
2044 | } | 2071 | } |
2045 | if (! e->isAutoRepeat() ) | 2072 | if (! e->isAutoRepeat() ) |
2046 | mFlagKeyPressed = true; | 2073 | mFlagKeyPressed = true; |
2047 | KOPrefs *p = KOPrefs::instance(); | 2074 | KOPrefs *p = KOPrefs::instance(); |
2048 | bool showSelectedDates = false; | 2075 | bool showSelectedDates = false; |
2049 | int size; | 2076 | int size; |
2050 | int pro = 0; | 2077 | int pro = 0; |
2051 | //qDebug("MainWindow::keyPressEvent "); | 2078 | //qDebug("MainWindow::keyPressEvent "); |
2052 | switch ( e->key() ) { | 2079 | switch ( e->key() ) { |
2053 | case Qt::Key_Right: | 2080 | case Qt::Key_Right: |
2054 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 2081 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
2055 | mView->goNextMonth(); | 2082 | mView->goNextMonth(); |
2056 | else | 2083 | else |
2057 | mView->goNext(); | 2084 | mView->goNext(); |
2058 | showSelectedDates = true; | 2085 | showSelectedDates = true; |
2059 | break; | 2086 | break; |
2060 | case Qt::Key_Left: | 2087 | case Qt::Key_Left: |
2061 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2088 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2062 | mView->goPreviousMonth(); | 2089 | mView->goPreviousMonth(); |
2063 | else | 2090 | else |
2064 | mView->goPrevious(); | 2091 | mView->goPrevious(); |
2065 | showSelectedDates = true; | 2092 | showSelectedDates = true; |
2066 | break; | 2093 | break; |
2067 | case Qt::Key_Down: | 2094 | case Qt::Key_Down: |
2068 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 2095 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
2069 | break; | 2096 | break; |
2070 | case Qt::Key_Up: | 2097 | case Qt::Key_Up: |
2071 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 2098 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
2072 | break; | 2099 | break; |
2073 | case Qt::Key_K: | 2100 | case Qt::Key_K: |
2074 | mView->viewManager()->showMonthViewWeek(); | 2101 | mView->viewManager()->showMonthViewWeek(); |
2075 | break; | 2102 | break; |
2076 | case Qt::Key_I: | 2103 | case Qt::Key_I: |
2077 | mView->showIncidence(); | 2104 | mView->showIncidence(); |
2078 | break; | 2105 | break; |
2079 | case Qt::Key_Delete: | 2106 | case Qt::Key_Delete: |
2080 | case Qt::Key_Backspace: | 2107 | case Qt::Key_Backspace: |
2081 | mView->deleteIncidence(); | 2108 | mView->deleteIncidence(); |
2082 | break; | 2109 | break; |
2083 | case Qt::Key_D: | 2110 | case Qt::Key_D: |
2084 | mView->viewManager()->showDayView(); | 2111 | mView->viewManager()->showDayView(); |
2085 | showSelectedDates = true; | 2112 | showSelectedDates = true; |
2086 | break; | 2113 | break; |
2087 | case Qt::Key_O: | 2114 | case Qt::Key_O: |
2088 | mView->toggleFilerEnabled( ); | 2115 | mView->toggleFilerEnabled( ); |
2089 | break; | 2116 | break; |
2090 | case Qt::Key_0: | 2117 | case Qt::Key_0: |
2091 | case Qt::Key_1: | 2118 | case Qt::Key_1: |
2092 | case Qt::Key_2: | 2119 | case Qt::Key_2: |
2093 | case Qt::Key_3: | 2120 | case Qt::Key_3: |
2094 | case Qt::Key_4: | 2121 | case Qt::Key_4: |
2095 | case Qt::Key_5: | 2122 | case Qt::Key_5: |
2096 | case Qt::Key_6: | 2123 | case Qt::Key_6: |
2097 | case Qt::Key_7: | 2124 | case Qt::Key_7: |
2098 | case Qt::Key_8: | 2125 | case Qt::Key_8: |
2099 | case Qt::Key_9: | 2126 | case Qt::Key_9: |
2100 | pro = e->key()-48; | 2127 | pro = e->key()-48; |
2101 | if ( pro == 0 ) | 2128 | if ( pro == 0 ) |
2102 | pro = 10; | 2129 | pro = 10; |
2103 | if ( e->state() == Qt::ControlButton) | 2130 | if ( e->state() == Qt::ControlButton) |
2104 | pro += 10; | 2131 | pro += 10; |
2105 | break; | 2132 | break; |
2106 | case Qt::Key_M: | 2133 | case Qt::Key_M: |
2107 | mView->viewManager()->showMonthView(); | 2134 | mView->viewManager()->showMonthView(); |
2108 | showSelectedDates = true; | 2135 | showSelectedDates = true; |
2109 | break; | 2136 | break; |
2110 | case Qt::Key_Insert: | 2137 | case Qt::Key_Insert: |
2111 | mView->newEvent(); | 2138 | mView->newEvent(); |
2112 | break; | 2139 | break; |
2113 | case Qt::Key_S : | 2140 | case Qt::Key_S : |
2114 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 2141 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
2115 | mView->newSubTodo(); | 2142 | mView->newSubTodo(); |
2116 | else | 2143 | else |
2117 | mView->dialogManager()->showSearchDialog(); | 2144 | mView->dialogManager()->showSearchDialog(); |
2118 | break; | 2145 | break; |
2119 | case Qt::Key_Y : | 2146 | case Qt::Key_Y : |
2120 | case Qt::Key_Z : | 2147 | case Qt::Key_Z : |
2121 | mView->viewManager()->showWorkWeekView(); | 2148 | mView->viewManager()->showWorkWeekView(); |
2122 | showSelectedDates = true; | 2149 | showSelectedDates = true; |
2123 | break; | 2150 | break; |
2124 | case Qt::Key_U : | 2151 | case Qt::Key_U : |
2125 | mView->viewManager()->showWeekView(); | 2152 | mView->viewManager()->showWeekView(); |
2126 | showSelectedDates = true; | 2153 | showSelectedDates = true; |
2127 | break; | 2154 | break; |
2128 | case Qt::Key_H : | 2155 | case Qt::Key_H : |
2129 | keyBindings(); | 2156 | keyBindings(); |
2130 | break; | 2157 | break; |
2131 | case Qt::Key_W: | 2158 | case Qt::Key_W: |
2132 | mView->viewManager()->showWhatsNextView(); | 2159 | mView->viewManager()->showWhatsNextView(); |
2133 | break; | 2160 | break; |
2134 | case Qt::Key_L: | 2161 | case Qt::Key_L: |
2135 | mView->viewManager()->showListView(); | 2162 | mView->viewManager()->showListView(); |
2136 | break; | 2163 | break; |
2137 | case Qt::Key_N: | 2164 | case Qt::Key_N: |
2138 | mView->viewManager()->showNextView(); | 2165 | mView->viewManager()->showNextView(); |
2139 | break; | 2166 | break; |
2140 | case Qt::Key_V: | 2167 | case Qt::Key_V: |
2141 | mView->viewManager()->showTodoView(); | 2168 | mView->viewManager()->showTodoView(); |
2142 | break; | 2169 | break; |
2143 | case Qt::Key_C: | 2170 | case Qt::Key_C: |
2144 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 2171 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
2145 | break; | 2172 | break; |
2146 | case Qt::Key_P: | 2173 | case Qt::Key_P: |
2147 | mView->showDatePicker( ); | 2174 | mView->showDatePicker( ); |
2148 | break; | 2175 | break; |
2149 | case Qt::Key_F: | 2176 | case Qt::Key_F: |
2150 | mView->editFilters(); | 2177 | mView->editFilters(); |
2151 | break; | 2178 | break; |
2152 | case Qt::Key_R: | 2179 | case Qt::Key_R: |
2153 | mView->toggleFilter(); | 2180 | mView->toggleFilter(); |
2154 | break; | 2181 | break; |
2155 | case Qt::Key_X: | 2182 | case Qt::Key_X: |
2156 | if ( e->state() == Qt::ControlButton ) | 2183 | if ( e->state() == Qt::ControlButton ) |
2157 | mView->toggleDateNavigatorWidget(); | 2184 | mView->toggleDateNavigatorWidget(); |
2158 | else { | 2185 | else { |
2159 | mView->viewManager()->showNextXView(); | 2186 | mView->viewManager()->showNextXView(); |
2160 | showSelectedDates = true; | 2187 | showSelectedDates = true; |
2161 | } | 2188 | } |
2162 | break; | 2189 | break; |
2163 | case Qt::Key_Space: | 2190 | case Qt::Key_Space: |
2164 | mView->toggleExpand(); | 2191 | mView->toggleExpand(); |
2165 | break; | 2192 | break; |
2166 | case Qt::Key_A: | 2193 | case Qt::Key_A: |
2167 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) | 2194 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) |
2168 | mView->showNextAlarms(); | 2195 | mView->showNextAlarms(); |
2169 | else | 2196 | else |
2170 | mView->toggleAllDaySize(); | 2197 | mView->toggleAllDaySize(); |
2171 | break; | 2198 | break; |
2172 | case Qt::Key_T: | 2199 | case Qt::Key_T: |
2173 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2200 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2174 | mView->newTodo(); | 2201 | mView->newTodo(); |
2175 | else { | 2202 | else { |
2176 | mView->goToday(); | 2203 | mView->goToday(); |
2177 | showSelectedDates = true; | 2204 | showSelectedDates = true; |
2178 | } | 2205 | } |
2179 | break; | 2206 | break; |
2180 | case Qt::Key_Q: | 2207 | case Qt::Key_Q: |
2181 | if ( e->state() == Qt::ControlButton ) | 2208 | if ( e->state() == Qt::ControlButton ) |
2182 | mView->conflictNotAll(); | 2209 | mView->conflictNotAll(); |
2183 | else if ( e->state() == Qt::ShiftButton ) | 2210 | else if ( e->state() == Qt::ShiftButton ) |
2184 | mView->conflictAllday(); | 2211 | mView->conflictAllday(); |
2185 | else | 2212 | else |
2186 | mView->conflictAll(); | 2213 | mView->conflictAll(); |
2187 | break; | 2214 | break; |
2188 | case Qt::Key_J: | 2215 | case Qt::Key_J: |
2189 | mView->viewManager()->showJournalView(); | 2216 | mView->viewManager()->showJournalView(); |
2190 | break; | 2217 | break; |
2191 | case Qt::Key_B: | 2218 | case Qt::Key_B: |
2192 | mView->editIncidenceDescription();; | 2219 | mView->editIncidenceDescription();; |
2193 | break; | 2220 | break; |
2194 | // case Qt::Key_Return: | 2221 | // case Qt::Key_Return: |
2195 | case Qt::Key_E: | 2222 | case Qt::Key_E: |
2196 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2223 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2197 | mView->newEvent(); | 2224 | mView->newEvent(); |
2198 | else | 2225 | else |
2199 | mView->editIncidence(); | 2226 | mView->editIncidence(); |
2200 | break; | 2227 | break; |
2201 | case Qt::Key_Plus: | 2228 | case Qt::Key_Plus: |
2202 | size = p->mHourSize +2; | 2229 | size = p->mHourSize +2; |
2203 | if ( size <= 22 ) | 2230 | if ( size <= 22 ) |
2204 | configureAgenda( size ); | 2231 | configureAgenda( size ); |
2205 | break; | 2232 | break; |
2206 | case Qt::Key_Minus: | 2233 | case Qt::Key_Minus: |
2207 | size = p->mHourSize - 2; | 2234 | size = p->mHourSize - 2; |
2208 | if ( size >= 4 ) | 2235 | if ( size >= 4 ) |
2209 | configureAgenda( size ); | 2236 | configureAgenda( size ); |
2210 | break; | 2237 | break; |
2211 | 2238 | ||
2212 | 2239 | ||
2213 | default: | 2240 | default: |
2214 | e->ignore(); | 2241 | e->ignore(); |
2215 | } | 2242 | } |
2216 | if ( pro > 0 ) { | 2243 | if ( pro > 0 ) { |
2217 | selectFilter( pro+1 ); | 2244 | selectFilter( pro+1 ); |
2218 | } | 2245 | } |
2219 | if ( showSelectedDates ) { | 2246 | if ( showSelectedDates ) { |
2220 | ;// setCaptionToDates(); | 2247 | ;// setCaptionToDates(); |
2221 | } | 2248 | } |
2222 | 2249 | ||
2223 | } | 2250 | } |
2224 | void MainWindow::fillFilterMenuTB() | 2251 | void MainWindow::fillFilterMenuTB() |
2225 | { | 2252 | { |
2226 | selectFilterMenuTB->clear(); | 2253 | selectFilterMenuTB->clear(); |
2227 | selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); | 2254 | selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); |
2228 | selectFilterMenuTB->insertSeparator(); | 2255 | selectFilterMenuTB->insertSeparator(); |
2229 | selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); | 2256 | selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); |
2230 | 2257 | ||
2231 | selectFilterMenuTB->insertSeparator(); | 2258 | selectFilterMenuTB->insertSeparator(); |
2232 | QPtrList<CalFilter> fili = mView->filters(); | 2259 | QPtrList<CalFilter> fili = mView->filters(); |
2233 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2260 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2234 | CalFilter *filter = fili.first(); | 2261 | CalFilter *filter = fili.first(); |
2235 | int iii = 2; | 2262 | int iii = 2; |
2236 | bool checkitem = mView->filterView()->filtersEnabled(); | 2263 | bool checkitem = mView->filterView()->filtersEnabled(); |
2237 | while(filter) { | 2264 | while(filter) { |
2238 | selectFilterMenuTB->insertItem( filter->name(), iii ); | 2265 | selectFilterMenuTB->insertItem( filter->name(), iii ); |
2239 | if ( filter == curfilter) | 2266 | if ( filter == curfilter) |
2240 | selectFilterMenuTB->setItemChecked( iii, checkitem ); | 2267 | selectFilterMenuTB->setItemChecked( iii, checkitem ); |
2241 | filter = fili.next(); | 2268 | filter = fili.next(); |
2242 | ++iii; | 2269 | ++iii; |
2243 | } | 2270 | } |
2244 | if ( !checkitem ) | 2271 | if ( !checkitem ) |
2245 | selectFilterMenuTB->setItemChecked( 1, true ); | 2272 | selectFilterMenuTB->setItemChecked( 1, true ); |
2246 | 2273 | ||
2247 | int x = 0; | 2274 | int x = 0; |
2248 | int y = iconToolBar->height(); | 2275 | int y = iconToolBar->height(); |
2249 | int dX = 0; | 2276 | int dX = 0; |
2250 | int dY = 0; | 2277 | int dY = 0; |
2251 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 2278 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
2252 | if ( iconToolBar->y() > height()/2 ) { | 2279 | if ( iconToolBar->y() > height()/2 ) { |
2253 | dY = selectFilterMenuTB->sizeHint().height()+8; | 2280 | dY = selectFilterMenuTB->sizeHint().height()+8; |
2254 | y = 0; | 2281 | y = 0; |
2255 | } | 2282 | } |
2256 | } else { | 2283 | } else { |
2257 | if ( iconToolBar->x() > width()/2 ) { // right side | 2284 | if ( iconToolBar->x() > width()/2 ) { // right side |
2258 | x=0; | 2285 | x=0; |
2259 | dX= selectFilterMenuTB->sizeHint().width()+8; | 2286 | dX= selectFilterMenuTB->sizeHint().width()+8; |
2260 | y = 0; | 2287 | y = 0; |
2261 | } else { | 2288 | } else { |
2262 | x= iconToolBar->width(); | 2289 | x= iconToolBar->width(); |
2263 | y = 0; | 2290 | y = 0; |
2264 | } | 2291 | } |
2265 | } | 2292 | } |
2266 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); | 2293 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); |
2267 | selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); | 2294 | selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); |
2268 | } | 2295 | } |
2269 | void MainWindow::fillFilterMenu() | 2296 | void MainWindow::fillFilterMenu() |
2270 | { | 2297 | { |
2271 | selectFilterMenu->clear(); | 2298 | selectFilterMenu->clear(); |
2272 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); | 2299 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); |
2273 | selectFilterMenu->insertSeparator(); | 2300 | selectFilterMenu->insertSeparator(); |
2274 | selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); | 2301 | selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); |
2275 | 2302 | ||
2276 | selectFilterMenu->insertSeparator(); | 2303 | selectFilterMenu->insertSeparator(); |
2277 | QPtrList<CalFilter> fili = mView->filters(); | 2304 | QPtrList<CalFilter> fili = mView->filters(); |
2278 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2305 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2279 | CalFilter *filter = fili.first(); | 2306 | CalFilter *filter = fili.first(); |
2280 | int iii = 2; | 2307 | int iii = 2; |
2281 | bool checkitem = mView->filterView()->filtersEnabled(); | 2308 | bool checkitem = mView->filterView()->filtersEnabled(); |
2282 | while(filter) { | 2309 | while(filter) { |
2283 | selectFilterMenu->insertItem( filter->name(), iii ); | 2310 | selectFilterMenu->insertItem( filter->name(), iii ); |
2284 | if ( filter == curfilter) | 2311 | if ( filter == curfilter) |
2285 | selectFilterMenu->setItemChecked( iii, checkitem ); | 2312 | selectFilterMenu->setItemChecked( iii, checkitem ); |
2286 | filter = fili.next(); | 2313 | filter = fili.next(); |
2287 | ++iii; | 2314 | ++iii; |
2288 | } | 2315 | } |
2289 | if ( !checkitem ) | 2316 | if ( !checkitem ) |
2290 | selectFilterMenu->setItemChecked( 1, true ); | 2317 | selectFilterMenu->setItemChecked( 1, true ); |
2291 | } | 2318 | } |
2292 | void MainWindow::fillFilterMenuPopup() | 2319 | void MainWindow::fillFilterMenuPopup() |
2293 | { | 2320 | { |
2294 | filterPopupMenu->clear(); | 2321 | filterPopupMenu->clear(); |
2295 | filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); | 2322 | filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); |
2296 | 2323 | ||
2297 | filterPopupMenu->insertSeparator(); | 2324 | filterPopupMenu->insertSeparator(); |
2298 | QPtrList<CalFilter> fili = mView->filters(); | 2325 | QPtrList<CalFilter> fili = mView->filters(); |
2299 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2326 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2300 | CalFilter *filter = fili.first(); | 2327 | CalFilter *filter = fili.first(); |
2301 | int iii = 1; | 2328 | int iii = 1; |
2302 | bool checkitem = mView->filterView()->filtersEnabled(); | 2329 | bool checkitem = mView->filterView()->filtersEnabled(); |
2303 | while(filter) { | 2330 | while(filter) { |
2304 | filterPopupMenu->insertItem( filter->name(), iii ); | 2331 | filterPopupMenu->insertItem( filter->name(), iii ); |
2305 | if ( filter == curfilter) | 2332 | if ( filter == curfilter) |
2306 | filterPopupMenu->setItemChecked( iii, checkitem ); | 2333 | filterPopupMenu->setItemChecked( iii, checkitem ); |
2307 | filter = fili.next(); | 2334 | filter = fili.next(); |
2308 | ++iii; | 2335 | ++iii; |
2309 | } | 2336 | } |
2310 | if ( !checkitem ) | 2337 | if ( !checkitem ) |
2311 | filterPopupMenu->setItemChecked( 0, true ); | 2338 | filterPopupMenu->setItemChecked( 0, true ); |
2312 | } | 2339 | } |
2313 | void MainWindow::selectFilter( int fil ) | 2340 | void MainWindow::selectFilter( int fil ) |
2314 | { | 2341 | { |
2315 | 2342 | ||
2316 | if ( fil == 0 ) { | 2343 | if ( fil == 0 ) { |
2317 | mView->editFilters( ); | 2344 | mView->editFilters( ); |
2318 | } else if ( fil == 1 ){ | 2345 | } else if ( fil == 1 ){ |
2319 | if ( mView->filterView()->filtersEnabled() ) | 2346 | if ( mView->filterView()->filtersEnabled() ) |
2320 | mView->toggleFilerEnabled( ); | 2347 | mView->toggleFilerEnabled( ); |
2321 | } else { | 2348 | } else { |
2322 | if ( !mView->filterView()->filtersEnabled() ) { | 2349 | if ( !mView->filterView()->filtersEnabled() ) { |
2323 | mView->filterView()->blockSignals( true ); | 2350 | mView->filterView()->blockSignals( true ); |
2324 | mView->toggleFilerEnabled( ); | 2351 | mView->toggleFilerEnabled( ); |
2325 | mView->filterView()->blockSignals( false ); | 2352 | mView->filterView()->blockSignals( false ); |
2326 | } | 2353 | } |
2327 | mView->selectFilter( fil-2 ); | 2354 | mView->selectFilter( fil-2 ); |
2328 | } | 2355 | } |
2329 | } | 2356 | } |
2330 | void MainWindow::updateFilterToolbar() | 2357 | void MainWindow::updateFilterToolbar() |
2331 | { | 2358 | { |
2332 | if ( filterMenubar ) { | 2359 | if ( filterMenubar ) { |
2333 | if ( !mView->filterView()->filtersEnabled() ) { | 2360 | if ( !mView->filterView()->filtersEnabled() ) { |
2334 | filterMenubar->changeItem( 0, i18n("No Filter") ); | 2361 | filterMenubar->changeItem( 0, i18n("No Filter") ); |
2335 | } else { | 2362 | } else { |
2336 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 2363 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
2337 | if ( curfilter ) { | 2364 | if ( curfilter ) { |
2338 | QString name = curfilter->name(); | 2365 | QString name = curfilter->name(); |
2339 | if ( name.length() > 12 ) | 2366 | if ( name.length() > 12 ) |
2340 | name = name.left(10)+"..."; | 2367 | name = name.left(10)+"..."; |
2341 | filterMenubar->changeItem( 0, name ); | 2368 | filterMenubar->changeItem( 0, name ); |
2342 | } | 2369 | } |
2343 | } | 2370 | } |
2344 | } | 2371 | } |
2345 | } | 2372 | } |
2346 | void MainWindow::selectFilterPopup( int fil ) | 2373 | void MainWindow::selectFilterPopup( int fil ) |
2347 | { | 2374 | { |
2348 | selectFilter( fil + 1 ); | 2375 | selectFilter( fil + 1 ); |
2349 | 2376 | ||
2350 | } | 2377 | } |
2351 | void MainWindow::configureToolBar( int item ) | 2378 | void MainWindow::configureToolBar( int item ) |
2352 | { | 2379 | { |
2353 | 2380 | ||
2354 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 2381 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
2355 | KOPrefs *p = KOPrefs::instance(); | 2382 | KOPrefs *p = KOPrefs::instance(); |
2356 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 2383 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
2357 | p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); | 2384 | p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); |
2358 | p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); | 2385 | p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); |
2359 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 2386 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
2360 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 2387 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
2361 | p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); | 2388 | p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); |
2362 | p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); | 2389 | p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); |
2363 | p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); | 2390 | p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); |
2364 | p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); | 2391 | p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); |
2365 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 2392 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
2366 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 2393 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
2367 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 2394 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
2368 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 2395 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
2369 | p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); | 2396 | p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); |
2370 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 2397 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
2371 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 2398 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
2372 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 2399 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
2373 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 2400 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
2374 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 2401 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
2375 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 2402 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
2376 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 2403 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
2377 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 2404 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
2378 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 2405 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
2379 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 2406 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
2380 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 2407 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
2381 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 2408 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
2382 | p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); | 2409 | p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); |
2383 | // initActions(); | 2410 | // initActions(); |
2384 | setCaption ( i18n("Toolbar changes needs a restart!") ); | 2411 | setCaption ( i18n("Toolbar changes needs a restart!") ); |
2385 | } | 2412 | } |
2386 | void MainWindow::setCaption ( const QString & c ) | 2413 | void MainWindow::setCaption ( const QString & c ) |
2387 | { | 2414 | { |
2388 | QString cap = c; | 2415 | QString cap = c; |
2389 | cap.replace( QRegExp("\n"), " " ); | 2416 | cap.replace( QRegExp("\n"), " " ); |
2390 | cap = cap.stripWhiteSpace(); | 2417 | cap = cap.stripWhiteSpace(); |
2391 | if ( cap.isEmpty() ) | 2418 | if ( cap.isEmpty() ) |
2392 | cap = "KO/Pi"; | 2419 | cap = "KO/Pi"; |
2393 | QWidget::setCaption( cap ); | 2420 | QWidget::setCaption( cap ); |
2394 | } | 2421 | } |
2395 | void MainWindow::setCaptionToDates() | 2422 | void MainWindow::setCaptionToDates() |
2396 | { | 2423 | { |
2397 | QString selDates; | 2424 | QString selDates; |
2398 | QDate date = mView->startDate(); | 2425 | QDate date = mView->startDate(); |
2399 | if ( ! date.isValid() ) { | 2426 | if ( ! date.isValid() ) { |
2400 | setCaption(""); | 2427 | setCaption(""); |
2401 | return; | 2428 | return; |
2402 | } | 2429 | } |
2403 | selDates = KGlobal::locale()->formatDate( date, true); | 2430 | selDates = KGlobal::locale()->formatDate( date, true); |
2404 | if (mView->startDate() < mView->endDate() ) | 2431 | if (mView->startDate() < mView->endDate() ) |
2405 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 2432 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
2406 | else { | 2433 | else { |
2407 | QString addString; | 2434 | QString addString; |
2408 | if ( date == QDateTime::currentDateTime().date() ) | 2435 | if ( date == QDateTime::currentDateTime().date() ) |
2409 | addString = i18n("Today"); | 2436 | addString = i18n("Today"); |
2410 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 2437 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
2411 | addString = i18n("Tomorrow"); | 2438 | addString = i18n("Tomorrow"); |
2412 | if ( !addString.isEmpty() ) | 2439 | if ( !addString.isEmpty() ) |
2413 | selDates = addString+", "+selDates ; | 2440 | selDates = addString+", "+selDates ; |
2414 | } | 2441 | } |
2415 | setCaption( i18n("Dates: ") + selDates ); | 2442 | setCaption( i18n("Dates: ") + selDates ); |
2416 | 2443 | ||
2417 | } | 2444 | } |
2418 | void MainWindow::showConfigureAgenda( ) | 2445 | void MainWindow::showConfigureAgenda( ) |
2419 | { | 2446 | { |
2420 | int iii; | 2447 | int iii; |
2421 | for ( iii = 1;iii<= 10 ;++iii ){ | 2448 | for ( iii = 1;iii<= 10 ;++iii ){ |
2422 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); | 2449 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); |
2423 | } | 2450 | } |
2424 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); | 2451 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); |
2425 | } | 2452 | } |
2426 | void MainWindow::configureAgenda( int item ) | 2453 | void MainWindow::configureAgenda( int item ) |
2427 | { | 2454 | { |
2428 | if ( KOPrefs::instance()->mHourSize == item ) | 2455 | if ( KOPrefs::instance()->mHourSize == item ) |
2429 | return; | 2456 | return; |
2430 | KOPrefs::instance()->mHourSize=item; | 2457 | KOPrefs::instance()->mHourSize=item; |
2431 | mView->viewManager()->agendaView()->updateConfig(); | 2458 | mView->viewManager()->agendaView()->updateConfig(); |
2432 | } | 2459 | } |
2433 | 2460 | ||
2434 | void MainWindow::saveCalendar() | 2461 | void MainWindow::saveCalendar() |
2435 | { | 2462 | { |
2436 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; | 2463 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; |
2437 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) | 2464 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) |
2438 | bupDir = KGlobalSettings::backupDataDir(); | 2465 | bupDir = KGlobalSettings::backupDataDir(); |
2439 | bupDir = KGlobal::formatMessage ( bupDir, 0 ); | 2466 | bupDir = KGlobal::formatMessage ( bupDir, 0 ); |
2440 | QString bupHint; | 2467 | QString bupHint; |
2441 | if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) | 2468 | if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) |
2442 | bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)"); | 2469 | bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)"); |
2443 | if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return; | 2470 | if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return; |
2444 | bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled; | 2471 | bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled; |
2445 | KPimGlobalPrefs::instance()->mBackupEnabled = false; | 2472 | KPimGlobalPrefs::instance()->mBackupEnabled = false; |
2446 | save(); | 2473 | save(); |
2447 | KPimGlobalPrefs::instance()->mBackupEnabled = enabled; | 2474 | KPimGlobalPrefs::instance()->mBackupEnabled = enabled; |
2448 | backupAllFiles(); | 2475 | backupAllFiles(); |
2449 | } | 2476 | } |
2450 | void MainWindow::loadCalendar() | 2477 | void MainWindow::loadCalendar() |
2451 | { | 2478 | { |
2452 | 2479 | ||
2453 | 2480 | ||
2454 | #if 0 | 2481 | #if 0 |
2455 | QString fn = KOPrefs::instance()->mLastLoadFile; | 2482 | QString fn = KOPrefs::instance()->mLastLoadFile; |
2456 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 2483 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
2457 | 2484 | ||
2458 | if ( fn == "" ) | 2485 | if ( fn == "" ) |
2459 | return; | 2486 | return; |
2460 | QFileInfo info; | 2487 | QFileInfo info; |
2461 | info.setFile( fn ); | 2488 | info.setFile( fn ); |
2462 | QString mess; | 2489 | QString mess; |
2463 | bool loadbup = true; | 2490 | bool loadbup = true; |
2464 | if ( info. exists() ) { | 2491 | if ( info. exists() ) { |
2465 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2492 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2466 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 2493 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
2467 | mess, | 2494 | mess, |
2468 | i18n("Load!"), i18n("Cancel"), 0, | 2495 | i18n("Load!"), i18n("Cancel"), 0, |
2469 | 0, 1 ); | 2496 | 0, 1 ); |
2470 | if ( result != 0 ) { | 2497 | if ( result != 0 ) { |
2471 | loadbup = false; | 2498 | loadbup = false; |
2472 | } | 2499 | } |
2473 | } else { | 2500 | } else { |
2474 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2501 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2475 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 2502 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
2476 | 0, 1 ); | 2503 | 0, 1 ); |
2477 | 2504 | ||
2478 | return; | 2505 | return; |
2479 | } | 2506 | } |
2480 | if ( loadbup ) { | 2507 | if ( loadbup ) { |
2481 | mView->openCalendar( fn ); | 2508 | mView->openCalendar( fn ); |
2482 | KOPrefs::instance()->mLastLoadFile = fn; | 2509 | KOPrefs::instance()->mLastLoadFile = fn; |
2483 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 2510 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
2484 | setCaption(mess); | 2511 | setCaption(mess); |
2485 | } | 2512 | } |
2486 | #endif | 2513 | #endif |
2487 | 2514 | ||
2488 | } | 2515 | } |
2489 | void MainWindow::quickImportIcal() | 2516 | void MainWindow::quickImportIcal() |
2490 | { | 2517 | { |
2491 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 2518 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
2492 | } | 2519 | } |
2493 | void MainWindow::importFile( QString fn, bool quick ) | 2520 | void MainWindow::importFile( QString fn, bool quick ) |
2494 | { | 2521 | { |
2495 | QFileInfo info; | 2522 | QFileInfo info; |
2496 | info.setFile( fn ); | 2523 | info.setFile( fn ); |
2497 | QString mess; | 2524 | QString mess; |
2498 | if ( !info. exists() ) { | 2525 | if ( !info. exists() ) { |
2499 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 2526 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
2500 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2527 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2501 | mess ); | 2528 | mess ); |
2502 | return; | 2529 | return; |
2503 | } | 2530 | } |
2504 | int result = 0; | 2531 | int result = 0; |
2505 | if ( !quick ) { | 2532 | if ( !quick ) { |
2506 | 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 )); | 2533 | 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 )); |
2507 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 2534 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
2508 | mess, | 2535 | mess, |
2509 | "Import", "Cancel", 0, | 2536 | "Import", "Cancel", 0, |
2510 | 0, 1 ); | 2537 | 0, 1 ); |
2511 | } | 2538 | } |
2512 | if ( result == 0 ) { | 2539 | if ( result == 0 ) { |
2513 | if ( mView->openCalendar( fn, true )) { | 2540 | if ( mView->openCalendar( fn, true )) { |
2514 | KOPrefs::instance()->mLastImportFile = fn; | 2541 | KOPrefs::instance()->mLastImportFile = fn; |
2515 | setCaption(i18n("Imported file successfully")); | 2542 | setCaption(i18n("Imported file successfully")); |
2516 | } else { | 2543 | } else { |
2517 | setCaption(i18n("Error importing file")); | 2544 | setCaption(i18n("Error importing file")); |
2518 | } | 2545 | } |
2546 | mView->updateView(); | ||
2519 | } | 2547 | } |
2520 | } | 2548 | } |
2521 | 2549 | ||
2522 | void MainWindow::importIcal() | 2550 | void MainWindow::importIcal() |
2523 | { | 2551 | { |
2524 | 2552 | ||
2525 | QString fn =KOPrefs::instance()->mLastImportFile; | 2553 | QString fn =KOPrefs::instance()->mLastImportFile; |
2526 | 2554 | ||
2527 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 2555 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
2528 | if ( fn == "" ) | 2556 | if ( fn == "" ) |
2529 | return; | 2557 | return; |
2530 | importFile( fn, true ); | 2558 | importFile( fn, true ); |
2531 | 2559 | ||
2532 | } | 2560 | } |
2533 | 2561 | ||
2534 | void MainWindow::exportVCalendar() | 2562 | void MainWindow::exportVCalendar() |
2535 | { | 2563 | { |
2536 | QString fn = KOPrefs::instance()->mLastVcalFile; | 2564 | QString fn = KOPrefs::instance()->mLastVcalFile; |
2537 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 2565 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
2538 | if ( fn == "" ) | 2566 | if ( fn == "" ) |
2539 | return; | 2567 | return; |
2540 | QFileInfo info; | 2568 | QFileInfo info; |
2541 | info.setFile( fn ); | 2569 | info.setFile( fn ); |
2542 | QString mes; | 2570 | QString mes; |
2543 | bool createbup = true; | 2571 | bool createbup = true; |
2544 | if ( info. exists() ) { | 2572 | if ( info. exists() ) { |
2545 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 2573 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
2546 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 2574 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
2547 | i18n("Overwrite!"), i18n("Cancel"), 0, | 2575 | i18n("Overwrite!"), i18n("Cancel"), 0, |
2548 | 0, 1 ); | 2576 | 0, 1 ); |
2549 | if ( result != 0 ) { | 2577 | if ( result != 0 ) { |
2550 | createbup = false; | 2578 | createbup = false; |
2551 | } | 2579 | } |
2552 | } | 2580 | } |
2553 | if ( createbup ) { | 2581 | if ( createbup ) { |
2554 | if ( mView->exportVCalendar( fn ) ) { | 2582 | if ( mView->exportVCalendar( fn ) ) { |
2555 | KOPrefs::instance()->mLastVcalFile = fn; | 2583 | KOPrefs::instance()->mLastVcalFile = fn; |
2556 | if ( fn.length() > 20 ) | 2584 | if ( fn.length() > 20 ) |
2557 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 2585 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
2558 | else | 2586 | else |
2559 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 2587 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
2560 | setCaption(mes); | 2588 | setCaption(mes); |
2561 | } | 2589 | } |
2562 | } | 2590 | } |
2563 | 2591 | ||
2564 | } | 2592 | } |
2565 | QString MainWindow::sentSyncFile() | 2593 | QString MainWindow::sentSyncFile() |
2566 | { | 2594 | { |
2567 | #ifdef DESKTOP_VERSION | 2595 | #ifdef DESKTOP_VERSION |
2568 | return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) ); | 2596 | return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) ); |
2569 | #else | 2597 | #else |
2570 | return QString( "/tmp/copysynccal.ics" ); | 2598 | return QString( "/tmp/copysynccal.ics" ); |
2571 | #endif | 2599 | #endif |
2572 | } | 2600 | } |
2573 | 2601 | ||
2574 | void MainWindow::syncFileRequest() | 2602 | void MainWindow::syncFileRequest() |
2575 | { | 2603 | { |
2576 | while ( mSyncManager->blockSave() ) { | 2604 | while ( mSyncManager->blockSave() ) { |
2577 | qApp->processEvents(); | 2605 | qApp->processEvents(); |
2578 | } | 2606 | } |
2579 | mSyncManager->setBlockSave(true); | 2607 | mSyncManager->setBlockSave(true); |
2580 | 2608 | ||
2581 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2609 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
2582 | mSyncManager->slotSyncMenu( 999 ); | 2610 | mSyncManager->slotSyncMenu( 999 ); |
2583 | } | 2611 | } |
2584 | 2612 | ||
2585 | setCaption(i18n("Saving Data to temp file ..." )); | 2613 | setCaption(i18n("Saving Data to temp file ..." )); |
2586 | mView->saveCalendar( sentSyncFile() ); | 2614 | mView->saveCalendar( sentSyncFile() ); |
2587 | setCaption(i18n("Data saved to temp file!" )); | 2615 | setCaption(i18n("Data saved to temp file!" )); |
2588 | mSyncManager->setBlockSave( false ); | 2616 | mSyncManager->setBlockSave( false ); |
2589 | 2617 | ||
2590 | } | 2618 | } |
2591 | void MainWindow::getFile( bool success ) | 2619 | void MainWindow::getFile( bool success ) |
2592 | { | 2620 | { |
2593 | if ( ! success ) { | 2621 | if ( ! success ) { |
2594 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2622 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2595 | return; | 2623 | return; |
2596 | } | 2624 | } |
2597 | mView->mergeFile( sentSyncFile() ); | 2625 | mView->mergeFile( sentSyncFile() ); |
2598 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2626 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
2599 | mSyncManager->slotSyncMenu( 999 ); | 2627 | mSyncManager->slotSyncMenu( 999 ); |
2600 | } | 2628 | } |
2601 | setCaption( i18n("Pi-Sync successful!") ); | 2629 | setCaption( i18n("Pi-Sync successful!") ); |
2602 | } | 2630 | } |
2603 | void MainWindow::printListView() | 2631 | void MainWindow::printListView() |
2604 | { | 2632 | { |
2605 | 2633 | ||
2606 | QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items."); | 2634 | QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items."); |
2607 | 2635 | ||
2608 | KMessageBox::information( this, message); | 2636 | KMessageBox::information( this, message); |
2609 | } | 2637 | } |
2610 | void MainWindow::printSel( ) | 2638 | void MainWindow::printSel( ) |
2611 | { | 2639 | { |
2612 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 2640 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
2613 | } | 2641 | } |
2614 | 2642 | ||
2615 | void MainWindow::printCal() | 2643 | void MainWindow::printCal() |
2616 | { | 2644 | { |
2617 | mView->print();//mCp->showDialog(); | 2645 | mView->print();//mCp->showDialog(); |
2618 | } | 2646 | } |
2619 | 2647 | ||
2620 | 2648 | ||
2621 | #include "libkdepim/kdatepicker.h" | 2649 | #include "libkdepim/kdatepicker.h" |
2622 | #include <kdatetbl.h> | 2650 | #include <kdatetbl.h> |
2623 | 2651 | ||
2624 | void MainWindow::weekAction() | 2652 | void MainWindow::weekAction() |
2625 | { | 2653 | { |
2626 | int month; | 2654 | int month; |
2627 | KPopupFrame* popup = new KPopupFrame(this); | 2655 | KPopupFrame* popup = new KPopupFrame(this); |
2628 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); | 2656 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); |
2629 | // ----- | 2657 | // ----- |
2630 | picker->resize(picker->sizeHint()); | 2658 | picker->resize(picker->sizeHint()); |
2631 | popup->setMainWidget(picker); | 2659 | popup->setMainWidget(picker); |
2632 | picker->setFocus(); | 2660 | picker->setFocus(); |
2633 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 2661 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
2634 | int x = 0; | 2662 | int x = 0; |
2635 | int y = iconToolBar->height(); | 2663 | int y = iconToolBar->height(); |
2636 | int dX = 0; | 2664 | int dX = 0; |
2637 | int dY = 0; | 2665 | int dY = 0; |
2638 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 2666 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
2639 | if ( iconToolBar->y() > height()/2 ) { | 2667 | if ( iconToolBar->y() > height()/2 ) { |
2640 | dY = picker->sizeHint().height()+8; | 2668 | dY = picker->sizeHint().height()+8; |
2641 | y = 0; | 2669 | y = 0; |
2642 | } | 2670 | } |
2643 | } else { | 2671 | } else { |
2644 | if ( iconToolBar->x() > width()/2 ) { // right side | 2672 | if ( iconToolBar->x() > width()/2 ) { // right side |
2645 | x=0; | 2673 | x=0; |
2646 | dX= picker->sizeHint().width()+8; | 2674 | dX= picker->sizeHint().width()+8; |
2647 | y = 0; | 2675 | y = 0; |
2648 | } else { | 2676 | } else { |
2649 | x= iconToolBar->width(); | 2677 | x= iconToolBar->width(); |
2650 | y = 0; | 2678 | y = 0; |
2651 | } | 2679 | } |
2652 | } | 2680 | } |
2653 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); | 2681 | //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); |
2654 | if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) | 2682 | if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) |
2655 | { | 2683 | { |
2656 | month = picker->getResult(); | 2684 | month = picker->getResult(); |
2657 | emit selectWeek ( month ); | 2685 | emit selectWeek ( month ); |
2658 | //qDebug("weekSelected %d ", month); | 2686 | //qDebug("weekSelected %d ", month); |
2659 | } | 2687 | } |
2660 | delete popup; | 2688 | delete popup; |
2661 | } | 2689 | } |
2662 | 2690 | ||
2663 | void MainWindow::hideEvent ( QHideEvent * ) | 2691 | void MainWindow::hideEvent ( QHideEvent * ) |
2664 | { | 2692 | { |
2665 | QString message; | 2693 | QString message; |
2666 | QDateTime nextA = mCalendar->nextAlarmEventDateTime(); | 2694 | QDateTime nextA = mCalendar->nextAlarmEventDateTime(); |
2667 | if ( nextA.isValid() ) { | 2695 | if ( nextA.isValid() ) { |
2668 | QString sum = mCalendar->nextSummary(); | 2696 | QString sum = mCalendar->nextSummary(); |
2669 | 2697 | ||
2670 | message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); | 2698 | message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); |
2671 | setCaption( message ); | 2699 | setCaption( message ); |
2672 | } | 2700 | } |
2673 | } | 2701 | } |
2674 | 2702 | ||
2675 | void MainWindow::resizeEvent( QResizeEvent* e) | 2703 | void MainWindow::resizeEvent( QResizeEvent* e) |
2676 | { | 2704 | { |
2677 | #ifndef DESKTOP_VERSION | 2705 | #ifndef DESKTOP_VERSION |
2678 | if ( filterToolBar ) { | 2706 | if ( filterToolBar ) { |
2679 | if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { | 2707 | if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { |
2680 | if (QApplication::desktop()->width() > QApplication::desktop()->height() ) | 2708 | if (QApplication::desktop()->width() > QApplication::desktop()->height() ) |
2681 | filterToolBar->hide(); | 2709 | filterToolBar->hide(); |
2682 | else | 2710 | else |
2683 | filterToolBar->show(); | 2711 | filterToolBar->show(); |
2684 | } | 2712 | } |
2685 | } | 2713 | } |
2686 | #endif | 2714 | #endif |
2687 | QMainWindow::resizeEvent( e); | 2715 | QMainWindow::resizeEvent( e); |
2688 | } | 2716 | } |
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 7d3d492..fdcf7c4 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -1,178 +1,184 @@ | |||
1 | #ifndef KORGE_MAINWINDOW_H | 1 | #ifndef KORGE_MAINWINDOW_H |
2 | #define KORGE_MAINWINDOW_H | 2 | #define KORGE_MAINWINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qtimer.h> | 5 | #include <qtimer.h> |
6 | #include <qdict.h> | 6 | #include <qdict.h> |
7 | #include <qfile.h> | 7 | #include <qfile.h> |
8 | #include <qmenubar.h> | 8 | #include <qmenubar.h> |
9 | #include <qtextstream.h> | 9 | #include <qtextstream.h> |
10 | #include <qregexp.h> | 10 | #include <qregexp.h> |
11 | 11 | ||
12 | #include <libkcal/incidence.h> | 12 | #include <libkcal/incidence.h> |
13 | #include <ksyncmanager.h> | 13 | #include <ksyncmanager.h> |
14 | #include <kpopupmenu.h> | 14 | #include <kpopupmenu.h> |
15 | #ifndef DESKTOP_VERSION | 15 | #ifndef DESKTOP_VERSION |
16 | #include <qcopchannel_qws.h> | 16 | #include <qcopchannel_qws.h> |
17 | #endif | 17 | #endif |
18 | class QAction; | 18 | class QAction; |
19 | class CalendarView; | 19 | class CalendarView; |
20 | class KSyncProfile; | 20 | class KSyncProfile; |
21 | #ifdef DESKTOP_VERSION | 21 | #ifdef DESKTOP_VERSION |
22 | 22 | ||
23 | #define QPEToolBar QToolBar | 23 | #define QPEToolBar QToolBar |
24 | #endif | 24 | #endif |
25 | class QPEToolBar; | 25 | class QPEToolBar; |
26 | 26 | ||
27 | 27 | ||
28 | namespace KCal { | 28 | namespace KCal { |
29 | class CalendarLocal; | 29 | class CalendarLocal; |
30 | } | 30 | } |
31 | 31 | ||
32 | using namespace KCal; | 32 | using namespace KCal; |
33 | 33 | ||
34 | class MainWindow : public QMainWindow | 34 | class MainWindow : public QMainWindow |
35 | { | 35 | { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | public: | 37 | public: |
38 | MainWindow( QWidget *parent = 0, const char *name = 0 ); | 38 | MainWindow( QWidget *parent = 0, const char *name = 0 ); |
39 | ~MainWindow(); | 39 | ~MainWindow(); |
40 | bool beamReceiveEnabled(); | 40 | bool beamReceiveEnabled(); |
41 | static QString defaultFileName(); | 41 | static QString defaultFileName(); |
42 | static QString syncFileName(); | 42 | static QString syncFileName(); |
43 | static QString resourcePath(); | 43 | static QString resourcePath(); |
44 | public slots: | 44 | public slots: |
45 | void setUsesBigPixmaps ( bool ); | 45 | void setUsesBigPixmaps ( bool ); |
46 | void setCaption ( const QString & ); | 46 | void setCaption ( const QString & ); |
47 | void updateWeekNum(const KCal::DateList &); | 47 | void updateWeekNum(const KCal::DateList &); |
48 | void updateWeek(QDate); | 48 | void updateWeek(QDate); |
49 | void updateFilterToolbar(); | 49 | void updateFilterToolbar(); |
50 | virtual void showMaximized (); | 50 | virtual void showMaximized (); |
51 | void configureAgenda( int ); | 51 | void configureAgenda( int ); |
52 | void recieve( const QCString& msg, const QByteArray& data ); | 52 | void recieve( const QCString& msg, const QByteArray& data ); |
53 | void receiveStart( const QCString& msg, const QByteArray& data ); | ||
53 | protected slots: | 54 | protected slots: |
55 | void loadDataAfterStart(); | ||
54 | void calHint(); | 56 | void calHint(); |
55 | void startMultiSync(); | 57 | void startMultiSync(); |
56 | void setCaptionToDates(); | 58 | void setCaptionToDates(); |
57 | void weekAction(); | 59 | void weekAction(); |
58 | void about(); | 60 | void about(); |
59 | void licence(); | 61 | void licence(); |
60 | void faq(); | 62 | void faq(); |
61 | void usertrans(); | 63 | void usertrans(); |
62 | void features(); | 64 | void features(); |
63 | void synchowto(); | 65 | void synchowto(); |
64 | void storagehowto(); | 66 | void storagehowto(); |
65 | void timetrackinghowto(); | 67 | void timetrackinghowto(); |
66 | void kdesynchowto(); | 68 | void kdesynchowto(); |
67 | void multisynchowto(); | 69 | void multisynchowto(); |
68 | void whatsNew(); | 70 | void whatsNew(); |
69 | void keyBindings(); | 71 | void keyBindings(); |
70 | void aboutAutoSaving();; | 72 | void aboutAutoSaving();; |
71 | void aboutKnownBugs(); | 73 | void aboutKnownBugs(); |
72 | 74 | ||
73 | void processIncidenceSelection( Incidence * ); | 75 | void processIncidenceSelection( Incidence * ); |
74 | 76 | ||
75 | void importQtopia(); | 77 | void importQtopia(); |
76 | void importBday(); | 78 | void importBday(); |
77 | void importOL(); | 79 | void importOL(); |
78 | void importIcal(); | 80 | void importIcal(); |
79 | void importFile( QString, bool ); | 81 | void importFile( QString, bool ); |
80 | void quickImportIcal(); | 82 | void quickImportIcal(); |
81 | 83 | ||
82 | void slotModifiedChanged( bool ); | 84 | void slotModifiedChanged( bool ); |
83 | 85 | ||
84 | void save(); | 86 | void save(); |
85 | void backupAllFiles(); | 87 | void backupAllFiles(); |
86 | void saveStopTimer(); | 88 | void saveStopTimer(); |
87 | void configureToolBar( int ); | 89 | void configureToolBar( int ); |
88 | void printSel(); | 90 | void printSel(); |
89 | void printCal(); | 91 | void printCal(); |
90 | void printListView(); | 92 | void printListView(); |
91 | void saveCalendar(); | 93 | void saveCalendar(); |
92 | void loadCalendar(); | 94 | void loadCalendar(); |
93 | void exportVCalendar(); | 95 | void exportVCalendar(); |
94 | void fillFilterMenu(); | 96 | void fillFilterMenu(); |
95 | void fillFilterMenuTB(); | 97 | void fillFilterMenuTB(); |
96 | void selectFilter( int ); | 98 | void selectFilter( int ); |
97 | void fillFilterMenuPopup(); | 99 | void fillFilterMenuPopup(); |
98 | void selectFilterPopup( int ); | 100 | void selectFilterPopup( int ); |
99 | void exportToPhone( int ); | 101 | void exportToPhone( int ); |
100 | void toggleBeamReceive(); | 102 | void toggleBeamReceive(); |
101 | void disableBR(bool); | 103 | void disableBR(bool); |
102 | signals: | 104 | signals: |
103 | void selectWeek ( int ); | 105 | void selectWeek ( int ); |
104 | private slots: | 106 | private slots: |
105 | void slotResetFocus(); | 107 | void slotResetFocus(); |
106 | void slotResetFocusLoop(); | 108 | void slotResetFocusLoop(); |
107 | void showConfigureAgenda(); | 109 | void showConfigureAgenda(); |
108 | void getFile( bool ); | 110 | void getFile( bool ); |
109 | void syncFileRequest(); | 111 | void syncFileRequest(); |
110 | 112 | ||
111 | protected: | 113 | protected: |
112 | int mFocusLoop; | 114 | int mFocusLoop; |
113 | void hideEvent ( QHideEvent * ); | 115 | void hideEvent ( QHideEvent * ); |
114 | QString sentSyncFile(); | 116 | QString sentSyncFile(); |
115 | void displayText( QString, QString); | 117 | void displayText( QString, QString); |
116 | void enableIncidenceActions( bool ); | 118 | void enableIncidenceActions( bool ); |
117 | 119 | ||
118 | private: | 120 | private: |
121 | |||
122 | QCString mCStringMess; | ||
123 | QByteArray mByteData; | ||
124 | |||
119 | //void setMenuBar( QMenuBar * ); | 125 | //void setMenuBar( QMenuBar * ); |
120 | bool mBRdisabled; | 126 | bool mBRdisabled; |
121 | #ifndef DESKTOP_VERSION | 127 | #ifndef DESKTOP_VERSION |
122 | QCopChannel* infrared; | 128 | QCopChannel* infrared; |
123 | #endif | 129 | #endif |
124 | QAction* brAction; | 130 | QAction* brAction; |
125 | KSyncManager* mSyncManager; | 131 | KSyncManager* mSyncManager; |
126 | bool mClosed; | 132 | bool mClosed; |
127 | void saveOnClose(); | 133 | void saveOnClose(); |
128 | bool mFlagKeyPressed; | 134 | bool mFlagKeyPressed; |
129 | bool mBlockAtStartup; | 135 | bool mBlockAtStartup; |
130 | KMenuBar *menuBar1; | 136 | KMenuBar *menuBar1; |
131 | QPEToolBar *iconToolBar; | 137 | QPEToolBar *iconToolBar; |
132 | QPEToolBar *viewToolBar; | 138 | QPEToolBar *viewToolBar; |
133 | QPEToolBar *navigatorToolBar; | 139 | QPEToolBar *navigatorToolBar; |
134 | QPEToolBar *filterToolBar; | 140 | QPEToolBar *filterToolBar; |
135 | KMenuBar *filterMenubar; | 141 | KMenuBar *filterMenubar; |
136 | QPopupMenu * filterPopupMenu; | 142 | QPopupMenu * filterPopupMenu; |
137 | QPopupMenu * mCurrentItemMenu; | 143 | QPopupMenu * mCurrentItemMenu; |
138 | void initActions(); | 144 | void initActions(); |
139 | void setDefaultPreferences(); | 145 | void setDefaultPreferences(); |
140 | void resizeEvent( QResizeEvent* e); | 146 | void resizeEvent( QResizeEvent* e); |
141 | void keyPressEvent ( QKeyEvent * ) ; | 147 | void keyPressEvent ( QKeyEvent * ) ; |
142 | void keyReleaseEvent ( QKeyEvent * ) ; | 148 | void keyReleaseEvent ( QKeyEvent * ) ; |
143 | QPopupMenu *configureToolBarMenu; | 149 | QPopupMenu *configureToolBarMenu; |
144 | QPopupMenu *selectFilterMenu; | 150 | QPopupMenu *selectFilterMenu; |
145 | QPopupMenu *selectFilterMenuTB; | 151 | QPopupMenu *selectFilterMenuTB; |
146 | QPopupMenu *configureAgendaMenu, *syncMenu; | 152 | QPopupMenu *configureAgendaMenu, *syncMenu; |
147 | CalendarLocal *mCalendar; | 153 | CalendarLocal *mCalendar; |
148 | CalendarView *mView; | 154 | CalendarView *mView; |
149 | QAction *mNewSubTodoAction; | 155 | QAction *mNewSubTodoAction; |
150 | QAction *mWeekAction; | 156 | QAction *mWeekAction; |
151 | QFont mWeekFont; | 157 | QFont mWeekFont; |
152 | QPixmap mWeekPixmap; | 158 | QPixmap mWeekPixmap; |
153 | QColor mWeekBgColor; | 159 | QColor mWeekBgColor; |
154 | 160 | ||
155 | QAction *mShowAction; | 161 | QAction *mShowAction; |
156 | QAction *mEditAction; | 162 | QAction *mEditAction; |
157 | QAction *mDeleteAction; | 163 | QAction *mDeleteAction; |
158 | QAction *mCloneAction; | 164 | QAction *mCloneAction; |
159 | QAction *mMoveAction; | 165 | QAction *mMoveAction; |
160 | QAction *mBeamAction; | 166 | QAction *mBeamAction; |
161 | QAction *mCancelAction; | 167 | QAction *mCancelAction; |
162 | QAction *mPrintSelAction; | 168 | QAction *mPrintSelAction; |
163 | 169 | ||
164 | QAction *mToggleNav; | 170 | QAction *mToggleNav; |
165 | QAction *mToggleFilter; | 171 | QAction *mToggleFilter; |
166 | QAction *mToggleAllday; | 172 | QAction *mToggleAllday; |
167 | QAction *actionFilterMenuTB; | 173 | QAction *actionFilterMenuTB; |
168 | 174 | ||
169 | void closeEvent( QCloseEvent* ce ); | 175 | void closeEvent( QCloseEvent* ce ); |
170 | QTimer mSaveTimer; | 176 | QTimer mSaveTimer; |
171 | //bool mBlockSaveFlag; | 177 | //bool mBlockSaveFlag; |
172 | bool mCalendarModifiedFlag; | 178 | bool mCalendarModifiedFlag; |
173 | QPixmap loadPixmap( QString ); | 179 | QPixmap loadPixmap( QString ); |
174 | QPixmap listviewPix, listviewPix0, listviewPix20, listviewPix40, listviewPix60, listviewPix80, journalPix; | 180 | QPixmap listviewPix, listviewPix0, listviewPix20, listviewPix40, listviewPix60, listviewPix80, journalPix; |
175 | }; | 181 | }; |
176 | 182 | ||
177 | 183 | ||
178 | #endif | 184 | #endif |