Spreadsheet: Added direct alias command.

This commit is contained in:
Eivind Kvedalen 2015-09-30 01:11:59 +02:00 committed by wmayer
parent 27cfcc5995
commit e334ac3aed
7 changed files with 248 additions and 1 deletions

View File

@ -39,6 +39,7 @@
#include "../App/Sheet.h"
#include "../App/Range.h"
#include "ViewProviderSpreadsheet.h"
#include "PropertiesDialog.h"
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@ -762,7 +763,69 @@ bool CmdSpreadsheetStyleUnderline::isActive()
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
if (activeWindow && freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow))
return true;
}
return false;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DEF_STD_CMD_A(CmdSpreadsheetSetAlias);
CmdSpreadsheetSetAlias::CmdSpreadsheetSetAlias()
: Command("Spreadsheet_SetAlias")
{
sAppModule = "Spreadsheet";
sGroup = QT_TR_NOOP("Spreadsheet");
sMenuText = QT_TR_NOOP("Set alias");
sToolTipText = QT_TR_NOOP("Set alias for selected cell");
sWhatsThis = sToolTipText;
sStatusTip = sToolTipText;
sAccel = "Ctrl+Shift+A";
sPixmap = "SpreadsheetAlias";
}
void CmdSpreadsheetSetAlias::activated(int iMsg)
{
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
SpreadsheetGui::SheetView * sheetView = freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
if (sheetView) {
Sheet * sheet = sheetView->getSheet();
QModelIndexList selection = sheetView->selectedIndexes();
if (selection.size() == 1) {
std::vector<Spreadsheet::Range> range;
range.push_back(Range(selection[0].row(), selection[0].column(),
selection[0].row(), selection[0].column()));
std::auto_ptr<PropertiesDialog> dialog(new PropertiesDialog(sheet, range, sheetView));
dialog->selectAlias();
if (dialog->exec() == QDialog::Accepted)
dialog->apply();
}
}
}
}
bool CmdSpreadsheetSetAlias::isActive()
{
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
if (activeWindow) {
SpreadsheetGui::SheetView * sheetView = freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
if (sheetView) {
QModelIndexList selection = sheetView->selectedIndexes();
if (selection.size() == 1)
return true;
}
}
}
return false;
}
@ -822,5 +885,7 @@ void CreateSpreadsheetCommands(void)
rcCmdMgr.addCommand(new CmdSpreadsheetStyleBold());
rcCmdMgr.addCommand(new CmdSpreadsheetStyleItalic());
rcCmdMgr.addCommand(new CmdSpreadsheetStyleUnderline());
rcCmdMgr.addCommand(new CmdSpreadsheetSetAlias());
}

View File

@ -295,4 +295,10 @@ void PropertiesDialog::apply()
}
}
void PropertiesDialog::selectAlias()
{
ui->tabWidget->setCurrentIndex(4);
ui->alias->setFocus();
}
#include "moc_PropertiesDialog.cpp"

View File

@ -42,6 +42,7 @@ public:
~PropertiesDialog();
void apply();
void selectAlias();
private Q_SLOTS:
void foregroundColorChanged(const QColor &color);

View File

@ -37,5 +37,6 @@
<file>translations/Spreadsheet_uk.qm</file>
<file>translations/Spreadsheet_it.qm</file>
<file>translations/Spreadsheet_pt-BR.qm</file>
<file>icons/SpreadsheetAlias.svg</file>
</qresource>
</RCC>

View File

@ -0,0 +1,171 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64px"
height="64px"
id="svg2860"
sodipodi:version="0.32"
inkscape:version="0.48.3.1 r9886"
sodipodi:docname="Spreadsheet.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.1">
<defs
id="defs2862">
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3377"
id="radialGradient3692"
cx="45.883327"
cy="28.869568"
fx="45.883327"
fy="28.869568"
r="19.467436"
gradientUnits="userSpaceOnUse" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3377"
id="radialGradient3703"
gradientUnits="userSpaceOnUse"
cx="135.38333"
cy="97.369568"
fx="135.38333"
fy="97.369568"
r="19.467436"
gradientTransform="matrix(0.97435,0.2250379,-0.4623105,2.0016728,48.487554,-127.99883)" />
<linearGradient
id="linearGradient3377">
<stop
id="stop3379"
offset="0"
style="stop-color:#faff2b;stop-opacity:1;" />
<stop
id="stop3381"
offset="1"
style="stop-color:#ffaa00;stop-opacity:1;" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3377"
id="radialGradient3705"
gradientUnits="userSpaceOnUse"
cx="148.88333"
cy="81.869568"
fx="148.88333"
fy="81.869568"
r="19.467436"
gradientTransform="matrix(1.3852588,-0.05136783,0.03705629,0.9993132,-60.392403,7.7040438)" />
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 32 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="64 : 32 : 1"
inkscape:persp3d-origin="32 : 21.333333 : 1"
id="perspective2868" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient4150"
id="radialGradient4160"
cx="16.19231"
cy="-8.2562485"
fx="16.19231"
fy="-8.2562485"
r="24.568377"
gradientTransform="matrix(-0.64879807,1.5256071,-1.4159262,-0.58281661,2.2505901,-36.277567)"
gradientUnits="userSpaceOnUse" />
<linearGradient
id="linearGradient4150">
<stop
style="stop-color:#ff0000;stop-opacity:0.07826087;"
offset="0"
id="stop4152" />
<stop
style="stop-color:#ff0000;stop-opacity:1;"
offset="1"
id="stop4154" />
</linearGradient>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="13.243709"
inkscape:cx="26.119218"
inkscape:cy="29.785311"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:window-width="1855"
inkscape:window-height="1056"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-maximized="1"
inkscape:snap-global="true">
<inkscape:grid
type="xygrid"
id="grid3088" />
</sodipodi:namedview>
<metadata
id="metadata2865">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<path
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
d="M 5,4 25,4 60,39 40,59 5,24 z"
id="path3086"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccc" />
<path
sodipodi:type="arc"
style="fill:none;stroke:#000000;stroke-width:9.54467487;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline"
id="path4081"
sodipodi:cx="10.783883"
sodipodi:cy="11.8779"
sodipodi:rx="24.068377"
sodipodi:ry="23.990232"
d="m 34.85226,11.8779 a 24.068377,23.990232 0 1 1 -48.136753,0 24.068377,23.990232 0 1 1 48.136753,0 z"
transform="matrix(0.20720128,-0.0159418,0.01620791,0.21065996,13.659851,12.874513)" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 35,24 50,39"
id="path5152"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 32,27 47,42"
id="path5152-7"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 29,30 44,45"
id="path5152-3"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -67,9 +67,10 @@ SheetTableView::SheetTableView(QWidget *parent)
connect(removeColumns, SIGNAL(triggered()), this, SLOT(removeColumns()));
QAction * cellProperties = new QAction(tr("Properties..."), this);
setContextMenuPolicy(Qt::ActionsContextMenu);
addAction(cellProperties);
setContextMenuPolicy(Qt::ActionsContextMenu);
connect(cellProperties, SIGNAL(triggered()), this, SLOT(cellProperties()));
}

View File

@ -223,6 +223,8 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
<< "Spreadsheet_StyleBold"
<< "Spreadsheet_StyleItalic"
<< "Spreadsheet_StyleUnderline"
<< "Separator"
<< "Spreadsheet_SetAlias"
<< "Separator"
;