summaryrefslogtreecommitdiff
authorzecke <zecke>2002-09-20 17:28:20 (UTC)
committer zecke <zecke>2002-09-20 17:28:20 (UTC)
commit55dd11ddae09bfc4907399c473f0387c135fdae6 (patch) (side-by-side diff)
tree69d52e2f0e1030bbdcbf518f0a334ff4861500fa
parent40df2487c53a5ab484d33d619f5b6ed449c0b485 (diff)
downloadopie-55dd11ddae09bfc4907399c473f0387c135fdae6.zip
opie-55dd11ddae09bfc4907399c473f0387c135fdae6.tar.gz
opie-55dd11ddae09bfc4907399c473f0387c135fdae6.tar.bz2
OTodo know is the first implementation of OPimRecord
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/libopie.pro33
-rw-r--r--libopie/ofileselector/ofileselector.cpp345
-rw-r--r--libopie/ofileselector/ofileselector.h125
-rw-r--r--libopie/ofileselector/olister.h1
-rw-r--r--libopie/pim/opimrecord.cpp26
-rw-r--r--libopie/pim/opimrecord.h4
-rw-r--r--libopie/pim/otodo.cpp265
-rw-r--r--libopie/pim/otodo.h26
-rw-r--r--libopie2/opiepim/core/opimrecord.cpp26
-rw-r--r--libopie2/opiepim/core/opimrecord.h4
-rw-r--r--libopie2/opiepim/otodo.cpp265
-rw-r--r--libopie2/opiepim/otodo.h26
12 files changed, 443 insertions, 703 deletions
diff --git a/libopie/libopie.pro b/libopie/libopie.pro
index 6c47e86..70be6ac 100644
--- a/libopie/libopie.pro
+++ b/libopie/libopie.pro
@@ -1,6 +1,6 @@
TEMPLATE = lib
CONFIG += qte warn_on release
-HEADERS = ofontmenu.h ofileselector.h \
- ofiledialog.h tododb.h \
+HEADERS = ofontmenu.h \
+ tododb.h \
todoevent.h todoresource.h \
todovcalresource.h xmltree.h \
@@ -9,7 +9,18 @@ HEADERS = ofontmenu.h ofileselector.h \
oprocess.h odevice.h \
otimepicker.h otabwidget.h \
- otabbar.h otabinfo.h
-SOURCES = ofontmenu.cc ofileselector.cc \
- ofiledialog.cc xmltree.cc \
+ otabbar.h otabinfo.h \
+ ofileselector/ofiledialog.h \
+ ofileselector/ofilelistview.h \
+ ofileselector/ofileselector.h \
+ ofileselector/ofileselectoritem.h \
+ ofileselector/ofileview.h \
+ ofileselector/olister.h \
+ ofileselector/olocallister.h \
+ ofileselector/ofileselectormain.h \
+ pim/opimrecord.h \
+ pim/otodo.h
+
+SOURCES = ofontmenu.cc \
+ xmltree.cc \
tododb.cpp todoevent.cpp \
todovcalresource.cpp colordialog.cpp \
@@ -17,5 +28,15 @@ SOURCES = ofontmenu.cc ofileselector.cc \
oprocctrl.cpp oprocess.cpp \
odevice.cpp otimepicker.cpp \
- otabwidget.cpp otabbar.cpp
+ otabwidget.cpp otabbar.cpp \
+ ofileselector/ofiledialog.cpp \
+ ofileselector/ofilelistview.cpp \
+ ofileselector/ofileselector.cpp \
+ ofileselector/ofileselectoritem.cpp \
+ ofileselector/ofileview.cpp \
+ ofileselector/olister.cpp \
+ ofileselector/olocallister.cpp \
+ ofileselector/ofileselectormain.cpp \
+ pim/opimrecord.cpp \
+ pim/otodo.cpp
TARGET = opie
INCLUDEPATH += $(OPIEDIR)/include
diff --git a/libopie/ofileselector/ofileselector.cpp b/libopie/ofileselector/ofileselector.cpp
index 98b61f7..c52aa62 100644
--- a/libopie/ofileselector/ofileselector.cpp
+++ b/libopie/ofileselector/ofileselector.cpp
@@ -31,5 +31,7 @@
#include "ofileview.h"
+#include "ofileselectormain.h"
#include "ofileselector.h"
+#include "olocallister.h"
#include "olister.h"
@@ -102,38 +104,20 @@ void OFileSelector::setNewVisible( bool visible )
{
m_shNew = visible;
- if( m_selector == Normal ){
- delete m_select;
- // we need to initialize but keep the selected mimetype
- QString mime = currentMimeType();
- m_select = new FileSelector( mime ,
- m_stack, "fileselector",
- m_shNew, m_shClose);
-
- connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
- this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
- connect(m_select, SIGNAL(closeMe() ),
- this, SIGNAL(closeMe() ) );
- //connect to close me and other signals as well
- m_stack->addWidget( m_select, Normal );
- }else{
- m_new->show();
- }
+ if (m_new )
+ m_new->show();
}
void OFileSelector::setCloseVisible( bool visible )
{
m_shClose = visible;
- if( m_selector == Normal ){
- setNewVisible( m_shNew ); // yeah baby
- }else{
+
+ if( m_close )
m_close->show();
- }
}
void OFileSelector::reread()
{
- if( m_selector == Normal ){
- setNewVisible( m_shNew ); // make it a initializeSelector
- }else {
- reparse();
- }
+ if( m_selector == Normal )
+ initializeOldSelector();
+ else
+ reparse();
}
@@ -148,4 +132,5 @@ void OFileSelector::setYesCancelVisible( bool show )
initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :(
m_shYesNo = show;
+
if( m_shYesNo )
m_boxOk->show();
@@ -157,5 +142,4 @@ void OFileSelector::setToolbarVisible( bool show )
{
m_shTool = show;
- initializeListView(); // FIXME see above waste of memory
if(!m_shTool ){
@@ -175,4 +159,5 @@ void OFileSelector::setPermissionBarVisible( bool show )
m_shPerm = show;
initializePerm();
+
if( m_shPerm )
m_checkPerm->show();
@@ -186,7 +171,7 @@ void OFileSelector::setLineEditVisible( bool show )
m_boxName->show();
}else{
- if( m_shLne && m_boxName != 0 ){ // check if we showed before this is the way to go
- m_boxName->hide();
- }
+ // check if we showed before this is the way to go
+ if( m_shLne && m_boxName != 0 )
+ m_boxName->hide();
}
m_shLne = show;
@@ -197,9 +182,10 @@ void OFileSelector::setChooserVisible( bool show )
m_shChooser = show;
initializeChooser();
- if( m_shChooser ){
- m_boxView->hide();
- }else{
- m_boxView->show();
- }
+
+ if( m_shChooser )
+ m_boxView->hide();
+ else
+ m_boxView->show();
+
}
@@ -227,13 +213,16 @@ void OFileSelector::setMode(int mode) // FIXME do direct raising
return;
}
-void OFileSelector::setShowDirs(bool )
+void OFileSelector::setShowDirs(bool dir)
{
- m_dir = true;
- reparse();
+ m_dir = dir;
+ if ( m_selector != Fileselector )
+ reparse();
}
void OFileSelector::setCaseSensetive(bool caSe )
{
m_case = caSe;
- reparse();
+
+ if ( m_selector != Fileselector )
+ reparse();
}
void OFileSelector::setShowFiles(bool show )
@@ -381,31 +370,16 @@ void OFileSelector::slotViewCheck(const QString &sel)
{
if( sel == tr("Documents" ) ){
- if( m_select == 0 ){
- // autMime? fix cause now we use All and not the current
- // yes currentMime fixes that for us
- QString mime = currentMimeType();
- m_select = new FileSelector(mime,
- m_stack, "fileselector",
- m_shNew, m_shClose);
- connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
- this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
- connect(m_select, SIGNAL(closeMe() ),
- this, SIGNAL(closeMe() ) );
- //connect to close me and other signals as well
-
- m_stack->addWidget( m_select, Normal );
- }
- m_stack->raiseWidget( Normal );
- m_selector = Normal;
+ initializeOldSelector();
+ m_selector = Normal;
+
}else if( sel == tr("Files") ){
m_selector = Extended;
- initializeListView();
- reparse();
- m_stack->raiseWidget( Extended );
+
+ // FIXME call the factory
+ //reparse();
}else if( sel == tr("All Files") ){
m_selector = ExtendedAll;
- initializeListView();
- reparse();
- m_stack->raiseWidget( Extended ); // same widget other QFileFilter
+/* see above
+ reparse(); */
}
}
@@ -414,7 +388,8 @@ QString OFileSelector::currentMimeType() const{
QString mime;
QString currentText;
- if (m_shChooser )
+ if (m_shChooser && m_mimeCheck )
currentText = m_mimeCheck->currentText();
+ qWarning("CurrentText" + currentText );
if (tr("All") == currentText ) return QString::null;
else if (currentText.isEmpty() ) {
@@ -423,5 +398,5 @@ QString OFileSelector::currentMimeType() const{
QMap<QString, QStringList>::ConstIterator it;
it = m_mimetypes.find( currentText );
- if ( it == m_mimetypes.end() ) {
+ if ( it != m_mimetypes.end() ) {
mime = it.data().join(";");
}else{
@@ -434,31 +409,9 @@ void OFileSelector::slotMimeCheck(const QString &mime)
{
if( m_selector == Normal ){
- //if( m_autoMime ){
- QString newMimeType;
- if (mime != tr("All") ) {
- QMap<QString, QStringList>::Iterator it;
- it = m_mimetypes.find(mime);
- if ( it != m_mimetypes.end() ) {
- newMimeType = it.data().join(";");
- }else{
- newMimeType = mime;
- }
- }
- delete m_select;
- m_select = new FileSelector( newMimeType,
- m_stack, "fileselector",
- m_shNew, m_shClose);
-
- connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
- this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
- connect(m_select, SIGNAL(closeMe() ),
- this, SIGNAL(closeMe() ) );
- //connect to close me and other signals as well
- m_stack->addWidget( m_select, Normal );
- m_stack->raiseWidget( Normal );
+ initializeOldSelector();
+
updateMimes();
updateMimeCheck();
m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) );
- //}
}else{ // others
qWarning("Mime %s", mime.latin1() );
@@ -525,5 +478,9 @@ void OFileSelector::init()
m_lay->setSpacing(0 );
- m_stack = new QWidgetStack( this );
+ /* take care of the main view... */
+ initToolbar();
+
+ /* initialize the file lister */
+ initLister();
if( m_selector == Normal ){
QString mime;
@@ -535,23 +492,8 @@ void OFileSelector::init()
}
}
- m_select = new FileSelector(mime,
- m_stack, "fileselector",
- m_shNew, m_shClose);
-
- connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
- this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
- connect(m_select, SIGNAL(closeMe() ),
- this, SIGNAL( closeMe() ) );
- //connect to close me and other signals as well
-
- m_stack->addWidget( m_select, Normal );
- m_stack->raiseWidget( Normal );
- }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL
- // and initializeListview will take care of those
- // toolbar get's generade in initializeListView
- initializeListView( ); // will raise the widget as well
- m_stack->raiseWidget( Extended );
+ initializeOldSelector();
+ }else{
+ initializeView();
}
- m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch
if( m_shLne ) // the LineEdit with the current FileName
@@ -604,4 +546,7 @@ void OFileSelector::initVars()
m_files = true;
m_showPopup = false;
+ m_mainView = 0l;
+ m_fileView = 0l;
+ m_lister = 0l;
if(m_pixmaps == 0 ) // init the pixmaps
@@ -624,5 +569,4 @@ void OFileSelector::initVars()
m_pseudoLayout = 0;
m_select = 0;
- m_stack = 0;
m_lay = 0;
m_Oselector = 0;
@@ -631,5 +575,4 @@ void OFileSelector::initVars()
m_boxName = 0;
m_boxView = 0;
- m_custom = 0;
m_edit = 0;
m_fnLabel = 0;
@@ -715,4 +658,5 @@ void OFileSelector::initializeChooser()
m_viewCheck->insertItem( tr("All Files") );
/* update to custom views */
+
updateMimeCheck();
@@ -723,85 +667,92 @@ void OFileSelector::initializeChooser()
}
}
-void OFileSelector::initializeListView()
-{
- qWarning("initializeListView");
- if( m_pseudo == 0 ){
- qWarning("init");
- m_pseudo = new QWidget( m_stack, "Pseudo Widget");
+/* generate the buttons for the toolbar */
+void OFileSelector::initToolbar() {
+ m_mainView = new OFileSelectorMain( this );
+
+ /* now generate the tool bar */
+ qWarning( "toolbar" );
+ m_pseudo = new QWidget( m_mainView, "Pseudo Widget" );
m_pseudoLayout = new QVBoxLayout( m_pseudo );
- // toolbar
+
m_boxToolbar = new QHBox( m_pseudo );
- m_boxToolbar->setSpacing(0 ); // next to each other please
-
- // toolbar members
- {
- // location QComboBox
- m_location = new QComboBox( m_boxToolbar );
- m_location->setEditable( TRUE );
- m_location->setDuplicatesEnabled( FALSE );
- connect( m_location, SIGNAL(activated(const QString &) ),
- this, SLOT( slotLocationActivated(const QString &) ) );
- connect( m_location->lineEdit(), SIGNAL(returnPressed() ),
- this, SLOT(locationComboChanged() ) );
- // UP Button
- m_up = new QPushButton(Resource::loadIconSet("up"),"",
- m_boxToolbar,"cdUpButton");
- m_up->setFixedSize( QSize( 20, 20 ) );
- connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) );
- m_up->setFlat(TRUE);
-
- // Home Button
- m_homeButton = new QPushButton(Resource::loadIconSet("home") ,
- "", m_boxToolbar);
- m_homeButton->setFixedSize( QSize( 20, 20 ) );
- connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) );
- m_homeButton->setFlat(TRUE);
- // Documents Button
- m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",
- m_boxToolbar,"docsButton");
- m_docButton->setFixedSize( QSize( 20, 20 ) );
- connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) );
- m_docButton->setFlat(TRUE);
-
- // Close button
- m_close = new QPushButton( Resource::loadIconSet( "close"), "",
- m_boxToolbar );
- connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) );
- m_close->setFixedSize( 20, 20 );
-
- m_boxToolbar->setFixedHeight( 20 );
- m_pseudoLayout->addWidget(m_boxToolbar );
-
- // let;s fill the Location ComboBox
- StorageInfo storage;
- const QList<FileSystem> &fs = storage.fileSystems();
- QListIterator<FileSystem> it ( fs );
- for( ; it.current(); ++it ){
+ m_boxToolbar->setSpacing( 0 );
+
+ // tool bar members now
+ m_location = new QComboBox( m_boxToolbar );
+ m_location->setEditable( TRUE );
+ m_location->setDuplicatesEnabled( FALSE );
+ connect( m_location, SIGNAL(activated(const QString& ) ),
+ this, SLOT(slotLocationActivated(const QString& )) );
+ connect( m_location->lineEdit(), SIGNAL(returnPressed() ) ,
+ this, SLOT(locationComboChanged() ) );
+
+ // UP Button
+ m_up = new QPushButton( Resource::loadIconSet("up"), QString::null,
+ m_boxToolbar, "cdUpButton" );
+ m_up->setFixedSize( QSize(20, 20 ) );
+ connect( m_up, SIGNAL( clicked() ), this, SLOT(cdUP() ) );
+ m_up->setFlat( TRUE );
+
+ // Home Button
+ m_homeButton = new QPushButton(Resource::loadIconSet("home"),
+ QString::null, m_boxToolbar );
+ m_homeButton->setFixedSize( QSize(20, 20 ) );
+ connect(m_homeButton, SIGNAL(clicked() ), this, SLOT(slotHome() ) );
+ m_homeButton->setFlat( TRUE );
+
+ // Documents Button
+ m_docButton = new QPushButton( Resource::loadIconSet("DocsIcon"),
+ QString::null, m_boxToolbar,
+ "docsButton" );
+ m_docButton->setFixedSize( QSize(20, 20 ) );
+ m_docButton->setFlat( true );
+ connect( m_docButton, SIGNAL(clicked() ),
+ this, SLOT(slotDoc() ) );
+
+ // close button
+ m_close = new QPushButton( Resource::loadIconSet( "close"), "",
+ m_boxToolbar );
+ connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) );
+ m_close->setFixedSize( 20, 20 );
+
+ m_boxToolbar->setFixedHeight( 20 );
+ m_pseudoLayout->addWidget(m_boxToolbar );
+
+ /* init the locations */
+ initLocations();
+
+ if( !m_shTool ){
+ m_location->hide( );
+ m_up->hide( );
+ m_homeButton->hide( );
+ m_docButton->hide( );
+ }
+ if(!m_shClose )
+ m_close->hide();
+
+ m_mainView->setToolbar( m_pseudo );
+ m_lay->addWidget( m_mainView, 100 );
+}
+/* initialize the OLocalLister */
+void OFileSelector::initLister() {
+ m_lister = new OLocalLister(this);
+}
+/* put default locations into the bar */
+void OFileSelector::initLocations () {
+
+ // let;s fill the Location ComboBox
+ StorageInfo storage;
+ const QList<FileSystem> &fs = storage.fileSystems();
+ QListIterator<FileSystem> it ( fs );
+ for( ; it.current(); ++it ){
const QString disk = (*it)->name();
const QString path = (*it)->path();
m_location->insertItem(path+ "<-"+disk );
- }
- int count = m_location->count();
- m_location->insertItem( m_currentDir );
- m_location->setCurrentItem( count );
- // due to the New and Close button we can not simply hide m_boxToolBar to not show it
- if( !m_shTool ){
- m_location->hide( );
- m_up->hide( );
- m_homeButton->hide( );
- m_docButton->hide( );
- }
- if(!m_shClose )
- m_close->hide();
- //if(!m_shNew)
- //m_close->hide();
-
- } // off toolbar
- // the Main ListView
- // make a QWidgetStack first so Views can share the Toolbar
+ }
+ int count = m_location->count();
+ m_location->insertItem( m_currentDir );
+ m_location->setCurrentItem( count );
- // m_pseudoLayout->addWidget( m_View, 288 );
- m_stack->addWidget( m_pseudo, Extended );
- }
}
void OFileSelector::initializePerm()
@@ -1003,8 +954,8 @@ void OFileSelector::reparse()
OFileView* OFileSelector::currentView() {
- return 0l;
+ return m_fileView;
}
OFileView* OFileSelector::currentView() const{
- return 0l;
+ return m_fileView;
}
int OFileSelector::filter() {
@@ -1048,4 +999,24 @@ QPixmap OFileSelector::pixmap( const QString& s ) {
}
OLister* OFileSelector::currentLister()const {
- return 0l;
+ return m_lister;
+}
+void OFileSelector::initializeOldSelector() {
+ qWarning("initializeOldSelector");
+
+ delete m_select;
+
+ // we need to initialize but keep the selected mimetype
+ /* we default not to show close and new buttons */
+ QString mime = currentMimeType();
+ qWarning("MimeType " + mime );
+ m_select = new FileSelector( mime ,
+ m_mainView, "fileselector",
+ FALSE, FALSE);
+
+ connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
+ this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
+ connect(m_select, SIGNAL(closeMe() ),
+ this, SIGNAL(closeMe() ) );
+ //connect to close me and other signals as well
+ m_mainView->setWidget( m_select );
}
diff --git a/libopie/ofileselector/ofileselector.h b/libopie/ofileselector/ofileselector.h
index a7b363f..bf9a26b 100644
--- a/libopie/ofileselector/ofileselector.h
+++ b/libopie/ofileselector/ofileselector.h
@@ -70,4 +70,5 @@ class QHBox;
class OFileView;
class OLister;
+class OFileSelectorMain;
//
@@ -109,5 +110,5 @@ class OFileSelector : public QWidget {
* ExtendedAll also shows 'hidden' files
*/
- enum Selector{Normal=0, Extended = 1, ExtendedAll =2 };
+ enum Selector{Normal=0, Extended = 1, ExtendedAll = 2};
/**
@@ -343,4 +344,6 @@ class OFileSelector : public QWidget {
int sorting();
QPixmap pixmap( const QString& );
+ /* our tool bar */
+ QWidget* toolBar();
signals:
@@ -370,4 +373,7 @@ class OFileSelector : public QWidget {
private:
+ OFileSelectorMain* m_mainView;
+ OLister* m_lister;
+ OFileView* m_fileView;
FileSelector* m_select;
int m_mode, m_selector;
@@ -391,70 +397,73 @@ class OFileSelector : public QWidget {
QString m_currentDir;
QString m_name;
- QMap<QString, QStringList> m_mimetypes;
-
-
- QWidgetStack *m_stack;
- QVBoxLayout *m_lay;
- QGridLayout *m_Oselector;
-
- QHBox *m_boxToolbar;
- QHBox *m_boxOk;
- QHBox *m_boxName;
- QHBox *m_boxView;
-
- QPopupMenu *m_custom;
-
- QLineEdit *m_edit;
- QLabel *m_fnLabel;
-
- bool m_shClose : 1;
- bool m_shNew : 1;
- bool m_shTool : 1;
- bool m_shPerm : 1;
- bool m_shLne : 1;
- bool m_shChooser : 1;
- bool m_shYesNo : 1;
- bool m_boCheckPerm : 1;
- bool m_autoMime : 1;
- bool m_case : 1;
- bool m_dir : 1;
- bool m_files : 1;
- bool m_showPopup : 1;
-
- void initVars();
-
- void delItems();
- void initializeName();
- void initializeYes();
- void initializeChooser();
- void initializeListView();
- void initializePerm();
- void initPics();
- bool compliesMime(const QString &path,
- const QString &mime);
- bool compliesMime(const QString& mime );
+
+ QMap<QString, QStringList> m_mimetypes;
+
+ QVBoxLayout *m_lay;
+ QGridLayout *m_Oselector;
+
+ QHBox *m_boxToolbar;
+ QHBox *m_boxOk;
+ QHBox *m_boxName;
+ QHBox *m_boxView;
+
+
+ QLineEdit *m_edit;
+ QLabel *m_fnLabel;
+
+ bool m_shClose : 1;
+ bool m_shNew : 1;
+ bool m_shTool : 1;
+ bool m_shPerm : 1;
+ bool m_shLne : 1;
+ bool m_shChooser : 1;
+ bool m_shYesNo : 1;
+ bool m_boCheckPerm : 1;
+ bool m_autoMime : 1;
+ bool m_case : 1;
+ bool m_dir : 1;
+ bool m_files : 1;
+ bool m_showPopup : 1;
+ bool m_showHidden : 1;
+
+ void initVars();
+
+ void delItems();
+ void initializeName();
+ void initializeYes();
+ void initializeChooser();
+ void initializePerm();
+ void initPics();
+ bool compliesMime(const QString &path,
+ const QString &mime);
+ bool compliesMime(const QString& mime );
/**
* Updates the QComboBox with the current mimetypes
*/
- void updateMimeCheck();
+ void updateMimeCheck();
+ void initializeOldSelector();
+ void initLister();
+ void initToolbar();
+ void initLocations();
+ void initializeView() {}; // FIXME
/**
* Returns the current mimetype
*/
- QString currentMimeType()const;
- class OFileSelectorPrivate;
- OFileSelectorPrivate *d;
- static QMap<QString,QPixmap> *m_pixmaps;
+ QString currentMimeType()const;
+ class OFileSelectorPrivate;
+ OFileSelectorPrivate *d;
+ static QMap<QString,QPixmap> *m_pixmaps;
private slots:
- void slotFileSelected(const QString & ); // not really meant to be a slot
- void slotFileBridgeSelected( const DocLnk & );
- // listview above
- // popup below
- virtual void slotDelete();
- virtual void cdUP();
- virtual void slotHome();
- virtual void slotDoc();
- virtual void slotNavigate( );
+ void slotFileSelected(const QString & ); // not really meant to be a slot
+ void slotFileBridgeSelected( const DocLnk & );
+ // listview above
+ // popup below
+ virtual void slotDelete();
+ virtual void cdUP();
+ virtual void slotHome();
+ virtual void slotDoc();
+ virtual void slotNavigate( );
/* for OLister */
diff --git a/libopie/ofileselector/olister.h b/libopie/ofileselector/olister.h
index 081b876..ef61cab 100644
--- a/libopie/ofileselector/olister.h
+++ b/libopie/ofileselector/olister.h
@@ -5,4 +5,5 @@
#include <qmap.h>
#include <qstring.h>
+#include <qstringlist.h>
class OFileSelector;
diff --git a/libopie/pim/opimrecord.cpp b/libopie/pim/opimrecord.cpp
index 95de1df..d8f73c7 100644
--- a/libopie/pim/opimrecord.cpp
+++ b/libopie/pim/opimrecord.cpp
@@ -3,5 +3,7 @@
OPimRecord::OPimRecord( int uid )
: Qtopia::Record() {
+
setUid( uid );
+ /* assign a new UID */
if ( uid == 1 )
assignUid();
@@ -9,5 +11,5 @@ OPimRecord::OPimRecord( int uid )
OPimRecord::~OPimRecord() {
}
-OPimRecord::OPimRecord( OPimRecord& rec )
+OPimRecord::OPimRecord( const OPimRecord& rec )
: Qtopia::Record( rec )
{
@@ -16,7 +18,7 @@ OPimRecord::OPimRecord( OPimRecord& rec )
OPimRecord &OPimRecord::operator=( const OPimRecord& rec) {
- /* how do I call the parent copy operator ? */
- setUid( rec.uid() );
- setCategories( rec.categories() );
+ Qtopia::Record::operator=( rec );
+ m_relations = rec.m_relations;
+
return *this;
}
@@ -26,5 +28,5 @@ QStringList OPimRecord::categoryNames()const {
return list;
}
-void OPimRecord::setCategoryName( const QStringList& ) {
+void OPimRecord::setCategoryNames( const QStringList& ) {
}
@@ -89,2 +91,16 @@ void OPimRecord::setRelations( const QString& app, QArray<int> ids ) {
m_relations.replace( app, tmp );
}
+QString OPimRecord::crossToString()const {
+ QString str;
+ QMap<QString, QArray<int> >::ConstIterator it;
+ for (it = m_relations.begin(); it != m_relations.end(); ++it ) {
+ QArray<int> id = it.data();
+ for ( uint i = 0; i < id.size(); ++i ) {
+ str += it.key() + "," + QString::number( i ) + ";";
+ }
+ }
+ str = str.remove( str.length()-1, 1); // strip the ;
+ //qWarning("IDS " + str );
+
+ return str;
+}
diff --git a/libopie/pim/opimrecord.h b/libopie/pim/opimrecord.h
index a0e0413..18112d4 100644
--- a/libopie/pim/opimrecord.h
+++ b/libopie/pim/opimrecord.h
@@ -20,5 +20,5 @@ public:
* copy c'tor
*/
- OPimRecord( OPimRecord& rec );
+ OPimRecord( const OPimRecord& rec );
/**
@@ -35,5 +35,5 @@ public:
* set category names they will be resolved
*/
- void setCategoryName( const QStringList& );
+ void setCategoryNames( const QStringList& );
/**
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp
index d8e0447..3c93838 100644
--- a/libopie/pim/otodo.cpp
+++ b/libopie/pim/otodo.cpp
@@ -12,12 +12,11 @@
#include <qpe/categoryselect.h>
-#include "todoevent.h"
-using namespace Opie;
-Qtopia::UidGen ToDoEvent::m_gen;
+#include "otodo.h"
-struct ToDoEvent::ToDoEventData : public QShared {
- ToDoEventData() : QShared() {
+
+struct OTodo::OTodoData : public QShared {
+ OTodoData() : QShared() {
};
@@ -30,6 +29,4 @@ struct ToDoEvent::ToDoEventData : public QShared {
QString sum;
QMap<QString, QString> extra;
- QMap<QString, QArray<int> > relations;
- int uid;
ushort prog;
bool hasAlarmDateTime :1;
@@ -37,13 +34,13 @@ struct ToDoEvent::ToDoEventData : public QShared {
};
-ToDoEvent::ToDoEvent(const ToDoEvent &event )
- : data( event.data )
+OTodo::OTodo(const OTodo &event )
+ : OPimRecord( event ), data( event.data )
{
data->ref();
//qWarning("ref up");
}
-ToDoEvent::~ToDoEvent() {
+OTodo::~OTodo() {
if ( data->deref() ) {
- //qWarning("ToDoEvent::dereffing");
+ //qWarning("OTodo::dereffing");
delete data;
data = 0l;
@@ -51,5 +48,5 @@ ToDoEvent::~ToDoEvent() {
}
-ToDoEvent::ToDoEvent(bool completed, int priority,
+OTodo::OTodo(bool completed, int priority,
const QStringList &category,
const QString& summary,
@@ -57,33 +54,20 @@ ToDoEvent::ToDoEvent(bool completed, int priority,
ushort progress,
bool hasDate, QDate date, int uid )
+ : OPimRecord( uid )
{
- //qWarning("ToDoEventData");
- data = new ToDoEventData;
+ //qWarning("OTodoData");
+ setCategories( idsFromString( category.join(";") ) );
+ data = new OTodoData;
data->date = date;
data->isCompleted = completed;
data->hasDate = hasDate;
data->priority = priority;
- data->category = category;
data->sum = summary;
data->prog = progress;
data->desc = Qtopia::simplifyMultiLineSpace(description );
- if (uid == -1 ) {
- uid = m_gen.generate();
-
- }// generated the ids
- m_gen.store( uid );
-
- data->uid = uid;
data->hasAlarmDateTime = false;
}
-QArray<int> ToDoEvent::categories()const
-{
- qWarning( "ToDoEvent:cats" + data->category.join(";") );
- QArray<int> array(data->category.count() ); // currently the datebook can be only in one category
- array = Qtopia::Record::idsFromString( data->category.join(";") );
- return array;
-}
-bool ToDoEvent::match( const QRegExp &regExp )const
+bool OTodo::match( const QRegExp &regExp )const
{
if( QString::number( data->priority ).find( regExp ) != -1 ){
@@ -93,184 +77,88 @@ bool ToDoEvent::match( const QRegExp &regExp )const
}else if(data->desc.find( regExp ) != -1 ){
return true;
+ }else if(data->sum.find( regExp ) != -1 ) {
+ return true;
}
return false;
}
-bool ToDoEvent::isCompleted() const
+bool OTodo::isCompleted() const
{
return data->isCompleted;
}
-bool ToDoEvent::hasDueDate() const
+bool OTodo::hasDueDate() const
{
return data->hasDate;
}
-bool ToDoEvent::hasAlarmDateTime() const
+bool OTodo::hasAlarmDateTime() const
{
return data->hasAlarmDateTime;
}
-int ToDoEvent::priority()const
+int OTodo::priority()const
{
return data->priority;
}
-QStringList ToDoEvent::allCategories()const
-{
- return data->category;
-}
-QString ToDoEvent::extra(const QString& )const
-{
- return QString::null;
-}
-QString ToDoEvent::summary() const
+QString OTodo::summary() const
{
return data->sum;
}
-ushort ToDoEvent::progress() const
+ushort OTodo::progress() const
{
return data->prog;
}
-QStringList ToDoEvent::relatedApps() const
-{
- QStringList list;
- QMap<QString, QArray<int> >::ConstIterator it;
- for ( it = data->relations.begin(); it != data->relations.end(); ++it ) {
- list << it.key();
- }
- return list;
-}
-QArray<int> ToDoEvent::relations( const QString& app)const
-{
- QArray<int> tmp;
- QMap<QString, QArray<int> >::ConstIterator it;
- it = data->relations.find( app);
- if ( it != data->relations.end() )
- tmp = it.data();
- return tmp;
-}
-void ToDoEvent::insertCategory(const QString &str )
-{
- changeOrModify();
- qWarning("insert category;" + str );
- data->category.append( str );
-}
-void ToDoEvent::clearCategories()
-{
- changeOrModify();
- data->category.clear();
-}
-void ToDoEvent::setCategories(const QStringList &list )
-{
- changeOrModify();
- qWarning("set categories" + list.join(";") );
- data->category = list;
-}
-QDate ToDoEvent::dueDate()const
+QDate OTodo::dueDate()const
{
return data->date;
}
-QDateTime ToDoEvent::alarmDateTime() const
+QDateTime OTodo::alarmDateTime() const
{
return data->alarmDateTime;
}
-QString ToDoEvent::description()const
+QString OTodo::description()const
{
return data->desc;
}
-void ToDoEvent::setCompleted( bool completed )
+void OTodo::setCompleted( bool completed )
{
changeOrModify();
data->isCompleted = completed;
}
-void ToDoEvent::setHasDueDate( bool hasDate )
+void OTodo::setHasDueDate( bool hasDate )
{
changeOrModify();
data->hasDate = hasDate;
}
-void ToDoEvent::setHasAlarmDateTime( bool hasAlarmDateTime )
+void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime )
{
changeOrModify();
data->hasAlarmDateTime = hasAlarmDateTime;
}
-void ToDoEvent::setDescription(const QString &desc )
+void OTodo::setDescription(const QString &desc )
{
changeOrModify();
data->desc = Qtopia::simplifyMultiLineSpace(desc );
}
-void ToDoEvent::setExtra( const QString&, const QString& )
-{
-
-}
-void ToDoEvent::setSummary( const QString& sum )
+void OTodo::setSummary( const QString& sum )
{
changeOrModify();
data->sum = sum;
}
-void ToDoEvent::setCategory( const QString &cat )
-{
- changeOrModify();
- //qWarning("setCategory %s", cat.latin1() );
- data->category.clear();
- data->category << cat;
-}
-void ToDoEvent::setPriority(int prio )
+void OTodo::setPriority(int prio )
{
changeOrModify();
data->priority = prio;
}
-void ToDoEvent::setDueDate( QDate date )
+void OTodo::setDueDate( QDate date )
{
changeOrModify();
data->date = date;
}
-void ToDoEvent::setAlarmDateTime( const QDateTime& alarm )
+void OTodo::setAlarmDateTime( const QDateTime& alarm )
{
changeOrModify();
data->alarmDateTime = alarm;
}
-void ToDoEvent::addRelated( const QString &app, int id )
-{
- changeOrModify();
-
- QMap<QString, QArray<int> >::Iterator it;
- QArray<int> tmp;
- it = data->relations.find( app );
- if ( it == data->relations.end() ) {
- tmp.resize(1 );
- tmp[0] = id;
- }else{
- tmp = it.data();
- tmp.resize( tmp.size() + 1 );
- tmp[tmp.size() - 1] = id;
- }
- data->relations.replace( app, tmp );
-}
-void ToDoEvent::addRelated(const QString& app, QArray<int> ids )
-{
- changeOrModify();
-
- QMap<QString, QArray<int> >::Iterator it;
- QArray<int> tmp;
- it = data->relations.find( app);
- if ( it == data->relations.end() ) { // not there
- /** tmp.resize( ids.size() ); stupid??
- */
- tmp = ids;
- }else{
- tmp = it.data();
- int offset = tmp.size()-1;
- tmp.resize( tmp.size() + ids.size() );
- for (uint i = 0; i < ids.size(); i++ ) {
- tmp[offset+i] = ids[i];
- }
-
- }
- data->relations.replace( app, tmp );
-}
-void ToDoEvent::clearRelated( const QString& app )
-{
- changeOrModify();
- data->relations.remove( app );
-}
-bool ToDoEvent::isOverdue( )
+bool OTodo::isOverdue( )
{
if( data->hasDate )
@@ -278,13 +166,16 @@ bool ToDoEvent::isOverdue( )
return false;
}
-void ToDoEvent::setProgress(ushort progress )
+void OTodo::setProgress(ushort progress )
{
changeOrModify();
data->prog = progress;
}
+QString OTodo::toShortText() const {
+ return summary();
+}
/*!
Returns a richt text string
*/
-QString ToDoEvent::richText() const
+QString OTodo::toRichText() const
{
QString text;
@@ -317,26 +208,12 @@ QString ToDoEvent::richText() const
}
- // Open database of all categories and get the list of
- // the categories this todoevent belongs to.
- // Then print them...
- // I am not sure whether there is no better way doing this !?
- Categories catdb;
- bool firstloop = true;
- catdb.load( categoryFileName() );
- catlist = allCategories();
-
text += "<b>" + QObject::tr( "Category:") + "</b> ";
- for ( QStringList::Iterator it = catlist.begin(); it != catlist.end(); ++it ) {
- if (!firstloop){
- text += ", ";
- }
- firstloop = false;
- text += catdb.label ("todo", (*it).toInt());
- }
+ text += categoryNames().join(", ");
text += "<br>";
+
return text;
}
-bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{
+bool OTodo::operator<( const OTodo &toDoEvent )const{
if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
@@ -350,5 +227,5 @@ bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{
return false;
}
-bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const
+bool OTodo::operator<=(const OTodo &toDoEvent )const
{
if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
@@ -363,5 +240,5 @@ bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const
return true;
}
-bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const
+bool OTodo::operator>(const OTodo &toDoEvent )const
{
if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false;
@@ -376,5 +253,5 @@ bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const
return false;
}
-bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const
+bool OTodo::operator>=(const OTodo &toDoEvent )const
{
if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
@@ -389,5 +266,5 @@ bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const
return true;
}
-bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const
+bool OTodo::operator==(const OTodo &toDoEvent )const
{
if( data->priority == toDoEvent.data->priority &&
@@ -405,5 +282,5 @@ bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const
return false;
}
-void ToDoEvent::deref() {
+void OTodo::deref() {
//qWarning("deref in ToDoEvent");
@@ -414,21 +291,19 @@ void ToDoEvent::deref() {
}
}
-ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item )
+OTodo &OTodo::operator=(const OTodo &item )
{
+ OPimRecord::operator=( item );
//qWarning("operator= ref ");
item.data->ref();
deref();
- data = item.data;
-
-
return *this;
}
-QMap<int, QString> ToDoEvent::toMap() const {
+QMap<int, QString> OTodo::toMap() const {
QMap<int, QString> map;
- map.insert( Uid, QString::number( data->uid ) );
- map.insert( Category, data->category.join(";") );
+ map.insert( Uid, QString::number( uid() ) );
+ map.insert( Category, idsToString( categories() ) );
map.insert( HasDate, QString::number( data->hasDate ) );
map.insert( Completed, QString::number( data->isCompleted ) );
@@ -447,30 +322,5 @@ QMap<int, QString> ToDoEvent::toMap() const {
}
-
-QString ToDoEvent::crossToString()const {
- QString str;
- QMap<QString, QArray<int> >::ConstIterator it;
- for (it = data->relations.begin(); it != data->relations.end(); ++it ) {
- QArray<int> id = it.data();
- for ( uint i = 0; i < id.size(); ++i ) {
- str += it.key() + "," + QString::number( i ) + ";";
- }
- }
- str = str.remove( str.length()-1, 1); // strip the ;
- //qWarning("IDS " + str );
-
- return str;
-}
-int ToDoEvent::uid()const {
- return data->uid;
-}
-void ToDoEvent::setUid( int id ) {
- if ( id == -1 )
- id = m_gen.generate();
- m_gen.store(id );
- changeOrModify();
- data->uid = id;
-}
-QMap<QString, QString> ToDoEvent::extras()const {
+QMap<QString, QString> OTodo::toExtraMap()const {
return data->extra;
}
@@ -480,24 +330,21 @@ QMap<QString, QString> ToDoEvent::extras()const {
* right in place
*/
-void ToDoEvent::changeOrModify() {
+void OTodo::changeOrModify() {
if ( data->count != 1 ) {
//qWarning("changeOrModify");
data->deref();
- ToDoEventData* d2 = new ToDoEventData();
+ OTodoData* d2 = new OTodoData();
copy(data, d2 );
data = d2;
}
}
-void ToDoEvent::copy( ToDoEventData* src, ToDoEventData* dest ) {
+void OTodo::copy( OTodoData* src, OTodoData* dest ) {
dest->date = src->date;
dest->isCompleted = src->isCompleted;
dest->hasDate = src->hasDate;
dest->priority = src->priority;
- dest->category = src->category;
dest->desc = src->desc;
dest->sum = src->sum;
dest->extra = src->extra;
- dest->relations = src->relations;
- dest->uid = src->uid;
dest->prog = src->prog;
dest->hasAlarmDateTime = src->hasAlarmDateTime;
diff --git a/libopie/pim/otodo.h b/libopie/pim/otodo.h
index 429108a..e1729db 100644
--- a/libopie/pim/otodo.h
+++ b/libopie/pim/otodo.h
@@ -19,5 +19,5 @@
class OTodo : public OPimRecord {
public:
- typedef QValueList<ToDoEvent> ValueList;
+ typedef QValueList<OTodo> ValueList;
enum RecordFields {
Uid = Qtopia::UID_ID,
@@ -119,4 +119,11 @@ public:
QString toRichText() const;
+ /**
+ * reimplementation
+ */
+ QString type()const;
+ QString toShortText()const;
+ QMap<QString, QString> toExtraMap()const;
+ QString recordField(int id )const;
/**
@@ -184,22 +191,21 @@ public:
bool operator>=(const OTodo &toDoEvent)const;
bool operator==(const OTodo &toDoEvent )const;
- ToDoEvent &operator=(const OTodo &toDoEvent );
+ OTodo &operator=(const OTodo &toDoEvent );
private:
class OTodoPrivate;
- struct OTodoEventData;
+ struct OTodoData;
void deref();
void changeOrModify();
void copy( OTodoData* src, OTodoData* dest );
- ToDoEventPrivate *d;
- ToDoEventData *data;
+ OTodoPrivate *d;
+ OTodoData *data;
- static Qtopia::UidGen m_gen;
-};
- inline bool ToDoEvent::operator!=(const ToDoEvent &toDoEvent )const {
- return !(*this == toDoEvent);
- }
};
+inline bool OTodo::operator!=(const OTodo &toDoEvent )const {
+ return !(*this == toDoEvent);
+}
+
#endif
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp
index 95de1df..d8f73c7 100644
--- a/libopie2/opiepim/core/opimrecord.cpp
+++ b/libopie2/opiepim/core/opimrecord.cpp
@@ -3,5 +3,7 @@
OPimRecord::OPimRecord( int uid )
: Qtopia::Record() {
+
setUid( uid );
+ /* assign a new UID */
if ( uid == 1 )
assignUid();
@@ -9,5 +11,5 @@ OPimRecord::OPimRecord( int uid )
OPimRecord::~OPimRecord() {
}
-OPimRecord::OPimRecord( OPimRecord& rec )
+OPimRecord::OPimRecord( const OPimRecord& rec )
: Qtopia::Record( rec )
{
@@ -16,7 +18,7 @@ OPimRecord::OPimRecord( OPimRecord& rec )
OPimRecord &OPimRecord::operator=( const OPimRecord& rec) {
- /* how do I call the parent copy operator ? */
- setUid( rec.uid() );
- setCategories( rec.categories() );
+ Qtopia::Record::operator=( rec );
+ m_relations = rec.m_relations;
+
return *this;
}
@@ -26,5 +28,5 @@ QStringList OPimRecord::categoryNames()const {
return list;
}
-void OPimRecord::setCategoryName( const QStringList& ) {
+void OPimRecord::setCategoryNames( const QStringList& ) {
}
@@ -89,2 +91,16 @@ void OPimRecord::setRelations( const QString& app, QArray<int> ids ) {
m_relations.replace( app, tmp );
}
+QString OPimRecord::crossToString()const {
+ QString str;
+ QMap<QString, QArray<int> >::ConstIterator it;
+ for (it = m_relations.begin(); it != m_relations.end(); ++it ) {
+ QArray<int> id = it.data();
+ for ( uint i = 0; i < id.size(); ++i ) {
+ str += it.key() + "," + QString::number( i ) + ";";
+ }
+ }
+ str = str.remove( str.length()-1, 1); // strip the ;
+ //qWarning("IDS " + str );
+
+ return str;
+}
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h
index a0e0413..18112d4 100644
--- a/libopie2/opiepim/core/opimrecord.h
+++ b/libopie2/opiepim/core/opimrecord.h
@@ -20,5 +20,5 @@ public:
* copy c'tor
*/
- OPimRecord( OPimRecord& rec );
+ OPimRecord( const OPimRecord& rec );
/**
@@ -35,5 +35,5 @@ public:
* set category names they will be resolved
*/
- void setCategoryName( const QStringList& );
+ void setCategoryNames( const QStringList& );
/**
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp
index d8e0447..3c93838 100644
--- a/libopie2/opiepim/otodo.cpp
+++ b/libopie2/opiepim/otodo.cpp
@@ -12,12 +12,11 @@
#include <qpe/categoryselect.h>
-#include "todoevent.h"
-using namespace Opie;
-Qtopia::UidGen ToDoEvent::m_gen;
+#include "otodo.h"
-struct ToDoEvent::ToDoEventData : public QShared {
- ToDoEventData() : QShared() {
+
+struct OTodo::OTodoData : public QShared {
+ OTodoData() : QShared() {
};
@@ -30,6 +29,4 @@ struct ToDoEvent::ToDoEventData : public QShared {
QString sum;
QMap<QString, QString> extra;
- QMap<QString, QArray<int> > relations;
- int uid;
ushort prog;
bool hasAlarmDateTime :1;
@@ -37,13 +34,13 @@ struct ToDoEvent::ToDoEventData : public QShared {
};
-ToDoEvent::ToDoEvent(const ToDoEvent &event )
- : data( event.data )
+OTodo::OTodo(const OTodo &event )
+ : OPimRecord( event ), data( event.data )
{
data->ref();
//qWarning("ref up");
}
-ToDoEvent::~ToDoEvent() {
+OTodo::~OTodo() {
if ( data->deref() ) {
- //qWarning("ToDoEvent::dereffing");
+ //qWarning("OTodo::dereffing");
delete data;
data = 0l;
@@ -51,5 +48,5 @@ ToDoEvent::~ToDoEvent() {
}
-ToDoEvent::ToDoEvent(bool completed, int priority,
+OTodo::OTodo(bool completed, int priority,
const QStringList &category,
const QString& summary,
@@ -57,33 +54,20 @@ ToDoEvent::ToDoEvent(bool completed, int priority,
ushort progress,
bool hasDate, QDate date, int uid )
+ : OPimRecord( uid )
{
- //qWarning("ToDoEventData");
- data = new ToDoEventData;
+ //qWarning("OTodoData");
+ setCategories( idsFromString( category.join(";") ) );
+ data = new OTodoData;
data->date = date;
data->isCompleted = completed;
data->hasDate = hasDate;
data->priority = priority;
- data->category = category;
data->sum = summary;
data->prog = progress;
data->desc = Qtopia::simplifyMultiLineSpace(description );
- if (uid == -1 ) {
- uid = m_gen.generate();
-
- }// generated the ids
- m_gen.store( uid );
-
- data->uid = uid;
data->hasAlarmDateTime = false;
}
-QArray<int> ToDoEvent::categories()const
-{
- qWarning( "ToDoEvent:cats" + data->category.join(";") );
- QArray<int> array(data->category.count() ); // currently the datebook can be only in one category
- array = Qtopia::Record::idsFromString( data->category.join(";") );
- return array;
-}
-bool ToDoEvent::match( const QRegExp &regExp )const
+bool OTodo::match( const QRegExp &regExp )const
{
if( QString::number( data->priority ).find( regExp ) != -1 ){
@@ -93,184 +77,88 @@ bool ToDoEvent::match( const QRegExp &regExp )const
}else if(data->desc.find( regExp ) != -1 ){
return true;
+ }else if(data->sum.find( regExp ) != -1 ) {
+ return true;
}
return false;
}
-bool ToDoEvent::isCompleted() const
+bool OTodo::isCompleted() const
{
return data->isCompleted;
}
-bool ToDoEvent::hasDueDate() const
+bool OTodo::hasDueDate() const
{
return data->hasDate;
}
-bool ToDoEvent::hasAlarmDateTime() const
+bool OTodo::hasAlarmDateTime() const
{
return data->hasAlarmDateTime;
}
-int ToDoEvent::priority()const
+int OTodo::priority()const
{
return data->priority;
}
-QStringList ToDoEvent::allCategories()const
-{
- return data->category;
-}
-QString ToDoEvent::extra(const QString& )const
-{
- return QString::null;
-}
-QString ToDoEvent::summary() const
+QString OTodo::summary() const
{
return data->sum;
}
-ushort ToDoEvent::progress() const
+ushort OTodo::progress() const
{
return data->prog;
}
-QStringList ToDoEvent::relatedApps() const
-{
- QStringList list;
- QMap<QString, QArray<int> >::ConstIterator it;
- for ( it = data->relations.begin(); it != data->relations.end(); ++it ) {
- list << it.key();
- }
- return list;
-}
-QArray<int> ToDoEvent::relations( const QString& app)const
-{
- QArray<int> tmp;
- QMap<QString, QArray<int> >::ConstIterator it;
- it = data->relations.find( app);
- if ( it != data->relations.end() )
- tmp = it.data();
- return tmp;
-}
-void ToDoEvent::insertCategory(const QString &str )
-{
- changeOrModify();
- qWarning("insert category;" + str );
- data->category.append( str );
-}
-void ToDoEvent::clearCategories()
-{
- changeOrModify();
- data->category.clear();
-}
-void ToDoEvent::setCategories(const QStringList &list )
-{
- changeOrModify();
- qWarning("set categories" + list.join(";") );
- data->category = list;
-}
-QDate ToDoEvent::dueDate()const
+QDate OTodo::dueDate()const
{
return data->date;
}
-QDateTime ToDoEvent::alarmDateTime() const
+QDateTime OTodo::alarmDateTime() const
{
return data->alarmDateTime;
}
-QString ToDoEvent::description()const
+QString OTodo::description()const
{
return data->desc;
}
-void ToDoEvent::setCompleted( bool completed )
+void OTodo::setCompleted( bool completed )
{
changeOrModify();
data->isCompleted = completed;
}
-void ToDoEvent::setHasDueDate( bool hasDate )
+void OTodo::setHasDueDate( bool hasDate )
{
changeOrModify();
data->hasDate = hasDate;
}
-void ToDoEvent::setHasAlarmDateTime( bool hasAlarmDateTime )
+void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime )
{
changeOrModify();
data->hasAlarmDateTime = hasAlarmDateTime;
}
-void ToDoEvent::setDescription(const QString &desc )
+void OTodo::setDescription(const QString &desc )
{
changeOrModify();
data->desc = Qtopia::simplifyMultiLineSpace(desc );
}
-void ToDoEvent::setExtra( const QString&, const QString& )
-{
-
-}
-void ToDoEvent::setSummary( const QString& sum )
+void OTodo::setSummary( const QString& sum )
{
changeOrModify();
data->sum = sum;
}
-void ToDoEvent::setCategory( const QString &cat )
-{
- changeOrModify();
- //qWarning("setCategory %s", cat.latin1() );
- data->category.clear();
- data->category << cat;
-}
-void ToDoEvent::setPriority(int prio )
+void OTodo::setPriority(int prio )
{
changeOrModify();
data->priority = prio;
}
-void ToDoEvent::setDueDate( QDate date )
+void OTodo::setDueDate( QDate date )
{
changeOrModify();
data->date = date;
}
-void ToDoEvent::setAlarmDateTime( const QDateTime& alarm )
+void OTodo::setAlarmDateTime( const QDateTime& alarm )
{
changeOrModify();
data->alarmDateTime = alarm;
}
-void ToDoEvent::addRelated( const QString &app, int id )
-{
- changeOrModify();
-
- QMap<QString, QArray<int> >::Iterator it;
- QArray<int> tmp;
- it = data->relations.find( app );
- if ( it == data->relations.end() ) {
- tmp.resize(1 );
- tmp[0] = id;
- }else{
- tmp = it.data();
- tmp.resize( tmp.size() + 1 );
- tmp[tmp.size() - 1] = id;
- }
- data->relations.replace( app, tmp );
-}
-void ToDoEvent::addRelated(const QString& app, QArray<int> ids )
-{
- changeOrModify();
-
- QMap<QString, QArray<int> >::Iterator it;
- QArray<int> tmp;
- it = data->relations.find( app);
- if ( it == data->relations.end() ) { // not there
- /** tmp.resize( ids.size() ); stupid??
- */
- tmp = ids;
- }else{
- tmp = it.data();
- int offset = tmp.size()-1;
- tmp.resize( tmp.size() + ids.size() );
- for (uint i = 0; i < ids.size(); i++ ) {
- tmp[offset+i] = ids[i];
- }
-
- }
- data->relations.replace( app, tmp );
-}
-void ToDoEvent::clearRelated( const QString& app )
-{
- changeOrModify();
- data->relations.remove( app );
-}
-bool ToDoEvent::isOverdue( )
+bool OTodo::isOverdue( )
{
if( data->hasDate )
@@ -278,13 +166,16 @@ bool ToDoEvent::isOverdue( )
return false;
}
-void ToDoEvent::setProgress(ushort progress )
+void OTodo::setProgress(ushort progress )
{
changeOrModify();
data->prog = progress;
}
+QString OTodo::toShortText() const {
+ return summary();
+}
/*!
Returns a richt text string
*/
-QString ToDoEvent::richText() const
+QString OTodo::toRichText() const
{
QString text;
@@ -317,26 +208,12 @@ QString ToDoEvent::richText() const
}
- // Open database of all categories and get the list of
- // the categories this todoevent belongs to.
- // Then print them...
- // I am not sure whether there is no better way doing this !?
- Categories catdb;
- bool firstloop = true;
- catdb.load( categoryFileName() );
- catlist = allCategories();
-
text += "<b>" + QObject::tr( "Category:") + "</b> ";
- for ( QStringList::Iterator it = catlist.begin(); it != catlist.end(); ++it ) {
- if (!firstloop){
- text += ", ";
- }
- firstloop = false;
- text += catdb.label ("todo", (*it).toInt());
- }
+ text += categoryNames().join(", ");
text += "<br>";
+
return text;
}
-bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{
+bool OTodo::operator<( const OTodo &toDoEvent )const{
if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
@@ -350,5 +227,5 @@ bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{
return false;
}
-bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const
+bool OTodo::operator<=(const OTodo &toDoEvent )const
{
if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
@@ -363,5 +240,5 @@ bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const
return true;
}
-bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const
+bool OTodo::operator>(const OTodo &toDoEvent )const
{
if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false;
@@ -376,5 +253,5 @@ bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const
return false;
}
-bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const
+bool OTodo::operator>=(const OTodo &toDoEvent )const
{
if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
@@ -389,5 +266,5 @@ bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const
return true;
}
-bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const
+bool OTodo::operator==(const OTodo &toDoEvent )const
{
if( data->priority == toDoEvent.data->priority &&
@@ -405,5 +282,5 @@ bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const
return false;
}
-void ToDoEvent::deref() {
+void OTodo::deref() {
//qWarning("deref in ToDoEvent");
@@ -414,21 +291,19 @@ void ToDoEvent::deref() {
}
}
-ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item )
+OTodo &OTodo::operator=(const OTodo &item )
{
+ OPimRecord::operator=( item );
//qWarning("operator= ref ");
item.data->ref();
deref();
- data = item.data;
-
-
return *this;
}
-QMap<int, QString> ToDoEvent::toMap() const {
+QMap<int, QString> OTodo::toMap() const {
QMap<int, QString> map;
- map.insert( Uid, QString::number( data->uid ) );
- map.insert( Category, data->category.join(";") );
+ map.insert( Uid, QString::number( uid() ) );
+ map.insert( Category, idsToString( categories() ) );
map.insert( HasDate, QString::number( data->hasDate ) );
map.insert( Completed, QString::number( data->isCompleted ) );
@@ -447,30 +322,5 @@ QMap<int, QString> ToDoEvent::toMap() const {
}
-
-QString ToDoEvent::crossToString()const {
- QString str;
- QMap<QString, QArray<int> >::ConstIterator it;
- for (it = data->relations.begin(); it != data->relations.end(); ++it ) {
- QArray<int> id = it.data();
- for ( uint i = 0; i < id.size(); ++i ) {
- str += it.key() + "," + QString::number( i ) + ";";
- }
- }
- str = str.remove( str.length()-1, 1); // strip the ;
- //qWarning("IDS " + str );
-
- return str;
-}
-int ToDoEvent::uid()const {
- return data->uid;
-}
-void ToDoEvent::setUid( int id ) {
- if ( id == -1 )
- id = m_gen.generate();
- m_gen.store(id );
- changeOrModify();
- data->uid = id;
-}
-QMap<QString, QString> ToDoEvent::extras()const {
+QMap<QString, QString> OTodo::toExtraMap()const {
return data->extra;
}
@@ -480,24 +330,21 @@ QMap<QString, QString> ToDoEvent::extras()const {
* right in place
*/
-void ToDoEvent::changeOrModify() {
+void OTodo::changeOrModify() {
if ( data->count != 1 ) {
//qWarning("changeOrModify");
data->deref();
- ToDoEventData* d2 = new ToDoEventData();
+ OTodoData* d2 = new OTodoData();
copy(data, d2 );
data = d2;
}
}
-void ToDoEvent::copy( ToDoEventData* src, ToDoEventData* dest ) {
+void OTodo::copy( OTodoData* src, OTodoData* dest ) {
dest->date = src->date;
dest->isCompleted = src->isCompleted;
dest->hasDate = src->hasDate;
dest->priority = src->priority;
- dest->category = src->category;
dest->desc = src->desc;
dest->sum = src->sum;
dest->extra = src->extra;
- dest->relations = src->relations;
- dest->uid = src->uid;
dest->prog = src->prog;
dest->hasAlarmDateTime = src->hasAlarmDateTime;
diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h
index 429108a..e1729db 100644
--- a/libopie2/opiepim/otodo.h
+++ b/libopie2/opiepim/otodo.h
@@ -19,5 +19,5 @@
class OTodo : public OPimRecord {
public:
- typedef QValueList<ToDoEvent> ValueList;
+ typedef QValueList<OTodo> ValueList;
enum RecordFields {
Uid = Qtopia::UID_ID,
@@ -119,4 +119,11 @@ public:
QString toRichText() const;
+ /**
+ * reimplementation
+ */
+ QString type()const;
+ QString toShortText()const;
+ QMap<QString, QString> toExtraMap()const;
+ QString recordField(int id )const;
/**
@@ -184,22 +191,21 @@ public:
bool operator>=(const OTodo &toDoEvent)const;
bool operator==(const OTodo &toDoEvent )const;
- ToDoEvent &operator=(const OTodo &toDoEvent );
+ OTodo &operator=(const OTodo &toDoEvent );
private:
class OTodoPrivate;
- struct OTodoEventData;
+ struct OTodoData;
void deref();
void changeOrModify();
void copy( OTodoData* src, OTodoData* dest );
- ToDoEventPrivate *d;
- ToDoEventData *data;
+ OTodoPrivate *d;
+ OTodoData *data;
- static Qtopia::UidGen m_gen;
-};
- inline bool ToDoEvent::operator!=(const ToDoEvent &toDoEvent )const {
- return !(*this == toDoEvent);
- }
};
+inline bool OTodo::operator!=(const OTodo &toDoEvent )const {
+ return !(*this == toDoEvent);
+}
+
#endif