summaryrefslogtreecommitdiffabout
path: root/korganizer/journalentry.cpp
authorzautrix <zautrix>2005-06-29 11:08:57 (UTC)
committer zautrix <zautrix>2005-06-29 11:08:57 (UTC)
commit435e68d6ace30fb2121b718226e00be44971c617 (patch) (side-by-side diff)
tree2b7d2793f0244db82a9cddbfab8957d13989ed20 /korganizer/journalentry.cpp
parentb7044dfc9516d546683973985555c481d59fc677 (diff)
downloadkdepimpi-435e68d6ace30fb2121b718226e00be44971c617.zip
kdepimpi-435e68d6ace30fb2121b718226e00be44971c617.tar.gz
kdepimpi-435e68d6ace30fb2121b718226e00be44971c617.tar.bz2
fixx
Diffstat (limited to 'korganizer/journalentry.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/journalentry.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp
index 7274849..0b923ad 100644
--- a/korganizer/journalentry.cpp
+++ b/korganizer/journalentry.cpp
@@ -11,159 +11,164 @@
but WITHOUT ANY WARRANTY; without even the implied warranty of
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.
*/
//
// Journal Entry
#include <qlabel.h>
#include <qlayout.h>
#include <qvbox.h>
#include <qfile.h>
#include <qdir.h>
#include <qtextstream.h>
#include <qtextcodec.h>
#include <qpixmap.h>
#include <qpushbutton.h>
#include <qapplication.h>
#include <kdebug.h>
#include <kglobal.h>
#include <klocale.h>
#include <ktextedit.h>
#include <kfiledialog.h>
#include <kmessagebox.h>
#include "koprefs.h"
#include <libkcal/journal.h>
#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)
{
+ 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();
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 );
if ( QApplication::desktop()->width() < 321 )
icon = SmallIcon("fileexport16");
else
icon = SmallIcon("fileexport");
saveTemplate->setIconSet (icon ) ;
//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 );
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()
{
+ qDebug("JournalEntry::~JournalEntry() ");
+}
+QSize JournalEntry::sizeHint() const
+{
+ return QSize ( 240, heiHint );
}
-
void JournalEntry::slotSaveTemplate()
{
QString fileName =locateLocal( "templates", "journals" );
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 );
setDirty();