Permalink
Browse files

added DriveModel. just skeleton.

  • Loading branch information...
1 parent 755ee1c commit 39b2b4fb0ba9f3551702f18e7b33830f0740d92d @nestal nestal committed Apr 28, 2013
Showing with 124 additions and 3 deletions.
  1. +71 −0 bgrive/src/DriveModel.cc
  2. +43 −0 bgrive/src/DriveModel.hh
  3. +4 −0 bgrive/src/MainWnd.cc
  4. +4 −1 bgrive/src/MainWnd.hh
  5. +2 −2 bgrive/src/main.cc
View
@@ -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 <QtCore/QDebug>
+
+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
View
@@ -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 <QtCore/QAbstractItemModel>
+
+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
+
View
@@ -20,11 +20,15 @@
#include "MainWnd.hh"
+#include <cassert>
+
namespace gr {
MainWnd::MainWnd( )
{
m_ui.setupUi(this) ;
+
+ m_ui.m_dir->setModel( &m_drive ) ;
}
} // end of namespace
View
@@ -23,6 +23,8 @@
#include <QtGui/QMainWindow>
#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
View
@@ -55,7 +55,7 @@ int main( int argc, char **argv )
OAuth2 token( refresh_token, client_id, client_secret ) ;
AuthAgent agent( token, std::auto_ptr<http::Agent>( 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();

0 comments on commit 39b2b4f

Please sign in to comment.