File: exportdialog.cc

package info (click to toggle)
calligra 1%3A25.04.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 309,164 kB
  • sloc: cpp: 667,890; xml: 126,105; perl: 2,724; python: 2,497; yacc: 1,817; ansic: 1,326; sh: 1,223; lex: 1,107; javascript: 495; makefile: 24
file content (93 lines) | stat: -rw-r--r-- 2,529 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* This file is part of the KDE project
   SPDX-FileCopyrightText: 2005 Bram Schoenmakers <bramschoenmakers@kde.nl>

   SPDX-License-Identifier: LGPL-2.0-or-later
*/

#include "exportdialog.h"

#include <QCheckBox>
#include <QComboBox>
#include <QListWidget>
#include <QRadioButton>
#include <QSpinBox>
#include <QApplication>
#include <QUrl>

ExportDialog::ExportDialog(QWidget *parent)
        : KoDialog(parent), m_mainwidget(new ExportWidget(this))
{
    setCaption(i18n("Export Sheet to HTML"));
    setButtons(Ok | Cancel);
    setDefaultButton(Cancel);
    QApplication::restoreOverrideCursor();

    connect(m_mainwidget->mCustomButton, &QAbstractButton::toggled,
            m_mainwidget->mCustomURL, &QWidget::setEnabled);
    connect(m_mainwidget->mSelectAllButton, &QAbstractButton::clicked, this, &ExportDialog::selectAll);
    connect(m_mainwidget->mDeselectAllButton, &QAbstractButton::clicked,
            m_mainwidget->mSheets, &QAbstractItemView::clearSelection);

    m_mainwidget->mCustomURL->setMode(KFile::ExistingOnly);

    setMainWidget(m_mainwidget);
}

void ExportDialog::selectAll()
{

    QListWidget *view = m_mainwidget->mSheets;
    QAbstractItemModel *model = view->model();
    QModelIndex topLeft = model->index(0, 0);
    QModelIndex bottomRight = model->index(model->rowCount() - 1, model->columnCount() - 1);
    QItemSelection selection(topLeft, bottomRight);
    view->selectionModel()->select(selection , QItemSelectionModel::QItemSelectionModel::Select);
}

ExportDialog::~ExportDialog()
{
    QApplication::setOverrideCursor(Qt::WaitCursor);
}

bool ExportDialog::useBorders() const
{
    return m_mainwidget->mUseBorders->isChecked();
}

bool ExportDialog::separateFiles() const
{
    return m_mainwidget->mSeparateFiles->isChecked();
}

QUrl ExportDialog::customStyleURL() const
{
    QUrl url = m_mainwidget->mCustomURL->url();
    if (m_mainwidget->mCustomButton->isChecked() && url.isValid())
        return url;

    return QUrl();
}

void ExportDialog::setSheets(const QStringList &list)
{
    m_mainwidget->mSheets->addItems(list);
    selectAll();
}

QStringList ExportDialog::sheets() const
{
    QListWidget* view = m_mainwidget->mSheets;
    QStringList list;
    for (uint i = 0; i < (uint)view->count() ; i++) {
        QListWidgetItem* item = view->item(i);
        if (item->isSelected()) {
            list.append(item->text());
        }
    }
    return list;
}

int ExportDialog::pixelsBetweenCells() const
{
    return m_mainwidget->mPixelsBetweenCells->value();
}