[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Bgluon=5D_player/kdeext=3A_Add_a_Listmodel_for_the_K?=
From: Laszlo Papp <djszapi () archlinux ! us>
Date: 2011-02-03 23:46:53
Message-ID: 20110203234653.2D576A609B () git ! kde ! org
[Download RAW message or body]
Git commit 5ab6a8e1c82fbcb8010e10480f52ed785f305731 by Laszlo Papp.
Committed on 04/02/11 at 00:46.
Pushed by lpapp into branch 'master'.
Add a Listmodel for the KDE Extended Player listview.
M +1 -0 player/kdeext/CMakeLists.txt
M +10 -6 player/kdeext/gamesoverlay.cpp
M +5 -2 player/kdeext/gamesoverlay.h
A +60 -0 player/kdeext/models/listmodel.cpp [License: LGPL (v2.1+)]
A +53 -0 player/kdeext/models/listmodel.h [License: LGPL (v2.1+)]
http://commits.kde.org/gluon/5ab6a8e1c82fbcb8010e10480f52ed785f305731
diff --git a/player/kdeext/CMakeLists.txt b/player/kdeext/CMakeLists.txt
index 4f32b50..e10e8a4 100644
--- a/player/kdeext/CMakeLists.txt
+++ b/player/kdeext/CMakeLists.txt
@@ -13,6 +13,7 @@ set(kdeextplayer_SRCS
gamesoverlay.cpp
gamedetailsoverlay.cpp
loginform.cpp
+ models/listmodel.cpp
views/abstractitemview.cpp
views/achievementsview.cpp
views/newcommentform.cpp
diff --git a/player/kdeext/gamesoverlay.cpp b/player/kdeext/gamesoverlay.cpp
index 3aa1c49..bd808c7 100644
--- a/player/kdeext/gamesoverlay.cpp
+++ b/player/kdeext/gamesoverlay.cpp
@@ -18,27 +18,31 @@
*/
#include "gamesoverlay.h"
-#include "views/gamesview.h"
#include "loginform.h"
+#include "views/gamesview.h"
GamesOverlay::GamesOverlay( QWidget* parent, Qt::WindowFlags wFlags )
: QWidget( parent, wFlags )
- , m_tabWidget( new KTabWidget( this ) )
+ , m_view( new QListView( this ) )
, m_gamesView( new GamesView( this ) )
, m_loginForm( new LoginForm( this ) )
{
connect( m_gamesView, SIGNAL( gameToPlaySelected( QModelIndex ) ), SIGNAL( \
gameToPlaySelected( QModelIndex ) ) );
connect( m_gamesView, SIGNAL( gameSelected( QModelIndex ) ), SIGNAL( \
gameSelected( QModelIndex ) ) );
- m_tabWidget->addTab( m_gamesView, KIcon( "applications-games" ), i18n( \
"Installed" ) ); +
+ // QListView* view = new QListView( base );
+
+ // m_tabWidget->addTab( m_gamesView, KIcon( "applications-games" ), i18n( \
"Installed" ) );
QLabel* m_tempLabel = new QLabel( this );
m_tempLabel->setText( i18n( "Coming Soon!" ) );
- m_tabWidget->addTab( m_tempLabel, KIcon( "get-hot-new-stuff" ), i18n( \
"Available" ) ); + // m_tabWidget->addTab( m_tempLabel, KIcon( "get-hot-new-stuff" \
), i18n( "Available" ) );
- m_tabWidget->addTab( m_loginForm, KIcon( "network-connect" ), i18n( "Login" ) );
+ // m_tabWidget->addTab( m_loginForm, KIcon( "network-connect" ), i18n( "Login" ) \
);
QGridLayout* layout = new QGridLayout( );
- layout->addWidget( m_tabWidget );
+ layout->addWidget( m_view );
+ m_model = new ListModel( m_view );
setLayout( layout );
}
diff --git a/player/kdeext/gamesoverlay.h b/player/kdeext/gamesoverlay.h
index af7d395..dc44d87 100644
--- a/player/kdeext/gamesoverlay.h
+++ b/player/kdeext/gamesoverlay.h
@@ -20,12 +20,14 @@
#ifndef GAMESOVERLAY_H
#define GAMESOVERLAY_H
-#include <KDE/KTabWidget>
+#include "models/listmodel.h"
+
#include <KDE/KIcon>
#include <KDE/KLocalizedString>
#include <QtGui/QLabel>
#include <QtGui/QGridLayout>
+#include <QtGui/QListView>
#include <QtCore/QModelIndex>
class GamesView;
@@ -40,8 +42,9 @@ class GamesOverlay : public QWidget
GamesView* gamesView();
private:
- KTabWidget* m_tabWidget;
+ QListView* m_view;
GamesView* m_gamesView;
+ ListModel* m_model;
LoginForm* m_loginForm;
signals:
diff --git a/player/kdeext/models/listmodel.cpp b/player/kdeext/models/listmodel.cpp
new file mode 100644
index 0000000..780cb1e
--- /dev/null
+++ b/player/kdeext/models/listmodel.cpp
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * This file is part of the Gluon Development Platform
+ * Copyright (C) 2010 Laszlo Papp <djszapi@archlinux.us>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "listmodel.h"
+
+ListModel::ListModel( QObject* parent )
+ : QAbstractListModel( parent )
+{
+}
+
+QVariant ListModel::data( const QModelIndex& index, int role ) const
+{
+ switch ( role )
+ {
+ case Qt::DecorationRole:
+ return m_list.at(index.row()).second->pixmap(32, 32);
+ case Qt::DisplayRole:
+ return m_list.at(index.row()).first;
+ }
+
+ return QVariant();
+}
+
+int ListModel::columnCount( const QModelIndex& parent ) const
+{
+ Q_UNUSED( parent );
+ return 1;
+}
+
+int ListModel::rowCount( const QModelIndex& parent ) const
+{
+ Q_UNUSED( parent );
+ return m_list.count();
+}
+
+QVariant ListModel::headerData( int section, Qt::Orientation orientation, int role ) \
const +{
+ if( section == 0 )
+ {
+ return QString( "Game" );
+ }
+
+ return QAbstractListModel::headerData( section, orientation, role );
+}
diff --git a/player/kdeext/models/listmodel.h b/player/kdeext/models/listmodel.h
new file mode 100644
index 0000000..8a389f7
--- /dev/null
+++ b/player/kdeext/models/listmodel.h
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * This file is part of the Gluon Development Platform
+ * Copyright (C) 2010 Laszlo Papp <djszapi@archlinux.us>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef GLUONPLAYER_LISTMODEL_H
+#define GLUONPLAYER_LISTMODEL_H
+
+#include "gluon_player_export.h"
+
+#include <KDE/KIcon>
+
+#include <QtCore/QList>
+#include <QtCore/QAbstractListModel>
+#include <QtCore/QString>
+#include <QtCore/QPair>
+#include <QtCore/QVariant>
+
+/**
+ *\brief Model which contains a list of the main entries
+ *
+ * This model can be used to obtain a list of all the main entires
+ * Use the different columns of the model to obtain required properties.
+ *
+ */
+class ListModel : public QAbstractListModel
+{
+ public:
+ explicit ListModel( QObject* parent = 0 );
+ virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole \
) const; + virtual int columnCount( const QModelIndex& parent = QModelIndex() \
) const; + virtual int rowCount( const QModelIndex& parent = QModelIndex() ) \
const; + virtual QVariant headerData( int section, Qt::Orientation \
orientation, int role = Qt::DisplayRole ) const; +
+ private:
+ QList< QPair< QString, KIcon* > > m_list;
+};
+
+#endif // GLUONPLAYER_LISTMODEL_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic