Пример #1
0
DocumentTypesWidget::DocumentTypesWidget(QWidget *parent)
    : QWidget(parent)
    , m_createNodeTypeButton(new QPushButton(this))
    , m_createEdgeTypeButton(new QPushButton(this))
{
    QGridLayout *layout = new QGridLayout(this);

    // node types
    layout->addWidget(new QLabel(i18nc("@title", "Node Types")));

    m_createNodeTypeButton->setText(i18n("Create Type"));
    layout->addWidget(m_createNodeTypeButton);

    QListView *nodeTypeView = new QListView(this);
    NodeTypesDelegate *nodeDelegate = new NodeTypesDelegate(nodeTypeView);
    nodeTypeView->setItemDelegate(nodeDelegate);
    nodeTypeView->setModel(&m_nodeTypeModel);
    layout->addWidget(nodeTypeView);

    connect(nodeDelegate, &NodeTypesDelegate::colorChanged,
        this, &DocumentTypesWidget::onNodeTypeColorChanged);
    connect(nodeDelegate, &NodeTypesDelegate::nameChanged,
        this, &DocumentTypesWidget::onNodeTypeNameChanged);
    connect(m_createNodeTypeButton, &QPushButton::clicked,
        this, &DocumentTypesWidget::onCreateNodeType);

    // edge types
    layout->addWidget(new QLabel(i18nc("@title", "Edge Types")));

    m_createEdgeTypeButton->setText(i18n("Create Type"));
    layout->addWidget(m_createEdgeTypeButton);

    QListView *edgeTypeView = new QListView(this);
    EdgeTypesDelegate *edgeDelegate = new EdgeTypesDelegate(edgeTypeView);
    edgeTypeView->setItemDelegate(edgeDelegate);
    edgeTypeView->setModel(&m_edgeTypeModel);
    layout->addWidget(edgeTypeView);

    connect(edgeDelegate, &EdgeTypesDelegate::colorChanged,
        this, &DocumentTypesWidget::onEdgeTypeColorChanged);
    connect(edgeDelegate, &EdgeTypesDelegate::nameChanged,
        this, &DocumentTypesWidget::onEdgeTypeNameChanged);;
    connect(edgeDelegate, &EdgeTypesDelegate::directionChanged,
        this, &DocumentTypesWidget::onEdgeTypeDirectionChanged);
    connect(m_createEdgeTypeButton, &QPushButton::clicked,
        this, &DocumentTypesWidget::onCreateEdgeType);

    setLayout(layout);
    show();
}
Пример #2
0
PhotoView::PhotoView(QAbstractGallery *gallery, QWidget *parent, Qt::WindowFlags flags)
    : GalleryView(parent, flags)
    , model(new ThumbnailModel(gallery))
{
    model->setRootType(QDocumentGallery::Image);

    QHash<int, QString> properties;
    properties.insert(Qt::DisplayRole, QDocumentGallery::fileName);
    model->addColumn(properties);

    model->setSortPropertyNames(QStringList()
            << QDocumentGallery::title);

    QListView *view = new QListView;
    view->setIconSize(ThumbnailModel::thumbnailSize);
    view->setFlow(QListView::TopToBottom);
    view->setViewMode(QListView::IconMode);
    view->setUniformItemSizes(true);
    view->setWrapping(true);
    view->setModel(model.data());
    view->setItemDelegate(new PhotoDelegate(this));
    connect(view, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex)));

    QBoxLayout *layout = new QVBoxLayout;
    layout->setMargin(0);
    layout->setSpacing(0);
    layout->addWidget(view);

    setLayout(layout);
}
Пример #3
0
void MainWindow::prepareProjectListView()
{
    QListView *view = ui->centralWidget->findChild<QListView*>("projectLst");
    QStandardItemModel *model = new QStandardItemModel;
    view->setItemDelegate(new ProjectItemDelegate);
    view->setModel(model);
}
Пример #4
0
QgsWelcomePage::QgsWelcomePage( QWidget* parent )
    : QTabWidget( parent )
{
  QVBoxLayout* mainLayout = new QVBoxLayout;
  mainLayout->setMargin( 0 );
  setLayout( mainLayout );

  QHBoxLayout* layout = new QHBoxLayout();
  layout->setMargin( 9 );

  mainLayout->addLayout( layout );

  QWidget* recentProjctsContainer = new QWidget;
  recentProjctsContainer->setLayout( new QVBoxLayout );
  QLabel* recentProjectsTitle = new QLabel( QString( "<h1>%1</h1>" ).arg( tr( "Recent Projects" ) ) );
  recentProjctsContainer->layout()->addWidget( recentProjectsTitle );

  QListView* recentProjectsListView = new QListView();
  mModel = new QgsWelcomePageItemsModel( recentProjectsListView );
  recentProjectsListView->setModel( mModel );
  recentProjectsListView->setItemDelegate( new QgsWelcomePageItemDelegate( recentProjectsListView ) );

  recentProjctsContainer->layout()->addWidget( recentProjectsListView );

  addTab( recentProjctsContainer, "Recent Projects" );

  QWidget* whatsNewContainer = new QWidget;
  whatsNewContainer->setLayout( new QVBoxLayout );
  QLabel* whatsNewTitle = new QLabel( QString( "<h1>%1</h1>" ).arg( tr( "QGIS News" ) ) );
  whatsNewContainer->layout()->addWidget( whatsNewTitle );

  QgsWebView* whatsNewPage = new QgsWebView();
  whatsNewPage->setUrl( QUrl::fromLocalFile( QgsApplication::whatsNewFilePath() ) );
  whatsNewPage->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
  whatsNewPage->setContextMenuPolicy( Qt::NoContextMenu );
  whatsNewPage->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
  whatsNewPage->setStyleSheet( "background:transparent" );
  whatsNewPage->setAttribute( Qt::WA_TranslucentBackground );

  whatsNewContainer->layout()->addWidget( whatsNewPage );
//  whatsNewContainer->setMaximumWidth( 250 );
//  whatsNewContainer->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred );
  addTab( whatsNewContainer, "News" );

  connect( whatsNewPage, SIGNAL( linkClicked( QUrl ) ), this, SLOT( whatsNewLinkClicked( QUrl ) ) );

  mVersionInformation = new QLabel;
  mainLayout->addWidget( mVersionInformation );
  mVersionInformation->setVisible( false );

  mVersionInfo = new QgsVersionInfo();
  connect( mVersionInfo, SIGNAL( versionInfoAvailable() ), this, SLOT( versionInfoReceived() ) );
  mVersionInfo->checkVersion();

  connect( recentProjectsListView, SIGNAL( activated( QModelIndex ) ), this, SLOT( itemActivated( QModelIndex ) ) );
}
Пример #5
0
/*!
  \reimp
  Sets the QListView \a w as this ThemeListItem's widget.
  \a w must be non-zero and inherit QListView, otherwise this function will abort.
  An internal implementation of QItemDelegate is installed on the view to handle
  communication between itself and a ThemeListModel.
  If a ThemeListModel object has already been set using setModel(), it is installed immediately
  using QListView::setModel(). If a call is made to setModel() in the future, that model
  will be installed on this widget in the same way.
*/
void QThemeListItem::setWidget(QWidget *w)
{
    QThemeWidgetItem::setWidget(w);
    Q_ASSERT(widget() == 0 || widget()->inherits("QListView") == true);
    if (!widget())
        return;
    QListView* v = listView();
    v->setItemDelegate(new QThemeListDelegate(v, themedScene()->themedView(), themedScene()->themedView()));
    if (d->model != 0 && v->model() != d->model)
        v->setModel(d->model);
}
AMSamplePlatePre2013Selector::AMSamplePlatePre2013Selector(AMSamplePlatePre2013* sourcePlate, QWidget *parent)
	: QWidget(parent) {

	samplePlateTableName_ = AMDbObjectSupport::s()->tableNameForClass<AMSamplePlatePre2013>();
	// Either use an external plate (if specified in sourcePlate), or make an internal one.
	plate_ = sourcePlate ? sourcePlate : new AMSamplePlatePre2013(this);

	setupUi();
	notesEditor->setObjectName("notesEditor");
	notesEditor->setStyleSheet("#notesEditor { background-image: url(:/notepadBackground.png); font: bold 15px \"Marker Felt\";}");

	AMDetailedItemDelegate* del = new AMDetailedItemDelegate(this);
	// Setting a new view fixes a grayed-menu-background drawing bug on mac
	QListView* lview = new QListView(this);
	lview->setItemDelegate(del);
	lview->setAlternatingRowColors(true);
	plateComboBox->setView(lview);

	notesEditor->setMaximumHeight(80);
	this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);

	connect(&plateRefreshScheduler_, SIGNAL(executed()), this, SLOT(populateSamplePlates()));
	plateRefreshScheduler_.schedule();

	onSamplePlateChanged(/*plate_->valid()*/);

	connect(AMDatabase::database("user"), SIGNAL(updated(QString,int)), this, SLOT(onDatabaseUpdated(QString,int)), Qt::QueuedConnection);
	connect(AMDatabase::database("user"), SIGNAL(created(QString,int)), this, SLOT(onDatabaseCreated(QString,int)), Qt::QueuedConnection);
	connect(AMDatabase::database("user"), SIGNAL(removed(QString,int)), this, SLOT(onDatabaseRemoved(QString,int)), Qt::QueuedConnection);

	// GUI event connections
	connect(plateComboBox, SIGNAL(activated(int)), this, SLOT(onComboBoxActivated(int)));
	connect(nameEdit, SIGNAL(textEdited(QString)), this, SLOT(onNameEdited(QString)));
	connect(nameEdit, SIGNAL(editingFinished()), this, SLOT(onPlateEditingFinished()));
	connect(notesEditor, SIGNAL(textChanged()), this, SLOT(onNotesEdited()));
	connect(notesEditor, SIGNAL(editingFinished(int)), this, SLOT(onPlateEditingFinished()));

	notesHeaderButton->setChecked(false);
	notesEditor->setVisible(false);
	connect(notesHeaderButton, SIGNAL(clicked(bool)), notesEditor, SLOT(setVisible(bool)));

	// when our current sample plate is re-loaded out of the database, respond to update the GUI values
	connect(plate_, SIGNAL(loadedFromDb()), this, SLOT(onSamplePlateChanged()), Qt::QueuedConnection);
}
Пример #7
0
QgsWelcomePage::QgsWelcomePage( bool skipVersionCheck, QWidget* parent )
    : QWidget( parent )
{
  QSettings settings;

  QVBoxLayout* mainLayout = new QVBoxLayout;
  mainLayout->setMargin( 0 );
  setLayout( mainLayout );

  QHBoxLayout* layout = new QHBoxLayout();
  layout->setMargin( 9 );

  mainLayout->addLayout( layout );

  QWidget* recentProjctsContainer = new QWidget;
  recentProjctsContainer->setLayout( new QVBoxLayout );
  recentProjctsContainer->layout()->setContentsMargins( 3, 3, 3, 0 );
  QLabel* recentProjectsTitle = new QLabel( QString( "<h1>%1</h1>" ).arg( tr( "Recent Projects" ) ) );
  recentProjctsContainer->layout()->addWidget( recentProjectsTitle );

  QListView* recentProjectsListView = new QListView();
  recentProjectsListView->setResizeMode( QListView::Adjust );

  mModel = new QgsWelcomePageItemsModel( recentProjectsListView );
  recentProjectsListView->setModel( mModel );
  recentProjectsListView->setItemDelegate( new QgsWelcomePageItemDelegate( recentProjectsListView ) );

  recentProjctsContainer->layout()->addWidget( recentProjectsListView );

  layout->addWidget( recentProjctsContainer );

  mVersionInformation = new QLabel;
  mainLayout->addWidget( mVersionInformation );
  mVersionInformation->setVisible( false );

  mVersionInfo = new QgsVersionInfo();
  if ( !QgsApplication::isRunningFromBuildDir() && settings.value( "/qgis/checkVersion", true ).toBool() && !skipVersionCheck )
  {
    connect( mVersionInfo, SIGNAL( versionInfoAvailable() ), this, SLOT( versionInfoReceived() ) );
    mVersionInfo->checkVersion();
  }

  connect( recentProjectsListView, SIGNAL( activated( QModelIndex ) ), this, SLOT( itemActivated( QModelIndex ) ) );
}
Пример #8
0
TMainWindow::TMainWindow(TImageStorage* imageStorage, QAbstractItemModel* friendListModel)
    : QWidget(NULL)
{
    qDebug() << Q_FUNC_INFO;
    Q_ASSERT(friendListModel && "missing friendListModel");
    this->setGeometry(QDesktopWidget().availableGeometry().center().x() - (MAIN_WINDOW_WIDTH / 2),
                      QDesktopWidget().availableGeometry().center().y() - (MAIN_WINDOW_HEIGHT / 2),
                      MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT);
    QVBoxLayout* currentLayout = new QVBoxLayout(this);
    QListView* friendListView = new QListView();

    friendListView->setModel(friendListModel);

    TFriendItemDelegate* delegate = new TFriendItemDelegate(imageStorage);
    friendListView->setItemDelegate(delegate);

    connect(friendListView, &QListView::doubleClicked, delegate, &TFriendItemDelegate::OnDoubleClick);
    connect(delegate, &TFriendItemDelegate::FriendDoubleClicked, this, &TMainWindow::FriendDoubleClicked);

    currentLayout->addWidget(friendListView);

    this->show();
}
Пример #9
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    /*QLabel *id = new QLabel("Email or mobile phone");
    QLineEdit *idLine = new QLineEdit;
    QLabel *password = new QLabel("Password");
    QLineEdit *passwordLine = new QLineEdit;
    QPushButton *enter = new QPushButton("Enter");

    QHBoxLayout *enterBox = new QHBoxLayout;
    //LoginScreenForm *form = new LoginScreenForm(id, idLine, password, passwordLine, enter, box, enterBox);
    //LoginScreen mainWindow(form);*/
    QVBoxLayout *box = new QVBoxLayout;
    QWebView *view = new QWebView;
    QProgressBar *bar = new QProgressBar;
    WebLoginScreen scr(view, bar, box);
    scr.show();
    requester req("6585056", "effe73b8de201068cc9a8819dac22d518f4e6a06e304d542c71f7af93f88fad2b44db86ff2ccc28b831ed");
    req.getAudio("6585056");
    QEventLoop wait;
    QTimer::singleShot(5000, &wait, SLOT(quit()));
    wait.exec();
    qDebug() << "get Result " << req.getResult();
    QByteArray array = req.getResult();
    qDebug() << "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" << array;
    xmlParser prs;
    dataHolder* data = new dataHolder(prs.parseXML(array));
    qDebug() << data->getObject(102).value("title").toString();
    dataModel model(data);
    qDebug() << model.rowCount();
    QListView list;
    list.setModel(&model);
    songsListDelegate *del = new songsListDelegate;
    list.setItemDelegate(del);
    list.show();
    return app.exec();
}
Пример #10
0
void tst_QItemDelegate::enterKey()
{
    QFETCH(WidgetType, widget);
    QFETCH(int, key);
    QFETCH(bool, expectedFocus);

    QStandardItemModel model;
    model.appendRow(new QStandardItem());

    QListView view;
    view.setModel(&model);
    view.show();
    QApplication::setActiveWindow(&view);
    view.setFocus();
    QTest::qWait(30);

    struct TestDelegate : public QItemDelegate
    {
        WidgetType widgetType;
        virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& /*option*/, const QModelIndex& /*index*/) const
        {
            QWidget *editor = 0;
            switch(widgetType) {
            case LineEdit:
                editor = new QLineEdit(parent);
                break;
            case TextEdit:
                editor = new QTextEdit(parent);
                break;
            case PlainTextEdit:
                editor = new QPlainTextEdit(parent);
                break;
            }
            editor->setObjectName(QString::fromLatin1("TheEditor"));
            return editor;
        }
    } delegate;

    delegate.widgetType = widget;

    view.setItemDelegate(&delegate);
    QModelIndex index = model.index(0, 0);
    view.setCurrentIndex(index); // the editor will only selectAll on the current index
    view.edit(index);
    QTest::qWait(30);

    QList<QWidget*> lineEditors = qFindChildren<QWidget *>(view.viewport(), QString::fromLatin1("TheEditor"));
    QCOMPARE(lineEditors.count(), 1);

    QPointer<QWidget> editor = lineEditors.at(0);
    QCOMPARE(editor->hasFocus(), true);

    QTest::keyClick(editor, Qt::Key(key));
    QApplication::processEvents();

    // The line edit has already been destroyed, so avoid that case.
    if (widget == TextEdit || widget == PlainTextEdit) {
        QVERIFY(!editor.isNull());
        QCOMPARE(editor && editor->hasFocus(), expectedFocus);
    }
}