Recent: resize to "Title" column contents
[nomnom.git] / src / log / nlogdialog.cpp
blob5e9b8ee8ed2602fc09058e84187e3aa03dde26a1
1 /* NomNom
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/>.
18 #include "config.h"
20 #include <QCoreApplication>
21 #include <QDialogButtonBox>
22 #include <QMessageBox>
23 #include <QVBoxLayout>
24 #include <QToolBox>
26 #include <NLogDialog>
27 #include <NSettings>
28 #include <NUtil>
30 namespace nn
33 NLogDialog::NLogDialog(QWidget *parent/*=NULL*/)
34 : QDialog(parent), _toolbox(NULL)
37 // Toolbox
39 _toolbox = new QToolBox;
41 NLogRecent *recent = new NLogRecent;
42 connect(recent, SIGNAL(selected(QString)), this, SLOT(selected(QString)));
44 _toolbox->addItem(recent, tr("&Recent"));
46 // Button box
48 QDialogButtonBox *bb = new QDialogButtonBox(
49 QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
51 connect(bb, SIGNAL(accepted()), this, SLOT(accept()));
52 connect(bb, SIGNAL(rejected()), this, SLOT(reject()));
54 // Layout
56 QVBoxLayout *box = new QVBoxLayout;
57 box->addWidget(_toolbox);
58 box->addWidget(bb);
59 setLayout(box);
61 // Window
63 setMinimumSize(QSize(500,400));
64 setWindowTitle(tr("Log"));
65 setSizeGripEnabled(true);
67 foreachWidget();
70 void NLogDialog::foreachWidget()
72 const int c = _toolbox->count();
73 for (int i=0; i<c; ++i)
75 NLogWidget *l = dynamic_cast<NLogWidget*>(_toolbox->widget(i));
76 #ifdef _1
77 l->read();
78 #endif
79 l->init();
83 void NLogDialog::done(int n)
85 if (n == QDialog::Accepted)
87 if (_selected.isEmpty())
89 _toolbox->setCurrentIndex(0);
90 info(this, tr("Please select an item from the list"));
91 return;
94 QDialog::done(n);
95 close();
98 void NLogDialog::selected(QString s)
100 _selected = s;
103 QString NLogDialog::selected() const
105 return _selected;
108 // NLogWidget
110 NLogWidget::NLogWidget(QWidget *parent/*=NULL*/)
111 : QWidget(parent)
115 } // namespace nn
117 /* vim: set ts=2 sw=2 tw=72 expandtab: */