Diffstat (limited to 'core/pim/osearch/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/osearch/mainwindow.cpp | 92 |
1 files changed, 57 insertions, 35 deletions
diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp index 140d7bb..a0b7b23 100644 --- a/core/pim/osearch/mainwindow.cpp +++ b/core/pim/osearch/mainwindow.cpp | |||
@@ -27,3 +27,5 @@ | |||
27 | #include <qfile.h> | 27 | #include <qfile.h> |
28 | #include <qhbuttongroup.h> | ||
28 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qintdict.h> | ||
29 | #include <qlayout.h> | 31 | #include <qlayout.h> |
@@ -46,3 +48,3 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | |||
46 | 48 | ||
47 | setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | 49 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); |
48 | 50 | ||
@@ -55,4 +57,4 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | |||
55 | resultsList = new OListView( mainFrame ); | 57 | resultsList = new OListView( mainFrame ); |
56 | resultsList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | 58 | resultsList->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); |
57 | mainLayout->addWidget( resultsList ); | 59 | mainLayout->addWidget( resultsList, 1 ); |
58 | 60 | ||
@@ -61,23 +63,31 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | |||
61 | richEdit = new QTextView( detailsFrame ); | 63 | richEdit = new QTextView( detailsFrame ); |
62 | richEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | 64 | richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); |
63 | detailsLayout->addWidget( richEdit, 0 ); | 65 | //richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum )); |
64 | QHBoxLayout *buttonLayout = new QHBoxLayout( detailsFrame ); | 66 | detailsLayout->addWidget( richEdit, 1 ); |
65 | detailsLayout->addLayout( buttonLayout, 0 ); | 67 | |
68 | buttonGroupActions = new QHButtonGroup( this ); | ||
69 | _buttonCount = 0; | ||
70 | // buttonGroupActions->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | ||
71 | |||
72 | buttonLayout = new QHBoxLayout( detailsFrame ); | ||
73 | buttonGroupActions->hide(); | ||
74 | //buttonLayout->addWidget( buttonGroupActions, 0 ); | ||
75 | |||
76 | detailsLayout->addLayout( buttonLayout ); | ||
77 | /* | ||
66 | QPushButton *buttonShow = new QPushButton( detailsFrame, "Show" ); | 78 | QPushButton *buttonShow = new QPushButton( detailsFrame, "Show" ); |
67 | buttonShow->setText( tr("show") ); | 79 | buttonShow->setText( tr("show") ); |
68 | // buttonShow->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | ||
69 | QPushButton *buttonEdit = new QPushButton( detailsFrame, "Edit" ); | 80 | QPushButton *buttonEdit = new QPushButton( detailsFrame, "Edit" ); |
70 | buttonEdit->setText( tr("edit") ); | 81 | buttonEdit->setText( tr("edit") ); |
71 | // buttonEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | ||
72 | buttonLayout->addWidget( buttonShow, 0 ); | 82 | buttonLayout->addWidget( buttonShow, 0 ); |
73 | buttonLayout->addWidget( buttonEdit, 0 ); | 83 | buttonLayout->addWidget( buttonEdit, 0 ); |
74 | 84 | */ | |
75 | mainLayout->addWidget( detailsFrame, 0 ); | 85 | mainLayout->addWidget( detailsFrame ); |
76 | detailsFrame->hide(); | 86 | detailsFrame->hide(); |
77 | 87 | ||
78 | adrSearch = new AdressSearch( resultsList, tr("adressbook") ); | 88 | searches.append( new AdressSearch( resultsList, tr("adressbook") ) ); |
79 | todoSearch = new TodoSearch( resultsList, tr("todo") ); | 89 | searches.append( new TodoSearch( resultsList, tr("todo") ) ); |
80 | datebookSearch = new DatebookSearch( resultsList, tr("datebook") ); | 90 | searches.append( new DatebookSearch( resultsList, tr("datebook") ) ); |
81 | applnkSearch = new AppLnkSearch( resultsList, tr("applications") ); | 91 | searches.append( new AppLnkSearch( resultsList, tr("applications") ) ); |
82 | doclnkSearch = new DocLnkSearch( resultsList, tr("documents") ); | 92 | searches.append( new DocLnkSearch( resultsList, tr("documents") ) ); |
83 | 93 | ||
@@ -91,5 +101,4 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | |||
91 | connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); | 101 | connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); |
92 | connect(buttonShow, SIGNAL(clicked()), SLOT( showItem() ) ); | 102 | connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) ); |
93 | connect(buttonEdit, SIGNAL(clicked()), SLOT( editItem() ) ); | 103 | // connect(buttonEdit, SIGNAL(clicked()), SLOT( editItem() ) ); |
94 | |||
95 | 104 | ||
@@ -138,2 +147,26 @@ void MainWindow::setCurrent(QListViewItem *item) | |||
138 | richEdit->setText( res->toRichText() ); | 147 | richEdit->setText( res->toRichText() ); |
148 | QIntDict<QString> acts = res->actions(); | ||
149 | QButton *button; | ||
150 | for (uint i = 0; i < acts.count(); i++){ | ||
151 | button = buttonGroupActions->find( i ); | ||
152 | qDebug("action %i >%s<",i,acts[i]->latin1()); | ||
153 | if (!button) { | ||
154 | qDebug("BUTTON"); | ||
155 | button = new QPushButton( detailsFrame ); | ||
156 | buttonLayout->addWidget( button, 0 ); | ||
157 | buttonGroupActions->insert( button, i); | ||
158 | } | ||
159 | button->setText( *acts[i] ); | ||
160 | button->show(); | ||
161 | } | ||
162 | for (uint i = acts.count(); i < _buttonCount; i++){ | ||
163 | qDebug("remove button %i of %i",i, _buttonCount); | ||
164 | button = buttonGroupActions->find( i ); | ||
165 | if (button) button->hide(); | ||
166 | } | ||
167 | _buttonCount = acts.count(); | ||
168 | // buttonShow = new QPushButton( detailsFrame, "Show" ) ; | ||
169 | // buttonShow->setText( "test" ); | ||
170 | // buttonLayout->addWidget( buttonShow, 0 ); | ||
171 | // buttonGroupActions->insert(buttonShow); | ||
139 | detailsFrame->show(); | 172 | detailsFrame->show(); |
@@ -152,3 +185,3 @@ void MainWindow::showPopup() | |||
152 | qDebug("showPopup"); | 185 | qDebug("showPopup"); |
153 | if (!_item) return; | 186 | if (!_currentItem) return; |
154 | } | 187 | } |
@@ -157,7 +190,4 @@ void MainWindow::setSearch( const QString &key ) | |||
157 | { | 190 | { |
158 | adrSearch->setSearch(key); | 191 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) |
159 | todoSearch->setSearch(key); | 192 | s->setSearch( key ); |
160 | datebookSearch->setSearch(key); | ||
161 | applnkSearch->setSearch(key); | ||
162 | doclnkSearch->setSearch(key); | ||
163 | } | 193 | } |
@@ -165,3 +195,3 @@ void MainWindow::setSearch( const QString &key ) | |||
165 | 195 | ||
166 | void MainWindow::showItem() | 196 | void MainWindow::slotAction( int act) |
167 | { | 197 | { |
@@ -170,3 +200,3 @@ void MainWindow::showItem() | |||
170 | // ResultItem *res = dynamic_cast<ResultItem*>(item); | 200 | // ResultItem *res = dynamic_cast<ResultItem*>(item); |
171 | res->showItem(); | 201 | res->action(act); |
172 | } | 202 | } |
@@ -174,9 +204 @@ void MainWindow::showItem() | |||
174 | |||
175 | void MainWindow::editItem() | ||
176 | { | ||
177 | if (_currentItem->rtti() == OListViewItem::Result){ | ||
178 | ResultItem *res = (ResultItem*)_currentItem; | ||
179 | // ResultItem *res = dynamic_cast<ResultItem*>(item); | ||
180 | res->editItem(); | ||
181 | } | ||
182 | } | ||