author | tille <tille> | 2003-05-11 19:19:30 (UTC) |
---|---|---|
committer | tille <tille> | 2003-05-11 19:19:30 (UTC) |
commit | 43c18630840a98aed8deb96b454957c40f0a4344 (patch) (unidiff) | |
tree | 60e5b68d1d172c77560d5af7bea83e81be7144a6 /core/pim/osearch/mainwindow.cpp | |
parent | 38dc2fd6258f11ba0507c7bd8f8dfd5b39bc0df5 (diff) | |
download | opie-43c18630840a98aed8deb96b454957c40f0a4344.zip opie-43c18630840a98aed8deb96b454957c40f0a4344.tar.gz opie-43c18630840a98aed8deb96b454957c40f0a4344.tar.bz2 |
improved applnk and doclnk searching
clean up:
- mainwindow: handling of searchgroups
- searchgroups: introduced load, search and insertItem functions
- flexible actions handling
- doclnksearch inherits applnksearch
Diffstat (limited to 'core/pim/osearch/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/osearch/mainwindow.cpp | 92 |
1 files changed, 57 insertions, 35 deletions
diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp index 140d7bb..a0b7b23 100644 --- a/core/pim/osearch/mainwindow.cpp +++ b/core/pim/osearch/mainwindow.cpp | |||
@@ -22,13 +22,15 @@ | |||
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 <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qintdict.h> | ||
29 | #include <qlayout.h> | 31 | #include <qlayout.h> |
30 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
31 | #include <qtextbrowser.h> | 33 | #include <qtextbrowser.h> |
32 | 34 | ||
33 | #include "olistview.h" | 35 | #include "olistview.h" |
34 | #include "olistviewitem.h" | 36 | #include "olistviewitem.h" |
@@ -41,60 +43,67 @@ | |||
41 | 43 | ||
42 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | 44 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : |
43 | QMainWindow( parent, name, f ), _currentItem(0) | 45 | QMainWindow( parent, name, f ), _currentItem(0) |
44 | { | 46 | { |
45 | setCaption( tr("OSearch") ); | 47 | setCaption( tr("OSearch") ); |
46 | 48 | ||
47 | setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | 49 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); |
48 | 50 | ||
49 | QFrame *mainFrame = new QFrame( this, "mainFrame" ); | 51 | QFrame *mainFrame = new QFrame( this, "mainFrame" ); |
50 | 52 | ||
51 | mainLayout = new QVBoxLayout( mainFrame ); | 53 | mainLayout = new QVBoxLayout( mainFrame ); |
52 | mainLayout->setSpacing( 0 ); | 54 | mainLayout->setSpacing( 0 ); |
53 | mainLayout->setMargin( 0 ); | 55 | mainLayout->setMargin( 0 ); |
54 | 56 | ||
55 | resultsList = new OListView( mainFrame ); | 57 | resultsList = new OListView( mainFrame ); |
56 | resultsList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | 58 | resultsList->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); |
57 | mainLayout->addWidget( resultsList ); | 59 | mainLayout->addWidget( resultsList, 1 ); |
58 | 60 | ||
59 | detailsFrame = new QFrame( mainFrame, "detailsFrame" ); | 61 | detailsFrame = new QFrame( mainFrame, "detailsFrame" ); |
60 | QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame ); | 62 | QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame ); |
61 | richEdit = new QTextView( detailsFrame ); | 63 | richEdit = new QTextView( detailsFrame ); |
62 | richEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | 64 | richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); |
63 | detailsLayout->addWidget( richEdit, 0 ); | 65 | //richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum )); |
64 | QHBoxLayout *buttonLayout = new QHBoxLayout( detailsFrame ); | 66 | detailsLayout->addWidget( richEdit, 1 ); |
65 | detailsLayout->addLayout( buttonLayout, 0 ); | 67 | |
68 | buttonGroupActions = new QHButtonGroup( this ); | ||
69 | _buttonCount = 0; | ||
70 | // buttonGroupActions->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | ||
71 | |||
72 | buttonLayout = new QHBoxLayout( detailsFrame ); | ||
73 | buttonGroupActions->hide(); | ||
74 | //buttonLayout->addWidget( buttonGroupActions, 0 ); | ||
75 | |||
76 | detailsLayout->addLayout( buttonLayout ); | ||
77 | /* | ||
66 | QPushButton *buttonShow = new QPushButton( detailsFrame, "Show" ); | 78 | QPushButton *buttonShow = new QPushButton( detailsFrame, "Show" ); |
67 | buttonShow->setText( tr("show") ); | 79 | buttonShow->setText( tr("show") ); |
68 | // buttonShow->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | ||
69 | QPushButton *buttonEdit = new QPushButton( detailsFrame, "Edit" ); | 80 | QPushButton *buttonEdit = new QPushButton( detailsFrame, "Edit" ); |
70 | buttonEdit->setText( tr("edit") ); | 81 | buttonEdit->setText( tr("edit") ); |
71 | // buttonEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | ||
72 | buttonLayout->addWidget( buttonShow, 0 ); | 82 | buttonLayout->addWidget( buttonShow, 0 ); |
73 | buttonLayout->addWidget( buttonEdit, 0 ); | 83 | buttonLayout->addWidget( buttonEdit, 0 ); |
74 | 84 | */ | |
75 | mainLayout->addWidget( detailsFrame, 0 ); | 85 | mainLayout->addWidget( detailsFrame ); |
76 | detailsFrame->hide(); | 86 | detailsFrame->hide(); |
77 | 87 | ||
78 | adrSearch = new AdressSearch( resultsList, tr("adressbook") ); | 88 | searches.append( new AdressSearch( resultsList, tr("adressbook") ) ); |
79 | todoSearch = new TodoSearch( resultsList, tr("todo") ); | 89 | searches.append( new TodoSearch( resultsList, tr("todo") ) ); |
80 | datebookSearch = new DatebookSearch( resultsList, tr("datebook") ); | 90 | searches.append( new DatebookSearch( resultsList, tr("datebook") ) ); |
81 | applnkSearch = new AppLnkSearch( resultsList, tr("applications") ); | 91 | searches.append( new AppLnkSearch( resultsList, tr("applications") ) ); |
82 | doclnkSearch = new DocLnkSearch( resultsList, tr("documents") ); | 92 | searches.append( new DocLnkSearch( resultsList, tr("documents") ) ); |
83 | 93 | ||
84 | makeMenu(); | 94 | makeMenu(); |
85 | setCentralWidget( mainFrame ); | 95 | setCentralWidget( mainFrame ); |
86 | 96 | ||
87 | popupTimer = new QTimer(); | 97 | popupTimer = new QTimer(); |
88 | 98 | ||
89 | connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); | 99 | connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); |
90 | connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); | 100 | connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); |
91 | connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); | 101 | connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); |
92 | connect(buttonShow, SIGNAL(clicked()), SLOT( showItem() ) ); | 102 | connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) ); |
93 | connect(buttonEdit, SIGNAL(clicked()), SLOT( editItem() ) ); | 103 | // connect(buttonEdit, SIGNAL(clicked()), SLOT( editItem() ) ); |
94 | |||
95 | 104 | ||
96 | } | 105 | } |
97 | 106 | ||
98 | void MainWindow::makeMenu() | 107 | void MainWindow::makeMenu() |
99 | { | 108 | { |
100 | // QPEToolBar *toolBar = new QPEToolBar( this ); | 109 | // QPEToolBar *toolBar = new QPEToolBar( this ); |
@@ -133,12 +142,36 @@ void MainWindow::setCurrent(QListViewItem *item) | |||
133 | _currentItem = (OListViewItem*)item; | 142 | _currentItem = (OListViewItem*)item; |
134 | //_currentItem = dynamic_cast<OListViewItem*>(item); | 143 | //_currentItem = dynamic_cast<OListViewItem*>(item); |
135 | if (_currentItem->rtti() == OListViewItem::Result){ | 144 | if (_currentItem->rtti() == OListViewItem::Result){ |
136 | ResultItem *res = (ResultItem*)item; | 145 | ResultItem *res = (ResultItem*)item; |
137 | // ResultItem *res = dynamic_cast<ResultItem*>(item); | 146 | // ResultItem *res = dynamic_cast<ResultItem*>(item); |
138 | richEdit->setText( res->toRichText() ); | 147 | richEdit->setText( res->toRichText() ); |
148 | QIntDict<QString> acts = res->actions(); | ||
149 | QButton *button; | ||
150 | for (uint i = 0; i < acts.count(); i++){ | ||
151 | button = buttonGroupActions->find( i ); | ||
152 | qDebug("action %i >%s<",i,acts[i]->latin1()); | ||
153 | if (!button) { | ||
154 | qDebug("BUTTON"); | ||
155 | button = new QPushButton( detailsFrame ); | ||
156 | buttonLayout->addWidget( button, 0 ); | ||
157 | buttonGroupActions->insert( button, i); | ||
158 | } | ||
159 | button->setText( *acts[i] ); | ||
160 | button->show(); | ||
161 | } | ||
162 | for (uint i = acts.count(); i < _buttonCount; i++){ | ||
163 | qDebug("remove button %i of %i",i, _buttonCount); | ||
164 | button = buttonGroupActions->find( i ); | ||
165 | if (button) button->hide(); | ||
166 | } | ||
167 | _buttonCount = acts.count(); | ||
168 | // buttonShow = new QPushButton( detailsFrame, "Show" ) ; | ||
169 | // buttonShow->setText( "test" ); | ||
170 | // buttonLayout->addWidget( buttonShow, 0 ); | ||
171 | // buttonGroupActions->insert(buttonShow); | ||
139 | detailsFrame->show(); | 172 | detailsFrame->show(); |
140 | }else detailsFrame->hide(); | 173 | }else detailsFrame->hide(); |
141 | //_currentItem = (OListViewItem*)item; | 174 | //_currentItem = (OListViewItem*)item; |
142 | popupTimer->start( 300 ); | 175 | popupTimer->start( 300 ); |
143 | } | 176 | } |
144 | 177 | ||
@@ -147,36 +180,25 @@ void MainWindow::stopTimer(QListViewItem*) | |||
147 | popupTimer->stop(); | 180 | popupTimer->stop(); |
148 | } | 181 | } |
149 | 182 | ||
150 | void MainWindow::showPopup() | 183 | void MainWindow::showPopup() |
151 | { | 184 | { |
152 | qDebug("showPopup"); | 185 | qDebug("showPopup"); |
153 | if (!_item) return; | 186 | if (!_currentItem) return; |
154 | } | 187 | } |
155 | 188 | ||
156 | void MainWindow::setSearch( const QString &key ) | 189 | void MainWindow::setSearch( const QString &key ) |
157 | { | 190 | { |
158 | adrSearch->setSearch(key); | 191 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) |
159 | todoSearch->setSearch(key); | 192 | s->setSearch( key ); |
160 | datebookSearch->setSearch(key); | ||
161 | applnkSearch->setSearch(key); | ||
162 | doclnkSearch->setSearch(key); | ||
163 | } | 193 | } |
164 | 194 | ||
165 | 195 | ||
166 | void MainWindow::showItem() | 196 | void MainWindow::slotAction( int act) |
167 | { | 197 | { |
168 | if (_currentItem->rtti() == OListViewItem::Result){ | 198 | if (_currentItem->rtti() == OListViewItem::Result){ |
169 | ResultItem *res = (ResultItem*)_currentItem; | 199 | ResultItem *res = (ResultItem*)_currentItem; |
170 | // ResultItem *res = dynamic_cast<ResultItem*>(item); | 200 | // ResultItem *res = dynamic_cast<ResultItem*>(item); |
171 | res->showItem(); | 201 | res->action(act); |
172 | } | 202 | } |
173 | } | 203 | } |
174 | 204 | ||
175 | void MainWindow::editItem() | ||
176 | { | ||
177 | if (_currentItem->rtti() == OListViewItem::Result){ | ||
178 | ResultItem *res = (ResultItem*)_currentItem; | ||
179 | // ResultItem *res = dynamic_cast<ResultItem*>(item); | ||
180 | res->editItem(); | ||
181 | } | ||
182 | } | ||