summaryrefslogtreecommitdiff
authortille <tille>2003-05-12 11:26:06 (UTC)
committer tille <tille>2003-05-12 11:26:06 (UTC)
commit47a67025a4d34635877ece741def266e28e46db8 (patch) (side-by-side diff)
tree4f7e3e9bf4bfe82a217958959d4ab89eb1ae79bd
parentbc87629a1a871888e010f885ee40b2c3d6283ab4 (diff)
downloadopie-47a67025a4d34635877ece741def266e28e46db8.zip
opie-47a67025a4d34635877ece741def266e28e46db8.tar.gz
opie-47a67025a4d34635877ece741def266e28e46db8.tar.bz2
added menus
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/osearch/mainwindow.cpp54
-rw-r--r--core/pim/osearch/mainwindow.h4
-rw-r--r--core/pim/osearch/osearch.pro1
-rw-r--r--core/pim/osearch/searchgroup.cpp15
-rw-r--r--core/pim/osearch/searchgroup.h4
5 files changed, 42 insertions, 36 deletions
diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp
index a0b7b23..e15cc7e 100644
--- a/core/pim/osearch/mainwindow.cpp
+++ b/core/pim/osearch/mainwindow.cpp
@@ -1,204 +1,208 @@
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
#include "mainwindow.h"
#include <qpe/qpemenubar.h>
#include <qpe/qpemessagebox.h>
#include <qpe/resource.h>
#include <qpe/config.h>
#include <qpe/qpetoolbar.h>
#include <qpe/qpeapplication.h>
#include <qaction.h>
#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 <qregexp.h>
#include "olistview.h"
#include "olistviewitem.h"
#include "resultitem.h"
#include "adresssearch.h"
#include "todosearch.h"
#include "datebooksearch.h"
#include "applnksearch.h"
#include "doclnksearch.h"
MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
QMainWindow( parent, name, f ), _currentItem(0)
{
setCaption( tr("OSearch") );
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::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::Expanding, QSizePolicy::Expanding));
//richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ));
detailsLayout->addWidget( richEdit, 1 );
buttonGroupActions = new QHButtonGroup( this );
+ buttonGroupActions->hide();
_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") );
- QPushButton *buttonEdit = new QPushButton( detailsFrame, "Edit" );
- buttonEdit->setText( tr("edit") );
- buttonLayout->addWidget( buttonShow, 0 );
- buttonLayout->addWidget( buttonEdit, 0 );
-*/
+ detailsLayout->addLayout( buttonLayout );
+
mainLayout->addWidget( detailsFrame );
detailsFrame->hide();
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(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) );
-// connect(buttonEdit, SIGNAL(clicked()), SLOT( editItem() ) );
}
void MainWindow::makeMenu()
{
-// QPEToolBar *toolBar = new QPEToolBar( this );
-// QPEMenuBar *menuBar = new QPEMenuBar( toolBar );
-// QPopupMenu *searchMenu = new QPopupMenu( menuBar );
+ QPEToolBar *toolBar = new QPEToolBar( this );
+ QPEToolBar *searchBar = new QPEToolBar(this);
+ QPEMenuBar *menuBar = new QPEMenuBar( toolBar );
+ QPopupMenu *searchMenu = new QPopupMenu( menuBar );
// QPopupMenu *viewMenu = new QPopupMenu( menuBar );
// QPopupMenu *cfgMenu = new QPopupMenu( menuBar );
//
setToolBarsMovable( false );
-// toolBar->setHorizontalStretchable( true );
-// menuBar->insertItem( tr( "Search" ), searchMenu );
+ toolBar->setHorizontalStretchable( true );
+ menuBar->insertItem( tr( "Search" ), searchMenu );
// menuBar->insertItem( tr( "View" ), viewMenu );
// menuBar->insertItem( tr( "Settings" ), cfgMenu );
//SEARCH
- QPEToolBar *searchBar = new QPEToolBar(this);
- addToolBar( searchBar, "Search", QMainWindow::Top, TRUE );
- QLabel *label = new QLabel( tr("Search: "), searchBar );
-// label->setBackgroundMode( PaletteForeground );
- searchBar->setHorizontalStretchable( TRUE );
+ QAction *action = new QAction( tr("Search all"),QString::null, 0, this, 0 );
+ connect( action, SIGNAL(activated()), this, SLOT(searchAll()) );
+ action->addTo( searchMenu );
+ actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true );
+ actionCaseSensitiv->addTo( searchMenu );
+ actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true );
+ actionWildcards->addTo( searchMenu );
+
+ addToolBar( searchBar, "Search", QMainWindow::Top, TRUE );
QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" );
+ searchBar->setHorizontalStretchable( TRUE );
searchBar->setStretchableWidget( searchEdit );
connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
this, SLOT( setSearch( const QString & ) ) );
-
}
MainWindow::~MainWindow()
{
}
void MainWindow::setCurrent(QListViewItem *item)
{
if (!item) return;
_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 );
}
void MainWindow::stopTimer(QListViewItem*)
{
popupTimer->stop();
}
void MainWindow::showPopup()
{
qDebug("showPopup");
if (!_currentItem) return;
}
void MainWindow::setSearch( const QString &key )
{
+ QRegExp re( key, actionCaseSensitiv->isOn(), actionWildcards->isOn() );
for (SearchGroup *s = searches.first(); s != 0; s = searches.next() )
- s->setSearch( key );
+ s->setSearch( re );
}
+void MainWindow::searchAll()
+{
+ bool openState;
+ for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){
+ s->doSearch();
+ }
+}
void MainWindow::slotAction( int act)
{
if (_currentItem->rtti() == OListViewItem::Result){
ResultItem *res = (ResultItem*)_currentItem;
// ResultItem *res = dynamic_cast<ResultItem*>(item);
res->action(act);
}
}
diff --git a/core/pim/osearch/mainwindow.h b/core/pim/osearch/mainwindow.h
index f6ae0a4..2773205 100644
--- a/core/pim/osearch/mainwindow.h
+++ b/core/pim/osearch/mainwindow.h
@@ -1,70 +1,72 @@
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <qmainwindow.h>
#include <qdialog.h>
#include <qaction.h>
#include <qlist.h>
#include <qtimer.h>
#include <qpopupmenu.h>
class QPEToolBar;
class QVBoxLayout;
class QHBoxLayout;
class QTextView;
class QFrame;
class QListViewItem;
class OListView;
class OListViewItem;
class QHButtonGroup;
class SearchGroup;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
~MainWindow();
public slots:
void setCurrent(QListViewItem*);
void showPopup();
void stopTimer( QListViewItem* );
void setSearch( const QString& );
+ void searchAll();
protected slots:
void slotAction(int);
private:
OListView *resultsList;
QTextView *richEdit;
OListViewItem *_currentItem;
QVBoxLayout *mainLayout;
QHBoxLayout *buttonLayout;
QFrame *detailsFrame;
-// OListViewItem *_item;
QTimer *popupTimer;
QList<SearchGroup> searches;
QHButtonGroup *buttonGroupActions;
+ QAction *actionCaseSensitiv;
+ QAction *actionWildcards;
uint _buttonCount;
void makeMenu();
};
#endif
diff --git a/core/pim/osearch/osearch.pro b/core/pim/osearch/osearch.pro
index d5dcda2..2e571e3 100644
--- a/core/pim/osearch/osearch.pro
+++ b/core/pim/osearch/osearch.pro
@@ -1,39 +1,40 @@
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lopie
INTERFACES =
+include ( $(OPIEDIR)/include.pro )
TEMPLATE = app
CONFIG += debug warn_on qt
DESTDIR = $(OPIEDIR)/bin
TARGET = osearch
INCLUDEPATH = $(OPIEDIR)/include
SOURCES += main.cpp \
mainwindow.cpp \
olistview.cpp \
olistviewitem.cpp \
adresssearch.cpp \
todosearch.cpp \
datebooksearch.cpp \
searchgroup.cpp \
resultitem.cpp \
todoitem.cpp \
contactitem.cpp \
eventitem.cpp \
applnksearch.cpp \
applnkitem.cpp \
doclnkitem.cpp \
doclnksearch.cpp
HEADERS += mainwindow.h \
olistview.h \
olistviewitem.h \
adresssearch.h \
todosearch.h \
datebooksearch.h \
searchgroup.h \
resultitem.h \
todoitem.h \
contactitem.h \
eventitem.h \
applnksearch.h \
applnkitem.h \
doclnkitem.h \
doclnksearch.h
diff --git a/core/pim/osearch/searchgroup.cpp b/core/pim/osearch/searchgroup.cpp
index d062207..3159984 100644
--- a/core/pim/osearch/searchgroup.cpp
+++ b/core/pim/osearch/searchgroup.cpp
@@ -1,73 +1,74 @@
//
//
// C++ Implementation: $MODULE$
//
// Description:
//
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "searchgroup.h"
#include <qregexp.h>
#include "olistviewitem.h"
SearchGroup::SearchGroup(QListView* parent, QString name)
: OListViewItem(parent, name)
{
_name = name;
loaded = false;
expanded = false;
}
SearchGroup::~SearchGroup()
{
}
void SearchGroup::expand()
{
clearList();
if (_search.isEmpty()) return;
OListViewItem *dummy = new OListViewItem( this, "searching...");
setOpen( expanded );
if (!loaded) load();
int res_count = search();
setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")");
delete dummy;
}
+void SearchGroup::doSearch()
+{
+ clearList();
+ if (_search.isEmpty()) return;
+ if (!loaded) load();
+ int res_count = search();
+ setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")");
+}
void SearchGroup::clearList()
{
QListViewItem *item = firstChild();
QListViewItem *toDel;
while ( item != 0 ) {
toDel = item;
item = item->nextSibling();
delete toDel;
}
expanded = true;
}
-void SearchGroup::setSearch(QString s)
-{
- setSearch( QRegExp( s ) );
- _search.setCaseSensitive(false);
-}
-
-
void SearchGroup::setSearch(QRegExp re)
{
setText(0, _name+" - "+re.pattern() );
_search = re;
if (expanded) expand();
else new OListViewItem( this, "searching...");
}
diff --git a/core/pim/osearch/searchgroup.h b/core/pim/osearch/searchgroup.h
index 35949f0..bf5dc67 100644
--- a/core/pim/osearch/searchgroup.h
+++ b/core/pim/osearch/searchgroup.h
@@ -1,48 +1,46 @@
//
//
// C++ Interface: $MODULE$
//
// Description:
//
//
// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef SEARCHGROUP_H
#define SEARCHGROUP_H
#include "olistviewitem.h"
class QRegExp;
/**
@author Patrick S. Vogt
*/
class SearchGroup : public OListViewItem
{
public:
SearchGroup(QListView* parent, QString name);
~SearchGroup();
virtual void expand();
- virtual void setSearch(QString);
+ virtual void doSearch();
virtual void setSearch(QRegExp);
virtual int rtti() { return Searchgroup;}
-
-
protected:
QRegExp _search;
virtual void load() = 0;
virtual int search() = 0;
virtual void insertItem( void* ) = 0;
void clearList();
QString _name;
bool expanded;
bool loaded;
};
#endif