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
@@ -26,16 +26,17 @@
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 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"
38#include "adresssearch.h" 39#include "adresssearch.h"
39#include "todosearch.h" 40#include "todosearch.h"
40#include "datebooksearch.h" 41#include "datebooksearch.h"
41#include "applnksearch.h" 42#include "applnksearch.h"
@@ -61,32 +62,23 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
61 detailsFrame = new QFrame( mainFrame, "detailsFrame" ); 62 detailsFrame = new QFrame( mainFrame, "detailsFrame" );
62 QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame ); 63 QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame );
63 richEdit = new QTextView( detailsFrame ); 64 richEdit = new QTextView( detailsFrame );
64 richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); 65 richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));
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") ) );
89 searches.append( new TodoSearch( resultsList, tr("todo") ) ); 81 searches.append( new TodoSearch( resultsList, tr("todo") ) );
90 searches.append( new DatebookSearch( resultsList, tr("datebook") ) ); 82 searches.append( new DatebookSearch( resultsList, tr("datebook") ) );
91 searches.append( new AppLnkSearch( resultsList, tr("applications") ) ); 83 searches.append( new AppLnkSearch( resultsList, tr("applications") ) );
92 searches.append( new DocLnkSearch( resultsList, tr("documents") ) ); 84 searches.append( new DocLnkSearch( resultsList, tr("documents") ) );
@@ -95,46 +87,50 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
95 setCentralWidget( mainFrame ); 87 setCentralWidget( mainFrame );
96 88
97 popupTimer = new QTimer(); 89 popupTimer = new QTimer();
98 90
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{
137} 133}
138 134
139void MainWindow::setCurrent(QListViewItem *item) 135void MainWindow::setCurrent(QListViewItem *item)
140{ 136{
@@ -183,20 +179,28 @@ void MainWindow::stopTimer(QListViewItem*)
183void MainWindow::showPopup() 179void MainWindow::showPopup()
184{ 180{
185 qDebug("showPopup"); 181 qDebug("showPopup");
186 if (!_currentItem) return; 182 if (!_currentItem) return;
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){
199 ResultItem *res = (ResultItem*)_currentItem; 203 ResultItem *res = (ResultItem*)_currentItem;
200 // ResultItem *res = dynamic_cast<ResultItem*>(item); 204 // ResultItem *res = dynamic_cast<ResultItem*>(item);
201 res->action(act); 205 res->action(act);
202 } 206 }
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
@@ -41,30 +41,32 @@ public:
41 ~MainWindow(); 41 ~MainWindow();
42 42
43 43
44public slots: 44public 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
53private: 54private:
54 OListView *resultsList; 55 OListView *resultsList;
55 QTextView *richEdit; 56 QTextView *richEdit;
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
69#endif 71#endif
70 72
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,11 +1,12 @@
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
8INCLUDEPATH = $(OPIEDIR)/include 9INCLUDEPATH = $(OPIEDIR)/include
9SOURCES += main.cpp \ 10SOURCES += main.cpp \
10 mainwindow.cpp \ 11 mainwindow.cpp \
11 olistview.cpp \ 12 olistview.cpp \
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
@@ -37,37 +37,38 @@ void SearchGroup::expand()
37 OListViewItem *dummy = new OListViewItem( this, "searching..."); 37 OListViewItem *dummy = new OListViewItem( this, "searching...");
38 setOpen( expanded ); 38 setOpen( expanded );
39 if (!loaded) load(); 39 if (!loaded) load();
40 int res_count = search(); 40 int res_count = search();
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();
49 QListViewItem *toDel; 57 QListViewItem *toDel;
50 58
51 while ( item != 0 ) { 59 while ( item != 0 ) {
52 toDel = item; 60 toDel = item;
53 item = item->nextSibling(); 61 item = item->nextSibling();
54 delete toDel; 62 delete toDel;
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;
70 if (expanded) expand(); 71 if (expanded) expand();
71 else new OListViewItem( this, "searching..."); 72 else new OListViewItem( this, "searching...");
72} 73}
73 74
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
@@ -23,22 +23,20 @@ class QRegExp;
23class SearchGroup : public OListViewItem 23class SearchGroup : public OListViewItem
24{ 24{
25public: 25public:
26 SearchGroup(QListView* parent, QString name); 26 SearchGroup(QListView* parent, QString name);
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;
41 virtual void insertItem( void* ) = 0; 39 virtual void insertItem( void* ) = 0;
42 void clearList(); 40 void clearList();
43 QString _name; 41 QString _name;
44 bool expanded; 42 bool expanded;