Пример #1
1
QComboBox* FilterButton::createComboBox(const QStringList& options, const QString& currentOption)
{
	// Stylesheet
	QFile stylefile(":/qss/filterbutton.qss"); stylefile.open(QFile::ReadOnly);
	QString stylesheet(stylefile.readAll());

	filtersComboBox = new QComboBox;

	QListView * listView = new QListView(filtersComboBox);
	filtersComboBox->addItems(options);
	listView->setStyleSheet(stylesheet);


	filtersComboBox->setView(listView);
	filtersComboBox->setStyleSheet(stylesheet);

	// Filter
	filtersComboBox->setCurrentIndex(options.indexOf(currentOption));

	// Connect the combobox's signal to our own
	connect(filtersComboBox, SIGNAL(currentIndexChanged(const QString&)),
			this, SIGNAL(selectionChanged(const QString&)));

	return filtersComboBox;
}
Пример #2
0
void GraphicalArrayTest::test_removeItems()
{
  GraphicalArray * value = new GraphicalArray();
  QPushButton * button = findRemoveButton(value);
  QStringListModel * model = findModel(value);
  QListView * view = findListView(value);
  QItemSelectionModel::SelectionFlags flag = QItemSelectionModel::Select;

  model->setStringList( QStringList() << "Hello" << "World" << "and" << "Happy" << "New" << "Year!" );
  value->show();

  view->selectionModel()->select( model->index(0), flag ); // select "Hello"
  view->selectionModel()->select( model->index(1), flag ); // select "World"
  view->selectionModel()->select( model->index(3), flag ); // select "Happy"
  view->selectionModel()->select( model->index(5), flag ); // select "Year"

  // simulate a click on the 'Remove' button
  QTest::mouseClick( button, Qt::LeftButton );

  QStringList values = model->stringList();

  QCOMPARE( values.count(), 2 );
  QCOMPARE( values.at(0), QString("and") );
  QCOMPARE( values.at(1), QString("New") );

  delete value;
}
Пример #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
PrivateChatDialog::PrivateChatDialog(QWidget * parent)
    : QDialog(parent)
{
    m_name_w = new QLineEdit;

    m_owner_w = new QLineEdit;
    m_owner_w->setReadOnly(true);

    QListView * listView = new QListView;
    listView->setModel(&m_model);

    QFormLayout * formLayout = new QFormLayout;
    formLayout->addRow(tr("&Name : "), m_name_w);
    formLayout->addRow(tr("&Owner : "), m_owner_w);
    formLayout->addRow(tr("&Player : "), listView);

    m_buttonBox = new QDialogButtonBox;
    connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    QVBoxLayout * mainLayout = new QVBoxLayout;
    mainLayout->addLayout(formLayout);
    mainLayout->addWidget(m_buttonBox);

    setLayout(mainLayout);

    setSizeGripEnabled(true);
}
Пример #5
0
int main( int argc, char* argv[] )
{
  QApplication app( argc, argv );

  // Open the addressbook file in the working directory 
  QFile file("addressbook.csv");
  if ( !file.open(QIODevice::ReadOnly|QIODevice::Text) )
	  return 1;

  // Read its content into a string
  QString addresses = QString::fromUtf8(file.readAll());
  AddressbookModel model(addresses);

  QListView listView;
  listView.setModel(&model);
  listView.setModelColumn(0);
  listView.show();

  QTreeView treeView;
  treeView.setModel(&model);
  treeView.show();

  QTableView tableView;
  tableView.setModel(&model);
  tableView.show();

  return app.exec();
}
Пример #6
0
void VegetationWidget::slotDeleteSelected()
{
	QListView* view = qobject_cast<QListView*>(sender());
	QStandardItemModel* model = qobject_cast<QStandardItemModel*>(view->model());
	QString dirString("");
	if (view == _treeListView)
	{
		std::string plantDir = g_SystemContext._workContextDir;
		plantDir.append(CONTEXT_DIR);
		plantDir.append("/Plant/");
		dirString = chineseTextUTF8ToQString(plantDir + "Tree/");
	}
	else
	{
		std::string plantDir = g_SystemContext._workContextDir;
		plantDir.append(CONTEXT_DIR);
		plantDir.append("/Plant/");
		dirString = chineseTextUTF8ToQString(plantDir + "Grass/");
	}
	QItemSelectionModel* selectionModel = view->selectionModel();
	QModelIndexList	modelList = selectionModel->selectedIndexes();
	if (modelList.size() < 1)
		return;
	for (int i = 0; i < modelList.size(); ++i)
	{
		QStandardItem* everyItem = model->itemFromIndex(modelList.at(i));
		QFile::remove(dirString + everyItem->text());
		int row = everyItem->row();
		model->removeRow(row);
	}
}
void MainWindow::addBook()
{
    //Multiselection file dialog
    //http://www.qtcentre.org/threads/34226-QFileDialog-select-multiple-directories?p=220108#post220108
    QFileDialog getBookListDialog(this,"Choose Book to Convert",lastSelectDir);
    getBookListDialog.setFileMode(QFileDialog::DirectoryOnly);
    getBookListDialog.setOption(QFileDialog::DontUseNativeDialog,true);

    QListView *l = getBookListDialog.findChild<QListView*>("listView");
    if (l)
    {
        l->setSelectionMode(QAbstractItemView::ExtendedSelection);
    }

    QTreeView *t = getBookListDialog.findChild<QTreeView*>("treeView");
    if (t)
    {
        t->setSelectionMode(QAbstractItemView::ExtendedSelection);
    }
    //

    if(getBookListDialog.exec() == QDialog::Accepted)
    {
        ui->listWidget->addItems(getBookListDialog.selectedFiles());
    }
    this->lastSelectDir = getBookListDialog.directory().absolutePath();
}
MainWindow::MainWindow()
{
    QMenu *fileMenu = new QMenu(tr("&File"));

    QAction *quitAction = fileMenu->addAction(tr("E&xit"));
    quitAction->setShortcut(tr("Ctrl+Q"));

    menuBar()->addMenu(fileMenu);

//  For convenient quoting:
//! [0]
QListView *listView = new QListView(this);
listView->setSelectionMode(QAbstractItemView::ExtendedSelection);
listView->setDragEnabled(true);
listView->setAcceptDrops(true);
listView->setDropIndicatorShown(true);
//! [0]

    this->listView = listView;

    connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));

    setupListItems();

    setCentralWidget(listView);
    setWindowTitle(tr("List View"));
}
Пример #9
0
void TransparentBg::backgroundUpdated()
{
    if (parent()->inherits("QTextEdit")){
        QTextEdit *text = static_cast<QTextEdit*>(parent());
        const QPixmap *pix = background(text->colorGroup().color(QColorGroup::Base));
        QPoint pp = text->viewportToContents(QPoint(0, 0));
        bgX = pp.x();
        bgY = pp.y();
        if ((pix == NULL) || pix->isNull()){
            if (text->paper().pixmap() && !text->paper().pixmap()->isNull()){
                text->setPaper(QBrush(text->colorGroup().base()));
                text->setStaticBackground(false);
            }
            return;
        }
        QPoint pp1 = text->topLevelWidget()->mapFromGlobal(text->mapToGlobal(QPoint(0, 0)));
        QPixmap bg(bgX + text->width(), bgY + text->height());
        QPainter p;
        p.begin(&bg);
        p.drawTiledPixmap(bgX, bgY, text->width(), text->height(), *pix, pp1.x(), pp1.y());
        p.end();
        text->setPaper(QBrush(text->colorGroup().background(), bg));
        text->setStaticBackground(true);
        text->setBackgroundMode(QWidget::NoBackground);
        text->viewport()->setBackgroundMode(QWidget::NoBackground);
        return;
    }
    if (parent()->inherits("QListView")){
        QListView *p = static_cast<QListView*>(parent());
        p->viewport()->repaint();
    }
}
Пример #10
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QObject *parent = &app;

    QStringList numbers;
    numbers << "One" << "Two" << "Three" << "Four" << "Five";

    QAbstractItemModel *stringListModel = new QStringListModel(numbers, parent);

//! [0]
    QSortFilterProxyModel *filterModel = new QSortFilterProxyModel(parent);
    filterModel->setSourceModel(stringListModel);
//! [0]

    QWidget *window = new QWidget;

//! [1]
    QListView *filteredView = new QListView;
    filteredView->setModel(filterModel);
//! [1]
    filteredView->setWindowTitle("Filtered view onto a string list model");

    QLineEdit *patternEditor = new QLineEdit;
    QObject::
    connect(patternEditor, SIGNAL(textChanged(const QString &)),
            filterModel, SLOT(setFilterRegExp(const QString &)));

    QVBoxLayout *layout = new QVBoxLayout(window);
    layout->addWidget(filteredView);
    layout->addWidget(patternEditor);

    window->show();
    return app.exec();
}
Пример #11
0
WebView *TabWidget::newTab(bool makeCurrent)
{
    // line edit
    UrlLineEdit *urlLineEdit = new UrlLineEdit;
    QLineEdit *lineEdit = urlLineEdit->lineEdit();
    if (!m_lineEditCompleter && count() > 0) {
        HistoryCompletionModel *completionModel = new HistoryCompletionModel(this);
        completionModel->setSourceModel(BrowserApplication::historyManager()->historyFilterModel());
        m_lineEditCompleter = new QCompleter(completionModel, this);
        // Should this be in Qt by default?
        QAbstractItemView *popup = m_lineEditCompleter->popup();
        QListView *listView = qobject_cast<QListView*>(popup);
        if (listView)
            listView->setUniformItemSizes(true);
    }
    lineEdit->setCompleter(m_lineEditCompleter);
    connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(lineEditReturnPressed()));
    m_lineEdits->addWidget(urlLineEdit);
    m_lineEdits->setSizePolicy(lineEdit->sizePolicy());

    // optimization to delay creating the more expensive WebView, history, etc
    if (count() == 0) {
        QWidget *emptyWidget = new QWidget;
        QPalette p = emptyWidget->palette();
        p.setColor(QPalette::Window, palette().color(QPalette::Base));
        emptyWidget->setPalette(p);
        emptyWidget->setAutoFillBackground(true);
        disconnect(this, SIGNAL(currentChanged(int)),
                   this, SLOT(currentChanged(int)));
        addTab(emptyWidget, tr("(Untitled)"));
        connect(this, SIGNAL(currentChanged(int)),
                this, SLOT(currentChanged(int)));
        currentChanged(currentIndex());
        return 0;
    }
Пример #12
0
void Rozmowa::syg_rozm_slot(int index)
{
    //this->index=index;
    QListView* rozmowa = this->findChild<QListView*>("rozmowa");
    QStringList list= model->messages[index];
    rozmowa->setModel(new QStringListModel(list));
}
Window::Window(QWidget *parent)
    : QWidget(parent)
{
    FileListModel *model = new FileListModel(this);
    model->setDirPath(QLibraryInfo::location(QLibraryInfo::PrefixPath));

    QLabel *label = new QLabel(tr("&Directory:"));
    QLineEdit *lineEdit = new QLineEdit;
    label->setBuddy(lineEdit);

    QListView *view = new QListView;
    view->setModel(model);

    logViewer = new QTextBrowser;
    logViewer->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));

    connect(lineEdit, SIGNAL(textChanged(QString)),
            model, SLOT(setDirPath(QString)));
    connect(lineEdit, SIGNAL(textChanged(QString)),
            logViewer, SLOT(clear()));
    connect(model, SIGNAL(numberPopulated(int)),
            this, SLOT(updateLog(int)));
    
    QGridLayout *layout = new QGridLayout;
    layout->addWidget(label, 0, 0);
    layout->addWidget(lineEdit, 0, 1);
    layout->addWidget(view, 1, 0, 1, 2);
    layout->addWidget(logViewer, 2, 0, 1, 2);

    setLayout(layout);
    setWindowTitle(tr("Fetch More Example"));
}
Пример #14
0
// Reimplemented 
void QmvItem::paintCell( QPainter *p, const QColorGroup &cg,
                                 int column, int width, int alignment )
{
    QListView *listview = listView();
    
    QColorGroup g( cg );
    g.setColor( QColorGroup::Base, backgroundColor() );
    g.setColor( QColorGroup::Foreground, Qt::black );
    g.setColor( QColorGroup::Text, Qt::black );
    
    int indent = 0;
    if ( column == 0 ) {
        indent = 20 + (shuttletupleattribute  ? 20 : 0 );
        p->fillRect( 0, 0, width, height(), backgroundColor() );
        p->save();
        p->translate( indent, 0 );
    }

    if ( isChanged() && column == 0 ) {
        p->save();
        QFont f = p->font();
        f.setBold( TRUE );
        p->setFont( f );
    }

    if ( !hasCustomContents() || column != 1 ) {
        QListViewItem::paintCell( p, g, column, width - indent, alignment  );
    } else {
        p->fillRect( 0, 0, width, height(), backgroundColor() );
        drawCustomContents( p, QRect( 0, 0, width, height() ) );
    }
    
    if ( isChanged() && column == 0 )
        p->restore();
    if ( column == 0 )
        p->restore();
        // Draw +/- open/close control icon on tuple items
    if ( !shuttletupleattribute && column == 0 ) {
        p->save();
        p->setPen( cg.foreground() );
        p->setBrush( cg.base() );
        p->drawRect( 5, height() / 2 - 4, 9, 9 );
        p->drawLine( 7, height() / 2, 11, height() / 2 );
        if ( !isOpen() )
            p->drawLine( 9, height() / 2 - 2, 9, height() / 2 + 2 );
        p->restore();
    }
    
    p->save();
    p->setPen( QPen( cg.dark(), 1 ) );
    p->drawLine( 0, height() - 1, width, height() - 1 );
    p->drawLine( width - 1, 0, width - 1, height() );
    p->restore();

    if ( listview->currentItem() == this && column == 0 &&
         !listview->hasFocus() && !listview->viewport()->hasFocus() )
        paintFocus( p, cg, QRect( 0, 0, width, height() ) );


}
Пример #15
0
Rozmowa::Rozmowa(QWidget *parent, const QModelIndex& index, Model* mod ) :
    QDialog(parent),
    ui(new Ui::Rozmowa)
{
    ui->setupUi(this);
    message = this->findChild<QPlainTextEdit*>("wiadomosc");//message qplaintext wyslanie
    message->insertPlainText("");
    message->clear();
    QPushButton* send = this->findChild<QPushButton*>("send");
    model = mod;

    QModelIndex ind = model->index( index.row(), 0, QModelIndex() );
    //((MainWindow*)this->parent())->logged_user.numer;
    QVariant value = model->data( ind, Qt::DisplayRole).toString();
    QString title = value.toString();
    ind = model->index( index.row(), 2 );
    char numer[9];
    itoa(((MainWindow*)this->parent())->logged_user.numer,numer,10);
    title += " - (";
    //title += ind.data().toString();
    title += " moj numer: ";
    title += numer;
    title += ")";

    setWindowTitle(title);

    QListView* rozmowa = this->findChild<QListView*>("rozmowa");
    rozmowa->setModel(model);
    rozmowa->setRootIndex(index);

    connect(send, SIGNAL(clicked()), ((MainWindow*)this->parent())->socket, SLOT(send_text_message()));
    connect(this->model, SIGNAL(syg_rozm(int)),this,SLOT(syg_rozm_slot(int)));
}
//! [0]
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

// Unindented for quoting purposes:
//! [1]
QStringList numbers;
numbers << "One" << "Two" << "Three" << "Four" << "Five";

QAbstractItemModel *model = new StringListModel(numbers);
//! [0] //! [1] //! [2] //! [3]
QListView *view = new QListView;
//! [2]
view->setWindowTitle("View onto a string list model");
//! [4]
view->setModel(model);
//! [3] //! [4]

    model->insertRows(5, 7, QModelIndex());

    for (int row = 5; row < 12; ++row) {
        QModelIndex index = model->index(row, 0, QModelIndex());
        model->setData(index, QString::number(row+1));
    }

//! [5]
    view->show();
    return app.exec();
}
Пример #17
0
//! [0] //! [1]
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QSplitter *splitter = new QSplitter;

//! [2] //! [3]
    QFileSystemModel *model = new QFileSystemModel;
    model->setRootPath(QDir::currentPath());
//! [0] //! [2] //! [4] //! [5]
    QTreeView *tree = new QTreeView(splitter);
//! [3] //! [6]
    tree->setModel(model);
//! [4] //! [6] //! [7]
    tree->setRootIndex(model->index(QDir::currentPath()));
//! [7]

    QListView *list = new QListView(splitter);
    list->setModel(model);
    list->setRootIndex(model->index(QDir::currentPath()));

//! [5]
    QItemSelectionModel *selection = new QItemSelectionModel(model);
    tree->setSelectionModel(selection);
    list->setSelectionModel(selection);

//! [8]
    splitter->setWindowTitle("Two views onto the same file system model");
    splitter->show();
    return app.exec();
}
Пример #18
0
/**
 * Displays a tool-tip according to the current location of the mouse
 * pointer.
 * @param	pt	The mouse pointer coordinates
 */
void ListToolTip::maybeTip(const QPoint& pt)
{
	QString str;
	QListView* pList;
	QListViewItem* pItem;
	
	// Get the item at the given point
	pList = m_pList->getList();
	pItem = pList->itemAt(pt);
	if (pItem == NULL)
		return;

	// Get the tip string for this item
	if (!m_pList->getTip(pItem, str))
		return;

	// Get the bounding rectangle of the item
	const QRect rcItem = pList->itemRect(pItem);
	if (!rcItem.isValid())
		return;

	// Get the header coordinates
	const QRect rcHead = pList->header()->rect();
	if (!rcHead.isValid())
		return;

	// Calculate the tool-tip rectangle
	QRect rcCell(rcHead.left(), rcItem.top(), rcItem.width(), rcItem.height());

	// Display the tool-tip
	tip(rcCell, str);
}
Пример #19
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QDirModel model;

    QTreeView tree;
    QListView list;
    QTableView table;

    tree.setModel(&model);
    list.setModel(&model);
    table.setModel(&model);

    tree.setSelectionMode(QAbstractItemView::MultiSelection);
    list.setSelectionModel(tree.selectionModel());
    table.setSelectionModel(tree.selectionModel());

    QObject::connect(&tree,SIGNAL(doubleClicked(QModelIndex)),&list,SLOT(setRootIndex(QModelIndex)));
    QObject::connect(&tree,SIGNAL(doubleClicked(QModelIndex)),&table,SLOT(setRootIndex(QModelIndex)));

    QSplitter *splitter = new QSplitter;
    splitter->addWidget(&tree);
    splitter->addWidget(&list);
    splitter->addWidget(&table);
    splitter->setWindowTitle(QObject::tr("Model/View"));
    splitter->show();
    
    return a.exec();
}
Пример #20
0
Window::Window(QWidget *parent)
    : QWidget(parent)
{
    FileListModel *model = new FileListModel(this);

    model->init();

    QLabel *label = new QLabel(tr("&Directory:"));
    QLineEdit *lineEdit = new QLineEdit;
    label->setBuddy(lineEdit);

    QListView *view = new QListView;
    view->setModel(model);
    view->setUniformItemSizes(true);

    connect(lineEdit, SIGNAL(textChanged(QString)), model, SLOT(setDirPath(QString)));
    connect(lineEdit, SIGNAL(editingFinished()), model, SLOT(list()));


    /*
	here: connect the signal of special io thread entry added to the slot entryadded of filelistmodel
    */

    QGridLayout *layout = new QGridLayout;
    layout->addWidget(label, 0, 0);
    layout->addWidget(lineEdit, 0, 1);
    layout->addWidget(view, 1, 0, 1, 2);

    setLayout(layout);
    setWindowTitle(tr("Fetch More Example"));

}
Пример #21
0
void WidgetMain::on_pushButtonFilter_clicked()
{
    filterFolderPaths_.clear();
    QFileDialog fileDialog(this, "select folder ", "./");
    fileDialog.setFileMode(QFileDialog::DirectoryOnly);
    fileDialog.setOption(QFileDialog::DontUseNativeDialog, true);
    QListView *pListView = fileDialog.findChild<QListView*>("listView");
    if(NULL != pListView)
    {
        qDebug() << "find listview!";
        pListView->setSelectionMode(QAbstractItemView::ExtendedSelection);
    }

    if(fileDialog.exec())
    {
        QStringList folderPaths = fileDialog.selectedFiles();
        if(folderPaths.isEmpty())
        {
            qDebug() << "folders is empty!";
            return;
        }
#ifdef WIN32
        foreach (QString tmp, folderPaths)
        {
            filterFolderPaths_ << tmp.replace("/", "\\");
        }
Пример #22
0
//-----------------------------------------------------------------------------
int ctkExpandableWidgetTest1(int argc, char * argv [] )
{
  QApplication::setStyle(new QPlastiqueStyle);
  QApplication app(argc, argv);

  QWidget topLevel;
  QHBoxLayout* topLevelLayout = new QHBoxLayout;
  topLevel.setLayout(topLevelLayout);

  QWidget frame;
  topLevelLayout->addWidget(&frame);

  ctkExpandableWidget resizableFrame1(&frame);
  QListView* listView = new QListView(&resizableFrame1);
  listView->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
  QVBoxLayout* resizableFrameLayout1 = new QVBoxLayout(&resizableFrame1);
  resizableFrameLayout1->setContentsMargins(0,0,0,0);
  resizableFrame1.setSizeGripMargins(QSize(2, 2));
  resizableFrame1.setLayout(resizableFrameLayout1);
  resizableFrameLayout1->addWidget(listView);
  resizableFrame1.setOrientations(Qt::Horizontal | Qt::Vertical);

  ctkExpandableWidget resizableFrame(&frame);
  resizableFrame.setSizeGripInside(false);
  QTreeView* treeView = new QTreeView(&resizableFrame);
  treeView->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
  QVBoxLayout* resizableFrameLayout = new QVBoxLayout(&resizableFrame);
  resizableFrameLayout->setContentsMargins(0,0,0,0);
  //resizableFrame.setSizeGripMargins(QSize(2, 2));
  resizableFrame.setLayout(resizableFrameLayout);
  resizableFrameLayout->addWidget(treeView);
  resizableFrame.setOrientations(Qt::Horizontal);

  QVBoxLayout *vbox = new QVBoxLayout;
  vbox->setContentsMargins(0, 0, 0, 0);
  vbox->addWidget(&resizableFrame1);
  vbox->addWidget(&resizableFrame);
  frame.setLayout(vbox);

  ctkExpandableWidget resizableFrame0(&topLevel);
  QTableView* tableView = new QTableView(&resizableFrame0);
  tableView->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
  QVBoxLayout* resizableFrameLayout0 = new QVBoxLayout(&resizableFrame0);
  resizableFrameLayout0->setContentsMargins(0,0,0,0);
  resizableFrame0.setSizeGripMargins(QSize(2, 2));
  resizableFrame0.setLayout(resizableFrameLayout0);
  resizableFrameLayout0->addWidget(tableView);
  resizableFrame0.setOrientations(Qt::Vertical);
  topLevelLayout->addWidget(&resizableFrame0);

  topLevel.show();

  if (argc < 2 || QString(argv[1]) != "-I" )
    {
    QTimer::singleShot(200, &app, SLOT(quit()));
    }

  return app.exec();
}
Пример #23
0
/*!
  Constructs a QThemeListItem.
  The \a parent is passed to the base class constructor.
*/
QThemeListItem::QThemeListItem(QThemeItem *parent)
        : QThemeWidgetItem(parent), d(new QThemeListItemPrivate)
{
    QThemeItem::registerType(Type);
    QListView *lv = new QListView;
    lv->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setWidget(lv);
}
void MediaListsManager::videoListsChanged()
{
    QModelIndex index = m_videoListsModel->index(0, 0);
    if (index.isValid()) {
        QListView* videoLists = m_application->mainWindow()->videoListsStack()->ui->videoLists;
        videoLists->selectionModel()->select( index, QItemSelectionModel::Select );
    }
}
Пример #25
0
void ComboBox::hack()
{
	QListView *v = new QListView( this );
	v->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
	v->setMinimumHeight( 50 );
	v->setModel( model() );
	setView( v );
}
Пример #26
0
int print_dma(struct devinfo_rman *rman, void *arg)
{
	QListView *lbox = (QListView *)arg;
        if (strcmp(rman->dm_desc, "DMA request lines")==0) {
		(void)new QListViewItem(lbox, lbox->lastItem(), rman->dm_desc);
		devinfo_foreach_rman_resource(rman, print_resource, arg);
        }
        return(0);
}
Пример #27
0
/*!
  Sets \a model to be the ThemeListModel associated with this ThemeListItem.
  If this item currently has a QListView widget set, this model is installed
  immediately on the view using QListView::setModel().
  If a call is made to QWidget::setWidget() in the future, this model
  will be installed in the same way.
*/
void QThemeListItem::setModel(QThemeListModel *model)
{
    if (d->model != model) {
        d->model = model;
        QListView* view = listView();
        if (view != 0 && view->model() != d->model)
            view->setModel(d->model);
    }
}
Пример #28
0
void Rozmowa::reject()
{
    QListView* rozmowa = this->findChild<QListView*>("rozmowa");
    model->messages[index].clear();
    QStringList list= model->messages[index];
    rozmowa->setModel(new QStringListModel(list));
    message->clear();
    QDialog::reject();
}
Пример #29
0
/*!
    \reimp
*/
bool QFontComboBox::event(QEvent *e)
{
    if (e->type() == QEvent::Resize) {
        QListView *lview = qobject_cast<QListView*>(view());
        if (lview)
            lview->window()->setFixedWidth(width() * 5 / 3);
    }
    return QComboBox::event(e);
}
Пример #30
0
void VegetationWidget::slotViewSelected()
{
	QListView* view = qobject_cast<QListView*>(sender());
	QItemSelectionModel* selectionModel = view->selectionModel();
	QModelIndexList	modelList = selectionModel->selectedIndexes();
	if (modelList.size() < 1)
		return;
	QStandardItemModel* model = qobject_cast<QStandardItemModel*>(view->model());
	std::string dirString("");
	if (view == _treeListView)
	{
		std::string plantDir = g_SystemContext._workContextDir;
		plantDir.append(CONTEXT_DIR);
		plantDir.append("/Plant/");
		dirString = plantDir + "Tree/";
	}
	else
	{
		std::string plantDir = g_SystemContext._workContextDir;
		plantDir.append(CONTEXT_DIR);
		plantDir.append("/Plant/");
		dirString = plantDir + "Grass/";
	}
	QStandardItem* currentItem = model->itemFromIndex(modelList.at(0));
	dirString.append(chineseTextToUTF8String(currentItem->text()));
	osg::ref_ptr<osg::Node> node;
	if (currentItem->text().endsWith(".osgb"))
	{
		node = g_SystemContext._resourceLoader->getNodeByName(dirString, false);
	}
	else
	{
		osg::ref_ptr<osg::Image> image = g_SystemContext._resourceLoader->getImageByFileName(dirString);
		if (image.valid())
		{
			float s = image->s();
			float t = image->t();
			osg::ref_ptr<osg::Geometry> geometry = osg::createTexturedQuadGeometry(osg::Vec3(-s / 2.0f, -t / 2.0f, 0), osg::Vec3(s, 0, 0), osg::Vec3(0, t, 0));
			osg::ref_ptr<osg::Geode> geode = new osg::Geode;
			geode->addDrawable(geometry);
			osg::StateSet* ss = geode->getOrCreateStateSet();
			ss->setMode(GL_BLEND, osg::StateAttribute::ON);
			ss->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
			osg::Texture2D* texture = new osg::Texture2D(image);
			ss->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
			node = geode;
		}
	}
	if (node.valid())
	{
		_nodeViewDialog = new NodeViewDialog;
		_nodeViewDialog->setNode(node);
		_nodeViewDialog->exec();
		//_nodeViewDialog->setNode(NULL);
	}
}