summaryrefslogtreecommitdiffabout
path: root/korganizer/journalentry.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/journalentry.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/journalentry.cpp49
1 files changed, 19 insertions, 30 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp
index 0b923ad..05bfd31 100644
--- a/korganizer/journalentry.cpp
+++ b/korganizer/journalentry.cpp
@@ -37,16 +37,17 @@
#include <kdebug.h>
#include <kglobal.h>
#include <klocale.h>
#include <ktextedit.h>
#include <kfiledialog.h>
#include <kmessagebox.h>
#include "koprefs.h"
+#include <klineedit.h>
#include <libkcal/journal.h>
#include <libkcal/calendarresources.h>
#include <libkcal/resourcecalendar.h>
#include <kresources/resourceselectdialog.h>
#include "journalentry.h"
//#include "journalentry.moc"
@@ -58,37 +59,27 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) :
{
heiHint = QApplication::desktop()->height() / 5 ;
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();
+ int size = toggleJournal->sizeHint().height();
toggleJournal->setFixedSize( size * 2 /3 , size );
-
-
-
+ new QLabel(i18n(" Title: "),vb);
+ mTitle = new KLineEdit ( vb );
mTitleLabel = new QLabel(i18n("Title"),vb);
- mTitleLabel->setMargin(2);
+ mTitleLabel->setMargin(0);
mTitleLabel->setAlignment(AlignCenter);
QPushButton * loadTemplate = new QPushButton( vb );
QPushButton * saveTemplate = new QPushButton( vb );
if ( QApplication::desktop()->width() < 321 )
icon = SmallIcon("fileexport16");
else
icon = SmallIcon("fileexport");
saveTemplate->setIconSet (icon ) ;
@@ -106,24 +97,24 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) :
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( mTitle, SIGNAL( textChanged ( const QString & ) ), this , SLOT( setDirty() ) );
connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
- connect( newJournal, SIGNAL( clicked() ), this , SIGNAL( newJournal() ) );
connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) );
}
JournalEntry::~JournalEntry()
{
- qDebug("JournalEntry::~JournalEntry() ");
+ //qDebug("JournalEntry::~JournalEntry() ");
}
QSize JournalEntry::sizeHint() const
{
return QSize ( 240, heiHint );
}
void JournalEntry::slotSaveTemplate()
{
QString fileName =locateLocal( "templates", "journals" );
@@ -174,46 +165,45 @@ void JournalEntry::slotLoadTemplate()
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( " (" + calname +")");
}
void JournalEntry::toggleShowJournal()
{
+ flushEntry();
if ( showOnlyMode )
emit showJournalOnly( 0 );
else
emit showJournalOnly( mJournal );
}
-
+void JournalEntry::setShowOnly()
+{
+ showOnlyMode = true;
+ mEditor->setFocus();
+}
void JournalEntry::setJournal(Journal *journal)
{
writeJournal();
mJournal = journal;
-
+ mTitle->setText(mJournal->summary());
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));
- }
+ mTitleLabel->setText( " (" + calname +")");
+
mDirty = false;
}
Journal *JournalEntry::journal() const
{
return mJournal;
}
@@ -269,18 +259,17 @@ void JournalEntry::writeJournal()
if (!mJournal) {
mJournal = new Journal;
mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0)));
mCalendar->addJournal(mJournal);
}
mJournal->setDescription(mEditor->text());
- //qDebug("tttt%s ", mEditor->text().latin1());
-
+ mJournal->setSummary(mTitle->text());
mDirty = false;
}
void JournalEntry::flushEntry()
{
if (!mDirty) return;
writeJournal();