diff --git a/bgrive/src/DriveModel.cc b/bgrive/src/DriveModel.cc new file mode 100644 index 0000000..e207fb4 --- /dev/null +++ b/bgrive/src/DriveModel.cc @@ -0,0 +1,71 @@ +/* + grive: an GPL program to sync a local directory with Google Drive + Copyright (C) 2013 Wan Wai Ho + + 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 version 2 + of the License. + + 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 "DriveModel.hh" + +#include + +namespace gr { + +DriveModel::DriveModel( ) +{ +} + +Qt::ItemFlags DriveModel::flags( const QModelIndex& ) const +{ + return Qt::ItemIsEnabled | Qt::ItemIsSelectable ; +} + +QVariant DriveModel::data( const QModelIndex& index, int role ) const +{ + return role == Qt::DisplayRole ? QString("wow") : QVariant() ; +} + +QVariant DriveModel::headerData( int section, Qt::Orientation orientation, int role ) const +{ + return role == Qt::DisplayRole ? QString("header") : QVariant() ; +} + +int DriveModel::rowCount( const QModelIndex& parent ) const +{ + return 10 ; +} + +int DriveModel::columnCount( const QModelIndex& parent ) const +{ + return 1 ; +} + +bool DriveModel::hasChildren( const QModelIndex& parent ) const +{ + return parent.isValid() ? false : true ; +} + +QModelIndex DriveModel::index( int row, int column, const QModelIndex & parent ) const +{ + return parent.isValid() ? QModelIndex() : createIndex( row, column, 0 ) ; +} + +QModelIndex DriveModel::parent( const QModelIndex& idx ) const +{ + return QModelIndex() ; +} + +} // end of namespace diff --git a/bgrive/src/DriveModel.hh b/bgrive/src/DriveModel.hh new file mode 100644 index 0000000..cb5fd20 --- /dev/null +++ b/bgrive/src/DriveModel.hh @@ -0,0 +1,43 @@ +/* + grive: an GPL program to sync a local directory with Google Drive + Copyright (C) 2013 Wan Wai Ho + + 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 version 2 + of the License. + + 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. +*/ + +#pragma once + +#include + +namespace gr { + +class DriveModel : public QAbstractItemModel +{ +public : + DriveModel( ) ; + + Qt::ItemFlags flags( const QModelIndex & index ) const ; + QVariant data( const QModelIndex& index, int role ) const ; + QVariant headerData( int section, Qt::Orientation orientation, int role ) const ; + int rowCount( const QModelIndex& parent ) const ; + int columnCount( const QModelIndex& parent ) const ; + bool hasChildren ( const QModelIndex& parent ) const ; + QModelIndex index( int row, int column, const QModelIndex& parent ) const ; + QModelIndex parent( const QModelIndex& idx ) const ; +} ; + +} // end of namespace + diff --git a/bgrive/src/MainWnd.cc b/bgrive/src/MainWnd.cc index 1712ebc..d73c9c9 100644 --- a/bgrive/src/MainWnd.cc +++ b/bgrive/src/MainWnd.cc @@ -20,11 +20,15 @@ #include "MainWnd.hh" +#include + namespace gr { MainWnd::MainWnd( ) { m_ui.setupUi(this) ; + + m_ui.m_dir->setModel( &m_drive ) ; } } // end of namespace diff --git a/bgrive/src/MainWnd.hh b/bgrive/src/MainWnd.hh index f50d431..d5be664 100644 --- a/bgrive/src/MainWnd.hh +++ b/bgrive/src/MainWnd.hh @@ -23,6 +23,8 @@ #include #include "ui_MainWindow.h" +#include "DriveModel.hh" + namespace gr { class MainWnd : public QMainWindow @@ -33,7 +35,8 @@ public : MainWnd( ) ; private : - Ui::MainWindow m_ui ; + Ui::MainWindow m_ui ; + DriveModel m_drive ; } ; } // end of namespace diff --git a/bgrive/src/main.cc b/bgrive/src/main.cc index 4b61317..9b85d15 100644 --- a/bgrive/src/main.cc +++ b/bgrive/src/main.cc @@ -55,7 +55,7 @@ int main( int argc, char **argv ) OAuth2 token( refresh_token, client_id, client_secret ) ; AuthAgent agent( token, std::auto_ptr( new http::CurlAgent ) ) ; - +/* http::XmlResponse xml ; agent.Get( feed_base + "/-/folder?max-results=50&showroot=true", &xml, http::Header() ) ; @@ -69,7 +69,7 @@ int main( int argc, char **argv ) qDebug() << e.Name().c_str() ; } } while ( feed.GetNext( &agent, http::Header() ) ) ; - +*/ QApplication app( argc, argv ) ; MainWnd wnd ; wnd.show();