summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-29 10:36:31 (UTC)
committer zautrix <zautrix>2005-06-29 10:36:31 (UTC)
commitb7044dfc9516d546683973985555c481d59fc677 (patch) (side-by-side diff)
treeb521090cfc8eb6c8c6a6f6f8167c83058ea1361b
parentf226b4cd2ce06a6948811fe04d80fe3ffa44f695 (diff)
downloadkdepimpi-b7044dfc9516d546683973985555c481d59fc677.zip
kdepimpi-b7044dfc9516d546683973985555c481d59fc677.tar.gz
kdepimpi-b7044dfc9516d546683973985555c481d59fc677.tar.bz2
journal fixxx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp1
-rw-r--r--korganizer/journalentry.cpp61
-rw-r--r--korganizer/journalentry.h5
-rw-r--r--korganizer/kojournalview.cpp110
-rw-r--r--korganizer/kojournalview.h10
-rw-r--r--korganizer/koviewmanager.cpp7
-rw-r--r--korganizer/koviewmanager.h1
-rw-r--r--libkcal/calendar.h1
-rw-r--r--libkcal/calendarlocal.cpp14
-rw-r--r--libkcal/calendarlocal.h1
10 files changed, 173 insertions, 38 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index a62145a..697093e 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -454,24 +454,25 @@ void CalendarView::init()
mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
"CalendarView::DateNavigator", QDate::currentDate());
#endif
// mDateNavigator->blockSignals( true );
//leftFrameLayout->addWidget( mDateNavigator );
mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) );
connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
+ connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) );
connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) );
connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) );
connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) );
connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) );
mTodoList->setNavigator( mNavigator );
#if 0
if ( QApplication::desktop()->width() < 480 ) {
leftFrameLayout->addWidget(mFilterView);
leftFrameLayout->addWidget(mTodoList, 2 );
} else {
leftFrameLayout->addWidget(mTodoList,2 );
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp
index c19a5ca..7274849 100644
--- a/korganizer/journalentry.cpp
+++ b/korganizer/journalentry.cpp
@@ -47,62 +47,81 @@
#include <libkcal/calendarresources.h>
#include <libkcal/resourcecalendar.h>
#include <kresources/resourceselectdialog.h>
#include "journalentry.h"
//#include "journalentry.moc"
#ifndef DESKTOP_VERSION
#include <qpe/qpeapplication.h>
#endif
JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) :
QFrame(parent)
{
+ showOnlyMode = false;
mCalendar = calendar;
mJournal = 0;
mDirty = false;
QHBox * vb = new QHBox ( this );
+ QPushButton * newJournal = new QPushButton( vb );
+ QIconSet icon;
+ if ( QApplication::desktop()->width() < 321 )
+ icon = SmallIcon("ko16old");
+ else
+ icon = SmallIcon("ko24old");
+ newJournal->setIconSet (icon ) ;
+ int size = newJournal->sizeHint().height();
+ newJournal->setFixedSize( size, size );
+
+
+ QPushButton * toggleJournal = new QPushButton( vb );
+ icon = SmallIcon("1updownarrow");
+ toggleJournal->setIconSet (icon ) ;
+ //int size = toggleJournal->sizeHint().height();
+ toggleJournal->setFixedSize( size * 2 /3 , size );
+
+
+
+ mTitleLabel = new QLabel(i18n("Title"),vb);
+ mTitleLabel->setMargin(2);
+ mTitleLabel->setAlignment(AlignCenter);
QPushButton * loadTemplate = new QPushButton( vb );
QPushButton * saveTemplate = new QPushButton( vb );
- QIconSet icon;
if ( QApplication::desktop()->width() < 321 )
icon = SmallIcon("fileexport16");
else
icon = SmallIcon("fileexport");
saveTemplate->setIconSet (icon ) ;
- int size = saveTemplate->sizeHint().height();
+ //size = saveTemplate->sizeHint().height();
saveTemplate->setFixedSize( size, size );
if ( QApplication::desktop()->width() < 321 )
icon = SmallIcon("fileimport16");
else
icon = SmallIcon("fileimport");
loadTemplate->setIconSet (icon ) ;
loadTemplate->setFixedSize( size, size );
-
- mTitleLabel = new QLabel(i18n("Title"),vb);
- mTitleLabel->setMargin(2);
- mTitleLabel->setAlignment(AlignCenter);
-
mEditor = new KTextEdit(this);
connect(mEditor,SIGNAL(textChanged()),SLOT(setDirty()));
#ifndef DESKTOP_VERSION
QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold );
#endif
mEditor->setWordWrap( KTextEdit::WidgetWidth );
QBoxLayout *topLayout = new QVBoxLayout(this);
topLayout->addWidget(vb);
topLayout->addWidget(mEditor);
mEditor->installEventFilter(this);
connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) );
connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
+ connect( newJournal, SIGNAL( clicked() ), this , SIGNAL( newJournal() ) );
+ connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) );
}
JournalEntry::~JournalEntry()
{
}
void JournalEntry::slotSaveTemplate()
{
QString fileName =locateLocal( "templates", "journals" );
QDir t_dir;
if ( !t_dir.exists(fileName) )
t_dir.mkdir ( fileName );
@@ -142,40 +161,58 @@ void JournalEntry::slotLoadTemplate()
QTextStream tsIn( &fileIn );
tsIn.setCodec( QTextCodec::codecForName("utf8") );
QString text = tsIn.read();
fileIn.close();
int line, col;
mEditor->getCursorPosition (& line, & col );
mEditor-> insertAt ( text, line, col, true );
//mEditor->setIgnoreMark( true );
setDirty();
}
void JournalEntry::setDate(const QDate &date)
{
+ showOnlyMode = false;
+ mDate = date;
writeJournal();
+ int id = mCalendar->defaultCalendar();
+ if ( id == 1 ) {
+ mTitleLabel->setText(KGlobal::locale()->formatDate(date));
+ } else {
+ QString calname = KOPrefs::instance()->getCalendar( id )->mName;
+ mTitleLabel->setText( KGlobal::locale()->formatDate(mDate,true) + " (" + calname +")");
+ }
+}
- mTitleLabel->setText(KGlobal::locale()->formatDate(date));
-
-
- mDate = date;
+void JournalEntry::toggleShowJournal()
+{
+ if ( showOnlyMode )
+ emit showJournalOnly( 0 );
+ else
+ emit showJournalOnly( mJournal );
}
void JournalEntry::setJournal(Journal *journal)
{
writeJournal();
mJournal = journal;
mEditor->setText(mJournal->description());
-
+ int id = mJournal->calID();
+ if ( id > 1 ) {
+ QString calname = KOPrefs::instance()->getCalendar( id )->mName;
+ mTitleLabel->setText( KGlobal::locale()->formatDate(mDate,true) + " (" + calname +")");
+ } else {
+ mTitleLabel->setText(KGlobal::locale()->formatDate(mDate));
+ }
mDirty = false;
}
Journal *JournalEntry::journal() const
{
return mJournal;
}
void JournalEntry::setDirty()
{
mDirty = true;
diff --git a/korganizer/journalentry.h b/korganizer/journalentry.h
index f1a1fef..85ad5df 100644
--- a/korganizer/journalentry.h
+++ b/korganizer/journalentry.h
@@ -39,37 +39,42 @@ class JournalEntry : public QFrame {
public:
JournalEntry(Calendar *,QWidget *parent);
virtual ~JournalEntry();
void setJournal(Journal *);
Journal *journal() const;
void setDate(const QDate &);
void clear();
void flushEntry();
+ void setShowOnly() {showOnlyMode = true;}
protected slots:
void slotSaveTemplate();
void slotLoadTemplate();
void setDirty();
+ void toggleShowJournal();
signals:
void deleteJournal(Journal *);
+ void newJournal();
+ void showJournalOnly( Journal * );
protected:
bool eventFilter( QObject *o, QEvent *e );
void writeJournal();
private:
+ bool showOnlyMode;
Calendar *mCalendar;
Journal *mJournal;
QDate mDate;
void keyPressEvent ( QKeyEvent * ) ;
QLabel *mTitleLabel;
KTextEdit *mEditor;
bool mDirty;
};
#endif
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp
index bc16037..fae59d6 100644
--- a/korganizer/kojournalview.cpp
+++ b/korganizer/kojournalview.cpp
@@ -33,75 +33,147 @@
#include <libkcal/calendar.h>
#include "journalentry.h"
#include "kojournalview.h"
using namespace KOrg;
KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent,
const char *name)
: KOrg::BaseView(calendar, parent, name)
{
- mEntry = new JournalEntry(calendar,this);
- mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
- QBoxLayout *topLayout = new QVBoxLayout(this);
- topLayout->addWidget(mEntry);
- connect ( mEntry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ;
+ mCalendar = calendar;
+ mTopLayout = new QVBoxLayout(this);
+ getNewEntry();
}
KOJournalView::~KOJournalView()
{
}
int KOJournalView::currentDateCount()
{
return 0;
}
+JournalEntry* KOJournalView::getNewEntry()
+{
+ JournalEntry* Entry = new JournalEntry(mCalendar,this);
+ jEntries.append( Entry );
+ mTopLayout->addWidget(Entry);
+ Entry->setFont ( KOPrefs::instance()->mJornalViewFont );
+ connect ( Entry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ;
+ connect ( Entry,SIGNAL(newJournal() ),this ,SLOT(newJournal() ) ) ;
+ connect ( Entry,SIGNAL(showJournalOnly( Journal * ) ),this ,SLOT(showOnly ( Journal* ) ) ) ;
+ return Entry;
+}
QPtrList<Incidence> KOJournalView::selectedIncidences()
{
QPtrList<Incidence> eventList;
return eventList;
}
void KOJournalView::updateConfig()
{
- mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
+ JournalEntry* mEntry = jEntries.first();
+ while ( mEntry ) {
+ mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
+ mEntry = jEntries.next();
+ }
}
void KOJournalView::updateView()
-{
- mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
+{
+ JournalEntry* mEntry = jEntries.first();
+ while ( mEntry ) {
+ mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
+ mEntry = jEntries.next();
+ }
+ showDates( mDate, QDate() );
}
void KOJournalView::flushView()
-{
- mEntry->flushEntry();
+{
+ JournalEntry* mEntry = jEntries.first();
+ while ( mEntry ) {
+ mEntry->flushEntry();
+ mEntry = jEntries.next();
+ }
}
void KOJournalView::clearList()
{
- mEntry->clear();
+ JournalEntry* mEntry = jEntries.first();
+ while ( mEntry ) {
+ mEntry->clear();
+ mEntry = jEntries.next();
+ }
}
-void KOJournalView::showDates(const QDate &start, const QDate &)
+void KOJournalView::newJournal()
{
-// kdDebug() << "KOJournalView::selectDates()" << endl;
+ Journal* mJournal = new Journal;
+ mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0)));
+ mCalendar->addJournal(mJournal);
+ showDates( mDate, QDate() );
+}
- mEntry->setDate(start);
+void KOJournalView::showOnly ( Journal* j )
+{
+ if ( j == 0 ) {
+ showDates( mDate, QDate() );
+ return;
+ }
+ QPtrList<Journal> jl;
+ jl.append ( j );
+ showList( jl );
+ JournalEntry* mEntry = jEntries.first();
+ mEntry->setShowOnly();
+}
+void KOJournalView::showList(QPtrList<Journal> jl)
+{
+ JournalEntry* mEntry = jEntries.first();
+ JournalEntry* firstEntry = mEntry;
+ int count = jl.count();
+ int iii = 0;
+ while ( iii < count ) {
+ if ( !mEntry ) {
+ mEntry = getNewEntry();
+ mEntry->show();
+ mEntry->setDate(mDate);
+ mEntry->setJournal(jl.at(iii));
+ mEntry = 0;
+ } else {
+ mEntry->setDate(mDate);
+ mEntry->setJournal(jl.at(iii));
+ mEntry->show();
+ mEntry = jEntries.next();
+ }
+ ++iii;
+ }
+ while ( mEntry ) {
+ mEntry->setDate(mDate);
+ mEntry->clear();
+ if ( mEntry != firstEntry )
+ mEntry->hide();
+ else
+ mEntry->show();
+ mEntry = jEntries.next();
+ }
+}
- Journal *j = calendar()->journal(start);
- if (j) mEntry->setJournal(j);
- else mEntry->clear();
-
-// emit incidenceSelected( 0 );
+void KOJournalView::showDates(const QDate &start, const QDate &)
+{
+ mDate = start;
+ QPtrList<Journal> jl = calendar()->journals4Date( start );
+ showList( jl );
}
void KOJournalView::showEvents(QPtrList<Event>)
{
// After new creation of list view no events are selected.
// emit incidenceSelected( 0 );
}
void KOJournalView::changeEventDisplay(Event *, int /*action*/)
{
updateView();
}
diff --git a/korganizer/kojournalview.h b/korganizer/kojournalview.h
index 445f940..aabf11c 100644
--- a/korganizer/kojournalview.h
+++ b/korganizer/kojournalview.h
@@ -15,24 +15,25 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef _KOJOURNALVIEW_H
#define _KOJOURNALVIEW_H
#include <korganizer/baseview.h>
+#include <qlayout.h>
class JournalEntry;
/**
* This class provides a journal view.
* @short View for Journal components.
* @author Cornelius Schumacher <schumacher@kde.org>
* @see KOBaseView
*/
class KOJournalView : public KOrg::BaseView
{
@@ -42,27 +43,34 @@ class KOJournalView : public KOrg::BaseView
const char *name = 0);
~KOJournalView();
virtual int currentDateCount();
void clearList();
virtual QPtrList<Incidence> selectedIncidences();
DateList selectedDates()
{DateList q;
return q;};
signals:
void deleteJournal(Journal *);
public slots:
+ void showOnly ( Journal* );
+ void newJournal();
void updateView();
void flushView();
void updateConfig();
void showDates( const QDate &start, const QDate &end );
void showEvents(QPtrList<Event> eventList);
void changeEventDisplay(Event *, int);
private:
- JournalEntry *mEntry;
+ void showList(QPtrList<Journal> jl);
+ Calendar *mCalendar;
+ JournalEntry* getNewEntry();
+ QPtrList<JournalEntry> jEntries;
void keyPressEvent ( QKeyEvent * ) ;
+ QBoxLayout *mTopLayout;
+ QDate mDate;
};
#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index 5d9af6d..7b307f7 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -101,24 +101,25 @@ void KOViewManager::readSettings(KConfig *config)
else {
config->setGroup( "Views" );
int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
mCurrentAgendaView = dateCount;
showAgendaView();
mCurrentAgendaView = dateCount;
#ifdef DESKTOP_VERSION
QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) );
#endif
}
}
+
void KOViewManager::showDateView( int view, QDate date)
{
static int lastMode = 0;
static int lastCount = 0;
static bool lastNDMode = false;
static QDate lastDate;
//qDebug("date %d %s", view, date.toString().latin1());
if (view != 9)
lastMode = 0;
//qDebug("%d %d ", lastNDMode, mFlagShowNextxDays );
bool savemFlagShowNextxDays = mFlagShowNextxDays;
@@ -273,24 +274,30 @@ void KOViewManager::showNextView()
ENTE:
flagResetViewChangeDate = 0;
selecteddatescount = mMainView->dateNavigator()->selectedDates().count();
selecteddate = mMainView->dateNavigator()->selectedDates().first();
}
void KOViewManager::resetDateSilent( QDate date , int days )
{
mMainView->dateNavigator()->blockSignals( true );
mMainView->dateNavigator()->selectDates( date , days );
mMainView->dateNavigator()->blockSignals( false );
}
+void KOViewManager::setDefaultCalendar(int)
+{
+ if ( mJournalView && mCurrentView == mJournalView )
+ mJournalView->updateView();
+}
+
void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
{
if ( flagResetViewChangeDate < 10 )
++flagResetViewChangeDate;
//mFlagShowNextxDays = false;
//if(view == mCurrentView) return;
if ( view == 0 ) {
view = mCurrentView;
if ( view == 0 )
return;
}
bool callupdate = !(view == mCurrentView);
diff --git a/korganizer/koviewmanager.h b/korganizer/koviewmanager.h
index 838583b..d5a8e3b 100644
--- a/korganizer/koviewmanager.h
+++ b/korganizer/koviewmanager.h
@@ -74,24 +74,25 @@ class KOViewManager : public QObject
void addView(KOrg::BaseView *);
Incidence *currentSelection();
QDate currentSelectionDate();
KOAgendaView *agendaView() const { return mAgendaView; }
signals:
void printWNV();
void signalFullScreen( bool );
void signalAgendaView( bool );
public slots:
+ void setDefaultCalendar(int);
void slotprintWNV();
void showNextView();
void showMonth( const QDate & );
void showDateView( int, QDate );
void updateView();
void showWhatsNextView();
void showListView();
void showAgendaView( bool fullScreen = false );
void showDayView();
void showWorkWeekView();
void showWeekView();
void showNextXView();
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 2efa355..4652fe5 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -234,24 +234,25 @@ public:
virtual QPtrList<Todo> rawTodos() = 0;
/**
Add a Journal entry to calendar.
@return true on success, false on error.
*/
virtual bool addJournal( Journal * ) = 0;
/**
Return Journal for given date.
*/
virtual Journal *journal( const QDate & ) = 0;
+ virtual QPtrList<Journal> journals4Date( const QDate & ) = 0;
/**
Return Journal with given UID.
*/
virtual Journal *journal( const QString &UID ) = 0;
/**
Return list of all Journal entries.
*/
virtual QPtrList<Journal> journals() = 0;
/**
Searches all incidence types for an incidence with this unique
string identifier, returns a pointer or null.
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 418bfca..ca64e66 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -767,49 +767,51 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt )
}
QPtrList<Event> CalendarLocal::rawEvents()
{
QPtrList<Event> el;
for ( Event *it = mEventList.first(); it; it = mEventList.next() )
if ( it->calEnabled() ) el.append( it );
return el;
}
bool CalendarLocal::addJournal(Journal *journal)
{
- if ( journal->dtStart().isValid())
- kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl;
- else
- kdDebug(5800) << "Adding Journal without a DTSTART" << endl;
-
- mJournalList.append(journal);
+ mJournalList.append(journal);
journal->registerObserver( this );
setModified( true );
journal->setCalID( mDefaultCalendar );
journal->setCalEnabled( true );
return true;
}
void CalendarLocal::deleteJournal( Journal *journal )
{
if ( mUndoIncidence ) delete mUndoIncidence;
mUndoIncidence = journal->clone();
mUndoIncidence->setSummary( mUndoIncidence->description().left(25));
if ( mJournalList.removeRef(journal) ) {
setModified( true );
}
}
+QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date )
+{
+ QPtrList<Journal> el;
+ for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
+ if ( it->calEnabled() && it->dtStart().date() == date) el.append( it );
+ return el;
+}
Journal *CalendarLocal::journal( const QDate &date )
{
// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl;
for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
if ( it->calEnabled() && it->dtStart().date() == date )
return it;
return 0;
}
Journal *CalendarLocal::journal( const QString &uid )
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index d32597f..98d16a3 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -122,24 +122,25 @@ class CalendarLocal : public Calendar
/**
Add a Journal entry to calendar.
*/
bool addJournal( Journal * );
/**
Remove a Journal from the calendar.
*/
void deleteJournal( Journal * );
/**
Return Journal for given date.
*/
Journal *journal( const QDate & );
+ QPtrList<Journal> journals4Date( const QDate & );
/**
Return Journal with given UID.
*/
Journal *journal( const QString &uid );
/**
Return list of all Journals stored in calendar.
*/
QPtrList<Journal> journals();
/**
Return all alarms, which ocur in the given time interval.
*/