Exemplo n.º 1
0
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false),
	currentHeaderClicked(-1), searchBox(new QLineEdit(this))
{
	setUniformRowHeights(true);
	setItemDelegateForColumn(TreeItemDT::RATING, new StarWidgetsDelegate());
	QSortFilterProxyModel *model = new QSortFilterProxyModel(this);
	model->setSortRole(TreeItemDT::SORT_ROLE);
	model->setFilterKeyColumn(-1); // filter all columns
	setModel(model);
	connect(model, SIGNAL(layoutChanged()), this, SLOT(fixMessyQtModelBehaviour()));

	setSortingEnabled(false);
	setContextMenuPolicy(Qt::DefaultContextMenu);
	header()->setContextMenuPolicy(Qt::ActionsContextMenu);
	QAction *showSearchBox = new QAction(tr("Show Search Box"), this);
	showSearchBox->setShortcut( Qt::CTRL + Qt::Key_F);
	showSearchBox->setShortcutContext(Qt::ApplicationShortcut);
	addAction(showSearchBox);

	searchBox->installEventFilter(this);
	searchBox->hide();
	connect(showSearchBox, SIGNAL(triggered(bool)), this, SLOT(showSearchEdit()));
	connect(searchBox, SIGNAL(textChanged(QString)), model, SLOT(setFilterFixedString(QString)));
	selectedTrips.clear();
}
Exemplo n.º 2
0
    SpeedLimitsDlg::SpeedLimitsDlg(bt::TorrentInterface* current, Core* core, QWidget* parent)
        : QDialog(parent), core(core), current(current)
    {
        setupUi(this);
        setWindowIcon(QIcon::fromTheme("kt-speed-limits"));
        setWindowTitle(i18n("Speed Limits"));

        model = new SpeedLimitsModel(core, this);
        QSortFilterProxyModel* pm = new QSortFilterProxyModel(this);
        pm->setSourceModel(model);
        pm->setSortRole(Qt::UserRole);

        m_speed_limits_view->setModel(pm);
        m_speed_limits_view->setItemDelegate(new SpinBoxDelegate(this));
        m_speed_limits_view->setUniformRowHeights(true);
        m_speed_limits_view->setSortingEnabled(true);
        m_speed_limits_view->sortByColumn(0, Qt::AscendingOrder);
        m_speed_limits_view->header()->setSortIndicatorShown(true);
        m_speed_limits_view->header()->setClickable(true);
        m_speed_limits_view->setAlternatingRowColors(true);

        QPushButton* apply_btn = m_buttonBox->button(QDialogButtonBox::Apply);
        apply_btn->setEnabled(false);
        connect(model, &SpeedLimitsModel::enableApply, apply_btn, &QPushButton::setEnabled);
        connect(apply_btn, &QPushButton::clicked, this, &SpeedLimitsDlg::apply);
        connect(m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
        connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);

        m_upload_rate->setValue(Settings::maxUploadRate());
        m_download_rate->setValue(Settings::maxDownloadRate());
        connect(m_upload_rate, SIGNAL(valueChanged(int)), this, SLOT(spinBoxValueChanged(int)));
        connect(m_download_rate, SIGNAL(valueChanged(int)), this, SLOT(spinBoxValueChanged(int)));
        connect(m_filter, SIGNAL(textChanged(QString)), pm, SLOT(setFilterFixedString(QString)));
        loadState();

        // if current is specified, select it and scroll to it
        if (current)
        {
            kt::QueueManager* qman = core->getQueueManager();
            int idx = 0;
            QList<bt::TorrentInterface*>::iterator itr = qman->begin();
            while (itr != qman->end())
            {
                if (*itr == current)
                    break;

                idx++;
                itr++;
            }

            if (itr != qman->end())
            {
                QItemSelectionModel* sel = m_speed_limits_view->selectionModel();
                QModelIndex midx = pm->mapFromSource(model->index(idx, 0));
                QModelIndex midx2 = pm->mapFromSource(model->index(idx, 4));
                sel->select(QItemSelection(midx, midx2), QItemSelectionModel::Select);
                m_speed_limits_view->scrollTo(midx);
            }
        }
    }
void run_ui()
{
	qmlRegisterType<QMLManager>("org.subsurfacedivelog.mobile", 1, 0, "QMLManager");
	qmlRegisterType<QMLProfile>("org.subsurfacedivelog.mobile", 1, 0, "QMLProfile");
	QQmlApplicationEngine engine;
	engine.addImportPath("qrc://imports");
	DiveListModel diveListModel;
	QSortFilterProxyModel *sortModel = new QSortFilterProxyModel(0);
	sortModel->setSourceModel(&diveListModel);
	sortModel->setDynamicSortFilter(true);
	sortModel->setSortRole(DiveListModel::DiveDateRole);
	sortModel->sort(0, Qt::DescendingOrder);
	QQmlContext *ctxt = engine.rootContext();
	ctxt->setContextProperty("diveModel", sortModel);
	engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml")));
	qqWindowObject = engine.rootObjects().value(0);
	if (!qqWindowObject) {
		fprintf(stderr, "can't create window object\n");
		exit(1);
	}
	QQuickWindow *qml_window = qobject_cast<QQuickWindow *>(qqWindowObject);
	qml_window->setIcon(QIcon(":/subsurface-mobile-icon"));
	qqWindowObject->setProperty("messageText", QVariant("Subsurface mobile startup"));
#if !defined(Q_OS_ANDROID)
	qml_window->setHeight(1200);
	qml_window->setWidth(800);
#endif
	qml_window->show();
	qApp->exec();
}
Exemplo n.º 4
0
/** Constructor */
GxsIdChooser::GxsIdChooser(QWidget *parent)
    : QComboBox(parent), mFlags(IDCHOOSER_ANON_DEFAULT)
{
	mBase = new RsGxsUpdateBroadcastBase(rsIdentity, this);
	connect(mBase, SIGNAL(fillDisplay(bool)), this, SLOT(fillDisplay(bool)));

	/* Initialize ui */
	setSizeAdjustPolicy(QComboBox::AdjustToContents);

	mFirstLoad = true;
    	mAllowedCount = 0 ;

	mDefaultId.clear() ;

	/* Enable sort with own role */
	QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this);
	proxy->setSourceModel(model());
	proxy->setDynamicSortFilter(false);
	model()->setParent(proxy);
	setModel(proxy);

	proxy->setSortRole(ROLE_SORT);

	/* Connect signals */
	connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(myCurrentIndexChanged(int)));
	connect(this, SIGNAL(activated(int)), this, SLOT(indexActivated(int)));
}
Exemplo n.º 5
0
void MethodsTab::setObjectBaseName(const QString &baseName)
{
    m_objectBaseName = baseName;

    auto clientModel = new ClientMethodModel(this);
    clientModel->setSourceModel(ObjectBroker::model(baseName + '.' + "methods"));

    QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this);
    proxy->setDynamicSortFilter(true);
    proxy->setSourceModel(clientModel);
    proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
    proxy->setSortRole(ObjectMethodModelRole::MethodSortRole);
    m_ui->methodView->setModel(proxy);
    m_ui->methodView->sortByColumn(0, Qt::AscendingOrder);
    m_ui->methodView->setSelectionModel(ObjectBroker::selectionModel(proxy));
    m_ui->methodView->header()->setResizeMode(QHeaderView::ResizeToContents);
    new SearchLineController(m_ui->methodSearchLine, proxy);
    connect(m_ui->methodView, SIGNAL(doubleClicked(QModelIndex)),
            SLOT(methodActivated(QModelIndex)));
    connect(m_ui->methodView, SIGNAL(customContextMenuRequested(QPoint)),
            SLOT(methodContextMenu(QPoint)));
    m_ui->methodLog->setModel(ObjectBroker::model(baseName + '.' + "methodLog"));

    m_interface = ObjectBroker::object<MethodsExtensionInterface *>(baseName + ".methodsExtension");
    new PropertyBinder(m_interface, "hasObject", m_ui->methodLog, "visible");
}
Exemplo n.º 6
0
NoteBrowser::NoteBrowser(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f)
{
    m_model = new NotesModel( this );

    QSortFilterProxyModel * sortingModel = new QSortFilterProxyModel( this );
    sortingModel->setSourceModel( m_model );
    sortingModel->setSortRole( m_model->roleForProperty( NAO::created() ) );
    sortingModel->setDynamicSortFilter( true );
    sortingModel->sort( 0, Qt::DescendingOrder );

    m_view = new NotesView( this );
    m_view->setModel( sortingModel );

    connect( m_view, SIGNAL(doubleClicked(QModelIndex)),
             this, SLOT(slotNoteSelected(QModelIndex)) );

    Nepomuk2::Query::ResourceTypeTerm typeTerm( Nepomuk2::Types::Class( PIMO::Note() ) );
    Nepomuk2::Query::ComparisonTerm compTerm( NAO::created(), Nepomuk2::Query::Term() );
    compTerm.setSortWeight( 1, Qt::DescendingOrder );

    m_query = typeTerm && compTerm;

    //FIXME: Figure out why this stupid layout is required!
    QHBoxLayout* layout = new QHBoxLayout( this );
    layout->setMargin( 0 );
    layout->setSpacing( 0 );

    layout->addWidget( m_view );
}
int main(int argc, char *argv[])
{
    qmlRegisterType<Recorder>("harbour.recorder", 1, 0, "Recorder");
    qmlRegisterType<DirectoryModel>("harbour.recorder", 1, 0, "DirectoryModel");

    auto app = SailfishApp::application(argc, argv);

    QCoreApplication::setOrganizationName("harbour-recorder");
    QCoreApplication::setOrganizationDomain("www.corne.info");
    QCoreApplication::setApplicationName("Recorder");

    auto view = SailfishApp::createView();
    auto context = view->rootContext();

    Recorder recorder;
    context->setContextProperty("recorder", &recorder);

    RecordingsModel sourceModel;
    sourceModel.setRecorder(&recorder);
    QSortFilterProxyModel recordingsModel;
    recordingsModel.setSourceModel(&sourceModel);
    recordingsModel.setSortRole(RecordingsModel::Modified);
    recordingsModel.setDynamicSortFilter(true);
    recordingsModel.sort(0, Qt::DescendingOrder);
    context->setContextProperty("recordingsModel", &recordingsModel);

    view->setSource(SailfishApp::pathTo("qml/harbour-recorder.qml"));
    view->show();
    return app->exec();
}
Exemplo n.º 8
0
MainWidget::MainWidget( MainWindow * parent ) :
        QWidget( parent ), mMainWindow( parent )
{
    QVBoxLayout *layout = new QVBoxLayout( this );

    QSplitter *splitter = new QSplitter( Qt::Vertical, this );
    layout->addWidget( splitter );


    // Accounts
    Akonadi::AgentInstanceModel *model = new Akonadi::AgentInstanceModel( this );
    m_resourcesView = new QListView( splitter );
    m_resourcesView->setModel( model );
    connect( m_resourcesView, SIGNAL( clicked( const QModelIndex& ) ),
             SLOT( slotCurrentResourceChanged( const QModelIndex& ) ) );
    splitter->addWidget( m_resourcesView );
    
    // Filter the collection to only show the blogs
    Akonadi::AgentFilterProxyModel* proxy = new Akonadi::AgentFilterProxyModel( this );
    proxy->addMimeTypeFilter( "application/x-vnd.kde.microblog" );
    proxy->setSourceModel( model );
    m_resourcesView->setModel( proxy );

    // Bottom part
    KVBox* box = new KVBox( splitter );

    // Folders
    m_tabBar = new AkonadiTabBar( box );
    connect( m_tabBar, SIGNAL( currentChanged( const Akonadi::Collection& ) ),
             SLOT( slotCurrentTabChanged( const Akonadi::Collection& ) ) );

    mMessageList = new QTreeView( box );
    mMessageList->setRootIsDecorated( false );
    mMessageList->setDragEnabled( false );
    mMessageList->setSelectionMode( QAbstractItemView::ExtendedSelection );
    mMessageList->setSortingEnabled( true );

    MicroblogDelegate *delegate = new MicroblogDelegate( mMessageList, this );
    mMessageList->setItemDelegate( delegate );

    mMessageModel = new BlogModel( this );

    QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel( this );
    proxyModel->setSortRole( Qt::EditRole );
    proxyModel->setDynamicSortFilter( true );
    proxyModel->setSourceModel( mMessageModel );

    mMessageList->setModel( proxyModel );
    splitter->addWidget( box );

    splitter->setSizes( QList<int>() << 30 << 470 );
}
PreviewsSettingsPage::PreviewsSettingsPage(QWidget* parent) :
    SettingsPageBase(parent),
    m_initialized(false),
    m_listView(0),
    m_enabledPreviewPlugins(),
    m_remoteFileSizeBox(0)
{
    QVBoxLayout* topLayout = new QVBoxLayout(this);

    QLabel* showPreviewsLabel = new QLabel(i18nc("@title:group", "Show previews for:"), this);

    m_listView = new QListView(this);

    ServiceItemDelegate* delegate = new ServiceItemDelegate(m_listView, m_listView);
    connect(delegate, SIGNAL(requestServiceConfiguration(QModelIndex)),
            this, SLOT(configureService(QModelIndex)));

    ServiceModel* serviceModel = new ServiceModel(this);
    QSortFilterProxyModel* proxyModel = new QSortFilterProxyModel(this);
    proxyModel->setSourceModel(serviceModel);
    proxyModel->setSortRole(Qt::DisplayRole);

    m_listView->setModel(proxyModel);
    m_listView->setItemDelegate(delegate);
    m_listView->setVerticalScrollMode(QListView::ScrollPerPixel);

    QLabel* remoteFileSizeLabel = new QLabel(i18nc("@label", "Skip previews for remote files above:"), this);

    m_remoteFileSizeBox = new KIntSpinBox(this);
    m_remoteFileSizeBox->setSingleStep(1);
    m_remoteFileSizeBox->setSuffix(QLatin1String(" MB"));
    m_remoteFileSizeBox->setRange(0, 9999999); /* MB */

    QHBoxLayout* fileSizeBoxLayout = new QHBoxLayout(this);
    fileSizeBoxLayout->addWidget(remoteFileSizeLabel, 0, Qt::AlignRight);
    fileSizeBoxLayout->addWidget(m_remoteFileSizeBox);

    topLayout->addSpacing(KDialog::spacingHint());
    topLayout->addWidget(showPreviewsLabel);
    topLayout->addWidget(m_listView);
    topLayout->addLayout(fileSizeBoxLayout);

    loadSettings();

    connect(m_listView, SIGNAL(clicked(QModelIndex)), this, SIGNAL(changed()));
    connect(m_remoteFileSizeBox, SIGNAL(valueChanged(int)), this, SIGNAL(changed()));
}
Exemplo n.º 10
0
IssueSelector::IssueSelector( SimpleRedmineClient* redmine, MainWindow* mainWindow )
    : Window( "qrc:/IssueSelector.qml", mainWindow ),
      redmine_( redmine )
{
    ENTER();

    // Issue selector window initialisation
    setModality( Qt::ApplicationModal );
    setFlags( Qt::Dialog );
    setTitle( "Issue Selector" );

    // Set the models
    issuesProxyModel_.setSourceModel( &issuesModel_ );
    issuesProxyModel_.setSortRole( IssueModel::IssueRoles::IdRole );
    issuesProxyModel_.setDynamicSortFilter( true );
    issuesProxyModel_.setFilterCaseSensitivity( Qt::CaseInsensitive );
    issuesProxyModel_.setFilterRole( IssueModel::IssueRoles::SubjectRole );
    ctx_->setContextProperty( "issuesModel", &issuesProxyModel_ );

    QSortFilterProxyModel* projectProxyModel = new QSortFilterProxyModel( this );
    projectProxyModel->setSourceModel( &projectModel_ );
    projectProxyModel->setSortRole( SimpleModel::SimpleRoles::IdRole );
    projectProxyModel->setDynamicSortFilter( true );
    ctx_->setContextProperty( "projectModel", projectProxyModel );

    // Connect the project selected signal to the projectSelected slot
    connect( qml("project"), SIGNAL(activated(int)), this, SLOT(projectSelected(int)) );

    // Connect the issue selected signal to the issueSelected slot
    connect( qml("issues"), SIGNAL(activated(int)), this, SLOT(issueSelected(int)) );

    // Connect the search accepted signal to the filterIssues slot
    connect( qml("search"), SIGNAL(textChanged()), this, SLOT(filterIssues()) );

    // Connect the closed signal to the close slot
    connect( this, &Window::closed, [=](){ close(); } );

    RETURN();
}
Exemplo n.º 11
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    BookModel bookModel;

    QSortFilterProxyModel proxy;
    proxy.setSourceModel(&bookModel);

    proxy.setFilterRole(BookModel::NameRole);
    proxy.setFilterCaseSensitivity(Qt::CaseInsensitive);

    proxy.setSortRole(BookModel::NameRole);
    proxy.setDynamicSortFilter(true);
    proxy.sort(0);


    QDeclarativeView view;
    view.rootContext()->setContextProperty("bookModel", &proxy);
    view.setSource(QUrl::fromLocalFile("main.qml"));
    view.show();

    return app.exec();
}
Exemplo n.º 12
0
void DlgPrefController::slotPresetLoaded(ControllerPresetPointer preset) {
    m_ui.labelLoadedPreset->setText(presetName(preset));
    m_ui.labelLoadedPresetDescription->setText(presetDescription(preset));
    m_ui.labelLoadedPresetAuthor->setText(presetAuthor(preset));
    QStringList supportLinks;

    QString forumLink = presetForumLink(preset);
    if (forumLink.length() > 0) {
        supportLinks << forumLink;
    }

    QString wikiLink = presetWikiLink(preset);
    if (wikiLink.length() > 0) {
        supportLinks << wikiLink;
    }

    // There is always at least one support link.
    // TODO(rryan): This is a horrible general support link for MIDI!
    QString troubleShooting = QString(
        "<a href=\"http://mixxx.org/wiki/doku.php/midi_scripting\">%1</a>")
            .arg(tr("Troubleshooting"));
    supportLinks << troubleShooting;

    QString support = supportLinks.join("&nbsp;");
    m_ui.labelLoadedPresetSupportLinks->setText(support);

    // We mutate this preset so keep a reference to it while we are using it.
    // TODO(rryan): Clone it? Technically a waste since nothing else uses this
    // copy but if someone did they might not expect it to change.
    m_pPreset = preset;

    ControllerInputMappingTableModel* pInputModel =
            new ControllerInputMappingTableModel(this);
    // If the model reports changes, mark ourselves as dirty.
    connect(pInputModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
            this, SLOT(slotDirty()));
    connect(pInputModel, SIGNAL(rowsInserted(QModelIndex, int, int)),
            this, SLOT(slotDirty()));
    connect(pInputModel, SIGNAL(rowsRemoved(QModelIndex, int, int)),
            this, SLOT(slotDirty()));
    pInputModel->setPreset(preset);

    QSortFilterProxyModel* pInputProxyModel = new QSortFilterProxyModel(this);
    pInputProxyModel->setSortRole(Qt::UserRole);
    pInputProxyModel->setSourceModel(pInputModel);
    m_ui.m_pInputMappingTableView->setModel(pInputProxyModel);

    for (int i = 0; i < pInputModel->columnCount(); ++i) {
        QAbstractItemDelegate* pDelegate = pInputModel->delegateForColumn(
            i, m_ui.m_pInputMappingTableView);
        if (pDelegate != NULL) {
            qDebug() << "Setting input delegate for column" << i << pDelegate;
            m_ui.m_pInputMappingTableView->setItemDelegateForColumn(i, pDelegate);
        }
    }

    // Now that we have set the new model our old model can be deleted.
    delete m_pInputProxyModel;
    m_pInputProxyModel = pInputProxyModel;
    delete m_pInputTableModel;
    m_pInputTableModel = pInputModel;

    ControllerOutputMappingTableModel* pOutputModel =
            new ControllerOutputMappingTableModel(this);
    pOutputModel->setPreset(preset);

    QSortFilterProxyModel* pOutputProxyModel = new QSortFilterProxyModel(this);
    pOutputProxyModel->setSortRole(Qt::UserRole);
    pOutputProxyModel->setSourceModel(pOutputModel);
    m_ui.m_pOutputMappingTableView->setModel(pOutputProxyModel);

    for (int i = 0; i < pOutputModel->columnCount(); ++i) {
        QAbstractItemDelegate* pDelegate = pOutputModel->delegateForColumn(
            i, m_ui.m_pOutputMappingTableView);
        if (pDelegate != NULL) {
            qDebug() << "Setting output delegate for column" << i << pDelegate;
            m_ui.m_pOutputMappingTableView->setItemDelegateForColumn(i, pDelegate);
        }
    }

    // Now that we have set the new model our old model can be deleted.
    delete m_pOutputProxyModel;
    m_pOutputProxyModel = pOutputProxyModel;
    delete m_pOutputTableModel;
    m_pOutputTableModel = pOutputModel;

    // Populate the script tab with the scripts this preset uses.
    m_ui.m_pScriptsTableWidget->setRowCount(preset->scripts.length());
    m_ui.m_pScriptsTableWidget->setColumnCount(3);
    m_ui.m_pScriptsTableWidget->setHorizontalHeaderItem(
        0, new QTableWidgetItem(tr("Filename")));
    m_ui.m_pScriptsTableWidget->setHorizontalHeaderItem(
        1, new QTableWidgetItem(tr("Function Prefix")));
    m_ui.m_pScriptsTableWidget->setHorizontalHeaderItem(
        2, new QTableWidgetItem(tr("Built-in")));
    m_ui.m_pScriptsTableWidget->horizontalHeader()
            ->setResizeMode(QHeaderView::Stretch);

    for (int i = 0; i < preset->scripts.length(); ++i) {
        const ControllerPreset::ScriptFileInfo& script = preset->scripts.at(i);

        QTableWidgetItem* pScriptName = new QTableWidgetItem(script.name);
        m_ui.m_pScriptsTableWidget->setItem(i, 0, pScriptName);
        pScriptName->setFlags(pScriptName->flags() & ~Qt::ItemIsEditable);

        QTableWidgetItem* pScriptPrefix = new QTableWidgetItem(
                script.functionPrefix);
        m_ui.m_pScriptsTableWidget->setItem(i, 1, pScriptPrefix);

        // If the script is built-in don't allow editing of the prefix.
        if (script.builtin) {
            pScriptPrefix->setFlags(pScriptPrefix->flags() & ~Qt::ItemIsEditable);
        }

        QTableWidgetItem* pScriptBuiltin = new QTableWidgetItem();
        pScriptBuiltin->setCheckState(script.builtin ? Qt::Checked : Qt::Unchecked);
        pScriptBuiltin->setFlags(pScriptBuiltin->flags() & ~(Qt::ItemIsEnabled |
                                                             Qt::ItemIsEditable |
                                                             Qt::ItemIsUserCheckable));
        m_ui.m_pScriptsTableWidget->setItem(i, 2, pScriptBuiltin);
    }
}
Exemplo n.º 13
0
void IntroPage::createLayout()
{
	QSortFilterProxyModel * mdl = new QSortFilterProxyModel;
	mdl->setDynamicSortFilter(true);
	mdl->setSourceModel(new UDevSerialPortModel);
	mdl->setSortRole(Qt::DisplayRole);
	mdl->setSortCaseSensitivity(Qt::CaseInsensitive);
	mdl->sort(0, Qt::AscendingOrder);

	m_cbxType = new WizardComboBox();
	QLabel * lblType = new QLabel(tr("Dive Computer &Driver:"));
	lblType->setBuddy(m_cbxType);

	m_cbxModel = new WizardComboBox();
	m_lblModel = new QLabel(tr("Dive Computer &Model:"));
	m_lblModel->setBuddy(m_cbxModel);

	m_cbxDevice = new WizardComboBox();
	m_cbxDevice->setModel(mdl);
	m_lblDevice = new QLabel(tr("&Serial Port:"));
	m_lblDevice->setBuddy(m_cbxDevice);

	m_txtParams = new QLineEdit(this);
	m_txtParams->setHidden(true);

	m_txtSerial = new QLineEdit(this);
	m_txtSerial->setHidden(true);

	m_txtManuf = new QLineEdit(this);
	m_txtManuf->setHidden(true);

	m_txtModel = new QLineEdit(this);
	m_txtModel->setHidden(true);

	QPushButton * btnParams = new QPushButton(tr("Configure Connection"));
	btnParams->setToolTip(tr("Edit Driver Arguments"));
	connect(btnParams, SIGNAL(clicked()), this, SLOT(btnParamsClicked()));

	std::list<plugin_manifest_t>::const_iterator it;
	for (it = m_registry->plugins().begin(); it != m_registry->plugins().end(); it++)
	{
		std::list<driver_manifest_t>::const_iterator itd;
		for (itd = it->plugin_drivers.begin(); itd != it->plugin_drivers.end(); itd++)
			m_cbxType->addItem(QString::fromStdString(itd->driver_desc), QVariant(QString::fromStdString(itd->driver_name)));
	}

	updateModels(0);
	connect(m_cbxType, SIGNAL(currentIndexChanged(int)), this, SLOT(updateModels(int)));

	QGridLayout * gbox = new QGridLayout();
	gbox->addWidget(lblType, 0, 0);
	gbox->addWidget(m_cbxType, 0, 1);
	gbox->addWidget(m_lblModel, 1, 0);
	gbox->addWidget(m_cbxModel, 1, 1);
	gbox->addWidget(m_lblDevice, 2, 0);
	gbox->addWidget(m_cbxDevice, 2, 1);
	gbox->setColumnStretch(1, 1);

	QHBoxLayout * hbox = new QHBoxLayout();
	hbox->addStretch();
	hbox->addWidget(btnParams);

	QVBoxLayout * vbox = new QVBoxLayout();
	vbox->addLayout(gbox);
	vbox->addStretch();
	vbox->addLayout(hbox);

	setLayout(vbox);
}
Exemplo n.º 14
0
AnimalMovesWindow::AnimalMovesWindow(const std::map<QString, std::shared_ptr<db::Database>> & map, db::Database & db, const Animal & animal, QWidget * parent) :
    QWidget(),
    ui(new Ui::AnimalMovesWindow),
    m_parent(parent),
    m_db(db),
    m_dbMap(map),
    m_animal(animal)
{
    ui->setupUi(this);

    ui->label_Name->setText(m_animal.getName());

    QStringList horizontalHeader;
    horizontalHeader.append("Level");
    horizontalHeader.append("Move");
    horizontalHeader.append("Type");
    horizontalHeader.append("Category");
    horizontalHeader.append("Dmg");
    horizontalHeader.append("Acc");
    horizontalHeader.append("Prio");

    m_movesModel.setHorizontalHeaderLabels(horizontalHeader);

    ComboBoxDelegate * delegate = new ComboBoxDelegate(this);
    std::vector<QString> vec;
    for (const auto & move : m_db.getMovesByID()) {
        vec.emplace_back(move.second.getName());
    }
    delegate->setItems(vec);
    ui->tableView_Moves->setItemDelegateForColumn(1, delegate);

    QSortFilterProxyModel * proxyModel = new QSortFilterProxyModel(this);
    proxyModel->setSourceModel(&m_movesModel);
    proxyModel->setSortRole(NumericModel::SortRole);

    ui->tableView_Moves->setModel(proxyModel);
    ui->tableView_Moves->resizeColumnsToContents();
    ui->tableView_Moves->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);

    // calculate max move name size
    int size = 20;
    QFont font;
    QFontMetrics fm(font);
    for (const auto & move : m_db.getMoves()) {
        size = std::max(size, fm.width(move.first));
    }
    ui->tableView_Moves->horizontalHeader()->resizeSection(1, size + 30);

    // calculate max type name size
    size = 20;
    for (const auto & type : m_db.getTypes()) {
        size = std::max(size, fm.width(type.first));
    }
    ui->tableView_Moves->horizontalHeader()->resizeSection(2, size + 30);

    // fill moves
    for (const auto & p : m_animal.moves()) {

        assert(m_db.getMoves().count(p.second) != 0);
        const auto move = m_db.getMoves().at(p.second);
        QList<QStandardItem *> itemList;

        itemList.append(new QStandardItem(QString::number(p.first)));
        itemList.append(new QStandardItem(move.getName()));
        itemList.append(new QStandardItem(move.getType()));
        itemList.back()->setEditable(false);
        itemList.append(new QStandardItem(move.getCategory()));
        itemList.back()->setEditable(false);
        itemList.append(new QStandardItem(QString::number(move.getBaseDamage())));
        itemList.back()->setEditable(false);
        itemList.append(new QStandardItem(QString::number(move.getAccuracy())));
        itemList.back()->setEditable(false);
        itemList.append(new QStandardItem(QString::number(move.getPriority())));
        itemList.back()->setEditable(false);

        m_movesModel.appendRow(itemList);

    }

    connect(&m_movesModel, &QStandardItemModel::itemChanged, [&](QStandardItem * item){

        const auto col = item->column();

        if (col == 0) {

            // lvl changed
            ui->tableView_Moves->sortByColumn(0, Qt::AscendingOrder);

        } else if (col == 1) {

            // move changed
            const auto move = m_db.getMoves().at(item->text());
            m_movesModel.setItem(item->row(), 2, new QStandardItem(move.getType()));
            m_movesModel.setItem(item->row(), 3, new QStandardItem(move.getCategory()));
            m_movesModel.setItem(item->row(), 4, new QStandardItem(QString::number(move.getBaseDamage())));
            m_movesModel.setItem(item->row(), 5, new QStandardItem(QString::number(move.getAccuracy())));
            m_movesModel.setItem(item->row(), 6, new QStandardItem(QString::number(move.getPriority())));

        }

    });

}
Exemplo n.º 15
0
void run_ui()
{

#ifdef SUBSURFACE_MOBILE
	QQmlApplicationEngine engine;
	register_qml_types(&engine);
	LOG_STP("run_ui qml engine started");
	KirigamiPlugin::getInstance().registerTypes();
#if defined(__APPLE__) && !defined(Q_OS_IOS)
	// when running the QML UI on a Mac the deployment of the QML Components seems
	// to fail and the search path for the components is rather odd - simply the
	// same directory the executable was started from <bundle>/Contents/MacOS/
	// To work around this we need to manually copy the components at install time
	// to Contents/Frameworks/qml and make sure that we add the correct import path
	const QStringList importPathList = engine.importPathList();
	for (QString importPath: importPathList) {
		if (importPath.contains("MacOS"))
			engine.addImportPath(importPath.replace("MacOS", "Frameworks"));
	}
	qDebug() << "QML import path" << engine.importPathList();
#endif // __APPLE__ not Q_OS_IOS
	engine.addImportPath("qrc://imports");
	DiveListModel diveListModel;
	LOG_STP("run_ui diveListModel started");
	DiveListSortModel *sortModel = new DiveListSortModel(0);
	sortModel->setSourceModel(&diveListModel);
	sortModel->setDynamicSortFilter(true);
	sortModel->setSortRole(DiveListModel::DiveDateRole);
	sortModel->sort(0, Qt::DescendingOrder);
	LOG_STP("run_ui diveListModel sorted");
	GpsListModel gpsListModel;
	QSortFilterProxyModel *gpsSortModel = new QSortFilterProxyModel(0);
	gpsSortModel->setSourceModel(&gpsListModel);
	gpsSortModel->setDynamicSortFilter(true);
	gpsSortModel->setSortRole(GpsListModel::GpsWhenRole);
	gpsSortModel->sort(0, Qt::DescendingOrder);
	QQmlContext *ctxt = engine.rootContext();
	ctxt->setContextProperty("diveModel", sortModel);
	ctxt->setContextProperty("gpsModel", gpsSortModel);
	ctxt->setContextProperty("vendorList", vendorList);
	set_non_bt_addresses();
	LOG_STP("run_ui set_non_bt_adresses");

	ctxt->setContextProperty("connectionListModel", &connectionListModel);
	ctxt->setContextProperty("logModel", MessageHandlerModel::self());

	engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml")));
	LOG_STP("run_ui qml loaded");
	qqWindowObject = engine.rootObjects().value(0);
	if (!qqWindowObject) {
		fprintf(stderr, "can't create window object\n");
		exit(1);
	}
	QQuickWindow *qml_window = qobject_cast<QQuickWindow *>(qqWindowObject);
	qml_window->setIcon(QIcon(":subsurface-mobile-icon"));
	qDebug() << "qqwindow devicePixelRatio" << qml_window->devicePixelRatio() << qml_window->screen()->devicePixelRatio();
	QScreen *screen = qml_window->screen();
	QObject::connect(qml_window, &QQuickWindow::screenChanged, QMLManager::instance(), &QMLManager::screenChanged);
	QMLManager *manager = QMLManager::instance();
	LOG_STP("run_ui qmlmanager instance started");
	// now that the log file is initialized...
	show_computer_list();
	LOG_STP("run_ui show_computer_list");

	manager->setDevicePixelRatio(qml_window->devicePixelRatio(), qml_window->screen());
	manager->dlSortModel = sortModel;
	manager->qmlWindow = qqWindowObject;
	manager->screenChanged(screen);
	qDebug() << "qqwindow screen has ldpi/pdpi" << screen->logicalDotsPerInch() << screen->physicalDotsPerInch();
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
	qml_window->setHeight(1200);
	qml_window->setWidth(800);
#endif // not Q_OS_ANDROID and not Q_OS_IOS
	qml_window->show();
	LOG_STP("run_ui running exec");
#else
	MainWindow::instance()->show();
#endif // SUBSURFACE_MOBILE
	qApp->exec();
}
Exemplo n.º 16
0
  QUndoCommand* PropertiesExtension::performAction(QAction *action,
                                                   GLWidget *widget)
  {
    QUndoCommand *undo = 0;
    PropertiesModel *model;
    PropertiesView  *view;
    QDialog *dialog = new QDialog(qobject_cast<QWidget *>(parent()));
    QVBoxLayout *layout = new QVBoxLayout(dialog);
    dialog->setLayout(layout);
    // Don't show whitespace around the PropertiesView
    layout->setSpacing(0);
    layout->setContentsMargins(0,0,0,0);

    int i = action->data().toInt();
    switch (i) {
    case AtomPropIndex: // atom properties
      // model will be deleted in PropertiesView::hideEvent using deleteLater().
      model = new PropertiesModel(PropertiesModel::AtomType);
      model->setMolecule(m_molecule);
      // view will delete itself in PropertiesView::hideEvent using deleteLater().
      view = new PropertiesView(PropertiesView::AtomType, dialog);
      connect(m_molecule, SIGNAL( atomAdded(Atom*) ),
              model, SLOT( atomAdded(Atom*) ));
      connect(m_molecule, SIGNAL( atomRemoved(Atom*) ),
              model, SLOT( atomRemoved(Atom*) ));
      break;
    case BondPropIndex: // bond properties
      // model will be deleted in PropertiesView::hideEvent using deleteLater().
      model = new PropertiesModel(PropertiesModel::BondType);
      model->setMolecule( m_molecule );
      // view will delete itself in PropertiesView::hideEvent using deleteLater().
      view = new PropertiesView(PropertiesView::BondType, widget);
      connect(m_molecule, SIGNAL( bondAdded(Bond*) ),
              model, SLOT( bondAdded(Bond*) ));
      connect(m_molecule, SIGNAL( bondRemoved(Bond*) ),
              model, SLOT( bondRemoved(Bond*) ));
      break;
    case AnglePropIndex: // angle properties
      // model will be deleted in PropertiesView::hideEvent using deleteLater().
      model = new PropertiesModel(PropertiesModel::AngleType);
      model->setMolecule( m_molecule );
      // view will delete itself in PropertiesView::hideEvent using deleteLater().
      view = new PropertiesView(PropertiesView::AngleType, widget);
      break;
    case TorsionPropIndex: // torsion properties
      // model will be deleted in PropertiesView::hideEvent using deleteLater().
      model = new PropertiesModel(PropertiesModel::TorsionType);
      model->setMolecule( m_molecule );
      // view will delete itself in PropertiesView::hideEvent using deleteLater().
      view = new PropertiesView(PropertiesView::TorsionType, widget);
      break;
    /*case CartesianIndex: // cartesian editor
      // m_angleModel will be deleted in PropertiesView::hideEvent using deleteLater().
      model = new PropertiesModel(PropertiesModel::CartesianType);
      model->setMolecule( m_molecule );
      // m_view will delete itself in PropertiesView::hideEvent using deleteLater().
      view = new PropertiesView(PropertiesView::CartesianType, widget);
      connect(m_molecule, SIGNAL(atomAdded(Atom*)), model, SLOT( atomAdded(Atom*)));
      connect(m_molecule, SIGNAL(atomRemoved(Atom*)), model, SLOT(atomRemoved(Atom*)));
      break;*/
    case ConformerIndex: // conformers
      // model will be deleted in PropertiesView::hideEvent using deleteLater().
      model = new PropertiesModel(PropertiesModel::ConformerType, dialog);
      model->setMolecule( m_molecule );
      // view will delete itself in PropertiesView::hideEvent using deleteLater().
      view = new PropertiesView(PropertiesView::ConformerType, dialog);
      break;
    default:
      delete dialog;
      layout = 0; // deleted as a child of the dialog
      return 0;
    }

    connect(m_molecule, SIGNAL(moleculeChanged()), model, SLOT(moleculeChanged()));
    connect(m_molecule, SIGNAL( updated() ), model, SLOT( updateTable() ));

    QSortFilterProxyModel* proxyModel = new QSortFilterProxyModel(this);
    proxyModel->setSourceModel(model);
    proxyModel->setDynamicSortFilter(true);
    proxyModel->setSortLocaleAware(true);
    // this role will received direct floating-point numbers from the model
    proxyModel->setSortRole(Qt::UserRole);

    view->setMolecule( m_molecule );
    view->setWidget( widget );
    view->setModel( proxyModel );
    view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    view->resizeColumnsToContents();
    layout->addWidget(view);
    dialog->setWindowTitle(view->windowTitle());
    QSize dialogSize = dialog->size();
    double width = view->horizontalHeader()->length()+view->verticalHeader()->width()+5;
	if (model->rowCount() < 10) { // no scrollbar
	  dialogSize.setHeight(view->horizontalHeader()->height()+model->rowCount()*30+5);
      dialogSize.setWidth(width);
    } else { // scrollbar is needed
      dialogSize.setHeight(width/1.618);
      dialogSize.setWidth(width+view->verticalScrollBar()->width());
    }
    dialog->resize(dialogSize);
	dialog->setWindowFlags(Qt::Window);
    dialog->show();

    return undo;
  }
SelectionGenesWidget::SelectionGenesWidget(const UserSelection::STDataFrame &data,
                                           QWidget *parent, Qt::WindowFlags f)
    : QWidget(parent, f)
    , m_ui(new Ui::genesSelectionWidget())
{
    m_ui->setupUi(this);
    m_ui->searchField->setClearButtonEnabled(true);
    m_ui->searchField->setFixedSize(CELL_PAGE_SUB_MENU_LINE_EDIT_SIZE);
    m_ui->searchField->setStyleSheet(CELL_PAGE_SUB_MENU_LINE_EDIT_STYLE);

    // data model
    const int columns = 2;
    const int rows = data.genes.size();
    QStandardItemModel *model = new QStandardItemModel(rows,columns, this);
    model->setHorizontalHeaderItem(0, new QStandardItem(QString("Gene")));
    model->setHorizontalHeaderItem(1, new QStandardItem(QString("Count")));
    // populate
    for (uword i = 0; i < data.counts.n_cols; ++i) {
        const QString gene = data.genes.at(i);
        const float count = sum(data.counts.col(i));
        const QString count_str = QString::number(count);
        QStandardItem *gene_item = new QStandardItem(gene);
        gene_item->setData(gene, Qt::UserRole);
        gene_item->setData(gene, Qt::DisplayRole);
        model->setItem(i, 0, gene_item);
        QStandardItem *count_item = new QStandardItem(count_str);
        count_item->setData(count, Qt::UserRole);
        count_item->setData(count_str, Qt::DisplayRole);
        model->setItem(i, 1, count_item);
    }
    // sorting model
    QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this);
    proxy->setSourceModel(model);
    proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
    proxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
    proxy->setSortRole(Qt::UserRole);
    m_ui->tableview->setModel(proxy);

    // settings for the table
    m_ui->tableview->setSortingEnabled(true);
    m_ui->tableview->setShowGrid(true);
    m_ui->tableview->setWordWrap(true);
    m_ui->tableview->setAlternatingRowColors(true);
    m_ui->tableview->sortByColumn(0, Qt::AscendingOrder);

    m_ui->tableview->setFrameShape(QFrame::StyledPanel);
    m_ui->tableview->setFrameShadow(QFrame::Sunken);
    m_ui->tableview->setGridStyle(Qt::SolidLine);
    m_ui->tableview->setCornerButtonEnabled(false);
    m_ui->tableview->setLineWidth(1);

    m_ui->tableview->setSelectionBehavior(QAbstractItemView::SelectRows);
    m_ui->tableview->setSelectionMode(QAbstractItemView::NoSelection);
    m_ui->tableview->setEditTriggers(QAbstractItemView::NoEditTriggers);

    m_ui->tableview->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
    m_ui->tableview->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
    m_ui->tableview->horizontalHeader()->setSortIndicatorShown(true);
    m_ui->tableview->verticalHeader()->hide();

    m_ui->tableview->model()->submit(); // support for caching (speed up)

    // Connect the search field signal
    connect(m_ui->searchField,
            &QLineEdit::textChanged,
            proxy,
            &QSortFilterProxyModel::setFilterFixedString);

    // allow to copy the content of the table
    m_ui->tableview->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(m_ui->tableview, &QTableView::customContextMenuRequested,
            this, &SelectionGenesWidget::customMenuRequested);

}