mirror of https://github.com/vitalif/grive2
added DriveModel. just skeleton.
parent
755ee1c9ad
commit
39b2b4fb0b
|
@ -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
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue