mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 05:00:33 +01:00
Editor autonum dialog: add next/previous button
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3252 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -16,11 +16,12 @@
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "numerotationcontextcommands.h"
|
||||
#include "diagram.h"
|
||||
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
NumerotationContextCommands::NumerotationContextCommands(Diagram *d, const NumerotationContext &nc):
|
||||
NumerotationContextCommands::NumerotationContextCommands(const NumerotationContext &nc, Diagram *d):
|
||||
diagram_ (d),
|
||||
context_ (nc),
|
||||
strategy_ (NULL)
|
||||
@@ -48,6 +49,21 @@ NumerotationContext NumerotationContextCommands::next() {
|
||||
return contextnum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief NumerotationContextCommands::previous
|
||||
* @return the previous numerotation context
|
||||
*/
|
||||
NumerotationContext NumerotationContextCommands::previous() {
|
||||
NumerotationContext contextnum;
|
||||
|
||||
for (int i=0; i<context_.size(); ++i) {
|
||||
QStringList str = context_.itemAt(i);
|
||||
setNumStrategy(str.at(0));
|
||||
contextnum << strategy_ -> previous(context_, i);
|
||||
}
|
||||
return contextnum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief NumerotationContextCommands::toFinalString
|
||||
* @return the string represented by the numerotation context
|
||||
@@ -62,7 +78,8 @@ QString NumerotationContextCommands::toRepresentedString() {
|
||||
}
|
||||
return num;
|
||||
}
|
||||
return (diagram_ -> defaultConductorProperties.text);
|
||||
if (diagram_) return (diagram_ -> defaultConductorProperties.text);
|
||||
return QString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,6 +144,18 @@ NumerotationContext NumStrategy::nextNumber (const NumerotationContext &nc, cons
|
||||
return (newnc);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief NumStrategy::previousNumber
|
||||
* @return the previous value of @nc at position @i
|
||||
*/
|
||||
NumerotationContext NumStrategy::previousNumber(const NumerotationContext &nc, const int i) const {
|
||||
QStringList strl = nc.itemAt(i);
|
||||
NumerotationContext newnc;
|
||||
QString value = QString::number( (strl.at(1).toInt()) - (strl.at(2).toInt()) );
|
||||
newnc.addValue(strl.at(0), value, strl.at(2).toInt());
|
||||
return (newnc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@@ -150,6 +179,14 @@ NumerotationContext UnitNum::next (const NumerotationContext &nc, const int i) c
|
||||
return (nextNumber(nc, i));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief UnitNum::previous
|
||||
* @return the previous NumerotationContext nc at posiiton i
|
||||
*/
|
||||
NumerotationContext UnitNum::previous(const NumerotationContext &nc, const int i) const {
|
||||
return (previousNumber(nc, i));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@@ -176,6 +213,14 @@ NumerotationContext TenNum::next (const NumerotationContext &nc, const int i) co
|
||||
return (nextNumber(nc, i));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TenNum::previous
|
||||
* @return the previous NumerotationContext nc at posiiton i
|
||||
*/
|
||||
NumerotationContext TenNum::previous(const NumerotationContext &nc, const int i) const {
|
||||
return (previousNumber(nc, i));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@@ -207,6 +252,14 @@ NumerotationContext HundredNum::next (const NumerotationContext &nc, const int i
|
||||
return (nextNumber(nc, i));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief HundredNum::previous
|
||||
* @return the previous NumerotationContext nc at posiiton i
|
||||
*/
|
||||
NumerotationContext HundredNum::previous(const NumerotationContext &nc, const int i) const {
|
||||
return (previousNumber(nc, i));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@@ -230,6 +283,14 @@ NumerotationContext StringNum::next (const NumerotationContext &nc, const int i)
|
||||
return (nextString(nc, i));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief StringNum::previous
|
||||
* @return the previous NumerotationContext nc at posiiton i
|
||||
*/
|
||||
NumerotationContext StringNum::previous(const NumerotationContext &nc, const int i) const {
|
||||
return (nextString(nc, i));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -255,3 +316,11 @@ NumerotationContext FolioNum::next (const NumerotationContext &nc, const int i)
|
||||
return (nextString(nc, i));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief FolioNum::previous
|
||||
* @return the previous NumerotationContext nc at posiiton i
|
||||
*/
|
||||
NumerotationContext FolioNum::previous(const NumerotationContext &nc, const int i) const {
|
||||
return (nextString(nc, i));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user