-rw-r--r-- | core/pim/osearch/mainwindow.cpp | 50 | ||||
-rw-r--r-- | core/pim/osearch/mainwindow.h | 4 | ||||
-rw-r--r-- | core/pim/osearch/osearch.pro | 1 | ||||
-rw-r--r-- | core/pim/osearch/searchgroup.cpp | 15 | ||||
-rw-r--r-- | core/pim/osearch/searchgroup.h | 4 |
5 files changed, 40 insertions, 34 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 | |||
@@ -31,6 +31,7 @@ | |||
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" |
@@ -66,22 +67,13 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | |||
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(); | ||
74 | //buttonLayout->addWidget( buttonGroupActions, 0 ); | ||
75 | |||
76 | detailsLayout->addLayout( buttonLayout ); | 75 | detailsLayout->addLayout( buttonLayout ); |
77 | /* | 76 | |
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 | ||
@@ -100,36 +92,40 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | |||
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 | ||
107 | void MainWindow::makeMenu() | 98 | void 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 ); |
115 | connect( action, SIGNAL(activated()), this, SLOT(searchAll()) ); | ||
116 | action->addTo( searchMenu ); | ||
117 | actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true ); | ||
118 | actionCaseSensitiv->addTo( searchMenu ); | ||
119 | actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true ); | ||
120 | actionWildcards->addTo( searchMenu ); | ||
121 | |||
123 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 122 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
124 | QLabel *label = new QLabel( tr("Search: "), searchBar ); | ||
125 | // label->setBackgroundMode( PaletteForeground ); | ||
126 | searchBar->setHorizontalStretchable( 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 | ||
135 | MainWindow::~MainWindow() | 131 | MainWindow::~MainWindow() |
@@ -188,10 +184,18 @@ void MainWindow::showPopup() | |||
188 | 184 | ||
189 | void MainWindow::setSearch( const QString &key ) | 185 | void 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 | ||
192 | void MainWindow::searchAll() | ||
193 | { | ||
194 | bool openState; | ||
195 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ | ||
196 | s->doSearch(); | ||
197 | } | ||
198 | } | ||
195 | 199 | ||
196 | void MainWindow::slotAction( int act) | 200 | void MainWindow::slotAction( int act) |
197 | { | 201 | { |
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 | |||
@@ -46,6 +46,7 @@ public slots: | |||
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 | ||
50 | protected slots: | 51 | protected slots: |
51 | void slotAction(int); | 52 | void slotAction(int); |
@@ -57,11 +58,12 @@ private: | |||
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 | }; |
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,6 +1,7 @@ | |||
1 | DEPENDPATH += $(OPIEDIR)/include | 1 | DEPENDPATH += $(OPIEDIR)/include |
2 | LIBS += -lqpe -lopie | 2 | LIBS += -lqpe -lopie |
3 | INTERFACES = | 3 | INTERFACES = |
4 | include ( $(OPIEDIR)/include.pro ) | ||
4 | TEMPLATE = app | 5 | TEMPLATE = app |
5 | CONFIG += debug warn_on qt | 6 | CONFIG += debug warn_on qt |
6 | DESTDIR = $(OPIEDIR)/bin | 7 | DESTDIR = $(OPIEDIR)/bin |
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 | |||
@@ -42,6 +42,14 @@ void SearchGroup::expand() | |||
42 | delete dummy; | 42 | delete dummy; |
43 | } | 43 | } |
44 | 44 | ||
45 | void 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 | ||
46 | void SearchGroup::clearList() | 54 | void SearchGroup::clearList() |
47 | { | 55 | { |
@@ -56,13 +64,6 @@ void SearchGroup::clearList() | |||
56 | expanded = true; | 64 | expanded = true; |
57 | } | 65 | } |
58 | 66 | ||
59 | void SearchGroup::setSearch(QString s) | ||
60 | { | ||
61 | setSearch( QRegExp( s ) ); | ||
62 | _search.setCaseSensitive(false); | ||
63 | } | ||
64 | |||
65 | |||
66 | void SearchGroup::setSearch(QRegExp re) | 67 | void SearchGroup::setSearch(QRegExp re) |
67 | { | 68 | { |
68 | setText(0, _name+" - "+re.pattern() ); | 69 | setText(0, _name+" - "+re.pattern() ); |
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 | |||
@@ -28,12 +28,10 @@ public: | |||
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 | |||
37 | protected: | 35 | protected: |
38 | QRegExp _search; | 36 | QRegExp _search; |
39 | virtual void load() = 0; | 37 | virtual void load() = 0; |