2020-03-10 21:37:01 +03:00
/*
2021-05-27 18:01:00 +03:00
SPDX - FileCopyrightText : 2020 Michail Vourlakos < mvourlakos @ gmail . com >
SPDX - License - Identifier : GPL - 2.0 - or - later
*/
2020-03-10 21:37:01 +03:00
2020-03-12 12:53:37 +03:00
# include "layoutdata.h"
2020-03-10 21:37:01 +03:00
2020-08-14 09:57:39 +03:00
// Qt
# include <QDir>
2020-03-10 21:37:01 +03:00
namespace Latte {
namespace Data {
Layout : : Layout ( )
2020-08-17 14:40:32 +03:00
: Generic ( )
2020-03-10 21:37:01 +03:00
{
}
2020-03-14 17:14:28 +03:00
Layout : : Layout ( Layout & & o )
2020-08-17 14:40:32 +03:00
: Generic ( o ) ,
2020-07-30 18:52:29 +03:00
icon ( o . icon ) ,
2020-03-14 17:14:28 +03:00
color ( o . color ) ,
background ( o . background ) ,
textColor ( o . textColor ) ,
2020-08-30 20:32:13 +03:00
lastUsedActivity ( o . lastUsedActivity ) ,
2020-03-14 17:14:28 +03:00
isActive ( o . isActive ) ,
2021-03-24 01:12:50 +03:00
isConsideredActive ( o . isConsideredActive ) ,
2020-03-14 17:14:28 +03:00
isLocked ( o . isLocked ) ,
isShownInMenu ( o . isShownInMenu ) ,
2020-08-09 13:53:43 +03:00
isTemplate ( o . isTemplate ) ,
2020-03-14 17:14:28 +03:00
hasDisabledBorders ( o . hasDisabledBorders ) ,
2021-05-03 02:50:23 +03:00
popUpMargin ( o . popUpMargin ) ,
2021-06-16 10:07:34 +03:00
schemeFile ( o . schemeFile ) ,
2020-03-14 17:14:28 +03:00
activities ( o . activities ) ,
2021-03-21 01:13:16 +03:00
backgroundStyle ( o . backgroundStyle ) ,
2021-04-30 00:26:47 +03:00
errors ( o . errors ) ,
warnings ( o . warnings ) ,
2021-03-21 01:13:16 +03:00
views ( o . views )
2020-03-10 21:37:01 +03:00
{
}
Layout : : Layout ( const Layout & o )
2020-08-17 14:40:32 +03:00
: Generic ( o ) ,
2020-07-30 18:52:29 +03:00
icon ( o . icon ) ,
2020-03-12 16:12:13 +03:00
color ( o . color ) ,
2020-03-10 21:37:01 +03:00
background ( o . background ) ,
2020-03-12 16:12:13 +03:00
textColor ( o . textColor ) ,
2020-08-30 20:32:13 +03:00
lastUsedActivity ( o . lastUsedActivity ) ,
2020-03-11 16:46:25 +03:00
isActive ( o . isActive ) ,
2021-03-24 01:12:50 +03:00
isConsideredActive ( o . isConsideredActive ) ,
2020-03-10 21:37:01 +03:00
isLocked ( o . isLocked ) ,
isShownInMenu ( o . isShownInMenu ) ,
2020-08-09 13:53:43 +03:00
isTemplate ( o . isTemplate ) ,
2020-03-10 21:37:01 +03:00
hasDisabledBorders ( o . hasDisabledBorders ) ,
2021-05-03 02:50:23 +03:00
popUpMargin ( o . popUpMargin ) ,
2021-06-16 10:07:34 +03:00
schemeFile ( o . schemeFile ) ,
2020-03-10 21:37:01 +03:00
activities ( o . activities ) ,
2021-03-21 01:13:16 +03:00
backgroundStyle ( o . backgroundStyle ) ,
2021-04-30 00:26:47 +03:00
errors ( o . errors ) ,
warnings ( o . warnings ) ,
2021-03-21 01:13:16 +03:00
views ( o . views )
2020-03-10 21:37:01 +03:00
{
}
2020-03-14 17:14:28 +03:00
Layout & Layout : : operator = ( Layout & & rhs )
{
id = rhs . id ;
2020-03-20 16:05:25 +03:00
name = rhs . name ;
2020-07-30 18:52:29 +03:00
icon = rhs . icon ;
2020-03-14 17:14:28 +03:00
color = rhs . color ;
background = rhs . background ;
textColor = rhs . textColor ;
2020-08-30 20:32:13 +03:00
lastUsedActivity = rhs . lastUsedActivity ;
2020-03-14 17:14:28 +03:00
isActive = rhs . isActive ;
2021-03-24 01:12:50 +03:00
isConsideredActive = rhs . isConsideredActive ;
2020-03-14 17:14:28 +03:00
isLocked = rhs . isLocked ;
isShownInMenu = rhs . isShownInMenu ;
2020-08-09 13:53:43 +03:00
isTemplate = rhs . isTemplate ;
2020-03-14 17:14:28 +03:00
hasDisabledBorders = rhs . hasDisabledBorders ;
2021-05-03 02:50:23 +03:00
popUpMargin = rhs . popUpMargin ;
2021-06-16 10:07:34 +03:00
schemeFile = rhs . schemeFile ;
2020-03-14 17:14:28 +03:00
activities = rhs . activities ;
2020-04-15 17:34:58 +03:00
backgroundStyle = rhs . backgroundStyle ;
2021-04-30 00:26:47 +03:00
errors = rhs . errors ;
warnings = rhs . warnings ;
2021-03-21 01:13:16 +03:00
views = rhs . views ;
2020-03-14 17:14:28 +03:00
return ( * this ) ;
}
2020-03-10 21:37:01 +03:00
Layout & Layout : : operator = ( const Layout & rhs )
{
id = rhs . id ;
2020-03-20 16:05:25 +03:00
name = rhs . name ;
2020-07-30 18:52:29 +03:00
icon = rhs . icon ;
2020-03-12 16:12:13 +03:00
color = rhs . color ;
2020-03-10 21:37:01 +03:00
background = rhs . background ;
2020-03-12 16:12:13 +03:00
textColor = rhs . textColor ;
2020-08-30 20:32:13 +03:00
lastUsedActivity = rhs . lastUsedActivity ;
2020-03-11 16:46:25 +03:00
isActive = rhs . isActive ;
2021-03-24 01:12:50 +03:00
isConsideredActive = rhs . isConsideredActive ;
2020-03-10 21:37:01 +03:00
isLocked = rhs . isLocked ;
isShownInMenu = rhs . isShownInMenu ;
2020-08-09 13:53:43 +03:00
isTemplate = rhs . isTemplate ;
2020-03-10 21:37:01 +03:00
hasDisabledBorders = rhs . hasDisabledBorders ;
2021-05-03 02:50:23 +03:00
popUpMargin = rhs . popUpMargin ;
2021-06-16 10:07:34 +03:00
schemeFile = rhs . schemeFile ;
2020-03-10 21:37:01 +03:00
activities = rhs . activities ;
2020-04-15 17:34:58 +03:00
backgroundStyle = rhs . backgroundStyle ;
2021-04-30 00:26:47 +03:00
errors = rhs . errors ;
warnings = rhs . warnings ;
2021-03-21 01:13:16 +03:00
views = rhs . views ;
2020-03-10 21:37:01 +03:00
2020-03-14 17:14:28 +03:00
return ( * this ) ;
2020-03-10 21:37:01 +03:00
}
bool Layout : : operator = = ( const Layout & rhs ) const
{
return ( id = = rhs . id )
2020-03-20 16:05:25 +03:00
& & ( name = = rhs . name )
2020-07-30 18:52:29 +03:00
& & ( icon = = rhs . icon )
2020-03-12 16:12:13 +03:00
& & ( color = = rhs . color )
2020-03-10 21:37:01 +03:00
& & ( background = = rhs . background )
2020-03-12 16:12:13 +03:00
& & ( textColor = = rhs . textColor )
2021-04-30 21:35:54 +03:00
//&& (lastUsedActivity == rhs.lastUsedActivity) /*Disabled because this is not needed in order to track layout changes for saving*/
//&& (isActive == rhs.isActive) /*Disabled because this is not needed in order to track layout changes for saving*/
//&& (isConsideredActive == rhs.isConsideredActive) /*Disabled because this is not needed in order to track layout changes for saving*/
2020-03-10 21:37:01 +03:00
& & ( isLocked = = rhs . isLocked )
& & ( isShownInMenu = = rhs . isShownInMenu )
2020-08-09 13:53:43 +03:00
& & ( isTemplate = = rhs . isTemplate )
2020-03-10 21:37:01 +03:00
& & ( hasDisabledBorders = = rhs . hasDisabledBorders )
2021-05-03 02:50:23 +03:00
& & ( popUpMargin = = rhs . popUpMargin )
2021-06-16 10:07:34 +03:00
& & ( schemeFile = = rhs . schemeFile )
2020-03-10 21:37:01 +03:00
& & ( activities = = rhs . activities )
2021-03-21 01:13:16 +03:00
& & ( backgroundStyle = = rhs . backgroundStyle )
2021-04-30 21:35:54 +03:00
//&& (errors == rhs.errors) /*Disabled because this is not needed in order to track layout changes for saving*/
//&& (warnings == rhs.warnings) /*Disabled because this is not needed in order to track layout changes for saving*/
2021-03-21 01:13:16 +03:00
& & ( views = = rhs . views ) ;
2020-03-10 21:37:01 +03:00
}
bool Layout : : operator ! = ( const Layout & rhs ) const
{
return ! ( * this = = rhs ) ;
}
2020-08-25 14:39:00 +03:00
bool Layout : : isOnAllActivities ( ) const
{
return ( ( activities . count ( ) = = 1 ) & & ( activities [ 0 ] = = ALLACTIVITIESID ) ) ;
}
2020-03-15 17:20:29 +03:00
bool Layout : : isForFreeActivities ( ) const
{
return ( ( activities . count ( ) = = 1 ) & & ( activities [ 0 ] = = FREEACTIVITIESID ) ) ;
}
2020-03-21 02:46:33 +03:00
bool Layout : : isTemporary ( ) const
{
return id . startsWith ( " /tmp " ) ;
}
2020-03-20 16:05:25 +03:00
bool Layout : : isEmpty ( ) const
2020-03-10 21:37:01 +03:00
{
2020-03-20 16:05:25 +03:00
return isNull ( ) ;
2020-03-10 21:37:01 +03:00
}
2020-03-20 16:05:25 +03:00
bool Layout : : isNull ( ) const
2020-03-13 13:08:54 +03:00
{
2020-03-20 16:05:25 +03:00
return ( id . isEmpty ( ) & & name . isEmpty ( ) ) ;
2020-03-13 13:08:54 +03:00
}
2020-08-12 18:15:45 +03:00
bool Layout : : isSystemTemplate ( ) const
2020-08-09 13:53:43 +03:00
{
2020-08-14 09:57:39 +03:00
return isTemplate & & ! id . startsWith ( QDir : : tempPath ( ) ) & & ! id . startsWith ( QDir : : homePath ( ) ) ;
2020-08-09 13:53:43 +03:00
}
2021-04-30 01:01:31 +03:00
bool Layout : : hasErrors ( ) const
{
return errors > 0 ;
}
bool Layout : : hasWarnings ( ) const
{
return warnings > 0 ;
}
2020-03-10 21:37:01 +03:00
}
}
2020-03-11 16:46:25 +03:00