[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/kspread
From: Stefan Nikolaus <nikolaus4 () googlemail ! com>
Date: 2010-06-05 12:47:48
Message-ID: 20100605124748.19D02AC8CA () svn ! kde ! org
[Download RAW message or body]
SVN commit 1134829 by nikolaus:
Models:
Add a model for the map/workbook.
Add a MapViewModel, that keeps track of the active sheet.
Add a SheetModel and use it in combination with the MapModel.
Add a RegionModel.
M +1 -0 CHANGES
M +4 -3 CMakeLists.txt
M +8 -0 Map.cpp
M +6 -0 Map.h
A MapModel.cpp [License: LGPL (v2+)]
A MapModel.h [License: LGPL (v2+)]
A ModelSupport.h [License: LGPL (v2+)]
A RegionModel.cpp [License: LGPL (v2+)]
A RegionModel.h [License: LGPL (v2+)]
M +9 -0 Sheet.cpp
M +6 -0 Sheet.h
A SheetModel.cpp [License: LGPL (v2+)]
A SheetModel.h [License: LGPL (v2+)]
M +29 -0 interfaces/ReadOnlyTableModel.cpp
M +1 -0 interfaces/ReadOnlyTableModel.h
M +12 -1 part/View.cpp
M +2 -3 ui/CellToolBase.cpp
A ui/MapViewModel.cpp [License: LGPL (v2+)]
A ui/MapViewModel.h [License: LGPL (v2+)]
--- trunk/koffice/kspread/CHANGES #1134828:1134829
@@ -16,6 +16,7 @@
Developer-Visible Only
----------------------
Improved the function module loading/unloading. (@PACKAGERS: plugin interface \
changed!) +Implement models for Map/Sheet/Region.
--- trunk/koffice/kspread/CMakeLists.txt #1134828:1134829
@@ -109,9 +109,6 @@
SET (interfaces_DIR_SRCS
interfaces/MapAdaptor.cpp
- interfaces/ReadOnlyRegionModel.cpp
- interfaces/ReadOnlyTableModel.cpp
- interfaces/ReadWriteTableModel.cpp
interfaces/SheetAdaptor.cpp
interfaces/ViewAdaptor.cpp
)
@@ -154,6 +151,7 @@
ui/DragAndDropStrategy.cpp
ui/Editors.cpp
ui/HyperlinkStrategy.cpp
+ ui/MapViewModel.cpp
ui/MergeStrategy.cpp
ui/PasteStrategy.cpp
ui/SelectionStrategy.cpp
@@ -181,6 +179,7 @@
GenValidationStyle.cpp
Localization.cpp
Map.cpp
+ MapModel.cpp
SheetAccessModel.cpp
NamedAreaManager.cpp
Number.cpp
@@ -188,10 +187,12 @@
PrintSettings.cpp
RecalcManager.cpp
Region.cpp
+ RegionModel.cpp
RowColumnFormat.cpp
Selection.cpp
ShapeApplicationData.cpp
Sheet.cpp
+ SheetModel.cpp
SheetPrint.cpp
RectStorage.cpp
Style.cpp
--- trunk/koffice/kspread/Map.cpp #1134828:1134829
@@ -50,6 +50,7 @@
#include "part/Doc.h" // FIXME detach from part
#include "LoadingInfo.h"
#include "Localization.h"
+#include "MapModel.h"
#include "NamedAreaManager.h"
#include "OdfLoadingContext.h"
#include "OdfSavingContext.h"
@@ -77,6 +78,7 @@
class Map::Private
{
public:
+ MapModel *model;
Doc* doc;
/**
@@ -129,6 +131,7 @@
d(new Private)
{
setObjectName(name); // necessary for D-Bus
+ d->model = new MapModel(this);
d->doc = doc;
d->tableId = 1;
d->overallRowCount = 0;
@@ -196,6 +199,11 @@
delete d;
}
+QAbstractItemModel* Map::model() const
+{
+ return d->model;
+}
+
Doc* Map::doc() const
{
return d->doc;
--- trunk/koffice/kspread/Map.h #1134828:1134829
@@ -35,6 +35,7 @@
class KoEmbeddedDocumentSaver;
class KoStyleManager;
+class QAbstractItemModel;
class QDomElement;
class QDomDocument;
class KoXmlWriter;
@@ -82,6 +83,11 @@
virtual ~Map();
/**
+ * \return a model for this map
+ */
+ QAbstractItemModel* model() const;
+
+ /**
* \return the document this map belongs to
*/
Doc* doc() const;
--- trunk/koffice/kspread/Sheet.cpp #1134828:1134829
@@ -79,6 +79,7 @@
#include "ShapeApplicationData.h"
#include "SheetPrint.h"
#include "RectStorage.h"
+#include "SheetModel.h"
#include "Style.h"
#include "StyleManager.h"
#include "StyleStorage.h"
@@ -119,6 +120,7 @@
{
public:
Map* workbook;
+ SheetModel *model;
SheetAdaptor* dbus;
@@ -193,6 +195,7 @@
s_mapSheets = new QHash<int, Sheet*>;
d->workbook = map;
+ d->model = new SheetModel(this);
d->id = s_id++;
s_mapSheets->insert(d->id, this);
@@ -246,6 +249,7 @@
, d(new Private)
{
d->workbook = other.d->workbook;
+ d->model = new SheetModel(this);
// create a unique name
int i = 1;
@@ -325,6 +329,11 @@
delete d;
}
+QAbstractItemModel* Sheet::model() const
+{
+ return d->model;
+}
+
QString Sheet::sheetName() const
{
return d->name;
--- trunk/koffice/kspread/Sheet.h #1134828:1134829
@@ -41,6 +41,7 @@
#include "kspread_export.h"
+class QAbstractItemModel;
class QDomElement;
class QUndoCommand;
class QWidget;
@@ -114,6 +115,11 @@
~Sheet();
/**
+ * \return a model for this sheet
+ */
+ QAbstractItemModel *model() const;
+
+ /**
* \return the map this sheet belongs to
*/
Map* map() const;
--- trunk/koffice/kspread/interfaces/ReadOnlyTableModel.cpp #1134828:1134829
@@ -29,6 +29,7 @@
#include "ValueFormatter.h"
// Qt
+#include <QBrush>
#include <QSize>
using namespace KSpread;
@@ -91,6 +92,18 @@
return cell.userInput();
} else if (role == Qt::ToolTipRole) {
return cell.comment();
+ } else if (role == Qt::SizeHintRole) {
+ // TODO
+ } else if (role == Qt::FontRole) {
+ return style.font();
+ } else if (role == Qt::TextAlignmentRole) {
+ // TODO
+ } else if (role == Qt::BackgroundRole) {
+ return style.backgroundBrush();
+ } else if (role == Qt::BackgroundColorRole) {
+ return style.backgroundColor();
+ } else if (role == Qt::ForegroundRole) {
+ return style.fontColor();
}
return QVariant();
}
@@ -108,6 +121,22 @@
return QVariant();
}
+QModelIndex ReadOnlyTableModel::index(int row, int column, const QModelIndex \
&parent) const +{
+ QModelIndex index;
+ // A cell in our sheet?
+ if (!parent.isValid()) {
+ index = createIndex(row, column, d->sheet);
+ // Embedded in a MapModel?
+ } else if (parent.internalPointer() == d->sheet->map()) {
+ index = createIndex(row, column, d->sheet);
+ // A sub-table?
+ } else if (parent.internalPointer() == this) {
+ // TODO sub-tables
+ }
+ return index;
+}
+
Sheet* ReadOnlyTableModel::sheet() const
{
return d->sheet;
--- trunk/koffice/kspread/interfaces/ReadOnlyTableModel.h #1134828:1134829
@@ -44,6 +44,7 @@
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) \
const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = \
Qt::DisplayRole) const; + virtual QModelIndex index(int row, int column, const \
QModelIndex &parent = QModelIndex()) const;
protected:
Sheet* sheet() const;
--- trunk/koffice/kspread/part/View.cpp #1134828:1134829
@@ -141,6 +141,8 @@
#include "ValueConverter.h"
#include "PrintJob.h"
+#include "MapViewModel.h"
+
// commands
#include "commands/BorderColorCommand.h"
#include "commands/CommentCommand.h"
@@ -175,6 +177,7 @@
// the active sheet, may be 0
// this is the sheet which has the input focus
Sheet* activeSheet;
+ MapViewModel* mapViewModel;
QHash<const Sheet*, SheetView*> sheetViews;
// GUI elements
@@ -728,6 +731,13 @@
d->canvasController->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
d->canvasController->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ // Setup the map model.
+ d->mapViewModel = new MapViewModel(d->doc->map());
+ connect(d->mapViewModel, SIGNAL(addCommandRequested(QUndoCommand*)),
+ doc(), SLOT(addCommand(QUndoCommand*)));
+ connect(d->mapViewModel, SIGNAL(activeSheetChanged(Sheet*)),
+ this, SLOT(setActiveSheet(Sheet*)));
+
// Setup the selection.
d->selection = new Selection(d->canvas);
connect(d->selection, SIGNAL(changed(const Region&)), this, \
SLOT(slotChangeSelection(const Region&))); @@ -1246,7 +1256,7 @@
void View::setSelectionBorderColor(const QColor &bdColor)
{
BorderColorCommand* command = new BorderColorCommand();
- command->setSheet(d->activeSheet);
+ command->setSheet(activeSheet());
command->setColor(bdColor);
command->add(*selection());
command->execute();
@@ -1485,6 +1495,7 @@
if (!selection()->referenceSelectionMode())
selection()->emitCloseEditor(true); // save changes
setActiveSheet(t, false /* False: Endless loop because of setActiveTab() => do \
the visual area update manually*/); + d->mapViewModel->setActiveSheet(t);
//refresh toggle button
updateBorderButton();
--- trunk/koffice/kspread/ui/CellToolBase.cpp #1134828:1134829
@@ -133,7 +133,7 @@
#ifndef NDEBUG
#include <QTableView>
-#include "interfaces/ReadWriteTableModel.h"
+#include "SheetModel.h"
#endif
using namespace KSpread;
@@ -3241,8 +3241,7 @@
#ifndef NDEBUG
KDialog* const dialog = new KDialog(canvas()->canvasWidget());
QTableView* const view = new QTableView(dialog);
-// ReadOnlyTableModel* const model = new \
ReadOnlyTableModel(selection()->activeSheet());
- ReadWriteTableModel* const model = new \
ReadWriteTableModel(selection()->activeSheet()); + SheetModel* const model = new \
SheetModel(selection()->activeSheet()); view->setModel(model);
dialog->setCaption("Read{Only,Write}TableModel Test");
dialog->setMainWidget(view);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic