1 /***************************************************************************
2 * KSystemLog, a system log viewer tool *
3 * Copyright (C) 2007 by Nicolas Ternisien *
4 * nicolas.ternisien@gmail.com *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
20 ***************************************************************************/
22 #include "detailDialog.h"
26 #include <kiconloader.h>
29 #include "logViewWidget.h"
30 #include "logViewWidgetItem.h"
35 DetailDialog::DetailDialog(QWidget
* parent
) :
41 previous
->setText(i18n("&Previous"));
42 previous
->setIcon(KIcon("arrow-up"));
43 connect(previous
, SIGNAL(clicked()), this, SLOT(previousItem()));
45 next
->setText(i18n("&Next"));
46 next
->setIcon(KIcon("arrow-down"));
47 connect(next
, SIGNAL(clicked()), this, SLOT(nextItem()));
49 closeButton
->setText(KStandardGuiItem::close().text());
50 closeButton
->setIcon(KStandardGuiItem::close().icon());
51 connect(closeButton
, SIGNAL(clicked()), this, SLOT(close()));
55 DetailDialog::~DetailDialog() {
59 void DetailDialog::selectionChanged(LogViewWidget
* logViewWidget
) {
60 this->logViewWidget
=logViewWidget
;
65 //TODO Try to find a method that reload (an resize) correctly the content of the detail dialog
66 void DetailDialog::updateDetails() {
67 //logDebug() << "Updating Detail Dialog..." << endl;
69 //Get the current-last item selected
70 LogViewWidgetItem
* item
=logViewWidget
->lastSelectedItem();
72 logDebug() << "No item found." << endl
;
76 icon
->setPixmap(DesktopIcon(item
->logLine()->logLevel()->icon()));
78 header
->setText(item
->logLine()->formattedText());
80 message
->setText(item
->logLine()->logItems().last());
82 if (logViewWidget
->topLevelItem(logViewWidget
->indexOfTopLevelItem(item
) - 1)==NULL
)
83 previous
->setEnabled(false);
85 previous
->setEnabled(true);
87 if (logViewWidget
->topLevelItem(logViewWidget
->indexOfTopLevelItem(item
) + 1 )==NULL
)
88 next
->setEnabled(false);
90 next
->setEnabled(true);
98 void DetailDialog::moveToItem(int direction
) {
100 logDebug() << "Go to previous item..." << endl
;
102 logDebug() << "Go to next item..." << endl
;
104 //Get the current-last item selected
105 LogViewWidgetItem
* item
=logViewWidget
->lastSelectedItem();
107 logDebug() << "No item found." << endl
;
111 QTreeWidgetItem
* destinationItem
= logViewWidget
->topLevelItem( logViewWidget
->indexOfTopLevelItem(item
) + direction
);
112 if (destinationItem
==NULL
) {
114 logDebug() << "No previous item found." << endl
;
116 logDebug() << "No next item found." << endl
;
120 logViewWidget
->setItemSelected(item
, false);
121 logViewWidget
->setItemSelected(destinationItem
, true);
122 logViewWidget
->scrollToItem(destinationItem
);
127 void DetailDialog::previousItem() {
131 void DetailDialog::nextItem() {
135 #include "detailDialog.moc"