Skip to content

Commit

Permalink
initial cut
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterPetrik committed Dec 1, 2023
1 parent 9f2cf72 commit 7f6b093
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 923 deletions.
16 changes: 0 additions & 16 deletions app/projectsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ void ProjectsModel::initializeProjectsModel()

QObject::connect( mBackend, &MerginApi::projectDetached, this, &ProjectsModel::onProjectDetachedFromMergin );
QObject::connect( mBackend, &MerginApi::projectAttachedToMergin, this, &ProjectsModel::onProjectAttachedToMergin );
QObject::connect( mBackend, &MerginApi::authChanged, this, &ProjectsModel::onAuthChanged );

if ( mModelType == ProjectModelTypes::LocalProjectsModel )
{
Expand Down Expand Up @@ -544,17 +543,6 @@ void ProjectsModel::onProjectAttachedToMergin( const QString & )
listProjectsByName();
}

void ProjectsModel::onAuthChanged()
{
if ( !mBackend->userAuth() || !mBackend->userAuth()->hasAuthData() ) // user logged out, clear created and shared lists
{
if ( mModelType == CreatedProjectsModel || mModelType == SharedProjectsModel )
{
clearProjects();
}
}
}

void ProjectsModel::setMerginApi( MerginApi *merginApi )
{
if ( !merginApi || mBackend == merginApi )
Expand Down Expand Up @@ -586,10 +574,6 @@ QString ProjectsModel::modelTypeToFlag() const
{
switch ( mModelType )
{
case CreatedProjectsModel:
return QStringLiteral( "created" );
case SharedProjectsModel:
return QStringLiteral( "shared" );
case WorkspaceProjectsModel:
return QStringLiteral( "workspace" );
case PublicProjectsModel:
Expand Down
8 changes: 2 additions & 6 deletions app/projectsmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class LocalProjectsManager;
*
* Model can have different types that affect handling of the projects.
* - LocalProjectsModel always keeps all local projects and seek their mergin part when listProjectsByNameFinished
* - Created-, Shared-, and PublicProjectsModel does the opposite, keeps all mergin projects and seeks their local part in projects from LocalProjectsManager
* - Workspace-, and PublicProjectsModel does the opposite, keeps all mergin projects and seeks their local part in projects from LocalProjectsManager
* - EmptyProjectsModel is default state
*
* To avoid overriding of requests, model remembers last sent request ID and upon receiving signal from MerginAPI about listProjectsFinished, it firsts compares
Expand Down Expand Up @@ -68,15 +68,13 @@ class ProjectsModel : public QAbstractListModel
/**
* \brief The ProjectModelTypes enum:
* - LocalProjectsModel always keeps all local projects and seek their mergin part when listProjectsByNameFinished
* - Created-, Shared-, and PublicProjectsModel does the opposite, keeps all mergin projects and seeks their local part in projects from LocalProjectsManager
* - Workspace-, and PublicProjectsModel does the opposite, keeps all mergin projects and seeks their local part in projects from LocalProjectsManager
* - EmptyProjectsModel is default state
*/
enum ProjectModelTypes
{
EmptyProjectsModel = 0, // default, holding no projects ~ invalid model
LocalProjectsModel,
CreatedProjectsModel,
SharedProjectsModel,
PublicProjectsModel,
WorkspaceProjectsModel,
RecentProjectsModel
Expand Down Expand Up @@ -165,8 +163,6 @@ class ProjectsModel : public QAbstractListModel
void onAboutToRemoveProject( const LocalProject &project );
void onProjectDataChanged( const LocalProject &project );

void onAuthChanged();

void setMerginApi( MerginApi *merginApi );
void setModelType( ProjectModelTypes modelType );
void setSyncManager( SynchronizationManager *newSyncManager );
Expand Down
Loading

0 comments on commit 7f6b093

Please sign in to comment.