2 * Copyright (C) 2011 Toni Gundogdu <legatvs@gmail.com>
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 3 of the License, or
7 * (at your option) any later version.
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.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <QCoreApplication>
21 #include <QDialogButtonBox>
22 #include <QPushButton>
23 #include <QVBoxLayout>
24 #include <QTextStream>
25 #include <QTreeWidget>
26 #include <QMessageBox>
28 #include <NRecentMutator>
29 #include <NRecentEntry>
34 extern nn::NRecentMutator recent
;
39 NLogRecent::NLogRecent(QWidget
*parent
/*=NULL*/)
40 : NLogWidget(parent
), _treew(NULL
)
45 _treew
= new QTreeWidget
;
46 _treew
->setHeaderLabels(QStringList() << tr("Title") << tr("Added"));
47 _treew
->setColumnCount(2);
49 connect(_treew
, SIGNAL(itemSelectionChanged()), this, SLOT(selected()));
51 QDialogButtonBox
*bb
= new QDialogButtonBox(QDialogButtonBox::Reset
);
53 connect(bb
->button(QDialogButtonBox::Reset
), SIGNAL(clicked()),
58 QVBoxLayout
*box
= new QVBoxLayout
;
59 box
->addWidget(_treew
);
65 void NLogRecent::read()
71 void NLogRecent::init()
73 recent
.populate(_treew
);
74 _treew
->resizeColumnToContents(0);
75 _treew
->sortByColumn(1);
76 _treew
->setSortingEnabled(true);
79 void NLogRecent::selected()
81 QTreeWidgetItem
*i
= _treew
->selectedItems().first();
82 i
= (i
->childCount() > 0) ? i
->child(0) : i
;
84 emit
selected(i
->text(0));
87 void NLogRecent::reset()
89 if (_treew
->topLevelItemCount() == 0)
92 if (ask(this, tr("All records will be lost permanently. Really clear?"))
104 /* vim: set ts=2 sw=2 tw=72 expandtab: */