diff --git a/src/danbooru_clientui.rc b/src/danbooru_clientui.rc index 0480f80..c7b1096 100644 --- a/src/danbooru_clientui.rc +++ b/src/danbooru_clientui.rc @@ -1,8 +1,22 @@ + - - - &Move - - - + + + Main Toolbar + + + + + + + + + + &File + + + + + + diff --git a/src/danbooruclientview.cpp b/src/danbooruclientview.cpp index 116d252..3c98836 100644 --- a/src/danbooruclientview.cpp +++ b/src/danbooruclientview.cpp @@ -17,44 +17,73 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ -#include "danbooru_clientview.h" -#include "settings.h" +#include "danbooruclientview.h" -#include -#include +// Own -danbooru_clientView::danbooru_clientView(QWidget *) -{ - ui_danbooru_clientview_base.setupUi(this); - settingsChanged(); - setAutoFillBackground(true); -} +#include "model/danboorupostmodel.h" +#include "model/danboorupostdelegate.h" -danbooru_clientView::~danbooru_clientView() -{ +// Qt -} +#include -void danbooru_clientView::switchColors() -{ - // switch the foreground/background colors of the label - QColor color = Settings::col_background(); - Settings::setCol_background( Settings::col_foreground() ); - Settings::setCol_foreground( color ); +// KDE - settingsChanged(); -} +#include +#include -void danbooru_clientView::settingsChanged() -{ - QPalette pal; - pal.setColor( QPalette::Window, Settings::col_background()); - pal.setColor( QPalette::WindowText, Settings::col_foreground()); - ui_danbooru_clientview_base.kcfg_sillyLabel->setPalette( pal ); +namespace Danbooru { - // i18n : internationalization - ui_danbooru_clientview_base.kcfg_sillyLabel->setText( i18n("This project is %1 days old",Settings::val_time()) ); - emit signalChangeStatusbar( i18n("Settings changed") ); -} + DanbooruClientView::DanbooruClientView(QWidget * parent): QWidget(parent), + m_model(new DanbooruPostModel(this)), + m_delegate(0), + m_service(0), + m_timer(0) + { + setupUi(this); -#include "danbooru_clientview.moc" + 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 diff --git a/src/danbooruclientview.h b/src/danbooruclientview.h index 1224267..2af6fd1 100644 --- a/src/danbooruclientview.h +++ b/src/danbooruclientview.h @@ -20,54 +20,58 @@ #ifndef DANBOORU_CLIENTVIEW_H #define DANBOORU_CLIENTVIEW_H -#include +#include "ui_danbooruclientview.h" -#include "ui_danbooru_clientview_base.h" +#include "kurl.h" -class QPainter; -class KUrl; +#include -/** - * This is the main view class for danbooru_client. Most of the non-menu, - * non-toolbar, and non-statusbar (e.g., non frame) GUI code should go - * here. - * - * @short Main view - * @author %{AUTHOR} <%{EMAIL}> - * @version %{VERSION} - */ +class QTimer; -class danbooru_clientView : public QWidget, public Ui::danbooru_clientview_base -{ - Q_OBJECT -public: - /** - * Default constructor - */ - danbooru_clientView(QWidget *parent); +namespace Danbooru { + + class DanbooruPostModel; + class DanbooruPostDelegate; + class DanbooruService; /** - * Destructor + * This is the main view class for danbooru_client. Most of the non-menu, + * non-toolbar, and non-statusbar (e.g., non frame) GUI code should go + * here. + * + * @short Main view + * @author %{AUTHOR} <%{EMAIL}> + * @version %{VERSION} */ - virtual ~danbooru_clientView(); -private: - Ui::danbooru_clientview_base ui_danbooru_clientview_base; + class DanbooruClientView : public QWidget, public Ui::DanbooruClientView + { + Q_OBJECT -signals: - /** - * Use this signal to change the content of the statusbar - */ - void signalChangeStatusbar(const QString& text); + public: + /** + * Default constructor + */ + DanbooruClientView(QWidget *parent=0); - /** - * Use this signal to change the content of the caption - */ - void signalChangeCaption(const QString& text); + /** + * Destructor + */ + virtual ~DanbooruClientView(); + + private Q_SLOTS: + void slotHandleDownload(KUrl); + void slotHandleView(KUrl); + + private: + DanbooruPostModel* m_model; + DanbooruPostDelegate* m_delegate; + DanbooruService* m_service; + + QTimer* m_timer; -private slots: - void switchColors(); - void settingsChanged(); }; +} // namespace Danbooru + #endif // danbooru_clientVIEW_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b18332a..6904fa7 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -17,13 +17,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ -#include "danbooru_client.h" -#include "danbooru_clientview.h" -#include "settings.h" - -#include -#include -#include +#include "mainwindow.h" +#include "danbooruclientview.h" +#include "model/danboorupostmodel.h" #include #include @@ -34,75 +30,65 @@ #include -danbooru_client::danbooru_client() - : KXmlGuiWindow(), - m_view(new danbooru_clientView(this)), - m_printer(0) -{ - // accept dnd - setAcceptDrops(true); +namespace Danbooru { - // tell the KXmlGuiWindow that this is indeed the main widget - setCentralWidget(m_view); + DanbooruMainWindow::DanbooruMainWindow() + : KXmlGuiWindow(), + m_view(new DanbooruClientView(this)), + m_service(0), + m_model(new(DanbooruPostModel(this))) + { + // tell the KXmlGuiWindow that this is indeed the main widget + setCentralWidget(m_view); - // then, setup our actions - setupActions(); + // then, setup our actions + setupActions(); - // add a status bar - statusBar()->show(); + // add a status bar + statusBar()->show(); - // a call to KXmlGuiWindow::setupGUI() populates the GUI - // with actions, using KXMLGUI. - // It also applies the saved mainwindow settings, if any, and ask the - // mainwindow to automatically save settings if changed: window size, - // toolbar position, icon size, etc. - setupGUI(); -} - -danbooru_client::~danbooru_client() -{ -} - -void danbooru_client::setupActions() -{ - KStandardAction::openNew(this, SLOT(fileNew()), actionCollection()); - KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollection()); - - KStandardAction::preferences(this, SLOT(optionsPreferences()), actionCollection()); - - // custom menu and menu item - the slot is in the class danbooru_clientView - KAction *custom = new KAction(KIcon("colorize"), i18n("Swi&tch Colors"), this); - actionCollection()->addAction( QLatin1String("switch_action"), custom ); - connect(custom, SIGNAL(triggered(bool)), m_view, SLOT(switchColors())); -} - -void danbooru_client::fileNew() -{ - // this slot is called whenever the File->New menu is selected, - // the New shortcut is pressed (usually CTRL+N) or the New toolbar - // button is clicked - - // create a new window - (new danbooru_client)->show(); -} - -void danbooru_client::optionsPreferences() -{ - // The preference dialog is derived from prefs_base.ui - // - // compare the names of the widgets in the .ui file - // to the names of the variables in the .kcfg file - //avoid to have 2 dialogs shown - if ( KConfigDialog::showDialog( "settings" ) ) { - return; + // a call to KXmlGuiWindow::setupGUI() populates the GUI + // with actions, using KXMLGUI. + // It also applies the saved mainwindow settings, if any, and ask the + // mainwindow to automatically save settings if changed: window size, + // toolbar position, icon size, etc. + setupGUI(); + } - KConfigDialog *dialog = new KConfigDialog(this, "settings", Settings::self()); - QWidget *generalSettingsDlg = new QWidget; - ui_prefs_base.setupUi(generalSettingsDlg); - dialog->addPage(generalSettingsDlg, i18n("General"), "package_setting"); - connect(dialog, SIGNAL(settingsChanged(QString)), m_view, SLOT(settingsChanged())); - dialog->setAttribute( Qt::WA_DeleteOnClose ); - dialog->show(); -} -#include "danbooru_client.moc" + DanbooruMainWindow::~DanbooruMainWindow() + { + } + + void DanbooruMainWindow::setupActions() + { + // KStandardAction::openNew(this, SLOT(fileNew()), actionCollection()); + // KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollection()); + // + // KStandardAction::preferences(this, SLOT(optionsPreferences()), actionCollection()); + // + // // custom menu and menu item - the slot is in the class DanbooruMainWindowView + // KAction *custom = new KAction(KIcon("colorize"), i18n("Swi&tch Colors"), this); + // actionCollection()->addAction( QLatin1String("switch_action"), custom ); + // connect(custom, SIGNAL(triggered(bool)), m_view, SLOT(switchColors())); + } + + void DanbooruMainWindow::connectToBoard() + { + + } + + void DanbooruMainWindow::downloadPosts() + { + + } + + void DanbooruMainWindow::optionsPreferences() + { + + } + + +} // namespace Danbooru + +#include "DanbooruMainWindow.moc" diff --git a/src/mainwindow.h b/src/mainwindow.h index 61cbc82..acc7765 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -23,49 +23,49 @@ #include -#include "ui_prefs_base.h" +namespace Danbooru { -class danbooru_clientView; -class QPrinter; -class KToggleAction; -class KUrl; - -/** - * This class serves as the main window for danbooru_client. It handles the - * menus, toolbars and status bars. - * - * @short Main window class - * @author %{AUTHOR} <%{EMAIL}> - * @version %{VERSION} - */ -class danbooru_client : public KXmlGuiWindow -{ - Q_OBJECT -public: - /** - * Default Constructor - */ - danbooru_client(); + class DanbooruClientView; + class DanbooruService; + class DanbooruPostModel; /** - * Default Destructor + * This class serves as the main window for danbooru_client. It handles the + * menus, toolbars and status bars. + * + * @short Main window class + * @author Luca Beltrame + * @version 0.01 */ - virtual ~danbooru_client(); + class DanbooruMainWindow : public KXmlGuiWindow + { + Q_OBJECT + public: + /** + * Default Constructor + */ + DanbooruMainWindow(); -private slots: - void fileNew(); - void optionsPreferences(); + /** + * Default Destructor + */ + virtual ~DanbooruMainWindow(); -private: - void setupActions(); + private Q_SLOTS: + void connectToBoard(); + void downloadPosts(); + void optionsPreferences(); -private: - Ui::prefs_base ui_prefs_base ; - danbooru_clientView *m_view; + private: + void setupActions(); - QPrinter *m_printer; - KToggleAction *m_toolbarAction; - KToggleAction *m_statusbarAction; -}; + private: + DanbooruClientView *m_view; + DanbooruPostModel* m_model; + DanbooruService* m_service; + + + }; +} // namespace Danbooru #endif // _DANBOORU_CLIENT_H_