danbooru-client/src/danbooruclientview.cpp

89 lines
3.3 KiB
C++

/***************************************************************************
* Copyright (C) %{CURRENT_YEAR} by %{AUTHOR} <%{EMAIL}> *
* *
* This program 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 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#include "danbooruclientview.h"
// Own
#include "model/danboorupostmodel.h"
#include "model/danboorupostdelegate.h"
// Qt
#include <QTimer>
// KDE
#include <KRun>
#include <KFileDialog>
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, SIGNAL(postDownloadRequested(KUrl)), this,
SLOT(slotHandleDownload(KUrl)));
connect(m_delegate, SIGNAL(postViewRequested(KUrl)), this,
SLOT(slotHandleView(KUrl)));
// connect(m_listView, SIGNAL(clicked(const QModelIndex&)), parent(),
// SLOT(displayInfo(const QModelIndex&));
}
DanbooruClientView::~DanbooruClientView()
{
}
void DanbooruClientView::slotHandleDownload(KUrl url)
{
// TODO
Q_UNUSED(url)
}
void DanbooruClientView::slotHandleView(KUrl url)
{
KRun* runViewer = new KRun(url, this /*window*/, 0 /*mode*/,
false /*isLocalFile*/,
true /*showProgressInfo*/, "" /*asn*/);
runViewer->setAutoDelete(true);
}
} // namespace Danbooru