#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

#include "konaclient.h"
#include "konasearch.h"
#include "konaimage.h"
#include "konatags.h"
#include "konatag.h"
#include "konarelatedtags.h"
#include <QStyle>
#include "flowlayout.h"
#include "imageviewer.h"

#define ITEMS_PER_SEARCH 50
#define RELATED_TAGS_AMOUNT 10


#define SEARCHTYPE_POSTS 0
#define SEARCHTYPE_POOLS 1



// SETTINGS
#define PRELOAD_AMOUNT 3 // TODO:

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    
public slots:
    // GUI Events
    void onScroll(int value);
    void searchPosts();
    void searchPools();
    void jumpToPage();
    void tagClicked(QString link);

    // Int
    void searchFinished(KonaSearch *ks);
    void tagsFinished(KonaTags *kt);
    void relatedTagsFinished(KonaRelatedTags *krt);
    void downloadImage(KonaImage *Ki);
    void downloadImage(KonaImage *Ki, bool overwrite);
    void showImage(KonaImage *Ki);
    void jumpNext();
    void jumpPrev();

private:
    Ui::MainWindow *ui;

    KonaClient *kc;
    KonaSearch *search;
    KonaTags *tags;
    KonaRelatedTags *relatedTags;

    FlowLayout *flowLayout;

    ImageViewer *imageViewer;

    bool insertAtBeginning;

    void clearList();

    int upperPage;
    int bottomPage;

    QString currentSearch;
};

#endif // MAINWINDOW_H
