]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/information/informationpanel.cpp
disable rating, comments and tags if no meta data is available
[dolphin.git] / src / panels / information / informationpanel.cpp
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #include "informationpanel.h"
21
22 #include <config-nepomuk.h>
23
24 #include <kdialog.h>
25 #include <kdirnotify.h>
26 #include <kfileitem.h>
27 #include <kfilemetainfo.h>
28 #include <kfileplacesmodel.h>
29 #include <kglobalsettings.h>
30 #include <kio/previewjob.h>
31 #include <kiconeffect.h>
32 #include <kiconloader.h>
33 #include <klocale.h>
34 #include <kmenu.h>
35 #include <kseparator.h>
36
37 #ifdef HAVE_NEPOMUK
38 #include <Nepomuk/Resource>
39 #include <Nepomuk/Types/Property>
40 #include <Nepomuk/Variant>
41 #endif
42
43 #include <Phonon/BackendCapabilities>
44 #include <Phonon/MediaObject>
45 #include <Phonon/SeekSlider>
46
47 #include <QEvent>
48 #include <QInputDialog>
49 #include <QLabel>
50 #include <QPainter>
51 #include <QPixmap>
52 #include <QResizeEvent>
53 #include <QScrollArea>
54 #include <QTextLayout>
55 #include <QTextLine>
56 #include <QTimer>
57 #include <QScrollBar>
58 #include <QVBoxLayout>
59
60 #include "dolphin_informationpanelsettings.h"
61 #include "settings/dolphinsettings.h"
62 #include "metadatawidget.h"
63 #include "metatextlabel.h"
64 #include "phononwidget.h"
65 #include "pixmapviewer.h"
66
67 /**
68 * Helper function for sorting items with qSort() in
69 * InformationPanel::contextMenu().
70 */
71 bool lessThan(const QAction* action1, const QAction* action2)
72 {
73 return action1->text() < action2->text();
74 }
75
76
77 InformationPanel::InformationPanel(QWidget* parent) :
78 Panel(parent),
79 m_initialized(false),
80 m_pendingPreview(false),
81 m_infoTimer(0),
82 m_outdatedPreviewTimer(0),
83 m_shownUrl(),
84 m_urlCandidate(),
85 m_fileItem(),
86 m_selection(),
87 m_nameLabel(0),
88 m_preview(0),
89 m_phononWidget(0),
90 m_metaDataWidget(0),
91 m_metaTextArea(0),
92 m_metaTextLabel(0)
93 {
94 }
95
96 InformationPanel::~InformationPanel()
97 {
98 }
99
100 QSize InformationPanel::sizeHint() const
101 {
102 QSize size = Panel::sizeHint();
103 size.setWidth(minimumSizeHint().width());
104 return size;
105 }
106
107 void InformationPanel::setUrl(const KUrl& url)
108 {
109 Panel::setUrl(url);
110 if (url.isValid() && !isEqualToShownUrl(url)) {
111 if (isVisible()) {
112 cancelRequest();
113 m_shownUrl = url;
114 showItemInfo();
115 } else {
116 m_shownUrl = url;
117 }
118 }
119 }
120
121 void InformationPanel::setSelection(const KFileItemList& selection)
122 {
123 if (!isVisible()) {
124 return;
125 }
126
127 if ((selection.count() == 0) && (m_selection.count() == 0)) {
128 // The selection has not really changed, only the current index.
129 // QItemSelectionModel emits a signal in this case and it is less
130 // expensive doing the check this way instead of patching
131 // DolphinView::emitSelectionChanged().
132 return;
133 }
134
135 m_selection = selection;
136
137 const int count = selection.count();
138 if (count == 0) {
139 if (!isEqualToShownUrl(url())) {
140 m_shownUrl = url();
141 showItemInfo();
142 }
143 } else {
144 if ((count == 1) && !selection.first().url().isEmpty()) {
145 m_urlCandidate = selection.first().url();
146 }
147 m_infoTimer->start();
148 }
149 }
150
151 void InformationPanel::requestDelayedItemInfo(const KFileItem& item)
152 {
153 if (!isVisible()) {
154 return;
155 }
156
157 cancelRequest();
158
159 m_fileItem = KFileItem();
160 if (item.isNull()) {
161 // The cursor is above the viewport. If files are selected,
162 // show information regarding the selection.
163 if (m_selection.size() > 0) {
164 m_pendingPreview = false;
165 m_infoTimer->start();
166 }
167 } else {
168 const KUrl url = item.url();
169 if (url.isValid() && !isEqualToShownUrl(url)) {
170 m_urlCandidate = item.url();
171 m_fileItem = item;
172 m_infoTimer->start();
173 }
174 }
175 }
176
177 void InformationPanel::showEvent(QShowEvent* event)
178 {
179 Panel::showEvent(event);
180 if (!event->spontaneous()) {
181 if (!m_initialized) {
182 // do a delayed initialization so that no performance
183 // penalty is given when Dolphin is started with a closed
184 // Information Panel
185 init();
186 }
187 showItemInfo();
188 }
189 }
190
191 void InformationPanel::resizeEvent(QResizeEvent* event)
192 {
193 if (isVisible()) {
194 // If the text inside the name label or the info label cannot
195 // get wrapped, then the maximum width of the label is increased
196 // so that the width of the information panel gets increased.
197 // To prevent this, the maximum width is adjusted to
198 // the current width of the panel.
199 const int maxWidth = event->size().width() - KDialog::spacingHint() * 4;
200 m_nameLabel->setMaximumWidth(maxWidth);
201
202 // try to increase the preview as large as possible
203 m_preview->setSizeHint(QSize(maxWidth, maxWidth));
204 m_urlCandidate = m_shownUrl; // reset the URL candidate if a resizing is done
205 m_infoTimer->start();
206 }
207 Panel::resizeEvent(event);
208 }
209
210 bool InformationPanel::eventFilter(QObject* obj, QEvent* event)
211 {
212 // Check whether the size of the meta text area has changed and adjust
213 // the fixed width in a way that no horizontal scrollbar needs to be shown.
214 if ((obj == m_metaTextArea->viewport()) && (event->type() == QEvent::Resize)) {
215 QResizeEvent* resizeEvent = static_cast<QResizeEvent*>(event);
216 m_metaTextLabel->setFixedWidth(resizeEvent->size().width());
217 }
218 return Panel::eventFilter(obj, event);
219 }
220
221 void InformationPanel::contextMenuEvent(QContextMenuEvent* event)
222 {
223 Panel::contextMenuEvent(event);
224
225 #ifdef HAVE_NEPOMUK
226 if (showMultipleSelectionInfo()) {
227 return;
228 }
229
230 KMenu popup(this);
231
232 QAction* previewAction = popup.addAction(i18nc("@action:inmenu", "Preview"));
233 previewAction->setIcon(KIcon("view-preview"));
234 previewAction->setCheckable(true);
235 previewAction->setChecked(InformationPanelSettings::showPreview());
236
237 const bool metaDataAvailable = MetaDataWidget::metaDataAvailable();
238
239 QAction* ratingAction = popup.addAction(i18nc("@action:inmenu", "Rating"));
240 ratingAction->setIcon(KIcon("rating"));
241 ratingAction->setCheckable(true);
242 ratingAction->setChecked(InformationPanelSettings::showRating());
243 ratingAction->setEnabled(metaDataAvailable);
244
245 QAction* commentAction = popup.addAction(i18nc("@action:inmenu", "Comment"));
246 commentAction->setIcon(KIcon("text-plain"));
247 commentAction->setCheckable(true);
248 commentAction->setChecked(InformationPanelSettings::showComment());
249 commentAction->setEnabled(metaDataAvailable);
250
251 QAction* tagsAction = popup.addAction(i18nc("@action:inmenu", "Tags"));
252 tagsAction->setCheckable(true);
253 tagsAction->setChecked(InformationPanelSettings::showTags());
254 tagsAction->setEnabled(metaDataAvailable);
255
256 KConfig config("kmetainformationrc", KConfig::NoGlobals);
257 KConfigGroup settings = config.group("Show");
258 initMetaInfoSettings(settings);
259
260 QList<QAction*> actions;
261
262 // Get all meta information labels that are available for
263 // the currently shown file item and add them to the popup.
264 Nepomuk::Resource res(fileItem().url());
265 QHash<QUrl, Nepomuk::Variant> properties = res.properties();
266 QHash<QUrl, Nepomuk::Variant>::const_iterator it = properties.constBegin();
267 while (it != properties.constEnd()) {
268 Nepomuk::Types::Property prop(it.key());
269 const QString key = prop.label();
270
271 // Meta information provided by Nepomuk that is already
272 // available from KFileItem should not be configurable.
273 bool skip = (key == "fileExtension") ||
274 (key == "name") ||
275 (key == "sourceModified") ||
276 (key == "size") ||
277 (key == "mime type");
278 if (!skip) {
279 // Check whether there is already a meta information
280 // having the same label. In this case don't show it
281 // twice in the menu.
282 foreach (const QAction* action, actions) {
283 if (action->data().toString() == key) {
284 skip = true;
285 break;
286 }
287 }
288 }
289
290 if (!skip) {
291 const QString label = key; // TODO
292 QAction* action = new QAction(label, &popup);
293 action->setCheckable(true);
294 action->setChecked(settings.readEntry(key, true));
295 action->setData(key);
296 actions.append(action);
297 }
298
299 ++it;
300 }
301
302 if (actions.count() > 0) {
303 popup.addSeparator();
304
305 // add all items alphabetically sorted to the popup
306 qSort(actions.begin(), actions.end(), lessThan);
307 foreach (QAction* action, actions) {
308 popup.addAction(action);
309 }
310 }
311
312 // Open the popup and adjust the settings for the
313 // selected action.
314 QAction* action = popup.exec(QCursor::pos());
315 if (action == 0) {
316 return;
317 }
318
319 if (action == previewAction) {
320 // TODO
321 } else if (action == ratingAction) {
322 // TODO
323 } else if (action == commentAction) {
324 // TODO
325 } else if (action == tagsAction) {
326 // TODO
327 } else {
328 settings.writeEntry(action->data().toString(), action->isChecked());
329 settings.sync();
330 showMetaInfo();
331 }
332 #endif
333 }
334
335 void InformationPanel::showItemInfo()
336 {
337 if (!isVisible()) {
338 return;
339 }
340
341 cancelRequest();
342
343 if (showMultipleSelectionInfo()) {
344 KIconLoader iconLoader;
345 QPixmap icon = iconLoader.loadIcon("dialog-information",
346 KIconLoader::NoGroup,
347 KIconLoader::SizeEnormous);
348 m_preview->setPixmap(icon);
349 setNameLabelText(i18ncp("@info", "%1 item selected", "%1 items selected", m_selection.count()));
350 m_shownUrl = KUrl();
351 } else {
352 const KFileItem item = fileItem();
353 const KUrl itemUrl = item.url();
354 if (!applyPlace(itemUrl)) {
355 // try to get a preview pixmap from the item...
356 m_pendingPreview = true;
357
358 // Mark the currently shown preview as outdated. This is done
359 // with a small delay to prevent a flickering when the next preview
360 // can be shown within a short timeframe.
361 m_outdatedPreviewTimer->start();
362
363 KIO::PreviewJob* job = KIO::filePreview(KFileItemList() << item,
364 m_preview->width(),
365 m_preview->height(),
366 0,
367 0,
368 false,
369 true);
370
371 connect(job, SIGNAL(gotPreview(const KFileItem&, const QPixmap&)),
372 this, SLOT(showPreview(const KFileItem&, const QPixmap&)));
373 connect(job, SIGNAL(failed(const KFileItem&)),
374 this, SLOT(showIcon(const KFileItem&)));
375
376 setNameLabelText(itemUrl.fileName());
377 }
378 }
379
380 showMetaInfo();
381 }
382
383 void InformationPanel::slotInfoTimeout()
384 {
385 m_shownUrl = m_urlCandidate;
386 showItemInfo();
387 }
388
389 void InformationPanel::markOutdatedPreview()
390 {
391 KIconEffect iconEffect;
392 QPixmap disabledPixmap = iconEffect.apply(m_preview->pixmap(),
393 KIconLoader::Desktop,
394 KIconLoader::DisabledState);
395 m_preview->setPixmap(disabledPixmap);
396 }
397
398 void InformationPanel::showIcon(const KFileItem& item)
399 {
400 m_outdatedPreviewTimer->stop();
401 m_pendingPreview = false;
402 if (!applyPlace(item.url())) {
403 m_preview->setPixmap(item.pixmap(KIconLoader::SizeEnormous));
404 }
405 }
406
407 void InformationPanel::showPreview(const KFileItem& item,
408 const QPixmap& pixmap)
409 {
410 m_outdatedPreviewTimer->stop();
411
412 Q_UNUSED(item);
413 if (m_pendingPreview) {
414 m_preview->setPixmap(pixmap);
415 m_pendingPreview = false;
416 }
417 }
418
419 void InformationPanel::slotFileRenamed(const QString& source, const QString& dest)
420 {
421 const KUrl sourceUrl = KUrl(source);
422
423 // Verify whether the renamed item is selected. If this is the case, the
424 // selection must be updated with the renamed item.
425 bool isSelected = false;
426 for (int i = m_selection.size() - 1; i >= 0; --i) {
427 if (m_selection[i].url() == sourceUrl) {
428 m_selection.removeAt(i);
429 isSelected = true;
430 break;
431 }
432 }
433
434 if ((m_shownUrl == sourceUrl) || isSelected) {
435 m_shownUrl = KUrl(dest);
436 m_fileItem = KFileItem(KFileItem::Unknown, KFileItem::Unknown, m_shownUrl);
437 if (isSelected) {
438 m_selection.append(m_fileItem);
439 }
440 showItemInfo();
441 }
442 }
443
444 void InformationPanel::slotFilesAdded(const QString& directory)
445 {
446 if (m_shownUrl == KUrl(directory)) {
447 // If the 'trash' icon changes because the trash has been emptied or got filled,
448 // the signal filesAdded("trash:/") will be emitted.
449 KFileItem item(KFileItem::Unknown, KFileItem::Unknown, KUrl(directory));
450 requestDelayedItemInfo(item);
451 }
452 }
453
454 void InformationPanel::slotFilesChanged(const QStringList& files)
455 {
456 foreach (const QString& fileName, files) {
457 if (m_shownUrl == KUrl(fileName)) {
458 showItemInfo();
459 break;
460 }
461 }
462 }
463
464 void InformationPanel::slotFilesRemoved(const QStringList& files)
465 {
466 foreach (const QString& fileName, files) {
467 if (m_shownUrl == KUrl(fileName)) {
468 // the currently shown item has been removed, show
469 // the parent directory as fallback
470 reset();
471 break;
472 }
473 }
474 }
475
476 void InformationPanel::slotEnteredDirectory(const QString& directory)
477 {
478 if (m_shownUrl == KUrl(directory)) {
479 KFileItem item(KFileItem::Unknown, KFileItem::Unknown, KUrl(directory));
480 requestDelayedItemInfo(item);
481 }
482 }
483
484 void InformationPanel::slotLeftDirectory(const QString& directory)
485 {
486 if (m_shownUrl == KUrl(directory)) {
487 // The signal 'leftDirectory' is also emitted when a media
488 // has been unmounted. In this case no directory change will be
489 // done in Dolphin, but the Information Panel must be updated to
490 // indicate an invalid directory.
491 reset();
492 }
493 }
494
495 bool InformationPanel::applyPlace(const KUrl& url)
496 {
497 KFilePlacesModel* placesModel = DolphinSettings::instance().placesModel();
498 int count = placesModel->rowCount();
499
500 for (int i = 0; i < count; ++i) {
501 QModelIndex index = placesModel->index(i, 0);
502
503 if (url.equals(placesModel->url(index), KUrl::CompareWithoutTrailingSlash)) {
504 setNameLabelText(placesModel->text(index));
505 m_preview->setPixmap(placesModel->icon(index).pixmap(128, 128));
506 return true;
507 }
508 }
509
510 return false;
511 }
512
513 void InformationPanel::cancelRequest()
514 {
515 m_infoTimer->stop();
516 }
517
518 void InformationPanel::showMetaInfo()
519 {
520 m_metaTextLabel->clear();
521
522 if (showMultipleSelectionInfo()) {
523 if (m_metaDataWidget != 0) {
524 KUrl::List urls;
525 foreach (const KFileItem& item, m_selection) {
526 urls.append(item.targetUrl());
527 }
528 m_metaDataWidget->setFiles(urls);
529 }
530
531 quint64 totalSize = 0;
532 foreach (const KFileItem& item, m_selection) {
533 // Only count the size of files, not dirs to match what
534 // DolphinViewContainer::selectionStatusBarText() does.
535 if (!item.isDir() && !item.isLink()) {
536 totalSize += item.size();
537 }
538 }
539 m_metaTextLabel->add(i18nc("@label", "Total size:"), KIO::convertSize(totalSize));
540
541 delete m_phononWidget;
542 m_phononWidget = 0;
543 } else {
544 const KFileItem item = fileItem();
545 if (item.isDir()) {
546 m_metaTextLabel->add(i18nc("@label", "Type:"), i18nc("@label", "Folder"));
547 m_metaTextLabel->add(i18nc("@label", "Modified:"), item.timeString());
548 } else {
549 m_metaTextLabel->add(i18nc("@label", "Type:"), item.mimeComment());
550
551 m_metaTextLabel->add(i18nc("@label", "Size:"), KIO::convertSize(item.size()));
552 m_metaTextLabel->add(i18nc("@label", "Modified:"), item.timeString());
553
554 #ifdef HAVE_NEPOMUK
555 KConfig config("kmetainformationrc", KConfig::NoGlobals);
556 KConfigGroup settings = config.group("Show");
557 initMetaInfoSettings(settings);
558
559 Nepomuk::Resource res(item.url());
560
561 QHash<QUrl, Nepomuk::Variant> properties = res.properties();
562 QHash<QUrl, Nepomuk::Variant>::const_iterator it = properties.constBegin();
563 while (it != properties.constEnd()) {
564 Nepomuk::Types::Property prop(it.key());
565 const QString label = prop.label();
566 if (settings.readEntry(label, true)) {
567 // TODO: use Nepomuk::formatValue(res, prop) if available
568 // instead of it.value().toString()
569 m_metaTextLabel->add(label, it.value().toString());
570 }
571 ++it;
572 }
573 #endif
574 }
575
576 if (m_metaDataWidget != 0) {
577 m_metaDataWidget->setFile(item.targetUrl());
578 }
579
580 if (Phonon::BackendCapabilities::isMimeTypeAvailable(item.mimetype())) {
581 if (m_phononWidget == 0) {
582 m_phononWidget = new PhononWidget(this);
583
584 QVBoxLayout* vBoxLayout = qobject_cast<QVBoxLayout*>(layout());
585 Q_ASSERT(vBoxLayout != 0);
586 vBoxLayout->insertWidget(3, m_phononWidget);
587 }
588 m_phononWidget->setUrl(item.url());
589 } else {
590 delete m_phononWidget;
591 m_phononWidget = 0;
592 }
593 }
594 }
595
596 KFileItem InformationPanel::fileItem() const
597 {
598 if (!m_fileItem.isNull()) {
599 return m_fileItem;
600 }
601
602 if (!m_selection.isEmpty()) {
603 Q_ASSERT(m_selection.count() == 1);
604 return m_selection.first();
605 }
606
607 // no item is hovered and no selection has been done: provide
608 // an item for the directory represented by m_shownUrl
609 KFileItem item(KFileItem::Unknown, KFileItem::Unknown, m_shownUrl);
610 item.refresh();
611 return item;
612 }
613
614 bool InformationPanel::showMultipleSelectionInfo() const
615 {
616 return m_fileItem.isNull() && (m_selection.count() > 1);
617 }
618
619 bool InformationPanel::isEqualToShownUrl(const KUrl& url) const
620 {
621 return m_shownUrl.equals(url, KUrl::CompareWithoutTrailingSlash);
622 }
623
624 void InformationPanel::setNameLabelText(const QString& text)
625 {
626 QTextOption textOption;
627 textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
628
629 QTextLayout textLayout(text);
630 textLayout.setFont(m_nameLabel->font());
631 textLayout.setTextOption(textOption);
632
633 QString wrappedText;
634 wrappedText.reserve(text.length());
635
636 // wrap the text to fit into the width of m_nameLabel
637 textLayout.beginLayout();
638 QTextLine line = textLayout.createLine();
639 while (line.isValid()) {
640 line.setLineWidth(m_nameLabel->width());
641 wrappedText += text.mid(line.textStart(), line.textLength());
642
643 line = textLayout.createLine();
644 if (line.isValid()) {
645 wrappedText += QChar::LineSeparator;
646 }
647 }
648 textLayout.endLayout();
649
650 m_nameLabel->setText(wrappedText);
651 }
652
653 void InformationPanel::reset()
654 {
655 m_selection.clear();
656 m_shownUrl = url();
657 m_fileItem = KFileItem();
658 showItemInfo();
659 }
660
661 void InformationPanel::initMetaInfoSettings(KConfigGroup& group)
662 {
663 if (!group.readEntry("initialized", false)) {
664 // The resource file is read the first time. Assure
665 // that some meta information is disabled per default.
666 group.writeEntry("fileExtension", false);
667 group.writeEntry("url", false);
668 group.writeEntry("sourceModified", false);
669 group.writeEntry("parentUrl", false);
670 group.writeEntry("size", false);
671 group.writeEntry("mime type", false);
672 group.writeEntry("depth", false);
673 group.writeEntry("name", false);
674
675 // mark the group as initialized
676 group.writeEntry("initialized", true);
677 }
678 }
679
680 void InformationPanel::init()
681 {
682 const int spacing = KDialog::spacingHint();
683
684 m_infoTimer = new QTimer(this);
685 m_infoTimer->setInterval(300);
686 m_infoTimer->setSingleShot(true);
687 connect(m_infoTimer, SIGNAL(timeout()),
688 this, SLOT(slotInfoTimeout()));
689
690 // Initialize timer for disabling an outdated preview with a small
691 // delay. This prevents flickering if the new preview can be generated
692 // within a very small timeframe.
693 m_outdatedPreviewTimer = new QTimer(this);
694 m_outdatedPreviewTimer->setInterval(300);
695 m_outdatedPreviewTimer->setSingleShot(true);
696 connect(m_outdatedPreviewTimer, SIGNAL(timeout()),
697 this, SLOT(markOutdatedPreview()));
698
699 QVBoxLayout* layout = new QVBoxLayout;
700 layout->setSpacing(spacing);
701
702 // name
703 m_nameLabel = new QLabel(this);
704 QFont font = m_nameLabel->font();
705 font.setBold(true);
706 m_nameLabel->setFont(font);
707 m_nameLabel->setAlignment(Qt::AlignHCenter);
708 m_nameLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
709
710 // preview
711 m_preview = new PixmapViewer(this);
712 m_preview->setMinimumWidth(KIconLoader::SizeEnormous + KIconLoader::SizeMedium);
713 m_preview->setMinimumHeight(KIconLoader::SizeEnormous);
714
715 if (MetaDataWidget::metaDataAvailable()) {
716 // rating, comment and tags
717 m_metaDataWidget = new MetaDataWidget(this);
718 m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
719 }
720
721 // general meta text information
722 m_metaTextLabel = new MetaTextLabel(this);
723 m_metaTextLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
724
725 m_metaTextArea = new QScrollArea(this);
726 m_metaTextArea->setWidget(m_metaTextLabel);
727 m_metaTextArea->setWidgetResizable(true);
728 m_metaTextArea->setFrameShape(QFrame::NoFrame);
729
730 QWidget* viewport = m_metaTextArea->viewport();
731 viewport->installEventFilter(this);
732
733 QPalette palette = viewport->palette();
734 palette.setColor(viewport->backgroundRole(), QColor(Qt::transparent));
735 viewport->setPalette(palette);
736
737 layout->addWidget(m_nameLabel);
738 layout->addWidget(new KSeparator(this));
739 layout->addWidget(m_preview);
740 layout->addWidget(new KSeparator(this));
741 if (m_metaDataWidget != 0) {
742 layout->addWidget(m_metaDataWidget);
743 layout->addWidget(new KSeparator(this));
744 }
745 layout->addWidget(m_metaTextArea);
746 setLayout(layout);
747
748 org::kde::KDirNotify* dirNotify = new org::kde::KDirNotify(QString(), QString(),
749 QDBusConnection::sessionBus(), this);
750 connect(dirNotify, SIGNAL(FileRenamed(QString, QString)), SLOT(slotFileRenamed(QString, QString)));
751 connect(dirNotify, SIGNAL(FilesAdded(QString)), SLOT(slotFilesAdded(QString)));
752 connect(dirNotify, SIGNAL(FilesChanged(QStringList)), SLOT(slotFilesChanged(QStringList)));
753 connect(dirNotify, SIGNAL(FilesRemoved(QStringList)), SLOT(slotFilesRemoved(QStringList)));
754 connect(dirNotify, SIGNAL(enteredDirectory(QString)), SLOT(slotEnteredDirectory(QString)));
755 connect(dirNotify, SIGNAL(leftDirectory(QString)), SLOT(slotLeftDirectory(QString)));
756
757 m_initialized = true;
758 }
759
760 #include "informationpanel.moc"