author | tille <tille> | 2003-05-07 12:36:02 (UTC) |
---|---|---|
committer | tille <tille> | 2003-05-07 12:36:02 (UTC) |
commit | b8a79edda20f0b764c8d70fb664f21fb80b61299 (patch) (unidiff) | |
tree | d5a939395540c7e77fd0f50be0269c2a4537dba6 | |
parent | f9cc1ea78086e7df714a34412bbccdbd5c31f62f (diff) | |
download | opie-b8a79edda20f0b764c8d70fb664f21fb80b61299.zip opie-b8a79edda20f0b764c8d70fb664f21fb80b61299.tar.gz opie-b8a79edda20f0b764c8d70fb664f21fb80b61299.tar.bz2 |
initial import
searches contacts, todos and events
not much more yet
25 files changed, 1066 insertions, 0 deletions
diff --git a/core/pim/osearch/adresssearch.cpp b/core/pim/osearch/adresssearch.cpp new file mode 100644 index 0000000..4b0bd9c --- a/dev/null +++ b/core/pim/osearch/adresssearch.cpp | |||
@@ -0,0 +1,47 @@ | |||
1 | // | ||
2 | // | ||
3 | // C++ Implementation: $MODULE$ | ||
4 | // | ||
5 | // Description: | ||
6 | // | ||
7 | // | ||
8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 | ||
9 | // | ||
10 | // Copyright: See COPYING file that comes with this distribution | ||
11 | // | ||
12 | // | ||
13 | #include "adresssearch.h" | ||
14 | |||
15 | #include <opie/ocontactaccess.h> | ||
16 | |||
17 | #include "contactitem.h" | ||
18 | //#include <qdir.h> | ||
19 | |||
20 | AdressSearch::AdressSearch(QListView* parent, QString name): | ||
21 | SearchGroup(parent, name) | ||
22 | { | ||
23 | _contacts = 0; | ||
24 | } | ||
25 | |||
26 | |||
27 | AdressSearch::~AdressSearch() | ||
28 | { | ||
29 | delete _contacts; | ||
30 | } | ||
31 | |||
32 | |||
33 | void AdressSearch::expand() | ||
34 | { | ||
35 | SearchGroup::expand(); | ||
36 | if (_search.isEmpty()) return; | ||
37 | if (!_contacts) _contacts = new OContactAccess("osearch"); | ||
38 | ORecordList<OContact> results = _contacts->matchRegexp(_search); | ||
39 | for (uint i = 0; i < results.count(); i++) { | ||
40 | // qDebug("i=%i",i); | ||
41 | // OContact rec = results[i]; | ||
42 | // qDebug("fullname %s",rec.fullName().latin1()); | ||
43 | //(( new OListViewItem( this, rec.fullName() ); | ||
44 | new ContactItem( this, new OContact( results[i] )); | ||
45 | } | ||
46 | } | ||
47 | |||
diff --git a/core/pim/osearch/adresssearch.h b/core/pim/osearch/adresssearch.h new file mode 100644 index 0000000..ab560d0 --- a/dev/null +++ b/core/pim/osearch/adresssearch.h | |||
@@ -0,0 +1,38 @@ | |||
1 | // | ||
2 | // | ||
3 | // C++ Interface: $MODULE$ | ||
4 | // | ||
5 | // Description: | ||
6 | // | ||
7 | // | ||
8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 | ||
9 | // | ||
10 | // Copyright: See COPYING file that comes with this distribution | ||
11 | // | ||
12 | // | ||
13 | #ifndef ADRESSSEARCH_H | ||
14 | #define ADRESSSEARCH_H | ||
15 | |||
16 | #include "searchgroup.h" | ||
17 | |||
18 | class OContactAccess; | ||
19 | |||
20 | /** | ||
21 | @author Patrick S. Vogt | ||
22 | */ | ||
23 | class AdressSearch : public SearchGroup | ||
24 | { | ||
25 | public: | ||
26 | AdressSearch(QListView* parent, QString name); | ||
27 | ~AdressSearch(); | ||
28 | |||
29 | virtual void expand(); | ||
30 | |||
31 | protected: | ||
32 | |||
33 | |||
34 | private: | ||
35 | OContactAccess *_contacts; | ||
36 | }; | ||
37 | |||
38 | #endif | ||
diff --git a/core/pim/osearch/config.in b/core/pim/osearch/config.in new file mode 100644 index 0000000..85fa632 --- a/dev/null +++ b/core/pim/osearch/config.in | |||
@@ -0,0 +1,4 @@ | |||
1 | config CONFEDIT | ||
2 | boolean "oseatch" | ||
3 | default "y" | ||
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | ||
diff --git a/core/pim/osearch/contactitem.cpp b/core/pim/osearch/contactitem.cpp new file mode 100644 index 0000000..36e4f00 --- a/dev/null +++ b/core/pim/osearch/contactitem.cpp | |||
@@ -0,0 +1,35 @@ | |||
1 | // | ||
2 | // | ||
3 | // C++ Implementation: $MODULE$ | ||
4 | // | ||
5 | // Description: | ||
6 | // | ||
7 | // | ||
8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 | ||
9 | // | ||
10 | // Copyright: See COPYING file that comes with this distribution | ||
11 | // | ||
12 | // | ||
13 | #include "contactitem.h" | ||
14 | |||
15 | #include <opie/ocontact.h> | ||
16 | |||
17 | ContactItem::ContactItem(OListViewItem* parent, OContact *contact) | ||
18 | : ResultItem(parent) | ||
19 | { | ||
20 | _contact = contact; | ||
21 | setText(0, _contact->fullName()); | ||
22 | } | ||
23 | |||
24 | |||
25 | ContactItem::~ContactItem() | ||
26 | { | ||
27 | delete _contact; | ||
28 | } | ||
29 | |||
30 | |||
31 | QString ContactItem::toRichText() | ||
32 | { | ||
33 | return _contact->toRichText(); | ||
34 | } | ||
35 | |||
diff --git a/core/pim/osearch/contactitem.h b/core/pim/osearch/contactitem.h new file mode 100644 index 0000000..3f2915c --- a/dev/null +++ b/core/pim/osearch/contactitem.h | |||
@@ -0,0 +1,37 @@ | |||
1 | // | ||
2 | // | ||
3 | // C++ Interface: $MODULE$ | ||
4 | // | ||
5 | // Description: | ||
6 | // | ||
7 | // | ||
8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 | ||
9 | // | ||
10 | // Copyright: See COPYING file that comes with this distribution | ||
11 | // | ||
12 | // | ||
13 | #ifndef CONTACTITEM_H | ||
14 | #define CONTACTITEM_H | ||
15 | |||
16 | #include "resultitem.h" | ||
17 | |||
18 | class OContact; | ||
19 | |||
20 | /** | ||
21 | @author Patrick S. Vogt | ||
22 | */ | ||
23 | class ContactItem : public ResultItem | ||
24 | { | ||
25 | public: | ||
26 | ContactItem(OListViewItem* parent, OContact *contact); | ||
27 | |||
28 | ~ContactItem(); | ||
29 | |||
30 | virtual QString toRichText(); | ||
31 | |||
32 | private: | ||
33 | OContact *_contact; | ||
34 | |||
35 | }; | ||
36 | |||
37 | #endif | ||
diff --git a/core/pim/osearch/datebooksearch.cpp b/core/pim/osearch/datebooksearch.cpp new file mode 100644 index 0000000..85c55c2 --- a/dev/null +++ b/core/pim/osearch/datebooksearch.cpp | |||
@@ -0,0 +1,59 @@ | |||
1 | // | ||
2 | // | ||
3 | // C++ Implementation: $MODULE$ | ||
4 | // | ||
5 | // Description: | ||
6 | // | ||
7 | // | ||
8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 | ||
9 | // | ||
10 | // Copyright: See COPYING file that comes with this distribution | ||
11 | // | ||
12 | // | ||
13 | #include "datebooksearch.h" | ||
14 | |||
15 | #include "eventitem.h" | ||
16 | |||
17 | #include <opie/oevent.h> | ||
18 | #include <opie/odatebookaccess.h> | ||
19 | |||
20 | DatebookSearch::DatebookSearch(QListView* parent, QString name) | ||
21 | : SearchGroup(parent, name) | ||
22 | { | ||
23 | _dates = 0; | ||
24 | } | ||
25 | |||
26 | |||
27 | DatebookSearch::~DatebookSearch() | ||
28 | { | ||
29 | delete _dates; | ||
30 | } | ||
31 | |||
32 | |||
33 | void DatebookSearch::expand() | ||
34 | { | ||
35 | SearchGroup::expand(); | ||
36 | if (!_dates){ | ||
37 | _dates = new ODateBookAccess(); | ||
38 | _dates->load(); | ||
39 | } | ||
40 | |||
41 | ORecordList<OEvent> list = _dates->allRecords(); | ||
42 | QArray<int> m_currentQuery( list.count() ); | ||
43 | for( uint i=0; i<list.count(); i++ ){ | ||
44 | |||
45 | if ( | ||
46 | ( list[i].description().contains( _search ) ) || | ||
47 | ( list[i].note().contains( _search ) ) || | ||
48 | ( list[i].location().contains( _search ) ) | ||
49 | // ( _search.find( list[i].description(), 0 ) > 0 ) || | ||
50 | // ( _search.find( list[i].note(), 0 ) > 0 ) || | ||
51 | // ( _search.find( list[i].location(), 0 ) > 0 ) | ||
52 | ){ | ||
53 | new EventItem( this, new OEvent( list[i] ) ); | ||
54 | // new OListViewItem( this, list[i].description() ); | ||
55 | } | ||
56 | |||
57 | } | ||
58 | } | ||
59 | |||
diff --git a/core/pim/osearch/datebooksearch.h b/core/pim/osearch/datebooksearch.h new file mode 100644 index 0000000..35bbe5a --- a/dev/null +++ b/core/pim/osearch/datebooksearch.h | |||
@@ -0,0 +1,36 @@ | |||
1 | // | ||
2 | // | ||
3 | // C++ Interface: $MODULE$ | ||
4 | // | ||
5 | // Description: | ||
6 | // | ||
7 | // | ||
8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 | ||
9 | // | ||
10 | // Copyright: See COPYING file that comes with this distribution | ||
11 | // | ||
12 | // | ||
13 | #ifndef DATEBOOKSEARCH_H | ||
14 | #define DATEBOOKSEARCH_H | ||
15 | |||
16 | #include "searchgroup.h" | ||
17 | |||
18 | class ODateBookAccess; | ||
19 | |||
20 | /** | ||
21 | @author Patrick S. Vogt | ||
22 | */ | ||
23 | class DatebookSearch : public SearchGroup | ||
24 | { | ||
25 | public: | ||
26 | DatebookSearch(QListView* parent, QString name); | ||
27 | |||
28 | ~DatebookSearch(); | ||
29 | |||
30 | virtual void expand(); | ||
31 | private: | ||
32 | ODateBookAccess *_dates; | ||
33 | |||
34 | }; | ||
35 | |||
36 | #endif | ||
diff --git a/core/pim/osearch/eventitem.cpp b/core/pim/osearch/eventitem.cpp new file mode 100644 index 0000000..516a274 --- a/dev/null +++ b/core/pim/osearch/eventitem.cpp | |||
@@ -0,0 +1,40 @@ | |||
1 | // | ||
2 | // | ||
3 | // C++ Implementation: $MODULE$ | ||
4 | // | ||
5 | // Description: | ||
6 | // | ||
7 | // | ||
8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 | ||
9 | // | ||
10 | // Copyright: See COPYING file that comes with this distribution | ||
11 | // | ||
12 | // | ||
13 | #include "eventitem.h" | ||
14 | |||
15 | #include <qpe/qcopenvelope_qws.h> | ||
16 | #include <opie/oevent.h> | ||
17 | |||
18 | EventItem::EventItem(OListViewItem* parent, OEvent *event) | ||
19 | : ResultItem(parent) | ||
20 | { | ||
21 | _event = event; | ||
22 | setText(0, _event->description() ); | ||
23 | } | ||
24 | |||
25 | |||
26 | EventItem::~EventItem() | ||
27 | { | ||
28 | } | ||
29 | |||
30 | |||
31 | QString EventItem::toRichText() | ||
32 | { | ||
33 | return _event->toRichText(); | ||
34 | } | ||
35 | |||
36 | void EventItem::editItem() | ||
37 | { | ||
38 | QCopEnvelope e("QPE/Application/datebook", "editEvent(int)"); | ||
39 | e << _event->uid(); | ||
40 | } \ No newline at end of file | ||
diff --git a/core/pim/osearch/eventitem.h b/core/pim/osearch/eventitem.h new file mode 100644 index 0000000..c3483de --- a/dev/null +++ b/core/pim/osearch/eventitem.h | |||
@@ -0,0 +1,38 @@ | |||
1 | // | ||
2 | // | ||
3 | // C++ Interface: $MODULE$ | ||
4 | // | ||
5 | // Description: | ||
6 | // | ||
7 | // | ||
8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 | ||
9 | // | ||
10 | // Copyright: See COPYING file that comes with this distribution | ||
11 | // | ||
12 | // | ||
13 | #ifndef EVENTITEM_H | ||
14 | #define EVENTITEM_H | ||
15 | |||
16 | #include "resultitem.h" | ||
17 | |||
18 | class OEvent; | ||
19 | |||
20 | /** | ||
21 | @author Patrick S. Vogt | ||
22 | */ | ||
23 | class EventItem : public ResultItem | ||
24 | { | ||
25 | public: | ||
26 | EventItem(OListViewItem* parent, OEvent *event); | ||
27 | |||
28 | ~EventItem(); | ||
29 | |||
30 | virtual QString toRichText(); | ||
31 | virtual void editItem(); | ||
32 | |||
33 | private: | ||
34 | OEvent *_event; | ||
35 | |||
36 | }; | ||
37 | |||
38 | #endif | ||
diff --git a/core/pim/osearch/main.cpp b/core/pim/osearch/main.cpp new file mode 100644 index 0000000..6c18adb --- a/dev/null +++ b/core/pim/osearch/main.cpp | |||
@@ -0,0 +1,14 @@ | |||
1 | |||
2 | #include "mainwindow.h" | ||
3 | |||
4 | #include <qpe/qpeapplication.h> | ||
5 | |||
6 | int main( int argc, char ** argv ) | ||
7 | { | ||
8 | |||
9 | QPEApplication a( argc, argv ); | ||
10 | MainWindow mw; | ||
11 | mw.showMaximized(); | ||
12 | a.showMainDocumentWidget( &mw ); | ||
13 | return a.exec(); | ||
14 | } | ||
diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp new file mode 100644 index 0000000..3dba3a9 --- a/dev/null +++ b/core/pim/osearch/mainwindow.cpp | |||
@@ -0,0 +1,177 @@ | |||
1 | /*************************************************************************** | ||
2 | * * | ||
3 | * This program is free software; you can redistribute it and/or modify * | ||
4 | * it under the terms of the GNU General Public License as published by * | ||
5 | * the Free Software Foundation; either version 2 of the License, or * | ||
6 | * (at your option) any later version. * | ||
7 | * * | ||
8 | ***************************************************************************/ | ||
9 | |||
10 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> | ||
11 | |||
12 | |||
13 | #include "mainwindow.h" | ||
14 | |||
15 | #include <qpe/qpemenubar.h> | ||
16 | #include <qpe/qpemessagebox.h> | ||
17 | #include <qpe/resource.h> | ||
18 | #include <qpe/config.h> | ||
19 | #include <qpe/qpetoolbar.h> | ||
20 | #include <qpe/qpeapplication.h> | ||
21 | #include <qaction.h> | ||
22 | #include <qmessagebox.h> | ||
23 | #include <qpopupmenu.h> | ||
24 | #include <qtoolbutton.h> | ||
25 | #include <qstring.h> | ||
26 | #include <qlabel.h> | ||
27 | #include <qfile.h> | ||
28 | #include <qpushbutton.h> | ||
29 | #include <qlayout.h> | ||
30 | #include <qlineedit.h> | ||
31 | #include <qtextbrowser.h> | ||
32 | |||
33 | #include "olistview.h" | ||
34 | #include "olistviewitem.h" | ||
35 | #include "resultitem.h" | ||
36 | #include "adresssearch.h" | ||
37 | #include "todosearch.h" | ||
38 | #include "datebooksearch.h" | ||
39 | |||
40 | |||
41 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | ||
42 | QMainWindow( parent, name, f ), _currentItem(0) | ||
43 | { | ||
44 | setCaption( tr("OSearch") ); | ||
45 | |||
46 | setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | ||
47 | |||
48 | QFrame *mainFrame = new QFrame( this, "mainFrame" ); | ||
49 | |||
50 | mainLayout = new QVBoxLayout( mainFrame ); | ||
51 | mainLayout->setSpacing( 0 ); | ||
52 | mainLayout->setMargin( 0 ); | ||
53 | |||
54 | resultsList = new OListView( mainFrame ); | ||
55 | resultsList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | ||
56 | mainLayout->addWidget( resultsList ); | ||
57 | |||
58 | detailsFrame = new QFrame( mainFrame, "detailsFrame" ); | ||
59 | QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame ); | ||
60 | richEdit = new QTextView( detailsFrame ); | ||
61 | richEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | ||
62 | detailsLayout->addWidget( richEdit, 0 ); | ||
63 | QHBoxLayout *buttonLayout = new QHBoxLayout( detailsFrame ); | ||
64 | detailsLayout->addLayout( buttonLayout, 0 ); | ||
65 | QPushButton *buttonShow = new QPushButton( detailsFrame, "Show" ); | ||
66 | buttonShow->setText( tr("show") ); | ||
67 | // buttonShow->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | ||
68 | QPushButton *buttonEdit = new QPushButton( detailsFrame, "Edit" ); | ||
69 | buttonEdit->setText( tr("edit") ); | ||
70 | // buttonEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | ||
71 | buttonLayout->addWidget( buttonShow, 0 ); | ||
72 | buttonLayout->addWidget( buttonEdit, 0 ); | ||
73 | |||
74 | mainLayout->addWidget( detailsFrame, 0 ); | ||
75 | detailsFrame->hide(); | ||
76 | |||
77 | adrSearch = new AdressSearch( resultsList, tr("adressbook") ); | ||
78 | todoSearch = new TodoSearch( resultsList, tr("todo") ); | ||
79 | datebookSearch = new DatebookSearch( resultsList, tr("datebook") ); | ||
80 | |||
81 | makeMenu(); | ||
82 | setCentralWidget( mainFrame ); | ||
83 | |||
84 | popupTimer = new QTimer(); | ||
85 | |||
86 | connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); | ||
87 | connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); | ||
88 | connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); | ||
89 | connect(buttonShow, SIGNAL(clicked()), SLOT( showItem() ) ); | ||
90 | connect(buttonEdit, SIGNAL(clicked()), SLOT( editItem() ) ); | ||
91 | |||
92 | |||
93 | } | ||
94 | |||
95 | void MainWindow::makeMenu() | ||
96 | { | ||
97 | // QPEToolBar *toolBar = new QPEToolBar( this ); | ||
98 | // QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); | ||
99 | // QPopupMenu *searchMenu = new QPopupMenu( menuBar ); | ||
100 | // QPopupMenu *viewMenu = new QPopupMenu( menuBar ); | ||
101 | // QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); | ||
102 | // | ||
103 | setToolBarsMovable( false ); | ||
104 | // toolBar->setHorizontalStretchable( true ); | ||
105 | // menuBar->insertItem( tr( "Search" ), searchMenu ); | ||
106 | // menuBar->insertItem( tr( "View" ), viewMenu ); | ||
107 | // menuBar->insertItem( tr( "Settings" ), cfgMenu ); | ||
108 | |||
109 | //SEARCH | ||
110 | QPEToolBar *searchBar = new QPEToolBar(this); | ||
111 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | ||
112 | QLabel *label = new QLabel( tr("Search: "), searchBar ); | ||
113 | // label->setBackgroundMode( PaletteForeground ); | ||
114 | searchBar->setHorizontalStretchable( TRUE ); | ||
115 | QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" ); | ||
116 | searchBar->setStretchableWidget( searchEdit ); | ||
117 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | ||
118 | this, SLOT( setSearch( const QString & ) ) ); | ||
119 | |||
120 | |||
121 | } | ||
122 | |||
123 | MainWindow::~MainWindow() | ||
124 | { | ||
125 | } | ||
126 | |||
127 | void MainWindow::setCurrent(QListViewItem *item) | ||
128 | { | ||
129 | if (!item) return; | ||
130 | _currentItem = (OListViewItem*)item; | ||
131 | //_currentItem = dynamic_cast<OListViewItem*>(item); | ||
132 | if (_currentItem->rtti() == OListViewItem::Result){ | ||
133 | ResultItem *res = (ResultItem*)item; | ||
134 | // ResultItem *res = dynamic_cast<ResultItem*>(item); | ||
135 | richEdit->setText( res->toRichText() ); | ||
136 | detailsFrame->show(); | ||
137 | }else detailsFrame->hide(); | ||
138 | //_currentItem = (OListViewItem*)item; | ||
139 | popupTimer->start( 300 ); | ||
140 | } | ||
141 | |||
142 | void MainWindow::stopTimer(QListViewItem*) | ||
143 | { | ||
144 | popupTimer->stop(); | ||
145 | } | ||
146 | |||
147 | void MainWindow::showPopup() | ||
148 | { | ||
149 | qDebug("showPopup"); | ||
150 | if (!_item) return; | ||
151 | } | ||
152 | |||
153 | void MainWindow::setSearch( const QString &key ) | ||
154 | { | ||
155 | adrSearch->setSearch(key); | ||
156 | todoSearch->setSearch(key); | ||
157 | datebookSearch->setSearch(key); | ||
158 | } | ||
159 | |||
160 | |||
161 | void MainWindow::showItem() | ||
162 | { | ||
163 | if (_currentItem->rtti() == OListViewItem::Result){ | ||
164 | ResultItem *res = (ResultItem*)_currentItem; | ||
165 | // ResultItem *res = dynamic_cast<ResultItem*>(item); | ||
166 | res->showItem(); | ||
167 | } | ||
168 | } | ||
169 | |||
170 | void MainWindow::editItem() | ||
171 | { | ||
172 | if (_currentItem->rtti() == OListViewItem::Result){ | ||
173 | ResultItem *res = (ResultItem*)_currentItem; | ||
174 | // ResultItem *res = dynamic_cast<ResultItem*>(item); | ||
175 | res->editItem(); | ||
176 | } | ||
177 | } | ||
diff --git a/core/pim/osearch/mainwindow.h b/core/pim/osearch/mainwindow.h new file mode 100644 index 0000000..f7e8f8e --- a/dev/null +++ b/core/pim/osearch/mainwindow.h | |||
@@ -0,0 +1,69 @@ | |||
1 | /*************************************************************************** | ||
2 | * * | ||
3 | * This program is free software; you can redistribute it and/or modify * | ||
4 | * it under the terms of the GNU General Public License as published by * | ||
5 | * the Free Software Foundation; either version 2 of the License, or * | ||
6 | * (at your option) any later version. * | ||
7 | * * | ||
8 | ***************************************************************************/ | ||
9 | |||
10 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> | ||
11 | |||
12 | #ifndef MAINWINDOW_H | ||
13 | #define MAINWINDOW_H | ||
14 | |||
15 | #include <qmainwindow.h> | ||
16 | #include <qdialog.h> | ||
17 | #include <qaction.h> | ||
18 | #include <qtimer.h> | ||
19 | #include <qpopupmenu.h> | ||
20 | |||
21 | class QPEToolBar; | ||
22 | class QVBoxLayout; | ||
23 | class QTextView; | ||
24 | class QFrame; | ||
25 | class QListViewItem; | ||
26 | class OListView; | ||
27 | class OListViewItem; | ||
28 | class AdressSearch; | ||
29 | class TodoSearch; | ||
30 | class DatebookSearch; | ||
31 | |||
32 | class MainWindow : public QMainWindow | ||
33 | { | ||
34 | Q_OBJECT | ||
35 | |||
36 | |||
37 | public: | ||
38 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | ||
39 | ~MainWindow(); | ||
40 | |||
41 | |||
42 | public slots: | ||
43 | void setCurrent(QListViewItem*); | ||
44 | void showPopup(); | ||
45 | void stopTimer( QListViewItem* ); | ||
46 | void setSearch( const QString& ); | ||
47 | |||
48 | protected slots: | ||
49 | void showItem(); | ||
50 | void editItem(); | ||
51 | |||
52 | private: | ||
53 | OListView *resultsList; | ||
54 | QTextView *richEdit; | ||
55 | OListViewItem *_currentItem; | ||
56 | QVBoxLayout *mainLayout; | ||
57 | QFrame *detailsFrame; | ||
58 | OListViewItem *_item; | ||
59 | QTimer *popupTimer; | ||
60 | |||
61 | AdressSearch *adrSearch; | ||
62 | TodoSearch *todoSearch; | ||
63 | DatebookSearch *datebookSearch; | ||
64 | |||
65 | void makeMenu(); | ||
66 | }; | ||
67 | |||
68 | #endif | ||
69 | |||
diff --git a/core/pim/osearch/olistview.cpp b/core/pim/osearch/olistview.cpp new file mode 100644 index 0000000..f5fe462 --- a/dev/null +++ b/core/pim/osearch/olistview.cpp | |||
@@ -0,0 +1,35 @@ | |||
1 | /*************************************************************************** | ||
2 | * * | ||
3 | * This program is free software; you can redistribute it and/or modify * | ||
4 | * it under the terms of the GNU General Public License as published by * | ||
5 | * the Free Software Foundation; either version 2 of the License, or * | ||
6 | * (at your option) any later version. * | ||
7 | * * | ||
8 | ***************************************************************************/ | ||
9 | // (c) 2002 Patrick S. Vogtp <tille@handhelds.org> | ||
10 | |||
11 | #include "olistview.h" | ||
12 | #include "olistviewitem.h" | ||
13 | #include <qmessagebox.h> | ||
14 | |||
15 | |||
16 | OListView::OListView(QWidget *parent, const char *name ) | ||
17 | : QListView(parent,name) | ||
18 | { | ||
19 | |||
20 | setRootIsDecorated( true ); | ||
21 | addColumn(tr("Results")); | ||
22 | |||
23 | connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); | ||
24 | } | ||
25 | |||
26 | |||
27 | OListView::~OListView() | ||
28 | { | ||
29 | } | ||
30 | |||
31 | void OListView::expand(QListViewItem *item) | ||
32 | { | ||
33 | ((OListViewItem*)item)->expand(); | ||
34 | } | ||
35 | |||
diff --git a/core/pim/osearch/olistview.h b/core/pim/osearch/olistview.h new file mode 100644 index 0000000..af3a50b --- a/dev/null +++ b/core/pim/osearch/olistview.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /*************************************************************************** | ||
2 | * * | ||
3 | * This program is free software; you can redistribute it and/or modify * | ||
4 | * it under the terms of the GNU General Public License as published by * | ||
5 | * the Free Software Foundation; either version 2 of the License, or * | ||
6 | * (at your option) any later version. * | ||
7 | * * | ||
8 | ***************************************************************************/ | ||
9 | |||
10 | // (c) 2002 Patrick S. Vogtp <tille@handhelds.org> | ||
11 | |||
12 | #ifndef LISTVIEWCONFDIR_H | ||
13 | #define LISTVIEWCONFDIR_H | ||
14 | |||
15 | #include <qwidget.h> | ||
16 | #include <qlistview.h> | ||
17 | #include <qdir.h> | ||
18 | |||
19 | class QDir; | ||
20 | |||
21 | class OListView : public QListView { | ||
22 | Q_OBJECT | ||
23 | public: | ||
24 | OListView(QWidget *parent=0, const char *name=0); | ||
25 | ~OListView(); | ||
26 | protected slots: | ||
27 | void expand(QListViewItem*); | ||
28 | }; | ||
29 | |||
30 | #endif | ||
diff --git a/core/pim/osearch/olistviewitem.cpp b/core/pim/osearch/olistviewitem.cpp new file mode 100644 index 0000000..29c5942 --- a/dev/null +++ b/core/pim/osearch/olistviewitem.cpp | |||
@@ -0,0 +1,30 @@ | |||
1 | /*************************************************************************** | ||
2 | * * | ||
3 | * This program is free software; you can redistribute it and/or modify * | ||
4 | * it under the terms of the GNU General Public License as published by * | ||
5 | * the Free Software Foundation; either version 2 of the License, or * | ||
6 | * (at your option) any later version. * | ||
7 | * * | ||
8 | ***************************************************************************/ | ||
9 | |||
10 | #include "olistviewitem.h" | ||
11 | |||
12 | OListViewItem::OListViewItem(OListViewItem *parent) | ||
13 | : QListViewItem(parent) | ||
14 | { | ||
15 | } | ||
16 | |||
17 | OListViewItem::OListViewItem(OListViewItem *parent, QString name) | ||
18 | : QListViewItem(parent,name) | ||
19 | { | ||
20 | } | ||
21 | |||
22 | OListViewItem::OListViewItem(QListView *parent, QString name) | ||
23 | : QListViewItem(parent, name) | ||
24 | { | ||
25 | } | ||
26 | |||
27 | OListViewItem::~OListViewItem() | ||
28 | { | ||
29 | } | ||
30 | |||
diff --git a/core/pim/osearch/olistviewitem.h b/core/pim/osearch/olistviewitem.h new file mode 100644 index 0000000..66471f1 --- a/dev/null +++ b/core/pim/osearch/olistviewitem.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /*************************************************************************** | ||
2 | * * | ||
3 | * This program is free software; you can redistribute it and/or modify * | ||
4 | * it under the terms of the GNU General Public License as published by * | ||
5 | * the Free Software Foundation; either version 2 of the License, or * | ||
6 | * (at your option) any later version. * | ||
7 | * * | ||
8 | ***************************************************************************/ | ||
9 | |||
10 | #ifndef LISTVIEWITEMCONF_H | ||
11 | #define LISTVIEWITEMCONF_H | ||
12 | |||
13 | #include <qlistview.h> | ||
14 | |||
15 | |||
16 | class OListViewItem : public QListViewItem | ||
17 | { | ||
18 | public: | ||
19 | enum {Raw, Searchgroup, Result, Contact, Todo, Event}; | ||
20 | OListViewItem(OListViewItem *parent); | ||
21 | OListViewItem(OListViewItem *parent, QString name); | ||
22 | OListViewItem(QListView *parent, QString name); | ||
23 | ~OListViewItem(); | ||
24 | |||
25 | virtual void expand(){}; | ||
26 | virtual int rtti() { return Raw;} | ||
27 | }; | ||
28 | |||
29 | #endif | ||
diff --git a/core/pim/osearch/opie-osearch.control b/core/pim/osearch/opie-osearch.control new file mode 100644 index 0000000..9c68681 --- a/dev/null +++ b/core/pim/osearch/opie-osearch.control | |||
@@ -0,0 +1,10 @@ | |||
1 | Packagename: opie-osearch | ||
2 | Files: bin/osearch apps/Applications/osearch.desktop pics/osearch/Osearch.png | ||
3 | Priority: optional | ||
4 | Section: opie/ | ||
5 | Maintainer: Patrick S. Vogt <tille@handhelds.org> | ||
6 | Architecture: arm | ||
7 | Version: $QPE_VERSION-$SUB_VERSION | ||
8 | Depends: task-opie-minimal | ||
9 | Description: search... | ||
10 | |||
diff --git a/core/pim/osearch/resultitem.cpp b/core/pim/osearch/resultitem.cpp new file mode 100644 index 0000000..31114d2 --- a/dev/null +++ b/core/pim/osearch/resultitem.cpp | |||
@@ -0,0 +1,41 @@ | |||
1 | // | ||
2 | // | ||
3 | // C++ Implementation: $MODULE$ | ||
4 | // | ||
5 | // Description: | ||
6 | // | ||
7 | // | ||
8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 | ||
9 | // | ||
10 | // Copyright: See COPYING file that comes with this distribution | ||
11 | // | ||
12 | // | ||
13 | #include "resultitem.h" | ||
14 | |||
15 | #include <qmessagebox.h> | ||
16 | |||
17 | #include <opie/otodo.h> | ||
18 | |||
19 | |||
20 | ResultItem::ResultItem(OListViewItem* parent) | ||
21 | : OListViewItem(parent) | ||
22 | { | ||
23 | |||
24 | } | ||
25 | |||
26 | |||
27 | ResultItem::~ResultItem() | ||
28 | { | ||
29 | } | ||
30 | |||
31 | void ResultItem::showItem() | ||
32 | { | ||
33 | QMessageBox::warning(0,"Not implemented","show is not yet implemented for this"); | ||
34 | } | ||
35 | |||
36 | |||
37 | void ResultItem::editItem() | ||
38 | { | ||
39 | QMessageBox::warning(0,"Not implemented","edit is not yet implemented for this"); | ||
40 | } | ||
41 | |||
diff --git a/core/pim/osearch/resultitem.h b/core/pim/osearch/resultitem.h new file mode 100644 index 0000000..2cfb7f8 --- a/dev/null +++ b/core/pim/osearch/resultitem.h | |||
@@ -0,0 +1,33 @@ | |||
1 | // | ||
2 | // | ||
3 | // C++ Interface: $MODULE$ | ||
4 | // | ||
5 | // Description: | ||
6 | // | ||
7 | // | ||
8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 | ||
9 | // | ||
10 | // Copyright: See COPYING file that comes with this distribution | ||
11 | // | ||
12 | // | ||
13 | #ifndef RESULTITEM_H | ||
14 | #define RESULTITEM_H | ||
15 | |||
16 | #include "olistviewitem.h" | ||
17 | |||
18 | /** | ||
19 | @author Patrick S. Vogt | ||
20 | */ | ||
21 | class ResultItem : public OListViewItem | ||
22 | { | ||
23 | public: | ||
24 | ResultItem(OListViewItem* parent); | ||
25 | ~ResultItem(); | ||
26 | |||
27 | virtual QString toRichText() {return "no text";}; | ||
28 | virtual int rtti() { return Result;} | ||
29 | virtual void showItem(); | ||
30 | virtual void editItem(); | ||
31 | }; | ||
32 | |||
33 | #endif | ||
diff --git a/core/pim/osearch/searchgroup.cpp b/core/pim/osearch/searchgroup.cpp new file mode 100644 index 0000000..dce3b14 --- a/dev/null +++ b/core/pim/osearch/searchgroup.cpp | |||
@@ -0,0 +1,57 @@ | |||
1 | // | ||
2 | // | ||
3 | // C++ Implementation: $MODULE$ | ||
4 | // | ||
5 | // Description: | ||
6 | // | ||
7 | // | ||
8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 | ||
9 | // | ||
10 | // Copyright: See COPYING file that comes with this distribution | ||
11 | // | ||
12 | // | ||
13 | #include "searchgroup.h" | ||
14 | #include "olistviewitem.h" | ||
15 | |||
16 | SearchGroup::SearchGroup(QListView* parent, QString name) | ||
17 | : OListViewItem(parent, name) | ||
18 | { | ||
19 | _name = name; | ||
20 | expanded = false; | ||
21 | } | ||
22 | |||
23 | |||
24 | SearchGroup::~SearchGroup() | ||
25 | { | ||
26 | } | ||
27 | |||
28 | |||
29 | void SearchGroup::expand() | ||
30 | { | ||
31 | QListViewItem *item = firstChild(); | ||
32 | QListViewItem *toDel; | ||
33 | |||
34 | while ( item != 0 ) { | ||
35 | toDel = item; | ||
36 | item = item->nextSibling(); | ||
37 | //takeItem(toDel); | ||
38 | delete toDel; | ||
39 | } | ||
40 | expanded = true; | ||
41 | } | ||
42 | |||
43 | void SearchGroup::setSearch(QString s) | ||
44 | { | ||
45 | setSearch( QRegExp( s ) ); | ||
46 | _search.setCaseSensitive(false); | ||
47 | } | ||
48 | |||
49 | |||
50 | void SearchGroup::setSearch(QRegExp re) | ||
51 | { | ||
52 | setText(0, _name+" - "+re.pattern() ); | ||
53 | _search = re; | ||
54 | if (expanded) expand(); | ||
55 | else new OListViewItem( this, "searching..."); | ||
56 | } | ||
57 | |||
diff --git a/core/pim/osearch/searchgroup.h b/core/pim/osearch/searchgroup.h new file mode 100644 index 0000000..d26ff17 --- a/dev/null +++ b/core/pim/osearch/searchgroup.h | |||
@@ -0,0 +1,42 @@ | |||
1 | // | ||
2 | // | ||
3 | // C++ Interface: $MODULE$ | ||
4 | // | ||
5 | // Description: | ||
6 | // | ||
7 | // | ||
8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 | ||
9 | // | ||
10 | // Copyright: See COPYING file that comes with this distribution | ||
11 | // | ||
12 | // | ||
13 | #ifndef SEARCHGROUP_H | ||
14 | #define SEARCHGROUP_H | ||
15 | |||
16 | #include "olistviewitem.h" | ||
17 | |||
18 | #include <qregexp.h> | ||
19 | |||
20 | /** | ||
21 | @author Patrick S. Vogt | ||
22 | */ | ||
23 | class SearchGroup : public OListViewItem | ||
24 | { | ||
25 | public: | ||
26 | SearchGroup(QListView* parent, QString name); | ||
27 | |||
28 | ~SearchGroup(); | ||
29 | |||
30 | virtual void expand(); | ||
31 | virtual void setSearch(QString); | ||
32 | virtual void setSearch(QRegExp); | ||
33 | virtual int rtti() { return Searchgroup;} | ||
34 | |||
35 | protected: | ||
36 | QRegExp _search; | ||
37 | private: | ||
38 | QString _name; | ||
39 | bool expanded; | ||
40 | }; | ||
41 | |||
42 | #endif | ||
diff --git a/core/pim/osearch/todoitem.cpp b/core/pim/osearch/todoitem.cpp new file mode 100644 index 0000000..422a6d8 --- a/dev/null +++ b/core/pim/osearch/todoitem.cpp | |||
@@ -0,0 +1,40 @@ | |||
1 | // | ||
2 | // | ||
3 | // C++ Implementation: $MODULE$ | ||
4 | // | ||
5 | // Description: | ||
6 | // | ||
7 | // | ||
8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 | ||
9 | // | ||
10 | // Copyright: See COPYING file that comes with this distribution | ||
11 | // | ||
12 | // | ||
13 | #include "todoitem.h" | ||
14 | |||
15 | #include <opie/otodo.h> | ||
16 | |||
17 | TodoItem::TodoItem(OListViewItem* parent, OTodo *todo) | ||
18 | : ResultItem(parent) | ||
19 | { | ||
20 | _todo = todo; | ||
21 | setText( 0, todo->summary() ); | ||
22 | } | ||
23 | |||
24 | |||
25 | TodoItem::~TodoItem() | ||
26 | { | ||
27 | delete _todo; | ||
28 | } | ||
29 | |||
30 | |||
31 | void TodoItem::expand() | ||
32 | { | ||
33 | ResultItem::expand(); | ||
34 | } | ||
35 | |||
36 | QString TodoItem::toRichText() | ||
37 | { | ||
38 | return _todo->toRichText(); | ||
39 | } | ||
40 | |||
diff --git a/core/pim/osearch/todoitem.h b/core/pim/osearch/todoitem.h new file mode 100644 index 0000000..1196c68 --- a/dev/null +++ b/core/pim/osearch/todoitem.h | |||
@@ -0,0 +1,37 @@ | |||
1 | // | ||
2 | // | ||
3 | // C++ Interface: $MODULE$ | ||
4 | // | ||
5 | // Description: | ||
6 | // | ||
7 | // | ||
8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 | ||
9 | // | ||
10 | // Copyright: See COPYING file that comes with this distribution | ||
11 | // | ||
12 | // | ||
13 | #ifndef TODOITEM_H | ||
14 | #define TODOITEM_H | ||
15 | |||
16 | #include "resultitem.h" | ||
17 | class OTodo; | ||
18 | |||
19 | /** | ||
20 | @author Patrick S. Vogt | ||
21 | */ | ||
22 | class TodoItem : public ResultItem | ||
23 | { | ||
24 | public: | ||
25 | TodoItem(OListViewItem* parent, OTodo *todo); | ||
26 | ~TodoItem(); | ||
27 | |||
28 | virtual void expand(); | ||
29 | //virtual int rtti() { return Result;} | ||
30 | virtual QString toRichText(); | ||
31 | |||
32 | private: | ||
33 | OTodo *_todo; | ||
34 | |||
35 | }; | ||
36 | |||
37 | #endif | ||
diff --git a/core/pim/osearch/todosearch.cpp b/core/pim/osearch/todosearch.cpp new file mode 100644 index 0000000..e34c384 --- a/dev/null +++ b/core/pim/osearch/todosearch.cpp | |||
@@ -0,0 +1,53 @@ | |||
1 | // | ||
2 | // | ||
3 | // C++ Implementation: $MODULE$ | ||
4 | // | ||
5 | // Description: | ||
6 | // | ||
7 | // | ||
8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 | ||
9 | // | ||
10 | // Copyright: See COPYING file that comes with this distribution | ||
11 | // | ||
12 | // | ||
13 | #include "todosearch.h" | ||
14 | |||
15 | #include <opie/otodoaccess.h> | ||
16 | #include <opie/otodo.h> | ||
17 | #include <qdir.h> | ||
18 | |||
19 | #include "todoitem.h" | ||
20 | |||
21 | TodoSearch::TodoSearch(QListView* parent, QString name) | ||
22 | : SearchGroup(parent, name) | ||
23 | { | ||
24 | //_fileName = QDir::homeDirPath()+"/Applications/todolist/todolist.xml"; | ||
25 | _todos = 0; | ||
26 | } | ||
27 | |||
28 | |||
29 | TodoSearch::~TodoSearch() | ||
30 | { | ||
31 | delete _todos; | ||
32 | } | ||
33 | |||
34 | |||
35 | void TodoSearch::expand() | ||
36 | { | ||
37 | SearchGroup::expand(); | ||
38 | if (!_todos){ | ||
39 | _todos = new OTodoAccess(); | ||
40 | _todos->load(); | ||
41 | } | ||
42 | ORecordList<OTodo> list = _todos->allRecords(); | ||
43 | QArray<int> m_currentQuery( list.count() ); | ||
44 | for( uint i=0; i<list.count(); i++ ){ | ||
45 | if ( list[i].match( _search ) ){ | ||
46 | new TodoItem( this, new OTodo( list[i] ) ); | ||
47 | } | ||
48 | |||
49 | } | ||
50 | |||
51 | } | ||
52 | |||
53 | |||
diff --git a/core/pim/osearch/todosearch.h b/core/pim/osearch/todosearch.h new file mode 100644 index 0000000..33c1064 --- a/dev/null +++ b/core/pim/osearch/todosearch.h | |||
@@ -0,0 +1,35 @@ | |||
1 | // | ||
2 | // | ||
3 | // C++ Interface: $MODULE$ | ||
4 | // | ||
5 | // Description: | ||
6 | // | ||
7 | // | ||
8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 | ||
9 | // | ||
10 | // Copyright: See COPYING file that comes with this distribution | ||
11 | // | ||
12 | // | ||
13 | #ifndef TODOSEARCH_H | ||
14 | #define TODOSEARCH_H | ||
15 | |||
16 | #include "filesearch.h" | ||
17 | |||
18 | class OTodoAccess; | ||
19 | |||
20 | /** | ||
21 | @author Patrick S. Vogt | ||
22 | */ | ||
23 | class TodoSearch : public SearchGroup | ||
24 | { | ||
25 | public: | ||
26 | TodoSearch(QListView* parent, QString name); | ||
27 | |||
28 | ~TodoSearch(); | ||
29 | |||
30 | virtual void expand(); | ||
31 | private: | ||
32 | OTodoAccess *_todos; | ||
33 | }; | ||
34 | |||
35 | #endif | ||