Exemplo n.º 1
0
//##############################################################################
//#########################  setter methods  ###################################
//##############################################################################
void DatapickerCurve::addDatasheet(const DatapickerImage::GraphType& type) {
	Q_D(DatapickerCurve);

	m_datasheet = new Spreadsheet(0, i18n("Data"));
	addChild(m_datasheet);
	QString xLabel('x');
	QString yLabel('y');

	if (type == DatapickerImage::PolarInDegree) {
		xLabel = "r";
		yLabel = "y(deg)";
	} else if (type == DatapickerImage::PolarInRadians) {
		xLabel = "r";
		yLabel = "y(rad)";
	} else if (type == DatapickerImage::LogarithmicX) {
		xLabel = "log(x)";
		yLabel = "y";
	} else if (type == DatapickerImage::LogarithmicY) {
		xLabel = "x";
		yLabel = "log(y)";
	}

	if (type == DatapickerImage::Ternary)
		d->posZColumn = appendColumn(i18n("c"));

	d->posXColumn = m_datasheet->column(0);
	d->posXColumn->setName(xLabel);

	d->posYColumn = m_datasheet->column(1);
	d->posYColumn->setName(yLabel);
}
Exemplo n.º 2
0
void DatapickerCurve::setCurveErrorTypes(const DatapickerCurve::Errors errors) {
	Q_D(DatapickerCurve);
	if (d->curveErrorTypes.x != errors.x || d->curveErrorTypes.y != errors.y) {
		beginMacro(i18n("%1: set xy-error type", name()));
		exec(new DatapickerCurveSetCurveErrorTypesCmd(d, errors, i18n("%1: set xy-error type")));

		if ( errors.x != NoError && !d->plusDeltaXColumn ) {
			setPlusDeltaXColumn(appendColumn(i18n("+delta_x")));
		} else if ( d->plusDeltaXColumn && errors.x == NoError ) {
			d->plusDeltaXColumn->remove();
			d->plusDeltaXColumn = 0;
		}

		if ( errors.x == AsymmetricError && !d->minusDeltaXColumn ) {
			setMinusDeltaXColumn(appendColumn(i18n("-delta_x")));
		} else if ( d->minusDeltaXColumn && errors.x != AsymmetricError ) {
			d->minusDeltaXColumn->remove();
			d->minusDeltaXColumn = 0;
		}

		if ( errors.y != NoError && !d->plusDeltaYColumn ) {
			setPlusDeltaYColumn(appendColumn(i18n("+delta_y")));
		} else if ( d->plusDeltaYColumn && errors.y == NoError ) {
			d->plusDeltaYColumn->remove();
			d->plusDeltaYColumn = 0;
		}

		if ( errors.y == AsymmetricError && !d->minusDeltaYColumn ) {
			setMinusDeltaYColumn(appendColumn(i18n("-delta_y")));
		} else if ( d->minusDeltaYColumn && errors.y != AsymmetricError ) {
			d->minusDeltaYColumn->remove();
			d->minusDeltaYColumn = 0;
		}

		endMacro();
	}
}
Exemplo n.º 3
0
 void appendColumn( std::shared_ptr<PrimaryKeySchema<T>> column )
 {
     appendColumn( static_cast<ColumnSchemaPtr>( column ) );
     m_primaryKey = column;
 }
Exemplo n.º 4
0
void LocationCompleterModel::refreshCompletions(const QString &string)
{
    if (m_lastCompletion == string) {
        refreshTabPositions();
        return;
    }

    m_lastCompletion = string;

    if (string.isEmpty()) {
        showMostVisited();
        return;
    }

    clear();

    Type showType = (Type) qzSettings->showLocationSuggestions;

    int limit = string.size() < 3 ? 25 : 15;
    QList<QUrl> urlList;
    QList<QStandardItem*> itemList;

    if (showType == HistoryAndBookmarks || showType == Bookmarks) {
        QSqlQuery query = createQuery(string, "history.count DESC", urlList, limit, true);
        query.exec();

        while (query.next()) {
            QStandardItem* item = new QStandardItem();
            const QUrl &url = query.value(1).toUrl();

            item->setIcon(qIconProvider->iconFromImage(QImage::fromData(query.value(4).toByteArray())));
            item->setText(url.toEncoded());
            item->setData(query.value(0), IdRole);
            item->setData(query.value(2), TitleRole);
            item->setData(query.value(3), CountRole);
            item->setData(QVariant(true), BookmarkRole);
            item->setData(string, SearchStringRole);
            if (qzSettings->showSwitchTab) {
                item->setData(QVariant::fromValue<TabPosition>(tabPositionForUrl(url)), TabPositionRole);
            }

            urlList.append(url);
            itemList.append(item);
        }

        limit -= query.size();
    }

    if (showType == HistoryAndBookmarks || showType == History) {
        QSqlQuery query = createQuery(string, "count DESC", urlList, limit);
        query.exec();

        while (query.next()) {
            QStandardItem* item = new QStandardItem();
            const QUrl &url = query.value(1).toUrl();

            item->setIcon(_iconForUrl(url));
            item->setText(url.toEncoded());
            item->setData(query.value(0), IdRole);
            item->setData(query.value(2), TitleRole);
            item->setData(query.value(3), CountRole);
            item->setData(QVariant(false), BookmarkRole);
            item->setData(string, SearchStringRole);
            if (qzSettings->showSwitchTab) {
                item->setData(QVariant::fromValue<TabPosition>(tabPositionForUrl(url)), TabPositionRole);
            }

            itemList.append(item);
        }
    }

    // Sort by count
    qSort(itemList.begin(), itemList.end(), countBiggerThan);

    appendColumn(itemList);
}
Exemplo n.º 5
0
LiveViewWindow::LiveViewWindow(DVRServerRepository *serverRepository, QWidget *parent, bool openfs, Qt::WindowFlags f)
    : QWidget(parent, f), m_liveView(0), m_serverRepository(serverRepository), m_savedLayouts(new QComboBox),
      m_lastLayoutIndex(-1), m_autoSized(false), m_isLayoutChanging(false),
	  m_wasOpenedFs(openfs)
{
    QBoxLayout *layout = new QVBoxLayout(this);
    layout->setMargin(0);
    layout->setSpacing(0);

	m_toolBar = new QToolBar(tr("Live View"));
	m_toolBar->setIconSize(QSize(16, 16));
	m_toolBar->setMovable(false);

#ifndef Q_OS_MAC
    //toolBar->setStyleSheet(QLatin1String("QToolBar { border: none; }"));
#endif

    m_liveView = new LiveViewArea(m_serverRepository);
    LiveViewLayout *viewLayout = m_liveView->layout();

    /* Saved layouts box */
    m_savedLayouts->setModel(SavedLayoutsModel::instance());
    m_savedLayouts->setSizeAdjustPolicy(QComboBox::AdjustToContents);
    m_savedLayouts->setInsertPolicy(QComboBox::NoInsert);
    m_savedLayouts->setMinimumWidth(100);
    m_savedLayouts->setContextMenuPolicy(Qt::CustomContextMenu);
    m_savedLayouts->setCurrentIndex(-1);
    m_savedLayouts->setMaxVisibleItems(22);
	m_toolBar->addWidget(m_savedLayouts);

    QWidget *spacer = new QWidget;
    spacer->setFixedWidth(20);
	m_toolBar->addWidget(spacer);

	aNewLayout = m_toolBar->addAction(QIcon(QLatin1String(":/icons/plus.png")), tr("New Layout"), this, SLOT(createNewLayout()));
	aRenameLayout = m_toolBar->addAction(QIcon(QLatin1String(":/icons/pencil.png")), tr("Rename Layout"), this, SLOT(renameLayout()));
	aDelLayout = m_toolBar->addAction(QIcon(QLatin1String(":/icons/cross.png")), tr("Delete Layout"), this, SLOT(deleteCurrentLayout()));

    aRenameLayout->setEnabled(false);
    aDelLayout->setEnabled(false);

    spacer = new QWidget;
    spacer->setFixedWidth(16);
	m_toolBar->addWidget(spacer);

    connect(m_savedLayouts, SIGNAL(currentIndexChanged(int)), SLOT(savedLayoutChanged(int)));
    connect(m_savedLayouts, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showLayoutMenu(QPoint)));

	m_addRowAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-split-vertical.png")),
                     tr("Add Row"), viewLayout, SLOT(appendRow()));
	m_removeRowAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-join-vertical.png")),
                        tr("Remove Row"), viewLayout, SLOT(removeRow()));

    spacer = new QWidget;
    spacer->setFixedWidth(16);
	m_toolBar->addWidget(spacer);

	m_addColumnAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-split.png")),
                        tr("Add Column"), viewLayout, SLOT(appendColumn()));
	m_removeColumnAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-join.png")),
                           tr("Remove Column"), viewLayout, SLOT(removeColumn()));

    spacer = new QWidget;
    spacer->setFixedWidth(16);
	m_toolBar->addWidget(spacer);

    QSignalMapper *mapper = new QSignalMapper(this);
    connect(mapper, SIGNAL(mapped(int)), viewLayout, SLOT(setGridSize(int)));

	m_singleAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout.png")),
                                    tr("Single"), mapper, SLOT(map()));
	mapper->setMapping(m_singleAction, 1);
	QAction *a = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-4.png")),
                           tr("2x2"), mapper, SLOT(map()));
    mapper->setMapping(a, 2);
	a = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-9.png")),
                           tr("3x3"), mapper, SLOT(map()));
    mapper->setMapping(a, 3);
	a = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-16.png")),
                           tr("4x4"), mapper, SLOT(map()));
    mapper->setMapping(a, 4);

    spacer = new QWidget;
    spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
	m_toolBar->addWidget(spacer);

	m_fullscreenAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/application-resize-full.png")),
                       tr("Fullscreen"), this, SLOT(toggleFullScreen()));
	m_fullscreenAction->setShortcut(Qt::Key_F11);

    if (m_wasOpenedFs)
    {
		m_closeAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/cross.png")), tr("Exit"),
                           this, SLOT(close()));
        new QShortcut(Qt::Key_Escape, this, SLOT(close()), 0, Qt::WindowShortcut);
    }
    else
        new QShortcut(Qt::Key_Escape, this, SLOT(exitFullScreen()), 0, Qt::WindowShortcut);

    connect(m_liveView->layout(), SIGNAL(layoutChanged()), SLOT(updateLayoutActionStates()));
    connect(m_liveView->layout(), SIGNAL(layoutChanged()), SLOT(saveLayout()));

    QMainWindow *wnd = qobject_cast<QMainWindow*>(window());
    if (wnd)
		wnd->addToolBar(Qt::TopToolBarArea, m_toolBar);
    else
		layout->addWidget(m_toolBar);
    layout->addWidget(m_liveView);

    updateLayoutActionStates();
}