QtBase: examples/widgets/itemviews code style
Change-Id: I78a7745f7dc3add3fd7780220118d1b35b50a941 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
parent
49a4d058cc
commit
ab0a007cb3
@ -38,10 +38,12 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtWidgets>
|
|
||||||
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QStandardItemModel>
|
||||||
|
#include <QTime>
|
||||||
|
|
||||||
void addMail(QAbstractItemModel *model, const QString &subject,
|
void addMail(QAbstractItemModel *model, const QString &subject,
|
||||||
const QString &sender, const QDateTime &date)
|
const QString &sender, const QDateTime &date)
|
||||||
{
|
{
|
||||||
|
@ -85,4 +85,4 @@ private:
|
|||||||
QComboBox *filterColumnComboBox;
|
QComboBox *filterColumnComboBox;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // WINDOW_H
|
||||||
|
@ -103,15 +103,17 @@ void MainWindow::openFile(const QString &path)
|
|||||||
{
|
{
|
||||||
QString fileName;
|
QString fileName;
|
||||||
if (path.isNull())
|
if (path.isNull())
|
||||||
fileName = QFileDialog::getOpenFileName(this, tr("Choose a data file"),
|
fileName = QFileDialog::getOpenFileName(this, tr("Choose a data file"), "", "*.cht");
|
||||||
"", "*.cht");
|
|
||||||
else
|
else
|
||||||
fileName = path;
|
fileName = path;
|
||||||
|
|
||||||
if (!fileName.isEmpty()) {
|
if (fileName.isEmpty())
|
||||||
QFile file(fileName);
|
return;
|
||||||
|
|
||||||
|
QFile file(fileName);
|
||||||
|
if (!file.open(QFile::ReadOnly | QFile::Text))
|
||||||
|
return;
|
||||||
|
|
||||||
if (file.open(QFile::ReadOnly | QFile::Text)) {
|
|
||||||
QTextStream stream(&file);
|
QTextStream stream(&file);
|
||||||
QString line;
|
QString line;
|
||||||
|
|
||||||
@ -121,7 +123,6 @@ void MainWindow::openFile(const QString &path)
|
|||||||
do {
|
do {
|
||||||
line = stream.readLine();
|
line = stream.readLine();
|
||||||
if (!line.isEmpty()) {
|
if (!line.isEmpty()) {
|
||||||
|
|
||||||
model->insertRows(row, 1, QModelIndex());
|
model->insertRows(row, 1, QModelIndex());
|
||||||
|
|
||||||
QStringList pieces = line.split(",", QString::SkipEmptyParts);
|
QStringList pieces = line.split(",", QString::SkipEmptyParts);
|
||||||
@ -138,19 +139,20 @@ void MainWindow::openFile(const QString &path)
|
|||||||
file.close();
|
file.close();
|
||||||
statusBar()->showMessage(tr("Loaded %1").arg(fileName), 2000);
|
statusBar()->showMessage(tr("Loaded %1").arg(fileName), 2000);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::saveFile()
|
void MainWindow::saveFile()
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getSaveFileName(this,
|
QString fileName = QFileDialog::getSaveFileName(this,
|
||||||
tr("Save file as"), "", "*.cht");
|
tr("Save file as"), "", "*.cht");
|
||||||
|
|
||||||
if (!fileName.isEmpty()) {
|
if (fileName.isEmpty())
|
||||||
QFile file(fileName);
|
return;
|
||||||
QTextStream stream(&file);
|
|
||||||
|
|
||||||
if (file.open(QFile::WriteOnly | QFile::Text)) {
|
QFile file(fileName);
|
||||||
|
if (!file.open(QFile::WriteOnly | QFile::Text))
|
||||||
|
return;
|
||||||
|
|
||||||
|
QTextStream stream(&file);
|
||||||
for (int row = 0; row < model->rowCount(QModelIndex()); ++row) {
|
for (int row = 0; row < model->rowCount(QModelIndex()); ++row) {
|
||||||
|
|
||||||
QStringList pieces;
|
QStringList pieces;
|
||||||
@ -164,9 +166,7 @@ void MainWindow::saveFile()
|
|||||||
|
|
||||||
stream << pieces.join(',') << "\n";
|
stream << pieces.join(',') << "\n";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
statusBar()->showMessage(tr("Saved %1").arg(fileName), 2000);
|
statusBar()->showMessage(tr("Saved %1").arg(fileName), 2000);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -69,4 +69,4 @@ private:
|
|||||||
QItemSelectionModel *selectionModel;
|
QItemSelectionModel *selectionModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // MAINWINDOW_H
|
||||||
|
@ -150,7 +150,7 @@ QModelIndex PieView::indexAt(const QPoint &point) const
|
|||||||
return model()->index(row, 0, rootIndex());
|
return model()->index(row, 0, rootIndex());
|
||||||
|
|
||||||
// Update the list index that corresponds to the next valid row.
|
// Update the list index that corresponds to the next valid row.
|
||||||
validRow++;
|
++validRow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -182,7 +182,8 @@ QRect PieView::itemRect(const QModelIndex &index) const
|
|||||||
else
|
else
|
||||||
valueIndex = index;
|
valueIndex = index;
|
||||||
|
|
||||||
if (model()->data(valueIndex).toDouble() > 0.0) {
|
if (model()->data(valueIndex).toDouble() <= 0.0)
|
||||||
|
return QRect();
|
||||||
|
|
||||||
int listItem = 0;
|
int listItem = 0;
|
||||||
for (int row = index.row()-1; row >= 0; --row) {
|
for (int row = index.row()-1; row >= 0; --row) {
|
||||||
@ -202,8 +203,6 @@ QRect PieView::itemRect(const QModelIndex &index) const
|
|||||||
case 1:
|
case 1:
|
||||||
return viewport()->rect();
|
return viewport()->rect();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
return QRect();
|
return QRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,7 +321,8 @@ void PieView::paintEvent(QPaintEvent *event)
|
|||||||
// Viewport rectangles
|
// Viewport rectangles
|
||||||
QRect pieRect = QRect(margin, margin, pieSize, pieSize);
|
QRect pieRect = QRect(margin, margin, pieSize, pieSize);
|
||||||
|
|
||||||
if (validItems > 0) {
|
if (validItems <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
painter.save();
|
painter.save();
|
||||||
painter.translate(pieRect.x() - horizontalScrollBar()->value(),
|
painter.translate(pieRect.x() - horizontalScrollBar()->value(),
|
||||||
@ -332,7 +332,6 @@ void PieView::paintEvent(QPaintEvent *event)
|
|||||||
int row;
|
int row;
|
||||||
|
|
||||||
for (row = 0; row < model()->rowCount(rootIndex()); ++row) {
|
for (row = 0; row < model()->rowCount(rootIndex()); ++row) {
|
||||||
|
|
||||||
QModelIndex index = model()->index(row, 1, rootIndex());
|
QModelIndex index = model()->index(row, 1, rootIndex());
|
||||||
double value = model()->data(index).toDouble();
|
double value = model()->data(index).toDouble();
|
||||||
|
|
||||||
@ -340,8 +339,7 @@ void PieView::paintEvent(QPaintEvent *event)
|
|||||||
double angle = 360*value/totalValue;
|
double angle = 360*value/totalValue;
|
||||||
|
|
||||||
QModelIndex colorIndex = model()->index(row, 0, rootIndex());
|
QModelIndex colorIndex = model()->index(row, 0, rootIndex());
|
||||||
QColor color = QColor(model()->data(colorIndex,
|
QColor color = QColor(model()->data(colorIndex, Qt::DecorationRole).toString());
|
||||||
Qt::DecorationRole).toString());
|
|
||||||
|
|
||||||
if (currentIndex() == index)
|
if (currentIndex() == index)
|
||||||
painter.setBrush(QBrush(color, Qt::Dense4Pattern));
|
painter.setBrush(QBrush(color, Qt::Dense4Pattern));
|
||||||
@ -350,8 +348,7 @@ void PieView::paintEvent(QPaintEvent *event)
|
|||||||
else
|
else
|
||||||
painter.setBrush(QBrush(color));
|
painter.setBrush(QBrush(color));
|
||||||
|
|
||||||
painter.drawPie(0, 0, pieSize, pieSize, int(startAngle*16),
|
painter.drawPie(0, 0, pieSize, pieSize, int(startAngle*16), int(angle*16));
|
||||||
int(angle*16));
|
|
||||||
|
|
||||||
startAngle += angle;
|
startAngle += angle;
|
||||||
}
|
}
|
||||||
@ -361,7 +358,6 @@ void PieView::paintEvent(QPaintEvent *event)
|
|||||||
int keyNumber = 0;
|
int keyNumber = 0;
|
||||||
|
|
||||||
for (row = 0; row < model()->rowCount(rootIndex()); ++row) {
|
for (row = 0; row < model()->rowCount(rootIndex()); ++row) {
|
||||||
|
|
||||||
QModelIndex index = model()->index(row, 1, rootIndex());
|
QModelIndex index = model()->index(row, 1, rootIndex());
|
||||||
double value = model()->data(index).toDouble();
|
double value = model()->data(index).toDouble();
|
||||||
|
|
||||||
@ -376,8 +372,7 @@ void PieView::paintEvent(QPaintEvent *event)
|
|||||||
option.state |= QStyle::State_HasFocus;
|
option.state |= QStyle::State_HasFocus;
|
||||||
itemDelegate()->paint(&painter, option, labelIndex);
|
itemDelegate()->paint(&painter, option, labelIndex);
|
||||||
|
|
||||||
keyNumber++;
|
++keyNumber;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -395,13 +390,12 @@ int PieView::rows(const QModelIndex &index) const
|
|||||||
void PieView::rowsInserted(const QModelIndex &parent, int start, int end)
|
void PieView::rowsInserted(const QModelIndex &parent, int start, int end)
|
||||||
{
|
{
|
||||||
for (int row = start; row <= end; ++row) {
|
for (int row = start; row <= end; ++row) {
|
||||||
|
|
||||||
QModelIndex index = model()->index(row, 1, rootIndex());
|
QModelIndex index = model()->index(row, 1, rootIndex());
|
||||||
double value = model()->data(index).toDouble();
|
double value = model()->data(index).toDouble();
|
||||||
|
|
||||||
if (value > 0.0) {
|
if (value > 0.0) {
|
||||||
totalValue += value;
|
totalValue += value;
|
||||||
validItems++;
|
++validItems;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,12 +405,11 @@ void PieView::rowsInserted(const QModelIndex &parent, int start, int end)
|
|||||||
void PieView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
|
void PieView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
|
||||||
{
|
{
|
||||||
for (int row = start; row <= end; ++row) {
|
for (int row = start; row <= end; ++row) {
|
||||||
|
|
||||||
QModelIndex index = model()->index(row, 1, rootIndex());
|
QModelIndex index = model()->index(row, 1, rootIndex());
|
||||||
double value = model()->data(index).toDouble();
|
double value = model()->data(index).toDouble();
|
||||||
if (value > 0.0) {
|
if (value > 0.0) {
|
||||||
totalValue -= value;
|
totalValue -= value;
|
||||||
validItems--;
|
--validItems;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,21 +426,23 @@ void PieView::scrollTo(const QModelIndex &index, ScrollHint)
|
|||||||
QRect area = viewport()->rect();
|
QRect area = viewport()->rect();
|
||||||
QRect rect = visualRect(index);
|
QRect rect = visualRect(index);
|
||||||
|
|
||||||
if (rect.left() < area.left())
|
if (rect.left() < area.left()) {
|
||||||
horizontalScrollBar()->setValue(
|
horizontalScrollBar()->setValue(
|
||||||
horizontalScrollBar()->value() + rect.left() - area.left());
|
horizontalScrollBar()->value() + rect.left() - area.left());
|
||||||
else if (rect.right() > area.right())
|
} else if (rect.right() > area.right()) {
|
||||||
horizontalScrollBar()->setValue(
|
horizontalScrollBar()->setValue(
|
||||||
horizontalScrollBar()->value() + qMin(
|
horizontalScrollBar()->value() + qMin(
|
||||||
rect.right() - area.right(), rect.left() - area.left()));
|
rect.right() - area.right(), rect.left() - area.left()));
|
||||||
|
}
|
||||||
|
|
||||||
if (rect.top() < area.top())
|
if (rect.top() < area.top()) {
|
||||||
verticalScrollBar()->setValue(
|
verticalScrollBar()->setValue(
|
||||||
verticalScrollBar()->value() + rect.top() - area.top());
|
verticalScrollBar()->value() + rect.top() - area.top());
|
||||||
else if (rect.bottom() > area.bottom())
|
} else if (rect.bottom() > area.bottom()) {
|
||||||
verticalScrollBar()->setValue(
|
verticalScrollBar()->setValue(
|
||||||
verticalScrollBar()->value() + qMin(
|
verticalScrollBar()->value() + qMin(
|
||||||
rect.bottom() - area.bottom(), rect.top() - area.top()));
|
rect.bottom() - area.bottom(), rect.top() - area.top()));
|
||||||
|
}
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@ -524,12 +519,12 @@ int PieView::verticalOffset() const
|
|||||||
QRect PieView::visualRect(const QModelIndex &index) const
|
QRect PieView::visualRect(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
QRect rect = itemRect(index);
|
QRect rect = itemRect(index);
|
||||||
if (rect.isValid())
|
if (!rect.isValid())
|
||||||
|
return rect;
|
||||||
|
|
||||||
return QRect(rect.left() - horizontalScrollBar()->value(),
|
return QRect(rect.left() - horizontalScrollBar()->value(),
|
||||||
rect.top() - verticalScrollBar()->value(),
|
rect.top() - verticalScrollBar()->value(),
|
||||||
rect.width(), rect.height());
|
rect.width(), rect.height());
|
||||||
else
|
|
||||||
return rect;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -42,18 +42,6 @@
|
|||||||
#define PIEVIEW_H
|
#define PIEVIEW_H
|
||||||
|
|
||||||
#include <QAbstractItemView>
|
#include <QAbstractItemView>
|
||||||
#include <QFont>
|
|
||||||
#include <QItemSelection>
|
|
||||||
#include <QItemSelectionModel>
|
|
||||||
#include <QModelIndex>
|
|
||||||
#include <QRect>
|
|
||||||
#include <QSize>
|
|
||||||
#include <QPoint>
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QRubberBand;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
class PieView : public QAbstractItemView
|
class PieView : public QAbstractItemView
|
||||||
@ -68,7 +56,8 @@ public:
|
|||||||
QModelIndex indexAt(const QPoint &point) const;
|
QModelIndex indexAt(const QPoint &point) const;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> & = QVector<int>());
|
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
|
||||||
|
const QVector<int> &roles = QVector<int>());
|
||||||
void rowsInserted(const QModelIndex &parent, int start, int end);
|
void rowsInserted(const QModelIndex &parent, int start, int end);
|
||||||
void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
|
void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
|
||||||
|
|
||||||
@ -111,4 +100,4 @@ private:
|
|||||||
};
|
};
|
||||||
//! [0]
|
//! [0]
|
||||||
|
|
||||||
#endif
|
#endif // PIEVIEW_H
|
||||||
|
@ -83,4 +83,4 @@ private:
|
|||||||
};
|
};
|
||||||
//! [Window definition]
|
//! [Window definition]
|
||||||
|
|
||||||
#endif
|
#endif // WINDOW_H
|
||||||
|
@ -70,4 +70,4 @@ private:
|
|||||||
};
|
};
|
||||||
//! [0]
|
//! [0]
|
||||||
|
|
||||||
#endif
|
#endif // MYSORTFILTERPROXYMODEL_H
|
||||||
|
@ -87,4 +87,4 @@ private:
|
|||||||
};
|
};
|
||||||
//! [0]
|
//! [0]
|
||||||
|
|
||||||
#endif
|
#endif // WINDOW_H
|
||||||
|
@ -38,7 +38,9 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtWidgets>
|
#include <QApplication>
|
||||||
|
#include <QFileSystemModel>
|
||||||
|
#include <QTreeView>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtWidgets>
|
#include <QApplication>
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
@ -38,17 +38,16 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtWidgets>
|
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "treemodel.h"
|
#include "treemodel.h"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
|
|
||||||
QStringList headers;
|
QStringList headers;
|
||||||
headers << tr("Title") << tr("Description");
|
headers << tr("Title") << tr("Description");
|
||||||
|
|
||||||
@ -95,8 +94,7 @@ void MainWindow::insertChild()
|
|||||||
QModelIndex child = model->index(0, column, index);
|
QModelIndex child = model->index(0, column, index);
|
||||||
model->setData(child, QVariant("[No data]"), Qt::EditRole);
|
model->setData(child, QVariant("[No data]"), Qt::EditRole);
|
||||||
if (!model->headerData(column, Qt::Horizontal).isValid())
|
if (!model->headerData(column, Qt::Horizontal).isValid())
|
||||||
model->setHeaderData(column, Qt::Horizontal, QVariant("[No header]"),
|
model->setHeaderData(column, Qt::Horizontal, QVariant("[No header]"), Qt::EditRole);
|
||||||
Qt::EditRole);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
view->selectionModel()->setCurrentIndex(model->index(0, 0, index),
|
view->selectionModel()->setCurrentIndex(model->index(0, 0, index),
|
||||||
@ -112,8 +110,7 @@ bool MainWindow::insertColumn(const QModelIndex &parent)
|
|||||||
// Insert a column in the parent item.
|
// Insert a column in the parent item.
|
||||||
bool changed = model->insertColumn(column + 1, parent);
|
bool changed = model->insertColumn(column + 1, parent);
|
||||||
if (changed)
|
if (changed)
|
||||||
model->setHeaderData(column + 1, Qt::Horizontal, QVariant("[No header]"),
|
model->setHeaderData(column + 1, Qt::Horizontal, QVariant("[No header]"), Qt::EditRole);
|
||||||
Qt::EditRole);
|
|
||||||
|
|
||||||
updateActions();
|
updateActions();
|
||||||
|
|
||||||
|
@ -41,14 +41,10 @@
|
|||||||
#ifndef MAINWINDOW_H
|
#ifndef MAINWINDOW_H
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
|
||||||
#include <QModelIndex>
|
|
||||||
|
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
|
|
||||||
class QAction;
|
#include <QMainWindow>
|
||||||
class QTreeView;
|
#include <QModelIndex>
|
||||||
class QWidget;
|
|
||||||
|
|
||||||
class MainWindow : public QMainWindow, private Ui::MainWindow
|
class MainWindow : public QMainWindow, private Ui::MainWindow
|
||||||
{
|
{
|
||||||
@ -68,4 +64,4 @@ private slots:
|
|||||||
void removeRow();
|
void removeRow();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // MAINWINDOW_H
|
||||||
|
@ -44,10 +44,10 @@
|
|||||||
A container for items of data supplied by the simple tree model.
|
A container for items of data supplied by the simple tree model.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QStringList>
|
|
||||||
|
|
||||||
#include "treeitem.h"
|
#include "treeitem.h"
|
||||||
|
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
TreeItem::TreeItem(const QVector<QVariant> &data, TreeItem *parent)
|
TreeItem::TreeItem(const QVector<QVariant> &data, TreeItem *parent)
|
||||||
{
|
{
|
||||||
|
@ -71,4 +71,4 @@ private:
|
|||||||
};
|
};
|
||||||
//! [0]
|
//! [0]
|
||||||
|
|
||||||
#endif
|
#endif // TREEITEM_H
|
||||||
|
@ -44,8 +44,7 @@
|
|||||||
#include "treemodel.h"
|
#include "treemodel.h"
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
TreeModel::TreeModel(const QStringList &headers, const QString &data,
|
TreeModel::TreeModel(const QStringList &headers, const QString &data, QObject *parent)
|
||||||
QObject *parent)
|
|
||||||
: QAbstractItemModel(parent)
|
: QAbstractItemModel(parent)
|
||||||
{
|
{
|
||||||
QVector<QVariant> rootData;
|
QVector<QVariant> rootData;
|
||||||
@ -99,7 +98,8 @@ TreeItem *TreeModel::getItem(const QModelIndex &index) const
|
|||||||
{
|
{
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
if (item) return item;
|
if (item)
|
||||||
|
return item;
|
||||||
}
|
}
|
||||||
return rootItem;
|
return rootItem;
|
||||||
}
|
}
|
||||||
@ -206,8 +206,7 @@ int TreeModel::rowCount(const QModelIndex &parent) const
|
|||||||
}
|
}
|
||||||
//! [8]
|
//! [8]
|
||||||
|
|
||||||
bool TreeModel::setData(const QModelIndex &index, const QVariant &value,
|
bool TreeModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||||
int role)
|
|
||||||
{
|
{
|
||||||
if (role != Qt::EditRole)
|
if (role != Qt::EditRole)
|
||||||
return false;
|
return false;
|
||||||
@ -249,7 +248,7 @@ void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent)
|
|||||||
while (position < lines[number].length()) {
|
while (position < lines[number].length()) {
|
||||||
if (lines[number].mid(position, 1) != " ")
|
if (lines[number].mid(position, 1) != " ")
|
||||||
break;
|
break;
|
||||||
position++;
|
++position;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString lineData = lines[number].mid(position).trimmed();
|
QString lineData = lines[number].mid(position).trimmed();
|
||||||
@ -283,6 +282,6 @@ void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent)
|
|||||||
parent->child(parent->childCount() - 1)->setData(column, columnData[column]);
|
parent->child(parent->childCount() - 1)->setData(column, columnData[column]);
|
||||||
}
|
}
|
||||||
|
|
||||||
number++;
|
++number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,4 +94,4 @@ private:
|
|||||||
};
|
};
|
||||||
//! [2]
|
//! [2]
|
||||||
|
|
||||||
#endif
|
#endif // TREEMODEL_H
|
||||||
|
@ -39,10 +39,11 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "filelistmodel.h"
|
#include "filelistmodel.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QPalette>
|
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QPalette>
|
||||||
|
|
||||||
FileListModel::FileListModel(QObject *parent)
|
FileListModel::FileListModel(QObject *parent)
|
||||||
: QAbstractListModel(parent)
|
: QAbstractListModel(parent)
|
||||||
@ -63,9 +64,9 @@ QVariant FileListModel::data(const QModelIndex &index, int role) const
|
|||||||
if (index.row() >= fileList.size() || index.row() < 0)
|
if (index.row() >= fileList.size() || index.row() < 0)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
if (role == Qt::DisplayRole)
|
if (role == Qt::DisplayRole) {
|
||||||
return fileList.at(index.row());
|
return fileList.at(index.row());
|
||||||
else if (role == Qt::BackgroundRole) {
|
} else if (role == Qt::BackgroundRole) {
|
||||||
int batch = (index.row() / 100) % 2;
|
int batch = (index.row() / 100) % 2;
|
||||||
if (batch == 0)
|
if (batch == 0)
|
||||||
return qApp->palette().base();
|
return qApp->palette().base();
|
||||||
|
@ -72,4 +72,4 @@ private:
|
|||||||
};
|
};
|
||||||
//![0]
|
//![0]
|
||||||
|
|
||||||
#endif
|
#endif // FILELISTMODEL_H
|
||||||
|
@ -38,9 +38,10 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
@ -38,10 +38,11 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtWidgets>
|
|
||||||
#include "filelistmodel.h"
|
#include "filelistmodel.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
|
#include <QtWidgets>
|
||||||
|
|
||||||
Window::Window(QWidget *parent)
|
Window::Window(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
|
@ -61,4 +61,4 @@ private:
|
|||||||
QTextBrowser *logViewer;
|
QTextBrowser *logViewer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // WINDOW_H
|
||||||
|
@ -38,10 +38,11 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtWidgets>
|
|
||||||
|
|
||||||
#include "freezetablewidget.h"
|
#include "freezetablewidget.h"
|
||||||
|
|
||||||
|
#include <QScrollBar>
|
||||||
|
#include <QHeaderView>
|
||||||
|
|
||||||
//! [constructor]
|
//! [constructor]
|
||||||
FreezeTableWidget::FreezeTableWidget(QAbstractItemModel * model)
|
FreezeTableWidget::FreezeTableWidget(QAbstractItemModel * model)
|
||||||
{
|
{
|
||||||
@ -86,7 +87,7 @@ void FreezeTableWidget::init()
|
|||||||
"background-color: #8EDE21;"
|
"background-color: #8EDE21;"
|
||||||
"selection-background-color: #999}"); //for demo purposes
|
"selection-background-color: #999}"); //for demo purposes
|
||||||
frozenTableView->setSelectionModel(selectionModel());
|
frozenTableView->setSelectionModel(selectionModel());
|
||||||
for(int col=1; col<model()->columnCount(); col++)
|
for (int col = 1; col < model()->columnCount(); ++col)
|
||||||
frozenTableView->setColumnHidden(col, true);
|
frozenTableView->setColumnHidden(col, true);
|
||||||
|
|
||||||
frozenTableView->setColumnWidth(0, columnWidth(0) );
|
frozenTableView->setColumnWidth(0, columnWidth(0) );
|
||||||
@ -105,7 +106,7 @@ void FreezeTableWidget::init()
|
|||||||
|
|
||||||
|
|
||||||
//! [sections]
|
//! [sections]
|
||||||
void FreezeTableWidget::updateSectionWidth(int logicalIndex, int, int newSize)
|
void FreezeTableWidget::updateSectionWidth(int logicalIndex, int /* oldSize */, int newSize)
|
||||||
{
|
{
|
||||||
if (logicalIndex == 0){
|
if (logicalIndex == 0){
|
||||||
frozenTableView->setColumnWidth(0, newSize);
|
frozenTableView->setColumnWidth(0, newSize);
|
||||||
@ -113,7 +114,7 @@ void FreezeTableWidget::updateSectionWidth(int logicalIndex, int, int newSize)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreezeTableWidget::updateSectionHeight(int logicalIndex, int, int newSize)
|
void FreezeTableWidget::updateSectionHeight(int logicalIndex, int /* oldSize */, int newSize)
|
||||||
{
|
{
|
||||||
frozenTableView->setRowHeight(logicalIndex, newSize);
|
frozenTableView->setRowHeight(logicalIndex, newSize);
|
||||||
}
|
}
|
||||||
@ -137,7 +138,6 @@ QModelIndex FreezeTableWidget::moveCursor(CursorAction cursorAction,
|
|||||||
|
|
||||||
if (cursorAction == MoveLeft && current.column() > 0
|
if (cursorAction == MoveLeft && current.column() > 0
|
||||||
&& visualRect(current).topLeft().x() < frozenTableView->columnWidth(0) ){
|
&& visualRect(current).topLeft().x() < frozenTableView->columnWidth(0) ){
|
||||||
|
|
||||||
const int newValue = horizontalScrollBar()->value() + visualRect(current).topLeft().x()
|
const int newValue = horizontalScrollBar()->value() + visualRect(current).topLeft().x()
|
||||||
- frozenTableView->columnWidth(0);
|
- frozenTableView->columnWidth(0);
|
||||||
horizontalScrollBar()->setValue(newValue);
|
horizontalScrollBar()->setValue(newValue);
|
||||||
@ -151,8 +151,6 @@ void FreezeTableWidget::scrollTo (const QModelIndex & index, ScrollHint hint){
|
|||||||
QTableView::scrollTo(index, hint);
|
QTableView::scrollTo(index, hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! [geometry]
|
//! [geometry]
|
||||||
void FreezeTableWidget::updateFrozenTableGeometry()
|
void FreezeTableWidget::updateFrozenTableGeometry()
|
||||||
{
|
{
|
||||||
|
@ -64,9 +64,9 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateSectionWidth(int logicalIndex,int, int newSize);
|
void updateSectionWidth(int logicalIndex, int oldSize, int newSize);
|
||||||
void updateSectionHeight(int logicalIndex, int, int newSize);
|
void updateSectionHeight(int logicalIndex, int oldSize, int newSize);
|
||||||
|
|
||||||
};
|
};
|
||||||
//! [Widget definition]
|
//! [Widget definition]
|
||||||
#endif
|
#endif // FREEZETABLEWIDGET_H
|
||||||
|
@ -44,22 +44,17 @@
|
|||||||
|
|
||||||
#include "freezetablewidget.h"
|
#include "freezetablewidget.h"
|
||||||
|
|
||||||
int main( int argc, char** argv )
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
Q_INIT_RESOURCE(grades);
|
Q_INIT_RESOURCE(grades);
|
||||||
|
|
||||||
|
|
||||||
QApplication app( argc, argv );
|
QApplication app( argc, argv );
|
||||||
QStandardItemModel *model=new QStandardItemModel();
|
QStandardItemModel *model=new QStandardItemModel();
|
||||||
|
|
||||||
|
|
||||||
QFile file(":/grades.txt");
|
QFile file(":/grades.txt");
|
||||||
QString line;
|
|
||||||
QStringList list;
|
|
||||||
if (file.open(QFile::ReadOnly)) {
|
if (file.open(QFile::ReadOnly)) {
|
||||||
line = file.readLine(200);
|
QString line = file.readLine(200);
|
||||||
list= line.simplified().split(",");
|
QStringList list = line.simplified().split(",");
|
||||||
model->setHorizontalHeaderLabels(list);
|
model->setHorizontalHeaderLabels(list);
|
||||||
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
@ -68,11 +63,11 @@ int main( int argc, char** argv )
|
|||||||
line = file.readLine(200);
|
line = file.readLine(200);
|
||||||
if (!line.startsWith("#") && line.contains(",")) {
|
if (!line.startsWith("#") && line.contains(",")) {
|
||||||
list= line.simplified().split(",");
|
list= line.simplified().split(",");
|
||||||
for(int col=0; col<list.length(); col++){
|
for (int col = 0; col < list.length(); ++col){
|
||||||
newItem = new QStandardItem(list.at(col));
|
newItem = new QStandardItem(list.at(col));
|
||||||
model->setItem(row, col, newItem);
|
model->setItem(row, col, newItem);
|
||||||
}
|
}
|
||||||
row++;
|
++row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,11 +42,11 @@
|
|||||||
#include "model.h"
|
#include "model.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QTableView>
|
#include <QHeaderView>
|
||||||
#include <QTreeView>
|
|
||||||
#include <QListView>
|
#include <QListView>
|
||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
#include <QHeaderView>
|
#include <QTableView>
|
||||||
|
#include <QTreeView>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "model.h"
|
#include "model.h"
|
||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
|
||||||
@ -60,10 +61,10 @@ Model::~Model()
|
|||||||
QModelIndex Model::index(int row, int column, const QModelIndex &parent) const
|
QModelIndex Model::index(int row, int column, const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
if (row < rc && row >= 0 && column < cc && column >= 0) {
|
if (row < rc && row >= 0 && column < cc && column >= 0) {
|
||||||
Node *p = static_cast<Node*>(parent.internalPointer());
|
Node *parentNode = static_cast<Node*>(parent.internalPointer());
|
||||||
Node *n = node(row, p);
|
Node *childNode = node(row, parentNode);
|
||||||
if (n)
|
if (childNode)
|
||||||
return createIndex(row, column, n);
|
return createIndex(row, column, childNode);
|
||||||
}
|
}
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
@ -71,10 +72,10 @@ QModelIndex Model::index(int row, int column, const QModelIndex &parent) const
|
|||||||
QModelIndex Model::parent(const QModelIndex &child) const
|
QModelIndex Model::parent(const QModelIndex &child) const
|
||||||
{
|
{
|
||||||
if (child.isValid()) {
|
if (child.isValid()) {
|
||||||
Node *n = static_cast<Node*>(child.internalPointer());
|
Node *childNode = static_cast<Node*>(child.internalPointer());
|
||||||
Node *p = parent(n);
|
Node *parentNode = parent(childNode);
|
||||||
if (p)
|
if (parentNode)
|
||||||
return createIndex(row(p), 0, p);
|
return createIndex(row(parentNode), 0, parentNode);
|
||||||
}
|
}
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
@ -143,5 +144,5 @@ Model::Node *Model::parent(Node *child) const
|
|||||||
int Model::row(Node *node) const
|
int Model::row(Node *node) const
|
||||||
{
|
{
|
||||||
const Node *first = node->parent ? &(node->parent->children->at(0)) : &(tree->at(0));
|
const Node *first = node->parent ? &(node->parent->children->at(0)) : &(tree->at(0));
|
||||||
return (node - first);
|
return node - first;
|
||||||
}
|
}
|
||||||
|
@ -82,9 +82,10 @@ private:
|
|||||||
int row(Node *node) const;
|
int row(Node *node) const;
|
||||||
|
|
||||||
QIcon services;
|
QIcon services;
|
||||||
int rc, cc;
|
int rc;
|
||||||
|
int cc;
|
||||||
QVector<Node> *tree;
|
QVector<Node> *tree;
|
||||||
QFileIconProvider iconProvider;
|
QFileIconProvider iconProvider;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // MODEL_H
|
||||||
|
@ -38,8 +38,6 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtWidgets>
|
|
||||||
|
|
||||||
#include "imagemodel.h"
|
#include "imagemodel.h"
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
|
@ -65,4 +65,4 @@ private:
|
|||||||
};
|
};
|
||||||
//! [0]
|
//! [0]
|
||||||
|
|
||||||
#endif
|
#endif // IMAGEMODEL_H
|
||||||
|
@ -38,16 +38,16 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "imagemodel.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include "pixeldelegate.h"
|
||||||
|
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
#ifndef QT_NO_PRINTER
|
#ifndef QT_NO_PRINTER
|
||||||
#include <QPrinter>
|
#include <QPrinter>
|
||||||
#include <QPrintDialog>
|
#include <QPrintDialog>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "imagemodel.h"
|
|
||||||
#include "mainwindow.h"
|
|
||||||
#include "pixeldelegate.h"
|
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
MainWindow::MainWindow()
|
MainWindow::MainWindow()
|
||||||
{
|
{
|
||||||
@ -155,8 +155,7 @@ void MainWindow::openImage(const QString &fileName)
|
|||||||
void MainWindow::printImage()
|
void MainWindow::printImage()
|
||||||
{
|
{
|
||||||
#ifndef QT_NO_PRINTER
|
#ifndef QT_NO_PRINTER
|
||||||
if (model->rowCount(QModelIndex())*model->columnCount(QModelIndex())
|
if (model->rowCount(QModelIndex())*model->columnCount(QModelIndex()) > 90000) {
|
||||||
> 90000) {
|
|
||||||
QMessageBox::StandardButton answer;
|
QMessageBox::StandardButton answer;
|
||||||
answer = QMessageBox::question(this, tr("Large Image Size"),
|
answer = QMessageBox::question(this, tr("Large Image Size"),
|
||||||
tr("The printed image may be very large. Are you sure that "
|
tr("The printed image may be very large. Are you sure that "
|
||||||
|
@ -71,4 +71,4 @@ private:
|
|||||||
QTableView *view;
|
QTableView *view;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // MAINWINDOW_H
|
||||||
|
@ -38,10 +38,10 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtWidgets>
|
|
||||||
|
|
||||||
#include "pixeldelegate.h"
|
#include "pixeldelegate.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
PixelDelegate::PixelDelegate(QObject *parent)
|
PixelDelegate::PixelDelegate(QObject *parent)
|
||||||
: QAbstractItemDelegate(parent)
|
: QAbstractItemDelegate(parent)
|
||||||
|
@ -42,7 +42,6 @@
|
|||||||
#define PIXELDELEGATE_H
|
#define PIXELDELEGATE_H
|
||||||
|
|
||||||
#include <QAbstractItemDelegate>
|
#include <QAbstractItemDelegate>
|
||||||
#include <QFontMetrics>
|
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
|
|
||||||
@ -76,4 +75,4 @@ private:
|
|||||||
};
|
};
|
||||||
//! [0]
|
//! [0]
|
||||||
|
|
||||||
#endif
|
#endif // PIXELDELEGATE_H
|
||||||
|
@ -38,10 +38,10 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
Q_INIT_RESOURCE(puzzle);
|
Q_INIT_RESOURCE(puzzle);
|
||||||
|
@ -38,13 +38,13 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtWidgets>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "piecesmodel.h"
|
#include "piecesmodel.h"
|
||||||
#include "puzzlewidget.h"
|
#include "puzzlewidget.h"
|
||||||
|
|
||||||
|
#include <QtWidgets>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
{
|
{
|
||||||
@ -61,9 +61,10 @@ void MainWindow::openImage(const QString &path)
|
|||||||
{
|
{
|
||||||
QString fileName = path;
|
QString fileName = path;
|
||||||
|
|
||||||
if (fileName.isNull())
|
if (fileName.isNull()) {
|
||||||
fileName = QFileDialog::getOpenFileName(this,
|
fileName = QFileDialog::getOpenFileName(this,
|
||||||
tr("Open Image"), "", tr("Image Files (*.png *.jpg *.bmp)"));
|
tr("Open Image"), "", tr("Image Files (*.png *.jpg *.bmp)"));
|
||||||
|
}
|
||||||
|
|
||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()) {
|
||||||
QPixmap newImage;
|
QPixmap newImage;
|
||||||
|
@ -41,8 +41,8 @@
|
|||||||
#ifndef MAINWINDOW_H
|
#ifndef MAINWINDOW_H
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include <QPixmap>
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include <QPixmap>
|
||||||
|
|
||||||
class PuzzleWidget;
|
class PuzzleWidget;
|
||||||
class PiecesModel;
|
class PiecesModel;
|
||||||
@ -74,4 +74,4 @@ private:
|
|||||||
PiecesModel *model;
|
PiecesModel *model;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // MAINWINDOW_H
|
||||||
|
@ -38,10 +38,11 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtWidgets>
|
|
||||||
|
|
||||||
#include "piecesmodel.h"
|
#include "piecesmodel.h"
|
||||||
|
|
||||||
|
#include <QIcon>
|
||||||
|
#include <QMimeData>
|
||||||
|
|
||||||
PiecesModel::PiecesModel(int pieceSize, QObject *parent)
|
PiecesModel::PiecesModel(int pieceSize, QObject *parent)
|
||||||
: QAbstractListModel(parent), m_PieceSize(pieceSize)
|
: QAbstractListModel(parent), m_PieceSize(pieceSize)
|
||||||
{
|
{
|
||||||
@ -153,8 +154,9 @@ bool PiecesModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
|
|||||||
endRow = pixmaps.size();
|
endRow = pixmaps.size();
|
||||||
else
|
else
|
||||||
endRow = qMin(row, pixmaps.size());
|
endRow = qMin(row, pixmaps.size());
|
||||||
} else
|
} else {
|
||||||
endRow = parent.row();
|
endRow = parent.row();
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray encodedData = data->data("image/x-puzzle-piece");
|
QByteArray encodedData = data->data("image/x-puzzle-piece");
|
||||||
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
||||||
|
@ -79,4 +79,4 @@ private:
|
|||||||
int m_PieceSize;
|
int m_PieceSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // PIECESLIST_H
|
||||||
|
@ -38,10 +38,10 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtWidgets>
|
|
||||||
|
|
||||||
#include "puzzlewidget.h"
|
#include "puzzlewidget.h"
|
||||||
|
|
||||||
|
#include <QtWidgets>
|
||||||
|
|
||||||
PuzzleWidget::PuzzleWidget(int imageSize, QWidget *parent)
|
PuzzleWidget::PuzzleWidget(int imageSize, QWidget *parent)
|
||||||
: QWidget(parent), m_ImageSize(imageSize)
|
: QWidget(parent), m_ImageSize(imageSize)
|
||||||
{
|
{
|
||||||
@ -130,10 +130,9 @@ void PuzzleWidget::dropEvent(QDropEvent *event)
|
|||||||
int PuzzleWidget::findPiece(const QRect &pieceRect) const
|
int PuzzleWidget::findPiece(const QRect &pieceRect) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < pieceRects.size(); ++i) {
|
for (int i = 0; i < pieceRects.size(); ++i) {
|
||||||
if (pieceRect == pieceRects[i]) {
|
if (pieceRect == pieceRects[i])
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,8 +42,8 @@
|
|||||||
#define PUZZLEWIDGET_H
|
#define PUZZLEWIDGET_H
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QPoint>
|
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
#include <QPoint>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@ -86,4 +86,4 @@ private:
|
|||||||
int m_ImageSize;
|
int m_ImageSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // PUZZLEWIDGET_H
|
||||||
|
@ -38,10 +38,10 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtXml>
|
|
||||||
|
|
||||||
#include "domitem.h"
|
#include "domitem.h"
|
||||||
|
|
||||||
|
#include <QtXml>
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
DomItem::DomItem(QDomNode &node, int row, DomItem *parent)
|
DomItem::DomItem(QDomNode &node, int row, DomItem *parent)
|
||||||
{
|
{
|
||||||
|
@ -63,4 +63,4 @@ private:
|
|||||||
};
|
};
|
||||||
//! [0]
|
//! [0]
|
||||||
|
|
||||||
#endif
|
#endif // DOMITEM_H
|
||||||
|
@ -38,12 +38,11 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtWidgets>
|
|
||||||
#include <QtXml>
|
|
||||||
|
|
||||||
#include "domitem.h"
|
#include "domitem.h"
|
||||||
#include "dommodel.h"
|
#include "dommodel.h"
|
||||||
|
|
||||||
|
#include <QtXml>
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
DomModel::DomModel(QDomDocument document, QObject *parent)
|
DomModel::DomModel(QDomDocument document, QObject *parent)
|
||||||
: QAbstractItemModel(parent), domDocument(document)
|
: QAbstractItemModel(parent), domDocument(document)
|
||||||
|
@ -44,7 +44,6 @@
|
|||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <QDomDocument>
|
#include <QDomDocument>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <QVariant>
|
|
||||||
|
|
||||||
class DomItem;
|
class DomItem;
|
||||||
|
|
||||||
@ -73,4 +72,4 @@ private:
|
|||||||
};
|
};
|
||||||
//! [0]
|
//! [0]
|
||||||
|
|
||||||
#endif
|
#endif // DOMMODEL_H
|
||||||
|
@ -38,10 +38,10 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
@ -38,20 +38,19 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QDomDocument>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QtWidgets>
|
|
||||||
|
|
||||||
#include "dommodel.h"
|
#include "dommodel.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
#include <QDomDocument>
|
||||||
|
#include <QTreeView>
|
||||||
|
#include <QMenuBar>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
MainWindow::MainWindow() : QMainWindow(), model(0)
|
MainWindow::MainWindow() : QMainWindow(), model(0)
|
||||||
{
|
{
|
||||||
fileMenu = menuBar()->addMenu(tr("&File"));
|
fileMenu = menuBar()->addMenu(tr("&File"));
|
||||||
fileMenu->addAction(tr("&Open..."), this, SLOT(openFile()),
|
fileMenu->addAction(tr("&Open..."), this, SLOT(openFile()), QKeySequence::Open);
|
||||||
QKeySequence::Open);
|
fileMenu->addAction(tr("E&xit"), this, SLOT(close()), QKeySequence::Quit);
|
||||||
fileMenu->addAction(tr("E&xit"), this, SLOT(close()),
|
|
||||||
QKeySequence::Quit);
|
|
||||||
|
|
||||||
model = new DomModel(QDomDocument(), this);
|
model = new DomModel(QDomDocument(), this);
|
||||||
view = new QTreeView(this);
|
view = new QTreeView(this);
|
||||||
|
@ -67,4 +67,4 @@ private:
|
|||||||
QTreeView *view;
|
QTreeView *view;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // MAINWINDOW_H
|
||||||
|
@ -38,10 +38,12 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtWidgets>
|
|
||||||
|
|
||||||
#include "treemodel.h"
|
#include "treemodel.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QTreeView>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
Q_INIT_RESOURCE(simpletreemodel);
|
Q_INIT_RESOURCE(simpletreemodel);
|
||||||
|
@ -67,4 +67,4 @@ private:
|
|||||||
};
|
};
|
||||||
//! [0]
|
//! [0]
|
||||||
|
|
||||||
#endif
|
#endif // TREEITEM_H
|
||||||
|
@ -45,11 +45,11 @@
|
|||||||
models.
|
models.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QtWidgets>
|
|
||||||
|
|
||||||
#include "treeitem.h"
|
#include "treeitem.h"
|
||||||
#include "treemodel.h"
|
#include "treemodel.h"
|
||||||
|
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
TreeModel::TreeModel(const QString &data, QObject *parent)
|
TreeModel::TreeModel(const QString &data, QObject *parent)
|
||||||
: QAbstractItemModel(parent)
|
: QAbstractItemModel(parent)
|
||||||
@ -213,6 +213,6 @@ void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent)
|
|||||||
parents.last()->appendChild(new TreeItem(columnData, parents.last()));
|
parents.last()->appendChild(new TreeItem(columnData, parents.last()));
|
||||||
}
|
}
|
||||||
|
|
||||||
number++;
|
++number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,4 +73,4 @@ private:
|
|||||||
};
|
};
|
||||||
//! [0]
|
//! [0]
|
||||||
|
|
||||||
#endif
|
#endif // TREEMODEL_H
|
||||||
|
@ -38,10 +38,10 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
@ -38,10 +38,10 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtWidgets>
|
|
||||||
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
|
#include <QtWidgets>
|
||||||
|
|
||||||
//! [Set up widgets]
|
//! [Set up widgets]
|
||||||
Window::Window(QWidget *parent)
|
Window::Window(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
@ -69,12 +69,9 @@ Window::Window(QWidget *parent)
|
|||||||
mapper->addMapping(addressEdit, 1);
|
mapper->addMapping(addressEdit, 1);
|
||||||
mapper->addMapping(ageSpinBox, 2);
|
mapper->addMapping(ageSpinBox, 2);
|
||||||
|
|
||||||
connect(previousButton, SIGNAL(clicked()),
|
connect(previousButton, SIGNAL(clicked()), mapper, SLOT(toPrevious()));
|
||||||
mapper, SLOT(toPrevious()));
|
connect(nextButton, SIGNAL(clicked()), mapper, SLOT(toNext()));
|
||||||
connect(nextButton, SIGNAL(clicked()),
|
connect(mapper, SIGNAL(currentIndexChanged(int)), this, SLOT(updateButtons(int)));
|
||||||
mapper, SLOT(toNext()));
|
|
||||||
connect(mapper, SIGNAL(currentIndexChanged(int)),
|
|
||||||
this, SLOT(updateButtons(int)));
|
|
||||||
//! [Set up the mapper]
|
//! [Set up the mapper]
|
||||||
|
|
||||||
//! [Set up the layout]
|
//! [Set up the layout]
|
||||||
|
@ -81,4 +81,4 @@ private:
|
|||||||
};
|
};
|
||||||
//! [Window definition]
|
//! [Window definition]
|
||||||
|
|
||||||
#endif
|
#endif // WINDOW_H
|
||||||
|
@ -45,10 +45,9 @@
|
|||||||
using a spin box widget.
|
using a spin box widget.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QtWidgets>
|
|
||||||
|
|
||||||
#include "delegate.h"
|
#include "delegate.h"
|
||||||
|
|
||||||
|
#include <QSpinBox>
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
SpinBoxDelegate::SpinBoxDelegate(QObject *parent)
|
SpinBoxDelegate::SpinBoxDelegate(QObject *parent)
|
||||||
|
@ -42,10 +42,6 @@
|
|||||||
#define DELEGATE_H
|
#define DELEGATE_H
|
||||||
|
|
||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
#include <QModelIndex>
|
|
||||||
#include <QObject>
|
|
||||||
#include <QSize>
|
|
||||||
#include <QSpinBox>
|
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
class SpinBoxDelegate : public QStyledItemDelegate
|
class SpinBoxDelegate : public QStyledItemDelegate
|
||||||
|
@ -45,14 +45,13 @@
|
|||||||
data obtained from a model.
|
data obtained from a model.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "delegate.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QItemSelectionModel>
|
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
|
|
||||||
#include "delegate.h"
|
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -39,9 +39,10 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtWidgets/QApplication>
|
|
||||||
#include "spreadsheet.h"
|
#include "spreadsheet.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
Q_INIT_RESOURCE(spreadsheet);
|
Q_INIT_RESOURCE(spreadsheet);
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
@ -39,13 +39,13 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "printview.h"
|
|
||||||
|
|
||||||
#ifndef QT_NO_PRINTER
|
#ifndef QT_NO_PRINTER
|
||||||
#include <QPrinter>
|
#include <QPrinter>
|
||||||
#endif
|
#endif
|
||||||
#include <QStyleOptionViewItem>
|
#include <QStyleOptionViewItem>
|
||||||
|
|
||||||
|
#include "printview.h"
|
||||||
|
|
||||||
PrintView::PrintView()
|
PrintView::PrintView()
|
||||||
{
|
{
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
@ -168,10 +168,8 @@ void SpreadSheet::setupMenuBar()
|
|||||||
void SpreadSheet::updateStatus(QTableWidgetItem *item)
|
void SpreadSheet::updateStatus(QTableWidgetItem *item)
|
||||||
{
|
{
|
||||||
if (item && item == table->currentItem()) {
|
if (item && item == table->currentItem()) {
|
||||||
statusBar()->showMessage(item->data(Qt::StatusTipRole).toString(),
|
statusBar()->showMessage(item->data(Qt::StatusTipRole).toString(), 1000);
|
||||||
1000);
|
cellLabel->setText(tr("Cell: (%1)").arg(encode_pos(table->row(item), table->column(item))));
|
||||||
cellLabel->setText(tr("Cell: (%1)").arg(encode_pos(table->row(item),
|
|
||||||
table->column(item))));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,9 +234,10 @@ void SpreadSheet::selectColor()
|
|||||||
if (selected.count() == 0)
|
if (selected.count() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach(QTableWidgetItem *i, selected)
|
foreach (QTableWidgetItem *i, selected) {
|
||||||
if (i)
|
if (i)
|
||||||
i->setBackgroundColor(col);
|
i->setBackgroundColor(col);
|
||||||
|
}
|
||||||
|
|
||||||
updateColor(table->currentItem());
|
updateColor(table->currentItem());
|
||||||
}
|
}
|
||||||
@ -254,10 +253,11 @@ void SpreadSheet::selectFont()
|
|||||||
|
|
||||||
if (!ok)
|
if (!ok)
|
||||||
return;
|
return;
|
||||||
foreach(QTableWidgetItem *i, selected)
|
foreach (QTableWidgetItem *i, selected) {
|
||||||
if (i)
|
if (i)
|
||||||
i->setFont(fnt);
|
i->setFont(fnt);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool SpreadSheet::runInputDialog(const QString &title,
|
bool SpreadSheet::runInputDialog(const QString &title,
|
||||||
const QString &c1Text,
|
const QString &c1Text,
|
||||||
@ -407,7 +407,8 @@ void SpreadSheet::actionSum()
|
|||||||
if (runInputDialog(tr("Sum cells"), tr("First cell:"), tr("Last cell:"),
|
if (runInputDialog(tr("Sum cells"), tr("First cell:"), tr("Last cell:"),
|
||||||
QString("%1").arg(QChar(0x03a3)), tr("Output to:"),
|
QString("%1").arg(QChar(0x03a3)), tr("Output to:"),
|
||||||
&cell1, &cell2, &out)) {
|
&cell1, &cell2, &out)) {
|
||||||
int row, col;
|
int row;
|
||||||
|
int col;
|
||||||
decode_pos(out, &row, &col);
|
decode_pos(out, &row, &col);
|
||||||
table->item(row, col)->setText(tr("sum %1 %2").arg(cell1, cell2));
|
table->item(row, col)->setText(tr("sum %1 %2").arg(cell1, cell2));
|
||||||
}
|
}
|
||||||
@ -631,8 +632,7 @@ void SpreadSheet::print()
|
|||||||
QPrintPreviewDialog dlg(&printer);
|
QPrintPreviewDialog dlg(&printer);
|
||||||
PrintView view;
|
PrintView view;
|
||||||
view.setModel(table->model());
|
view.setModel(table->model());
|
||||||
connect(&dlg, SIGNAL(paintRequested(QPrinter*)),
|
connect(&dlg, SIGNAL(paintRequested(QPrinter*)), &view, SLOT(print(QPrinter*)));
|
||||||
&view, SLOT(print(QPrinter*)));
|
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "spreadsheetdelegate.h"
|
#include "spreadsheetdelegate.h"
|
||||||
|
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
|
|
||||||
SpreadSheetDelegate::SpreadSheetDelegate(QObject *parent)
|
SpreadSheetDelegate::SpreadSheetDelegate(QObject *parent)
|
||||||
@ -70,8 +71,7 @@ QWidget *SpreadSheetDelegate::createEditor(QWidget *parent,
|
|||||||
|
|
||||||
QCompleter *autoComplete = new QCompleter(allStrings);
|
QCompleter *autoComplete = new QCompleter(allStrings);
|
||||||
editor->setCompleter(autoComplete);
|
editor->setCompleter(autoComplete);
|
||||||
connect(editor, SIGNAL(editingFinished()),
|
connect(editor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()));
|
||||||
this, SLOT(commitAndCloseEditor()));
|
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,9 @@ void SpreadSheetDelegate::setEditorData(QWidget *editor,
|
|||||||
QLineEdit *edit = qobject_cast<QLineEdit*>(editor);
|
QLineEdit *edit = qobject_cast<QLineEdit*>(editor);
|
||||||
if (edit) {
|
if (edit) {
|
||||||
edit->setText(index.model()->data(index, Qt::EditRole).toString());
|
edit->setText(index.model()->data(index, Qt::EditRole).toString());
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QDateTimeEdit *dateEditor = qobject_cast<QDateTimeEdit *>(editor);
|
QDateTimeEdit *dateEditor = qobject_cast<QDateTimeEdit *>(editor);
|
||||||
if (dateEditor) {
|
if (dateEditor) {
|
||||||
dateEditor->setDate(QDate::fromString(
|
dateEditor->setDate(QDate::fromString(
|
||||||
@ -96,7 +98,6 @@ void SpreadSheetDelegate::setEditorData(QWidget *editor,
|
|||||||
"d/M/yyyy"));
|
"d/M/yyyy"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void SpreadSheetDelegate::setModelData(QWidget *editor,
|
void SpreadSheetDelegate::setModelData(QWidget *editor,
|
||||||
QAbstractItemModel *model, const QModelIndex &index) const
|
QAbstractItemModel *model, const QModelIndex &index) const
|
||||||
@ -104,11 +105,10 @@ void SpreadSheetDelegate::setModelData(QWidget *editor,
|
|||||||
QLineEdit *edit = qobject_cast<QLineEdit *>(editor);
|
QLineEdit *edit = qobject_cast<QLineEdit *>(editor);
|
||||||
if (edit) {
|
if (edit) {
|
||||||
model->setData(index, edit->text());
|
model->setData(index, edit->text());
|
||||||
} else {
|
return;
|
||||||
QDateTimeEdit *dateEditor = qobject_cast<QDateTimeEdit *>(editor);
|
|
||||||
if (dateEditor) {
|
|
||||||
model->setData(index, dateEditor->date().toString("dd/M/yyyy"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QDateTimeEdit *dateEditor = qobject_cast<QDateTimeEdit *>(editor);
|
||||||
|
if (dateEditor)
|
||||||
|
model->setData(index, dateEditor->date().toString("dd/M/yyyy"));
|
||||||
|
}
|
||||||
|
@ -42,9 +42,10 @@
|
|||||||
#ifndef SPREADSHEETDELEGATE_H
|
#ifndef SPREADSHEETDELEGATE_H
|
||||||
#define SPREADSHEETDELEGATE_H
|
#define SPREADSHEETDELEGATE_H
|
||||||
|
|
||||||
#include <QItemDelegate>
|
|
||||||
#include "spreadsheet.h"
|
#include "spreadsheet.h"
|
||||||
|
|
||||||
|
#include <QItemDelegate>
|
||||||
|
|
||||||
class SpreadSheetDelegate : public QItemDelegate
|
class SpreadSheetDelegate : public QItemDelegate
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -42,10 +42,10 @@
|
|||||||
#ifndef SPREADSHEETITEM_H
|
#ifndef SPREADSHEETITEM_H
|
||||||
#define SPREADSHEETITEM_H
|
#define SPREADSHEETITEM_H
|
||||||
|
|
||||||
#include <QTableWidgetItem>
|
|
||||||
#include <QtWidgets>
|
|
||||||
#include "spreadsheet.h"
|
#include "spreadsheet.h"
|
||||||
|
|
||||||
|
#include <QTableWidgetItem>
|
||||||
|
|
||||||
class SpreadSheetItem : public QTableWidgetItem
|
class SpreadSheetItem : public QTableWidgetItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -59,7 +59,9 @@ public:
|
|||||||
QVariant display() const;
|
QVariant display() const;
|
||||||
|
|
||||||
inline QString formula() const
|
inline QString formula() const
|
||||||
{ return QTableWidgetItem::data(Qt::DisplayRole).toString(); }
|
{
|
||||||
|
return QTableWidgetItem::data(Qt::DisplayRole).toString();
|
||||||
|
}
|
||||||
|
|
||||||
static QVariant computeFormula(const QString &formula,
|
static QVariant computeFormula(const QString &formula,
|
||||||
const QTableWidget *widget,
|
const QTableWidget *widget,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user