summaryrefslogtreecommitdiff
authortille <tille>2003-05-12 11:26:06 (UTC)
committer tille <tille>2003-05-12 11:26:06 (UTC)
commit47a67025a4d34635877ece741def266e28e46db8 (patch) (unidiff)
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
@@ -30,8 +30,9 @@
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 35
35#include "olistview.h" 36#include "olistview.h"
36#include "olistviewitem.h" 37#include "olistviewitem.h"
37#include "resultitem.h" 38#include "resultitem.h"
@@ -65,24 +66,15 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
65 //richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum )); 66 //richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ));
66 detailsLayout->addWidget( richEdit, 1 ); 67 detailsLayout->addWidget( richEdit, 1 );
67 68
68 buttonGroupActions = new QHButtonGroup( this ); 69 buttonGroupActions = new QHButtonGroup( this );
70 buttonGroupActions->hide();
69 _buttonCount = 0; 71 _buttonCount = 0;
70// buttonGroupActions->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); 72// buttonGroupActions->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
71 73
72 buttonLayout = new QHBoxLayout( detailsFrame ); 74 buttonLayout = new QHBoxLayout( detailsFrame );
73 buttonGroupActions->hide(); 75 detailsLayout->addLayout( buttonLayout );
74 //buttonLayout->addWidget( buttonGroupActions, 0 ); 76
75
76 detailsLayout->addLayout( buttonLayout );
77 /*
78 QPushButton *buttonShow = new QPushButton( detailsFrame, "Show" );
79 buttonShow->setText( tr("show") );
80 QPushButton *buttonEdit = new QPushButton( detailsFrame, "Edit" );
81 buttonEdit->setText( tr("edit") );
82 buttonLayout->addWidget( buttonShow, 0 );
83 buttonLayout->addWidget( buttonEdit, 0 );
84*/
85 mainLayout->addWidget( detailsFrame ); 77 mainLayout->addWidget( detailsFrame );
86 detailsFrame->hide(); 78 detailsFrame->hide();
87 79
88 searches.append( new AdressSearch( resultsList, tr("adressbook") ) ); 80 searches.append( new AdressSearch( resultsList, tr("adressbook") ) );
@@ -99,38 +91,42 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
99 connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); 91 connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup()));
100 connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); 92 connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*)));
101 connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); 93 connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*)));
102 connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) ); 94 connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) );
103// connect(buttonEdit, SIGNAL(clicked()), SLOT( editItem() ) );
104 95
105} 96}
106 97
107void MainWindow::makeMenu() 98void MainWindow::makeMenu()
108{ 99{
109// QPEToolBar *toolBar = new QPEToolBar( this ); 100 QPEToolBar *toolBar = new QPEToolBar( this );
110// QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); 101 QPEToolBar *searchBar = new QPEToolBar(this);
111// QPopupMenu *searchMenu = new QPopupMenu( menuBar ); 102 QPEMenuBar *menuBar = new QPEMenuBar( toolBar );
103 QPopupMenu *searchMenu = new QPopupMenu( menuBar );
112// QPopupMenu *viewMenu = new QPopupMenu( menuBar ); 104// QPopupMenu *viewMenu = new QPopupMenu( menuBar );
113// QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); 105// QPopupMenu *cfgMenu = new QPopupMenu( menuBar );
114// 106//
115 setToolBarsMovable( false ); 107 setToolBarsMovable( false );
116// toolBar->setHorizontalStretchable( true ); 108 toolBar->setHorizontalStretchable( true );
117// menuBar->insertItem( tr( "Search" ), searchMenu ); 109 menuBar->insertItem( tr( "Search" ), searchMenu );
118// menuBar->insertItem( tr( "View" ), viewMenu ); 110// menuBar->insertItem( tr( "View" ), viewMenu );
119// menuBar->insertItem( tr( "Settings" ), cfgMenu ); 111// menuBar->insertItem( tr( "Settings" ), cfgMenu );
120 112
121 //SEARCH 113 //SEARCH
122 QPEToolBar *searchBar = new QPEToolBar(this); 114 QAction *action = new QAction( tr("Search all"),QString::null, 0, this, 0 );
123 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); 115 connect( action, SIGNAL(activated()), this, SLOT(searchAll()) );
124 QLabel *label = new QLabel( tr("Search: "), searchBar ); 116 action->addTo( searchMenu );
125// label->setBackgroundMode( PaletteForeground ); 117 actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true );
126 searchBar->setHorizontalStretchable( TRUE ); 118 actionCaseSensitiv->addTo( searchMenu );
119 actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true );
120 actionWildcards->addTo( searchMenu );
121
122 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE );
127 QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" ); 123 QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" );
124 searchBar->setHorizontalStretchable( TRUE );
128 searchBar->setStretchableWidget( searchEdit ); 125 searchBar->setStretchableWidget( searchEdit );
129 connect( searchEdit, SIGNAL( textChanged( const QString & ) ), 126 connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
130 this, SLOT( setSearch( const QString & ) ) ); 127 this, SLOT( setSearch( const QString & ) ) );
131 128
132
133} 129}
134 130
135MainWindow::~MainWindow() 131MainWindow::~MainWindow()
136{ 132{
@@ -187,12 +183,20 @@ void MainWindow::showPopup()
187} 183}
188 184
189void MainWindow::setSearch( const QString &key ) 185void MainWindow::setSearch( const QString &key )
190{ 186{
187 QRegExp re( key, actionCaseSensitiv->isOn(), actionWildcards->isOn() );
191 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) 188 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() )
192 s->setSearch( key ); 189 s->setSearch( re );
193} 190}
194 191
192void MainWindow::searchAll()
193{
194 bool openState;
195 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){
196 s->doSearch();
197 }
198}
195 199
196void MainWindow::slotAction( int act) 200void MainWindow::slotAction( int act)
197{ 201{
198 if (_currentItem->rtti() == OListViewItem::Result){ 202 if (_currentItem->rtti() == OListViewItem::Result){
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
@@ -45,8 +45,9 @@ public slots:
45 void setCurrent(QListViewItem*); 45 void setCurrent(QListViewItem*);
46 void showPopup(); 46 void showPopup();
47 void stopTimer( QListViewItem* ); 47 void stopTimer( QListViewItem* );
48 void setSearch( const QString& ); 48 void setSearch( const QString& );
49 void searchAll();
49 50
50protected slots: 51protected slots:
51 void slotAction(int); 52 void slotAction(int);
52 53
@@ -56,13 +57,14 @@ private:
56 OListViewItem *_currentItem; 57 OListViewItem *_currentItem;
57 QVBoxLayout *mainLayout; 58 QVBoxLayout *mainLayout;
58 QHBoxLayout *buttonLayout; 59 QHBoxLayout *buttonLayout;
59 QFrame *detailsFrame; 60 QFrame *detailsFrame;
60// OListViewItem *_item;
61 QTimer *popupTimer; 61 QTimer *popupTimer;
62 62
63 QList<SearchGroup> searches; 63 QList<SearchGroup> searches;
64 QHButtonGroup *buttonGroupActions; 64 QHButtonGroup *buttonGroupActions;
65 QAction *actionCaseSensitiv;
66 QAction *actionWildcards;
65 uint _buttonCount; 67 uint _buttonCount;
66 void makeMenu(); 68 void makeMenu();
67}; 69};
68 70
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,7 +1,8 @@
1DEPENDPATH += $(OPIEDIR)/include 1DEPENDPATH += $(OPIEDIR)/include
2LIBS += -lqpe -lopie 2LIBS += -lqpe -lopie
3INTERFACES = 3INTERFACES =
4include ( $(OPIEDIR)/include.pro )
4TEMPLATE = app 5TEMPLATE = app
5CONFIG += debug warn_on qt 6CONFIG += debug warn_on qt
6DESTDIR = $(OPIEDIR)/bin 7DESTDIR = $(OPIEDIR)/bin
7TARGET = osearch 8TARGET = osearch
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
@@ -41,8 +41,16 @@ void SearchGroup::expand()
41 setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")"); 41 setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")");
42 delete dummy; 42 delete dummy;
43} 43}
44 44
45void SearchGroup::doSearch()
46{
47 clearList();
48 if (_search.isEmpty()) return;
49 if (!loaded) load();
50 int res_count = search();
51 setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")");
52}
45 53
46void SearchGroup::clearList() 54void SearchGroup::clearList()
47{ 55{
48 QListViewItem *item = firstChild(); 56 QListViewItem *item = firstChild();
@@ -55,15 +63,8 @@ void SearchGroup::clearList()
55 } 63 }
56 expanded = true; 64 expanded = true;
57} 65}
58 66
59void SearchGroup::setSearch(QString s)
60{
61 setSearch( QRegExp( s ) );
62 _search.setCaseSensitive(false);
63}
64
65
66void SearchGroup::setSearch(QRegExp re) 67void SearchGroup::setSearch(QRegExp re)
67{ 68{
68 setText(0, _name+" - "+re.pattern() ); 69 setText(0, _name+" - "+re.pattern() );
69 _search = re; 70 _search = re;
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
@@ -27,14 +27,12 @@ public:
27 27
28 ~SearchGroup(); 28 ~SearchGroup();
29 29
30 virtual void expand(); 30 virtual void expand();
31 virtual void setSearch(QString); 31 virtual void doSearch();
32 virtual void setSearch(QRegExp); 32 virtual void setSearch(QRegExp);
33 virtual int rtti() { return Searchgroup;} 33 virtual int rtti() { return Searchgroup;}
34 34
35
36
37protected: 35protected:
38 QRegExp _search; 36 QRegExp _search;
39 virtual void load() = 0; 37 virtual void load() = 0;
40 virtual int search() = 0; 38 virtual int search() = 0;