flag.cpp
author insilmaril
Tue, 08 Sep 2009 12:15:39 +0000
changeset 792 7d67be709091
parent 774 2f002657dada
child 823 0bba81dde1bc
permissions -rw-r--r--
First results in moving colliding MapCenters apart
     1 #include "flag.h"
     2 
     3 #include <iostream>
     4 using namespace std;
     5 
     6 /////////////////////////////////////////////////////////////////
     7 // Flag
     8 /////////////////////////////////////////////////////////////////
     9 Flag::Flag()
    10 {
    11 	//cout << "Const Flag ()\n";
    12     init ();
    13 }
    14 
    15 Flag::Flag (Flag* io)
    16 {
    17 	//cout << "Const Flag (Flag)\n";
    18     copy (io);
    19 }
    20 
    21 Flag::~Flag()
    22 {
    23    //cout << "Destr Flag  this="<<this <<"  " << qPrintable(name) << "\n";
    24 }
    25 
    26 
    27 void Flag::init ()
    28 {
    29 	action=NULL;
    30 	name="undefined";
    31 	visible=true;
    32 	unsetGroup();
    33 
    34 	state=false;
    35 	used=false;
    36 }
    37 
    38 void Flag::copy (Flag* other)
    39 {
    40 	action=other->action;
    41 	name=other->name;
    42 	group=other->group;
    43 	tooltip=other->tooltip;
    44 	state=other->state;
    45 	used=other->used;
    46 	pixmap=other->pixmap;
    47 }
    48 
    49 
    50 void Flag::load (const QString &fn)
    51 {
    52 	pixmap.load(fn);
    53 }
    54 
    55 void Flag::load (const QPixmap &pm)
    56 {
    57 	pixmap=pm;
    58 }
    59 
    60 void Flag::setName(const QString &n)
    61 {
    62 	name=n;
    63 }
    64 
    65 const QString Flag::getName()
    66 {
    67 	return name;
    68 }
    69 
    70 void Flag::setVisible (bool b)
    71 {
    72 	visible=b;
    73 }
    74 
    75 bool Flag::isVisible ()
    76 {
    77 	return visible;
    78 }
    79 
    80 void Flag::setGroup (const QString &n)
    81 {
    82 	group=n;
    83 }
    84 
    85 const QString Flag::getGroup()
    86 {
    87 	return group;
    88 }
    89 
    90 void Flag::unsetGroup()
    91 {
    92 	group.clear();
    93 }
    94 
    95 void Flag::setToolTip(const QString &n)
    96 {
    97 	tooltip=n;
    98 }
    99 
   100 const QString Flag::getToolTip()
   101 {
   102 	return tooltip;
   103 }
   104 
   105 QPixmap Flag::getPixmap()
   106 {
   107 	return pixmap;
   108 }
   109 
   110 void Flag::setAction (QAction *a)
   111 {
   112 	action=a;
   113 }
   114 
   115 QAction* Flag::getAction ()
   116 {
   117 	return action;
   118 }
   119 
   120 void Flag::setUsed (bool b)
   121 {
   122 	used=b;
   123 }
   124 
   125 bool Flag::isUsed()
   126 {
   127 	return used;
   128 }
   129 
   130 void Flag::saveToDir (const QString &tmpdir, const QString &prefix)
   131 {
   132 	QString fn=tmpdir + prefix + name + ".png";
   133 	pixmap.save (fn,"PNG");
   134 }
   135 
   136