kontact Library API Documentation

knotes_part_p.h

00001 /*
00002    This file is part of the KDE project
00003    Copyright (C) 2004 Michael Brade <brade@kde.org>
00004 
00005    This program is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; see the file COPYING.  If not, write to
00017    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, USA.
00019 
00020    In addition, as a special exception, the copyright holders give
00021    permission to link the code of this program with any edition of
00022    the Qt library by Trolltech AS, Norway (or with modified versions
00023    of Qt that use the same license as Qt), and distribute linked
00024    combinations including the two.  You must obey the GNU General
00025    Public License in all respects for all of the code used other than
00026    Qt.  If you modify this file, you may extend this exception to
00027    your version of the file, but you are not obligated to do so.  If
00028    you do not wish to do so, delete this exception statement from
00029    your version.
00030 */
00031 
00032 #ifndef KNOTES_PART_P_H
00033 #define KNOTES_PART_P_H
00034 
00035 #include <qlayout.h>
00036 
00037 #include <kactioncollection.h>
00038 #include <klocale.h>
00039 #include <kiconview.h>
00040 #include <kglobal.h>
00041 #include <kiconloader.h>
00042 #include <ktoolbar.h>
00043 #include <kpopupmenu.h>
00044 #include <kdialogbase.h>
00045 #include <kxmlguiclient.h>
00046 #include <kxmlguifactory.h>
00047 #include <kxmlguibuilder.h>
00048 
00049 #include <libkcal/journal.h>
00050 
00051 #include "knotes/knoteedit.h"
00052 
00053 
00054 class KNotesIconViewItem : public KIconViewItem
00055 {
00056 public:
00057     KNotesIconViewItem( KIconView *parent, KCal::Journal *journal )
00058       : KIconViewItem( parent ),
00059         m_journal( journal )
00060     {
00061         setRenameEnabled( true );
00062 
00063         setPixmap( KGlobal::iconLoader()->loadIcon( "knotes", KIcon::Desktop ) );
00064         setText( journal->summary() );
00065     }
00066 
00067     KCal::Journal *journal()
00068     {
00069         return m_journal;
00070     }
00071 
00072     virtual void setText( const QString & text )
00073     {
00074         KIconViewItem::setText( text );
00075         m_journal->setSummary( text );
00076     }
00077 
00078 private:
00079     KCal::Journal *m_journal;
00080 };
00081 
00082 
00083 class KNoteEditDlg : public KDialogBase, virtual public KXMLGUIClient
00084 {
00085     Q_OBJECT
00086 public:
00087     KNoteEditDlg( QWidget *parent = 0, const char *name = 0 )
00088         : KDialogBase( Plain, i18n("Edit Note"), Ok|Cancel, Ok, parent, name, true, true )
00089     {
00090         // this dialog is modal to prevent one from editing the same note twice in two
00091         // different windows
00092 
00093         setInstance( new KInstance( "knotes" ) ); // TODO: hm, memleak??
00094         setXMLFile( "knotesui.rc" );
00095         actionCollection()->setWidget( this );
00096 
00097         QWidget *page = plainPage();
00098         QVBoxLayout *layout = new QVBoxLayout( page );
00099 
00100         m_noteEdit = new KNoteEdit( actionCollection(), page );
00101         m_noteEdit->setFocus();
00102 
00103         KXMLGUIBuilder builder( page );
00104         KXMLGUIFactory factory( &builder, this );
00105         factory.addClient( this );
00106 
00107         m_tool = static_cast<KToolBar *>(factory.container( "note_tool", this ));
00108 
00109         layout->addWidget( m_tool );
00110         layout->addWidget( m_noteEdit );
00111     }
00112 
00113     QString text() const
00114     {
00115         return m_noteEdit->text();
00116     }
00117 
00118     void setText( const QString& text )
00119     {
00120         m_noteEdit->setText( text );
00121     }
00122 
00123 private:
00124     KNoteEdit  *m_noteEdit;
00125     KToolBar   *m_tool;
00126     KPopupMenu *m_edit_menu;
00127 };
00128 
00129 
00130 #endif
KDE Logo
This file is part of the documentation for kontact Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Aug 2 09:56:36 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003