Diffstat (limited to 'core/pim/osearch/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/osearch/mainwindow.cpp | 177 |
1 files changed, 177 insertions, 0 deletions
diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp new file mode 100644 index 0000000..3dba3a9 --- a/dev/null +++ b/core/pim/osearch/mainwindow.cpp | |||
@@ -0,0 +1,177 @@ | |||
1 | /*************************************************************************** | ||
2 | * * | ||
3 | * This program is free software; you can redistribute it and/or modify * | ||
4 | * it under the terms of the GNU General Public License as published by * | ||
5 | * the Free Software Foundation; either version 2 of the License, or * | ||
6 | * (at your option) any later version. * | ||
7 | * * | ||
8 | ***************************************************************************/ | ||
9 | |||
10 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> | ||
11 | |||
12 | |||
13 | #include "mainwindow.h" | ||
14 | |||
15 | #include <qpe/qpemenubar.h> | ||
16 | #include <qpe/qpemessagebox.h> | ||
17 | #include <qpe/resource.h> | ||
18 | #include <qpe/config.h> | ||
19 | #include <qpe/qpetoolbar.h> | ||
20 | #include <qpe/qpeapplication.h> | ||
21 | #include <qaction.h> | ||
22 | #include <qmessagebox.h> | ||
23 | #include <qpopupmenu.h> | ||
24 | #include <qtoolbutton.h> | ||
25 | #include <qstring.h> | ||
26 | #include <qlabel.h> | ||
27 | #include <qfile.h> | ||
28 | #include <qpushbutton.h> | ||
29 | #include <qlayout.h> | ||
30 | #include <qlineedit.h> | ||
31 | #include <qtextbrowser.h> | ||
32 | |||
33 | #include "olistview.h" | ||
34 | #include "olistviewitem.h" | ||
35 | #include "resultitem.h" | ||
36 | #include "adresssearch.h" | ||
37 | #include "todosearch.h" | ||
38 | #include "datebooksearch.h" | ||
39 | |||
40 | |||
41 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | ||
42 | QMainWindow( parent, name, f ), _currentItem(0) | ||
43 | { | ||
44 | setCaption( tr("OSearch") ); | ||
45 | |||
46 | setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | ||
47 | |||
48 | QFrame *mainFrame = new QFrame( this, "mainFrame" ); | ||
49 | |||
50 | mainLayout = new QVBoxLayout( mainFrame ); | ||
51 | mainLayout->setSpacing( 0 ); | ||
52 | mainLayout->setMargin( 0 ); | ||
53 | |||
54 | resultsList = new OListView( mainFrame ); | ||
55 | resultsList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | ||
56 | mainLayout->addWidget( resultsList ); | ||
57 | |||
58 | detailsFrame = new QFrame( mainFrame, "detailsFrame" ); | ||
59 | QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame ); | ||
60 | richEdit = new QTextView( detailsFrame ); | ||
61 | richEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | ||
62 | detailsLayout->addWidget( richEdit, 0 ); | ||
63 | QHBoxLayout *buttonLayout = new QHBoxLayout( detailsFrame ); | ||
64 | detailsLayout->addLayout( buttonLayout, 0 ); | ||
65 | QPushButton *buttonShow = new QPushButton( detailsFrame, "Show" ); | ||
66 | buttonShow->setText( tr("show") ); | ||
67 | // buttonShow->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | ||
68 | QPushButton *buttonEdit = new QPushButton( detailsFrame, "Edit" ); | ||
69 | buttonEdit->setText( tr("edit") ); | ||
70 | // buttonEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | ||
71 | buttonLayout->addWidget( buttonShow, 0 ); | ||
72 | buttonLayout->addWidget( buttonEdit, 0 ); | ||
73 | |||
74 | mainLayout->addWidget( detailsFrame, 0 ); | ||
75 | detailsFrame->hide(); | ||
76 | |||
77 | adrSearch = new AdressSearch( resultsList, tr("adressbook") ); | ||
78 | todoSearch = new TodoSearch( resultsList, tr("todo") ); | ||
79 | datebookSearch = new DatebookSearch( resultsList, tr("datebook") ); | ||
80 | |||
81 | makeMenu(); | ||
82 | setCentralWidget( mainFrame ); | ||
83 | |||
84 | popupTimer = new QTimer(); | ||
85 | |||
86 | connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); | ||
87 | connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); | ||
88 | connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); | ||
89 | connect(buttonShow, SIGNAL(clicked()), SLOT( showItem() ) ); | ||
90 | connect(buttonEdit, SIGNAL(clicked()), SLOT( editItem() ) ); | ||
91 | |||
92 | |||
93 | } | ||
94 | |||
95 | void MainWindow::makeMenu() | ||
96 | { | ||
97 | // QPEToolBar *toolBar = new QPEToolBar( this ); | ||
98 | // QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); | ||
99 | // QPopupMenu *searchMenu = new QPopupMenu( menuBar ); | ||
100 | // QPopupMenu *viewMenu = new QPopupMenu( menuBar ); | ||
101 | // QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); | ||
102 | // | ||
103 | setToolBarsMovable( false ); | ||
104 | // toolBar->setHorizontalStretchable( true ); | ||
105 | // menuBar->insertItem( tr( "Search" ), searchMenu ); | ||
106 | // menuBar->insertItem( tr( "View" ), viewMenu ); | ||
107 | // menuBar->insertItem( tr( "Settings" ), cfgMenu ); | ||
108 | |||
109 | //SEARCH | ||
110 | QPEToolBar *searchBar = new QPEToolBar(this); | ||
111 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | ||
112 | QLabel *label = new QLabel( tr("Search: "), searchBar ); | ||
113 | // label->setBackgroundMode( PaletteForeground ); | ||
114 | searchBar->setHorizontalStretchable( TRUE ); | ||
115 | QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" ); | ||
116 | searchBar->setStretchableWidget( searchEdit ); | ||
117 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | ||
118 | this, SLOT( setSearch( const QString & ) ) ); | ||
119 | |||
120 | |||
121 | } | ||
122 | |||
123 | MainWindow::~MainWindow() | ||
124 | { | ||
125 | } | ||
126 | |||
127 | void MainWindow::setCurrent(QListViewItem *item) | ||
128 | { | ||
129 | if (!item) return; | ||
130 | _currentItem = (OListViewItem*)item; | ||
131 | //_currentItem = dynamic_cast<OListViewItem*>(item); | ||
132 | if (_currentItem->rtti() == OListViewItem::Result){ | ||
133 | ResultItem *res = (ResultItem*)item; | ||
134 | // ResultItem *res = dynamic_cast<ResultItem*>(item); | ||
135 | richEdit->setText( res->toRichText() ); | ||
136 | detailsFrame->show(); | ||
137 | }else detailsFrame->hide(); | ||
138 | //_currentItem = (OListViewItem*)item; | ||
139 | popupTimer->start( 300 ); | ||
140 | } | ||
141 | |||
142 | void MainWindow::stopTimer(QListViewItem*) | ||
143 | { | ||
144 | popupTimer->stop(); | ||
145 | } | ||
146 | |||
147 | void MainWindow::showPopup() | ||
148 | { | ||
149 | qDebug("showPopup"); | ||
150 | if (!_item) return; | ||
151 | } | ||
152 | |||
153 | void MainWindow::setSearch( const QString &key ) | ||
154 | { | ||
155 | adrSearch->setSearch(key); | ||
156 | todoSearch->setSearch(key); | ||
157 | datebookSearch->setSearch(key); | ||
158 | } | ||
159 | |||
160 | |||
161 | void MainWindow::showItem() | ||
162 | { | ||
163 | if (_currentItem->rtti() == OListViewItem::Result){ | ||
164 | ResultItem *res = (ResultItem*)_currentItem; | ||
165 | // ResultItem *res = dynamic_cast<ResultItem*>(item); | ||
166 | res->showItem(); | ||
167 | } | ||
168 | } | ||
169 | |||
170 | void MainWindow::editItem() | ||
171 | { | ||
172 | if (_currentItem->rtti() == OListViewItem::Result){ | ||
173 | ResultItem *res = (ResultItem*)_currentItem; | ||
174 | // ResultItem *res = dynamic_cast<ResultItem*>(item); | ||
175 | res->editItem(); | ||
176 | } | ||
177 | } | ||