summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-06-30 12:37:10 (UTC)
committer zautrix <zautrix>2005-06-30 12:37:10 (UTC)
commit4c19ba3345d1af263c02ebe564e56d9dec679347 (patch) (side-by-side diff)
tree1ac48610c5545998670fa1c14592ef4e1981ce94 /korganizer
parent13eb32c82e736b033435e596111b7b0f3fe75608 (diff)
downloadkdepimpi-4c19ba3345d1af263c02ebe564e56d9dec679347.zip
kdepimpi-4c19ba3345d1af263c02ebe564e56d9dec679347.tar.gz
kdepimpi-4c19ba3345d1af263c02ebe564e56d9dec679347.tar.bz2
fixx
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/journalentry.cpp13
-rw-r--r--korganizer/journalentry.h1
-rw-r--r--korganizer/kojournalview.cpp12
3 files changed, 17 insertions, 9 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp
index 9e2c902..ca8d5f7 100644
--- a/korganizer/journalentry.cpp
+++ b/korganizer/journalentry.cpp
@@ -117,120 +117,127 @@ void JournalEntry::slotSaveTemplate()
QDir t_dir;
if ( !t_dir.exists(fileName) )
t_dir.mkdir ( fileName );
fileName += "/journal";
fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this );
if ( fileName.length() == 0 )
return;
QFile fileIn( fileName );
if (!fileIn.open( IO_WriteOnly ) ) {
KMessageBox::error( this, i18n("Error saving template file\n '%1'.")
.arg( fileName ) );
return;
}
// QString text;
QTextStream tsIn( &fileIn );
tsIn.setCodec( QTextCodec::codecForName("utf8") );
tsIn << mEditor->text();
fileIn.close();
}
void JournalEntry::slotLoadTemplate()
{
QString fileName =locateLocal( "templates", "journals" );
QDir t_dir;
if ( !t_dir.exists(fileName) )
t_dir.mkdir ( fileName );
fileName += "/journal";
fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this );
if ( fileName.length() == 0 )
return;
QFile fileIn( fileName );
if (!fileIn.open( IO_ReadOnly ) ) {
KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
.arg( fileName ) );
return;
}
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 );
}
void JournalEntry::setDate(const QDate &date)
{
showOnlyMode = false;
- mDate = date;
writeJournal();
+ mDate = date;
int id = mCalendar->defaultCalendar();
QString calname = KOPrefs::instance()->getCalendar( id )->mName;
mTitleLabel->setText( " (" + calname +")");
}
void JournalEntry::toggleShowJournal()
{
if (!mEditor->text().isEmpty() || !mTitle->text().isEmpty())
flushEntry();
if ( showOnlyMode )
emit showJournalOnly( 0 );
else {
// we have to protect mJournal from deleting if mJournal has empty text
visibleMode = false; // set to true via :setShowOnly()
emit showJournalOnly( mJournal );
+ //QTimer::singleShot( 0, this, SLOT( setVisibleOn() ) );
}
}
+void JournalEntry::setVisibleOn()
+{
+ visibleMode = true;
+}
void JournalEntry::setShowOnly()
{
showOnlyMode = true;
- mEditor->setFocus();
- visibleMode = true;
+ if ( mTitle->text().isEmpty() )
+ mTitle->setFocus();
+ else
+ mEditor->setFocus();
}
void JournalEntry::setJournal(Journal *journal)
{
writeJournal();
mJournal = journal;
if ( journal->isReadOnly() )
mTitle->setText(mJournal->summary()+" ("+i18n("readonly")+")");
else
mTitle->setText(mJournal->summary());
mEditor->setText(mJournal->description());
mTitle->setReadOnly (journal->isReadOnly() );
mEditor->setReadOnly ( journal->isReadOnly() );
int id = mJournal->calID();
QString calname = KOPrefs::instance()->getCalendar( id )->mName;
mTitleLabel->setText( " (" + calname +")");
}
Journal *JournalEntry::journal() const
{
return mJournal;
}
void JournalEntry::clear()
{
mJournal = 0;
mEditor->setText("");
mTitle->setText("");
}
bool JournalEntry::eventFilter( QObject *o, QEvent *e )
{
// kdDebug() << "JournalEntry::event received " << e->type() << endl;
if ( e->type() == QEvent::FocusOut ) {
writeJournal();
}
if ( e->type() == QEvent::KeyPress ) {
QKeyEvent * k = (QKeyEvent *) e;
if ( k->state() == Qt::ControlButton ) {
k->ignore();
//return true;
}
}
diff --git a/korganizer/journalentry.h b/korganizer/journalentry.h
index e98d018..cc9b5ef 100644
--- a/korganizer/journalentry.h
+++ b/korganizer/journalentry.h
@@ -12,72 +12,73 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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 JOURNALENTRY_H
#define JOURNALENTRY_H
//
// Widget showing one Journal entry
#include <qframe.h>
#include <libkcal/calendar.h>
class QLabel;
class KTextEdit;
class KLineEdit;
using namespace KCal;
class JournalEntry : public QFrame {
Q_OBJECT
public:
JournalEntry(Calendar *,QWidget *parent);
virtual ~JournalEntry();
void setJournal(Journal *);
Journal *journal() const;
void setDate(const QDate &);
void clear();
void flushEntry();
void setShowOnly();
QSize sizeHint() const;
void setVisibleMode( bool b ) { visibleMode = b;}
protected slots:
void slotSaveTemplate();
void slotLoadTemplate();
void toggleShowJournal();
+ void setVisibleOn();
signals:
void deleteJournal(Journal *);
void newJournal();
void showJournalOnly( Journal * );
protected:
bool eventFilter( QObject *o, QEvent *e );
void writeJournal();
private:
bool visibleMode;
bool showOnlyMode;
Calendar *mCalendar;
Journal *mJournal;
QDate mDate;
void keyPressEvent ( QKeyEvent * ) ;
QLabel *mTitleLabel;
KLineEdit * mTitle;
KTextEdit *mEditor;
int heiHint;
};
#endif
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp
index 7a96aa5..6fa9b23 100644
--- a/korganizer/kojournalview.cpp
+++ b/korganizer/kojournalview.cpp
@@ -110,126 +110,126 @@ void KOJournalView::updateConfig()
}
}
void KOJournalView::updateView()
{
JournalEntry* mEntry = jEntries.first();
while ( mEntry ) {
mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
mEntry = jEntries.next();
}
showDates( mDate, QDate() );
}
void KOJournalView::checkModified()
{
flushView();
}
void KOJournalView::flushView()
{
static bool ff = false;
if ( ff ) return;
ff = true;
JournalEntry* mEntry = jEntries.first();
while ( mEntry ) {
mEntry->flushEntry();
mEntry = jEntries.next();
}
ff = false;
}
void KOJournalView::clearList()
{
JournalEntry* mEntry = jEntries.first();
while ( mEntry ) {
mEntry->clear();
mEntry = jEntries.next();
}
}
void KOJournalView::newJournal()
{
//qDebug(" KOJournalView::newJournal()");
flushView();
Journal* mJournal = new Journal;
mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0)));
mCalendar->addJournal(mJournal);
showDates( mDate, QDate() );
}
void KOJournalView::showOnly ( Journal* j )
{
- //qDebug("showOnly %x ", j);
+ qDebug("showOnly %x ", j);
flushView();
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)
{
- //qDebug("KOJournalView::showList %d",jl.count() );
+ qDebug("KOJournalView::showList %d",jl.count() );
JournalEntry* mEntry = jEntries.first();
JournalEntry* firstEntry = mEntry;
int count = jl.count();
int iii = 0;
while ( iii < count ) {
if ( !mEntry ) {
mEntry = getNewEntry();
- mEntry->show();
- mEntry->setVisibleMode( true );
mEntry->setDate(mDate);
mEntry->setJournal(jl.at(iii));
+ mEntry->setVisibleMode( true );
+ mEntry->show();
mEntry = 0;
} else {
mEntry->setDate(mDate);
mEntry->setJournal(jl.at(iii));
- mEntry->show();
mEntry->setVisibleMode( true );
+ mEntry->show();
mEntry = jEntries.next();
}
++iii;
}
while ( mEntry ) {
mEntry->setDate(mDate);
mEntry->clear();
if ( mEntry != firstEntry ) {
mEntry->hide();
mEntry->setVisibleMode( false );
}
else {
mEntry->setVisibleMode( true );
mEntry->show();
}
mEntry = jEntries.next();
}
}
void KOJournalView::showDates(const QDate &start, const QDate &)
{
mDate = start;
- mDateLabel-> setText(KGlobal::locale()->formatDate(mDate));
+ mDateLabel->setText(KGlobal::locale()->formatDate(mDate));
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();
}
void KOJournalView::keyPressEvent ( QKeyEvent * e )
{
//qDebug("keyPressEven ");
if ( e->state() == Qt::ControlButton ) {
if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left )
e->ignore();
}
}