danbooru-client/src/danbooruclientview.cpp
2014-10-12 14:27:44 +02:00

83 lines
2.2 KiB
C++

/*
* Copyright 2014 Luca Beltrame <lbeltrame@kde.org>
*
* This file is part of Danbooru Client.
*
* Danbooru Client is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version version of the License, or
* (at your option) any later version.
*
* Danbooru Client is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Danbooru Client. If not, see <http://www.gnu.org/licenses/>.
*/
#include "danbooruclientview.h"
// Own
#include "model/danboorupostmodel.h"
#include "model/danboorupostdelegate.h"
// Qt
// KDE
#include <KRun>
namespace Danbooru
{
DanbooruClientView::DanbooruClientView(QWidget *parent): QWidget(parent),
m_model(new DanbooruPostModel(this)),
m_delegate(0),
m_service(0),
m_timer(0)
{
setupUi(this);
m_delegate = new DanbooruPostDelegate(m_listView);
m_listView->setFlow(QListView::LeftToRight);
m_listView->setResizeMode(QListView::Adjust);
m_listView->setWrapping(true);
m_listView->setViewMode(QListView::IconMode);
m_listView->setGridSize(QSize(256, 256));
m_listView->setModel(m_model);
m_listView->setItemDelegate(m_delegate);
// signal-slot connections
connect(m_delegate, &DanbooruPostDelegate::postDownloadRequested, this, &DanbooruClientView::slotHandleDownload);
connect(m_delegate, &DanbooruPostDelegate::postViewRequested, this, &DanbooruClientView::slotHandleView);
// connect(m_listView, SIGNAL(clicked(QModelIndex)), parent(),
// SLOT(displayInfo(QModelIndex));
}
DanbooruClientView::~DanbooruClientView()
{
}
void DanbooruClientView::slotHandleDownload(QUrl url)
{
// TODO
Q_UNUSED(url)
}
void DanbooruClientView::slotHandleView(QUrl url)
{
KRun *runViewer = new KRun(url, this /*window*/, true /*showProgressInfo*/,
"" /*asn*/);
runViewer->setAutoDelete(true);
}
} // namespace Danbooru