author | tille <tille> | 2003-05-11 19:19:30 (UTC) |
---|---|---|
committer | tille <tille> | 2003-05-11 19:19:30 (UTC) |
commit | 43c18630840a98aed8deb96b454957c40f0a4344 (patch) (side-by-side diff) | |
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 @@ #include <qmessagebox.h> #include <qpopupmenu.h> #include <qtoolbutton.h> #include <qstring.h> #include <qlabel.h> #include <qfile.h> +#include <qhbuttongroup.h> #include <qpushbutton.h> +#include <qintdict.h> #include <qlayout.h> #include <qlineedit.h> #include <qtextbrowser.h> #include "olistview.h" #include "olistviewitem.h" @@ -41,60 +43,67 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : QMainWindow( parent, name, f ), _currentItem(0) { setCaption( tr("OSearch") ); - setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); + setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); QFrame *mainFrame = new QFrame( this, "mainFrame" ); mainLayout = new QVBoxLayout( mainFrame ); mainLayout->setSpacing( 0 ); mainLayout->setMargin( 0 ); resultsList = new OListView( mainFrame ); - resultsList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); - mainLayout->addWidget( resultsList ); + resultsList->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); + mainLayout->addWidget( resultsList, 1 ); detailsFrame = new QFrame( mainFrame, "detailsFrame" ); QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame ); richEdit = new QTextView( detailsFrame ); - richEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); - detailsLayout->addWidget( richEdit, 0 ); - QHBoxLayout *buttonLayout = new QHBoxLayout( detailsFrame ); - detailsLayout->addLayout( buttonLayout, 0 ); + richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); + //richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum )); + detailsLayout->addWidget( richEdit, 1 ); + + buttonGroupActions = new QHButtonGroup( this ); + _buttonCount = 0; +// buttonGroupActions->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); + + buttonLayout = new QHBoxLayout( detailsFrame ); + buttonGroupActions->hide(); + //buttonLayout->addWidget( buttonGroupActions, 0 ); + + detailsLayout->addLayout( buttonLayout ); + /* QPushButton *buttonShow = new QPushButton( detailsFrame, "Show" ); buttonShow->setText( tr("show") ); -// buttonShow->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); QPushButton *buttonEdit = new QPushButton( detailsFrame, "Edit" ); buttonEdit->setText( tr("edit") ); - // buttonEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); buttonLayout->addWidget( buttonShow, 0 ); buttonLayout->addWidget( buttonEdit, 0 ); - - mainLayout->addWidget( detailsFrame, 0 ); +*/ + mainLayout->addWidget( detailsFrame ); detailsFrame->hide(); - adrSearch = new AdressSearch( resultsList, tr("adressbook") ); - todoSearch = new TodoSearch( resultsList, tr("todo") ); - datebookSearch = new DatebookSearch( resultsList, tr("datebook") ); - applnkSearch = new AppLnkSearch( resultsList, tr("applications") ); - doclnkSearch = new DocLnkSearch( resultsList, tr("documents") ); + searches.append( new AdressSearch( resultsList, tr("adressbook") ) ); + searches.append( new TodoSearch( resultsList, tr("todo") ) ); + searches.append( new DatebookSearch( resultsList, tr("datebook") ) ); + searches.append( new AppLnkSearch( resultsList, tr("applications") ) ); + searches.append( new DocLnkSearch( resultsList, tr("documents") ) ); makeMenu(); setCentralWidget( mainFrame ); popupTimer = new QTimer(); connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); - connect(buttonShow, SIGNAL(clicked()), SLOT( showItem() ) ); - connect(buttonEdit, SIGNAL(clicked()), SLOT( editItem() ) ); - + connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) ); +// connect(buttonEdit, SIGNAL(clicked()), SLOT( editItem() ) ); } void MainWindow::makeMenu() { // QPEToolBar *toolBar = new QPEToolBar( this ); @@ -133,12 +142,36 @@ void MainWindow::setCurrent(QListViewItem *item) _currentItem = (OListViewItem*)item; // _currentItem = dynamic_cast<OListViewItem*>(item); if (_currentItem->rtti() == OListViewItem::Result){ ResultItem *res = (ResultItem*)item; // ResultItem *res = dynamic_cast<ResultItem*>(item); richEdit->setText( res->toRichText() ); + QIntDict<QString> acts = res->actions(); + QButton *button; + for (uint i = 0; i < acts.count(); i++){ + button = buttonGroupActions->find( i ); + qDebug("action %i >%s<",i,acts[i]->latin1()); + if (!button) { + qDebug("BUTTON"); + button = new QPushButton( detailsFrame ); + buttonLayout->addWidget( button, 0 ); + buttonGroupActions->insert( button, i); + } + button->setText( *acts[i] ); + button->show(); + } + for (uint i = acts.count(); i < _buttonCount; i++){ + qDebug("remove button %i of %i",i, _buttonCount); + button = buttonGroupActions->find( i ); + if (button) button->hide(); + } + _buttonCount = acts.count(); +// buttonShow = new QPushButton( detailsFrame, "Show" ) ; +// buttonShow->setText( "test" ); +// buttonLayout->addWidget( buttonShow, 0 ); +// buttonGroupActions->insert(buttonShow); detailsFrame->show(); }else detailsFrame->hide(); //_currentItem = (OListViewItem*)item; popupTimer->start( 300 ); } @@ -147,36 +180,25 @@ void MainWindow::stopTimer(QListViewItem*) popupTimer->stop(); } void MainWindow::showPopup() { qDebug("showPopup"); - if (!_item) return; + if (!_currentItem) return; } void MainWindow::setSearch( const QString &key ) { - adrSearch->setSearch(key); - todoSearch->setSearch(key); - datebookSearch->setSearch(key); - applnkSearch->setSearch(key); - doclnkSearch->setSearch(key); + for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) + s->setSearch( key ); } -void MainWindow::showItem() +void MainWindow::slotAction( int act) { if (_currentItem->rtti() == OListViewItem::Result){ ResultItem *res = (ResultItem*)_currentItem; // ResultItem *res = dynamic_cast<ResultItem*>(item); - res->showItem(); + res->action(act); } } -void MainWindow::editItem() -{ - if (_currentItem->rtti() == OListViewItem::Result){ - ResultItem *res = (ResultItem*)_currentItem; -// ResultItem *res = dynamic_cast<ResultItem*>(item); - res->editItem(); - } -} |