"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/backend/datasources/filters/QJsonModel.cpp" between
labplot-2.8.1.tar.gz and labplot-2.8.2.tar.gz

About: LabPlot is an application for plotting and analysis of 2D and 3D functions and data. It is a complete rewrite of LabPlot1 and lacks in the first release a lot of features available in the predecessor. On the other hand, the GUI and the usability is more superior.

QJsonModel.cpp  (labplot-2.8.1):QJsonModel.cpp  (labplot-2.8.2)
skipping to change at line 27 skipping to change at line 27
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*/ */
#include "QJsonModel.h" #include "QJsonModel.h"
#include "backend/lib/trace.h"
#include <QFile> #include <QFile>
#include <QMessageBox> #include <QMessageBox>
#include <QPainter>
#include <KLocalizedString> #include <KLocalizedString>
#include "backend/lib/trace.h"
QJsonTreeItem::QJsonTreeItem(QJsonTreeItem* parent) : mParent(parent) {} QJsonTreeItem::QJsonTreeItem(QJsonTreeItem* parent) : mParent(parent) {}
QJsonTreeItem::~QJsonTreeItem() { QJsonTreeItem::~QJsonTreeItem() {
qDeleteAll(mChildren); qDeleteAll(mChildren);
} }
void QJsonTreeItem::appendChild(QJsonTreeItem* item) { void QJsonTreeItem::appendChild(QJsonTreeItem* item) {
mChildren.append(item); mChildren.append(item);
} }
skipping to change at line 151 skipping to change at line 153
QJsonModel::QJsonModel(QObject* parent) : QAbstractItemModel(parent), QJsonModel::QJsonModel(QObject* parent) : QAbstractItemModel(parent),
mHeadItem(new QJsonTreeItem), mHeadItem(new QJsonTreeItem),
mRootItem(new QJsonTreeItem(mHeadItem)) { mRootItem(new QJsonTreeItem(mHeadItem)) {
mHeadItem->appendChild(mRootItem); mHeadItem->appendChild(mRootItem);
mHeaders.append(i18n("Key")); mHeaders.append(i18n("Key"));
mHeaders.append(i18n("Value")); mHeaders.append(i18n("Value"));
mHeaders.append(i18n("Size in Bytes")); mHeaders.append(i18n("Size in Bytes"));
//icons //icons
mObjectIcon = QIcon::fromTheme(QLatin1String("labplot-json-object")); QPainter painter;
mArrayIcon = QIcon::fromTheme(QLatin1String("labplot-json-array")); QPixmap pix(64, 64);
//dark theme is used -> invert the icons which use black colors QFont font;
if (qApp->palette().color(QPalette::Base).lightness() < 128) { font.setPixelSize(60);
//TODO: use different(standard?) pixel size?
QImage image = mObjectIcon.pixmap(64, 64).toImage(); const QColor& color = qApp->palette().color(QPalette::Text);
image.invertPixels(); painter.setPen(QPen(color));
mObjectIcon = QIcon(QPixmap::fromImage(image));
//draw the icon for JSON array
image = mArrayIcon.pixmap(64, 64).toImage(); pix.fill(QColor(Qt::transparent));
image.invertPixels(); painter.begin(&pix);
mArrayIcon = QIcon(QPixmap::fromImage(image)); painter.setFont(font);
} painter.drawText(pix.rect(), Qt::AlignCenter, QLatin1String("[ ]"));
painter.end();
mArrayIcon = QIcon(pix);
//draw the icon for JSON object
pix.fill(QColor(Qt::transparent));
painter.begin(&pix);
painter.setFont(font);
painter.drawText(pix.rect(), Qt::AlignCenter, QLatin1String("{ }"));
painter.end();
mObjectIcon = QIcon(pix);
} }
QJsonModel::~QJsonModel() { QJsonModel::~QJsonModel() {
//delete mRootItem; //delete mRootItem;
delete mHeadItem; delete mHeadItem;
} }
void QJsonModel::clear() { void QJsonModel::clear() {
beginResetModel(); beginResetModel();
delete mHeadItem; delete mHeadItem;
 End of changes. 5 change blocks. 
14 lines changed or deleted 26 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)