-rw-r--r-- | core/pim/osearch/mainwindow.cpp | 7 | ||||
-rw-r--r-- | core/pim/osearch/olistview.cpp | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp index 33a24bc..093ca54 100644 --- a/core/pim/osearch/mainwindow.cpp +++ b/core/pim/osearch/mainwindow.cpp | |||
@@ -1,220 +1,221 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 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 * | 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 * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> | 10 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> |
11 | 11 | ||
12 | 12 | ||
13 | #include "mainwindow.h" | 13 | #include "mainwindow.h" |
14 | 14 | ||
15 | #include <qpe/qpemenubar.h> | 15 | #include <qpe/qpemenubar.h> |
16 | #include <qpe/qpemessagebox.h> | 16 | #include <qpe/qpemessagebox.h> |
17 | #include <qpe/resource.h> | 17 | #include <qpe/resource.h> |
18 | #include <qpe/config.h> | 18 | #include <qpe/config.h> |
19 | #include <qpe/qpetoolbar.h> | 19 | #include <qpe/qpetoolbar.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qaction.h> | 21 | #include <qaction.h> |
22 | #include <qmessagebox.h> | 22 | #include <qmessagebox.h> |
23 | #include <qpopupmenu.h> | 23 | #include <qpopupmenu.h> |
24 | #include <qtoolbutton.h> | 24 | #include <qtoolbutton.h> |
25 | #include <qstring.h> | 25 | #include <qstring.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qfile.h> | 27 | #include <qfile.h> |
28 | #include <qhbuttongroup.h> | 28 | #include <qhbuttongroup.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qintdict.h> | 30 | #include <qintdict.h> |
31 | #include <qlayout.h> | 31 | #include <qlayout.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qtextbrowser.h> | 33 | #include <qtextbrowser.h> |
34 | #include <qregexp.h> | 34 | #include <qregexp.h> |
35 | 35 | ||
36 | #include "olistview.h" | 36 | #include "olistview.h" |
37 | #include "olistviewitem.h" | 37 | #include "olistviewitem.h" |
38 | #include "resultitem.h" | 38 | #include "resultitem.h" |
39 | #include "adresssearch.h" | 39 | #include "adresssearch.h" |
40 | #include "todosearch.h" | 40 | #include "todosearch.h" |
41 | #include "datebooksearch.h" | 41 | #include "datebooksearch.h" |
42 | #include "applnksearch.h" | 42 | #include "applnksearch.h" |
43 | #include "doclnksearch.h" | 43 | #include "doclnksearch.h" |
44 | 44 | ||
45 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | 45 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : |
46 | QMainWindow( parent, name, f ), _currentItem(0) | 46 | QMainWindow( parent, name, f ), _currentItem(0) |
47 | { | 47 | { |
48 | setCaption( tr("OSearch") ); | 48 | setCaption( tr("OSearch") ); |
49 | 49 | ||
50 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); | 50 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); |
51 | 51 | ||
52 | QFrame *mainFrame = new QFrame( this, "mainFrame" ); | 52 | QFrame *mainFrame = new QFrame( this, "mainFrame" ); |
53 | 53 | ||
54 | mainLayout = new QVBoxLayout( mainFrame ); | 54 | mainLayout = new QVBoxLayout( mainFrame ); |
55 | mainLayout->setSpacing( 0 ); | 55 | mainLayout->setSpacing( 0 ); |
56 | mainLayout->setMargin( 0 ); | 56 | mainLayout->setMargin( 0 ); |
57 | 57 | ||
58 | resultsList = new OListView( mainFrame ); | 58 | resultsList = new OListView( mainFrame ); |
59 | resultsList->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); | 59 | resultsList->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); |
60 | mainLayout->addWidget( resultsList, 1 ); | 60 | mainLayout->addWidget( resultsList, 1 ); |
61 | 61 | ||
62 | detailsFrame = new QFrame( mainFrame, "detailsFrame" ); | 62 | detailsFrame = new QFrame( mainFrame, "detailsFrame" ); |
63 | QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame ); | 63 | QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame ); |
64 | richEdit = new QTextView( detailsFrame ); | 64 | richEdit = new QTextView( detailsFrame ); |
65 | richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); | 65 | richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); |
66 | //richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum )); | 66 | //richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum )); |
67 | detailsLayout->addWidget( richEdit, 1 ); | 67 | detailsLayout->addWidget( richEdit, 1 ); |
68 | 68 | ||
69 | buttonGroupActions = new QHButtonGroup( this ); | 69 | buttonGroupActions = new QHButtonGroup( this ); |
70 | buttonGroupActions->hide(); | 70 | buttonGroupActions->hide(); |
71 | _buttonCount = 0; | 71 | _buttonCount = 0; |
72 | // buttonGroupActions->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | 72 | // buttonGroupActions->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); |
73 | 73 | ||
74 | buttonLayout = new QHBoxLayout( detailsFrame ); | 74 | buttonLayout = new QHBoxLayout( detailsFrame ); |
75 | detailsLayout->addLayout( buttonLayout ); | 75 | detailsLayout->addLayout( buttonLayout ); |
76 | 76 | ||
77 | mainLayout->addWidget( detailsFrame ); | 77 | mainLayout->addWidget( detailsFrame ); |
78 | detailsFrame->hide(); | 78 | detailsFrame->hide(); |
79 | 79 | ||
80 | searches.append( new AdressSearch( resultsList, tr("adressbook") ) ); | ||
81 | searches.append( new TodoSearch( resultsList, tr("todo") ) ); | ||
82 | searches.append( new DatebookSearch( resultsList, tr("datebook") ) ); | ||
83 | searches.append( new AppLnkSearch( resultsList, tr("applications") ) ); | 80 | searches.append( new AppLnkSearch( resultsList, tr("applications") ) ); |
84 | searches.append( new DocLnkSearch( resultsList, tr("documents") ) ); | 81 | searches.append( new DocLnkSearch( resultsList, tr("documents") ) ); |
82 | searches.append( new TodoSearch( resultsList, tr("todo") ) ); | ||
83 | searches.append( new DatebookSearch( resultsList, tr("datebook") ) ); | ||
84 | searches.append( new AdressSearch( resultsList, tr("adressbook") ) ); | ||
85 | 85 | ||
86 | makeMenu(); | 86 | makeMenu(); |
87 | setCentralWidget( mainFrame ); | 87 | setCentralWidget( mainFrame ); |
88 | 88 | ||
89 | popupTimer = new QTimer(); | 89 | popupTimer = new QTimer(); |
90 | searchTimer = new QTimer(); | 90 | searchTimer = new QTimer(); |
91 | 91 | ||
92 | connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); | 92 | connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); |
93 | connect(searchTimer, SIGNAL(timeout()), SLOT(searchStringChanged())); | 93 | connect(searchTimer, SIGNAL(timeout()), SLOT(searchStringChanged())); |
94 | connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); | 94 | connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); |
95 | connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); | 95 | connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); |
96 | connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) ); | 96 | connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) ); |
97 | 97 | ||
98 | } | 98 | } |
99 | 99 | ||
100 | void MainWindow::makeMenu() | 100 | void MainWindow::makeMenu() |
101 | { | 101 | { |
102 | QPEToolBar *toolBar = new QPEToolBar( this ); | 102 | QPEToolBar *toolBar = new QPEToolBar( this ); |
103 | QPEToolBar *searchBar = new QPEToolBar(this); | 103 | QPEToolBar *searchBar = new QPEToolBar(this); |
104 | QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); | 104 | QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); |
105 | QPopupMenu *searchMenu = new QPopupMenu( menuBar ); | 105 | QPopupMenu *searchMenu = new QPopupMenu( menuBar ); |
106 | // QPopupMenu *viewMenu = new QPopupMenu( menuBar ); | 106 | // QPopupMenu *viewMenu = new QPopupMenu( menuBar ); |
107 | // QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); | 107 | // QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); |
108 | // | 108 | // |
109 | setToolBarsMovable( false ); | 109 | setToolBarsMovable( false ); |
110 | toolBar->setHorizontalStretchable( true ); | 110 | toolBar->setHorizontalStretchable( true ); |
111 | menuBar->insertItem( tr( "Search" ), searchMenu ); | 111 | menuBar->insertItem( tr( "Search" ), searchMenu ); |
112 | // menuBar->insertItem( tr( "View" ), viewMenu ); | 112 | // menuBar->insertItem( tr( "View" ), viewMenu ); |
113 | // menuBar->insertItem( tr( "Settings" ), cfgMenu ); | 113 | // menuBar->insertItem( tr( "Settings" ), cfgMenu ); |
114 | 114 | ||
115 | //SEARCH | 115 | //SEARCH |
116 | SearchAllAction = new QAction( tr("Search all"),QString::null, 0, this, 0 ); | 116 | SearchAllAction = new QAction( tr("Search all"),QString::null, 0, this, 0 ); |
117 | SearchAllAction->setIconSet( Resource::loadIconSet( "find" ) ); | 117 | SearchAllAction->setIconSet( Resource::loadIconSet( "find" ) ); |
118 | connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) ); | 118 | connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) ); |
119 | SearchAllAction->addTo( searchMenu ); | 119 | SearchAllAction->addTo( searchMenu ); |
120 | actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true ); | 120 | actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true ); |
121 | actionCaseSensitiv->addTo( searchMenu ); | 121 | actionCaseSensitiv->addTo( searchMenu ); |
122 | actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true ); | 122 | actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true ); |
123 | actionWildcards->addTo( searchMenu ); | 123 | actionWildcards->addTo( searchMenu ); |
124 | 124 | ||
125 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 125 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
126 | QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" ); | 126 | QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" ); |
127 | searchEdit->setFocus(); | ||
127 | searchBar->setHorizontalStretchable( TRUE ); | 128 | searchBar->setHorizontalStretchable( TRUE ); |
128 | searchBar->setStretchableWidget( searchEdit ); | 129 | searchBar->setStretchableWidget( searchEdit ); |
129 | SearchAllAction->addTo( searchBar ); | 130 | SearchAllAction->addTo( searchBar ); |
130 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 131 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
131 | this, SLOT( setSearch( const QString & ) ) ); | 132 | this, SLOT( setSearch( const QString & ) ) ); |
132 | 133 | ||
133 | } | 134 | } |
134 | 135 | ||
135 | MainWindow::~MainWindow() | 136 | MainWindow::~MainWindow() |
136 | { | 137 | { |
137 | } | 138 | } |
138 | 139 | ||
139 | void MainWindow::setCurrent(QListViewItem *item) | 140 | void MainWindow::setCurrent(QListViewItem *item) |
140 | { | 141 | { |
141 | if (!item) return; | 142 | if (!item) return; |
142 | _currentItem = (OListViewItem*)item; | 143 | _currentItem = (OListViewItem*)item; |
143 | //_currentItem = dynamic_cast<OListViewItem*>(item); | 144 | //_currentItem = dynamic_cast<OListViewItem*>(item); |
144 | if (_currentItem->rtti() == OListViewItem::Result){ | 145 | if (_currentItem->rtti() == OListViewItem::Result){ |
145 | ResultItem *res = (ResultItem*)item; | 146 | ResultItem *res = (ResultItem*)item; |
146 | // ResultItem *res = dynamic_cast<ResultItem*>(item); | 147 | // ResultItem *res = dynamic_cast<ResultItem*>(item); |
147 | richEdit->setText( res->toRichText() ); | 148 | richEdit->setText( res->toRichText() ); |
148 | QIntDict<QString> acts = res->actions(); | 149 | QIntDict<QString> acts = res->actions(); |
149 | QButton *button; | 150 | QButton *button; |
150 | for (uint i = 0; i < acts.count(); i++){ | 151 | for (uint i = 0; i < acts.count(); i++){ |
151 | button = buttonGroupActions->find( i ); | 152 | button = buttonGroupActions->find( i ); |
152 | qDebug("action %i >%s<",i,acts[i]->latin1()); | 153 | qDebug("action %i >%s<",i,acts[i]->latin1()); |
153 | if (!button) { | 154 | if (!button) { |
154 | qDebug("BUTTON"); | 155 | qDebug("BUTTON"); |
155 | button = new QPushButton( detailsFrame ); | 156 | button = new QPushButton( detailsFrame ); |
156 | buttonLayout->addWidget( button, 0 ); | 157 | buttonLayout->addWidget( button, 0 ); |
157 | buttonGroupActions->insert( button, i); | 158 | buttonGroupActions->insert( button, i); |
158 | } | 159 | } |
159 | button->setText( *acts[i] ); | 160 | button->setText( *acts[i] ); |
160 | button->show(); | 161 | button->show(); |
161 | } | 162 | } |
162 | for (uint i = acts.count(); i < _buttonCount; i++){ | 163 | for (uint i = acts.count(); i < _buttonCount; i++){ |
163 | qDebug("remove button %i of %i",i, _buttonCount); | 164 | qDebug("remove button %i of %i",i, _buttonCount); |
164 | button = buttonGroupActions->find( i ); | 165 | button = buttonGroupActions->find( i ); |
165 | if (button) button->hide(); | 166 | if (button) button->hide(); |
166 | } | 167 | } |
167 | _buttonCount = acts.count(); | 168 | _buttonCount = acts.count(); |
168 | // buttonShow = new QPushButton( detailsFrame, "Show" ) ; | 169 | // buttonShow = new QPushButton( detailsFrame, "Show" ) ; |
169 | // buttonShow->setText( "test" ); | 170 | // buttonShow->setText( "test" ); |
170 | // buttonLayout->addWidget( buttonShow, 0 ); | 171 | // buttonLayout->addWidget( buttonShow, 0 ); |
171 | // buttonGroupActions->insert(buttonShow); | 172 | // buttonGroupActions->insert(buttonShow); |
172 | detailsFrame->show(); | 173 | detailsFrame->show(); |
173 | }else detailsFrame->hide(); | 174 | }else detailsFrame->hide(); |
174 | //_currentItem = (OListViewItem*)item; | 175 | //_currentItem = (OListViewItem*)item; |
175 | popupTimer->start( 300 ); | 176 | popupTimer->start( 300 ); |
176 | } | 177 | } |
177 | 178 | ||
178 | void MainWindow::stopTimer(QListViewItem*) | 179 | void MainWindow::stopTimer(QListViewItem*) |
179 | { | 180 | { |
180 | popupTimer->stop(); | 181 | popupTimer->stop(); |
181 | } | 182 | } |
182 | 183 | ||
183 | void MainWindow::showPopup() | 184 | void MainWindow::showPopup() |
184 | { | 185 | { |
185 | qDebug("showPopup"); | 186 | qDebug("showPopup"); |
186 | if (!_currentItem) return; | 187 | if (!_currentItem) return; |
187 | } | 188 | } |
188 | 189 | ||
189 | void MainWindow::setSearch( const QString &key ) | 190 | void MainWindow::setSearch( const QString &key ) |
190 | { | 191 | { |
191 | searchTimer->stop(); | 192 | searchTimer->stop(); |
192 | _searchString = key; | 193 | _searchString = key; |
193 | searchTimer->start( 300 ); | 194 | searchTimer->start( 300 ); |
194 | } | 195 | } |
195 | 196 | ||
196 | void MainWindow::searchStringChanged() | 197 | void MainWindow::searchStringChanged() |
197 | { | 198 | { |
198 | searchTimer->stop(); | 199 | searchTimer->stop(); |
199 | QRegExp re( _searchString, actionCaseSensitiv->isOn(), actionWildcards->isOn() ); | 200 | QRegExp re( _searchString, actionCaseSensitiv->isOn(), actionWildcards->isOn() ); |
200 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) | 201 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) |
201 | s->setSearch( re ); | 202 | s->setSearch( re ); |
202 | } | 203 | } |
203 | 204 | ||
204 | void MainWindow::searchAll() | 205 | void MainWindow::searchAll() |
205 | { | 206 | { |
206 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ | 207 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ |
207 | s->doSearch(); | 208 | s->doSearch(); |
208 | //resultsList->repaint(); | 209 | //resultsList->repaint(); |
209 | } | 210 | } |
210 | } | 211 | } |
211 | 212 | ||
212 | void MainWindow::slotAction( int act) | 213 | void MainWindow::slotAction( int act) |
213 | { | 214 | { |
214 | if (_currentItem->rtti() == OListViewItem::Result){ | 215 | if (_currentItem->rtti() == OListViewItem::Result){ |
215 | ResultItem *res = (ResultItem*)_currentItem; | 216 | ResultItem *res = (ResultItem*)_currentItem; |
216 | // ResultItem *res = dynamic_cast<ResultItem*>(item); | 217 | // ResultItem *res = dynamic_cast<ResultItem*>(item); |
217 | res->action(act); | 218 | res->action(act); |
218 | } | 219 | } |
219 | } | 220 | } |
220 | 221 | ||
diff --git a/core/pim/osearch/olistview.cpp b/core/pim/osearch/olistview.cpp index f5fe462..06392ba 100644 --- a/core/pim/osearch/olistview.cpp +++ b/core/pim/osearch/olistview.cpp | |||
@@ -1,35 +1,35 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 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 * | 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 * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | // (c) 2002 Patrick S. Vogtp <tille@handhelds.org> | 9 | // (c) 2002 Patrick S. Vogtp <tille@handhelds.org> |
10 | 10 | ||
11 | #include "olistview.h" | 11 | #include "olistview.h" |
12 | #include "olistviewitem.h" | 12 | #include "olistviewitem.h" |
13 | #include <qmessagebox.h> | 13 | #include <qmessagebox.h> |
14 | 14 | ||
15 | 15 | ||
16 | OListView::OListView(QWidget *parent, const char *name ) | 16 | OListView::OListView(QWidget *parent, const char *name ) |
17 | : QListView(parent,name) | 17 | : QListView(parent,name) |
18 | { | 18 | { |
19 | 19 | ||
20 | setRootIsDecorated( true ); | 20 | setRootIsDecorated( true ); |
21 | addColumn(tr("Results")); | 21 | addColumn(tr("Results")); |
22 | 22 | setSorting( -1 ); | |
23 | connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); | 23 | connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); |
24 | } | 24 | } |
25 | 25 | ||
26 | 26 | ||
27 | OListView::~OListView() | 27 | OListView::~OListView() |
28 | { | 28 | { |
29 | } | 29 | } |
30 | 30 | ||
31 | void OListView::expand(QListViewItem *item) | 31 | void OListView::expand(QListViewItem *item) |
32 | { | 32 | { |
33 | ((OListViewItem*)item)->expand(); | 33 | ((OListViewItem*)item)->expand(); |
34 | } | 34 | } |
35 | 35 | ||