treeitem.cpp
changeset 767 6d2b32f305f9
parent 766 7a71a914afdb
child 768 382a444f5b0c
     1.1 --- a/treeitem.cpp	Thu May 07 08:48:53 2009 +0000
     1.2 +++ b/treeitem.cpp	Wed May 13 08:26:27 2009 +0000
     1.3 @@ -278,20 +278,72 @@
     1.4  	return headingColor;
     1.5  }
     1.6  
     1.7 -void TreeItem::setNote(const QString s)
     1.8 +void TreeItem::setURL (const QString &u)
     1.9  {
    1.10 -	note.setNote(s);
    1.11 -	// updateNoteFlag();  FIXME-2 needed?
    1.12 -	if (model) 
    1.13 -		model->emitNoteHasChanged (this);
    1.14 +	url=u;
    1.15 +	if (!url.isEmpty())
    1.16 +		systemFlags.activate ("system-url");
    1.17 +	else
    1.18 +		systemFlags.deactivate ("system-url");
    1.19 +}
    1.20 +
    1.21 +QString TreeItem::getURL ()
    1.22 +{
    1.23 +	return url;
    1.24 +}
    1.25 +
    1.26 +void TreeItem::setVymLink (const QString &vl)
    1.27 +{
    1.28 +	if (!vl.isEmpty())
    1.29 +	{
    1.30 +		// We need the relative (from loading) 
    1.31 +		// or absolute path (from User event)
    1.32 +		// and build the absolute path.
    1.33 +		// Note: If we have relative, use path of
    1.34 +		// current map to build absolute path
    1.35 +		QDir d(vl);
    1.36 +		if (!d.path().startsWith ("/"))
    1.37 +		{
    1.38 +			QString p=model->getDestPath();
    1.39 +			int i=p.findRev("/",-1);
    1.40 +			d.setPath(p.left(i)+"/"+vl);
    1.41 +			d.convertToAbs();
    1.42 +		}
    1.43 +		vymLink=d.path();
    1.44 +		systemFlags.activate("system-vymLink");
    1.45 +	}	
    1.46 +	else	
    1.47 +	{
    1.48 +		systemFlags.deactivate("system-vymLink");
    1.49 +		vymLink.clear();
    1.50 +	}	
    1.51 +}
    1.52 +
    1.53 +QString TreeItem::getVymLink ()
    1.54 +{
    1.55 +	return vymLink;
    1.56 +}
    1.57 +
    1.58 +void TreeItem::setNote(const QString &s)
    1.59 +{
    1.60 +	NoteObj n;
    1.61 +	n.setNote(s);
    1.62 +	setNoteObj (n,false);
    1.63 +}
    1.64 +
    1.65 +void TreeItem::clearNote()
    1.66 +{
    1.67 +	note.clear();
    1.68 +	systemFlags.deactivate ("system-note");
    1.69  }
    1.70  
    1.71  void TreeItem::setNoteObj(const NoteObj &n, bool updateNoteEditor)
    1.72  {
    1.73  	note=n;
    1.74 -	// updateNoteFlag();  FIXME-2 needed?
    1.75 -	if (model && updateNoteEditor)	
    1.76 -		model->emitNoteHasChanged (this);
    1.77 +	if (!note.isEmpty() && !systemFlags.isActive ("system-note"))
    1.78 +		systemFlags.activate ("system-note");
    1.79 +	if (note.isEmpty() && systemFlags.isActive ("system-note"))
    1.80 +		systemFlags.deactivate ("system-note");
    1.81  }
    1.82  
    1.83  QString TreeItem::getNote()
    1.84 @@ -321,28 +373,26 @@
    1.85  
    1.86  void TreeItem::activateStandardFlag (const QString &name)
    1.87  {
    1.88 -	cout << "TI::activateStandardFlag "<<name.toStdString()<<" for item "<<getHeadingStd()<<endl;
    1.89 -	cout << "   lmo="<<lmo<< "  "<<isBranchLikeType()<<endl;
    1.90  	standardFlags.activate (name);
    1.91 -	if (lmo &&isBranchLikeType() ) 
    1.92 -		((BranchObj*)lmo)->activateStandardFlag (name);
    1.93 +	model->emitDataHasChanged(this);
    1.94  }
    1.95  
    1.96  void TreeItem::deactivateStandardFlag (const QString &name)
    1.97  {
    1.98 -	cout << "TI::deactivateStandardFlag "<<name.toStdString()<<" for item "<<getHeadingStd()<<endl;
    1.99  	standardFlags.deactivate (name);
   1.100 -	if (lmo &&isBranchLikeType() ) 
   1.101 -		((BranchObj*)lmo)->deactivateStandardFlag (name);
   1.102 +	model->emitDataHasChanged(this);
   1.103  }
   1.104  
   1.105 -void TreeItem::toggleStandardFlag(const QString &name)
   1.106 +void TreeItem::deactivateAllStandardFlags ()
   1.107  {
   1.108 -	cout << "TI::toggleStandardFlag "<<name.toStdString()<<" for item "<<getHeadingStd()<<endl;
   1.109 -	if (standardFlags.isActive (name))
   1.110 -		deactivateStandardFlag (name);
   1.111 -	else	
   1.112 -		activateStandardFlag (name);
   1.113 +	standardFlags.deactivateAll ();
   1.114 +	model->emitDataHasChanged(this);
   1.115 +}
   1.116 +
   1.117 +void TreeItem::toggleStandardFlag(const QString &name, FlagRow *master)
   1.118 +{
   1.119 +	standardFlags.toggle (name,master);
   1.120 +	model->emitDataHasChanged(this);
   1.121  }
   1.122  
   1.123  bool TreeItem::isActiveStandardFlag (const QString &name)
   1.124 @@ -350,6 +400,52 @@
   1.125  	return standardFlags.isActive (name);
   1.126  }
   1.127  
   1.128 +QStringList TreeItem::activeStandardFlagNames ()
   1.129 +{
   1.130 +	return standardFlags.activeFlagNames();
   1.131 +}
   1.132 +
   1.133 +QStringList TreeItem::activeSystemFlagNames ()	//FIXME-1 missing: scrolled-tmp,hideInExport
   1.134 +{
   1.135 +	return systemFlags.activeFlagNames();
   1.136 +}
   1.137 +
   1.138 +bool TreeItem::canMoveDown()
   1.139 +{
   1.140 +	switch (type)
   1.141 +	{
   1.142 +		case Undefined: return false;
   1.143 +		case MapCenter: 
   1.144 +		case Branch: 
   1.145 +			if (!parentItem) return false;
   1.146 +			if (parentItem->num (this) < parentItem->branchCount()-1)
   1.147 +				return true;
   1.148 +			else
   1.149 +				return false;
   1.150 +			break;	
   1.151 +		case Image: return false;
   1.152 +		default: return false;
   1.153 +	}
   1.154 +}
   1.155 +
   1.156 +bool TreeItem::canMoveUp()
   1.157 +{
   1.158 +	switch (type)
   1.159 +	{
   1.160 +		case Undefined: return false;
   1.161 +		case MapCenter: 
   1.162 +		case Branch: 
   1.163 +			if (!parentItem) return false;
   1.164 +			if (parentItem->num (this) > 0)
   1.165 +				return true;
   1.166 +			else
   1.167 +				return false;
   1.168 +			break;	
   1.169 +		case Image: return false;
   1.170 +		default: return false;
   1.171 +	}
   1.172 +}
   1.173 +
   1.174  void TreeItem::setID (const QString &s)
   1.175  {
   1.176  	objID=s;