Exemple #1
1
void MainWindow::createDockWindows()
{
	// Engine debug
	QDockWidget* engineDebugDock = new QDockWidget(tr("Engine Debug"), this);
	m_engineDebugLog = new PlainTextLog(engineDebugDock);
	connect(m_engineDebugLog, SIGNAL(saveLogToFileRequest()), this,
		SLOT(saveLogToFile()));
	engineDebugDock->setWidget(m_engineDebugLog);

	addDockWidget(Qt::BottomDockWidgetArea, engineDebugDock);

	// Move list
	QDockWidget* moveListDock = new QDockWidget(tr("Moves"), this);
	moveListDock->setWidget(m_moveList);

	addDockWidget(Qt::RightDockWidgetArea, moveListDock);

	// Tags
	QDockWidget* tagsDock = new QDockWidget(tr("Tags"), this);
	QTreeView* tagsView = new QTreeView(tagsDock);
	tagsView->setModel(m_tagsModel);
	tagsView->setAlternatingRowColors(true);
	tagsView->setRootIsDecorated(false);
	tagsDock->setWidget(tagsView);

	addDockWidget(Qt::RightDockWidgetArea, tagsDock);

	tabifyDockWidget(moveListDock, tagsDock);
	moveListDock->raise();

	// Add toggle view actions to the View menu
	m_viewMenu->addAction(moveListDock->toggleViewAction());
	m_viewMenu->addAction(tagsDock->toggleViewAction());
	m_viewMenu->addAction(engineDebugDock->toggleViewAction());
}
Exemple #2
0
void WorkSheetWidget::setupCompleters()
{
    QTreeView *itemTreeView =  new QTreeView;
    itemModel.setQuery("SELECT Description FROM item");
    pItemCompleter = new QCompleter(&itemModel,this);
    pItemCompleter->setPopup(itemTreeView);
    itemTreeView->setRootIsDecorated(false);
    itemTreeView->header()->hide();
    itemTreeView->header()->setStretchLastSection(false);
    itemTreeView->header()->setResizeMode(0, QHeaderView::ResizeToContents);

    pItemCompleter->setCaseSensitivity(Qt::CaseInsensitive);
    pItemCompleter->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
    ui->ItemEdit->setCompleter(pItemCompleter);

    QTreeView *categoryTreeView =  new QTreeView;
    categoryModel.setQuery("SELECT Name FROM category");
    pCategoryCompleter = new QCompleter(&categoryModel, this);
    pCategoryCompleter->setPopup(categoryTreeView);
    categoryTreeView->setRootIsDecorated(false);
    categoryTreeView->header()->hide();
    categoryTreeView->header()->setStretchLastSection(false);
    categoryTreeView->header()->setResizeMode(0, QHeaderView::ResizeToContents);

    pCategoryCompleter->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
    pCategoryCompleter->setCaseSensitivity(Qt::CaseInsensitive);
    ui->categoryEdit->setCompleter(pCategoryCompleter);


}
void tst_QDirModel::task196768_sorting()
{
    //this task showed that the persistent model indexes got corrupted when sorting
    QString path = SRCDIR;

    QDirModel model;

    /* QDirModel has a bug if we show the content of the subdirectory inside a hidden directory
       and we don't add QDir::Hidden. But as QDirModel is deprecated, we decided not to fix it. */
    model.setFilter(QDir::AllEntries | QDir::Hidden | QDir::AllDirs);

    QTreeView view;
    QPersistentModelIndex index = model.index(path);
    view.setModel(&model);
    QModelIndex index2 = model.index(path);
    QCOMPARE(index.data(), index2.data());
    view.setRootIndex(index);
    index2 = model.index(path);
    QCOMPARE(index.data(), index2.data());
    view.setCurrentIndex(index);
    index2 = model.index(path);
    QCOMPARE(index.data(), index2.data());
    view.setSortingEnabled(true);
    index2 = model.index(path);

#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
    QEXPECT_FAIL("", "QTBUG-43818", Continue);
#endif

    QCOMPARE(index.data(), index2.data());
}
Exemple #4
0
int TreeView::setHeader(lua_State * L) // ( QHeaderView * header )
{
    QTreeView* obj = QtObject<QTreeView>::check( L, 1);
    QHeaderView* header = QtObject<QHeaderView>::check( L, 2);
	obj->setHeader( header );
	return 0;
}
Exemple #5
0
int TreeView::setExpanded(lua_State * L) // ( const QModelIndex & index, bool expanded )
{
    QTreeView* obj = QtObject<QTreeView>::check( L, 1);
    QModelIndex* index = QtValue<QModelIndex>::check( L, 2 );
	obj->setExpanded( *index, Util::toBool( L, 3 ) );
	return 0;
}
ActionInspectorWidget::ActionInspectorWidget(QWidget *parent)
  : QWidget(parent)
{
  QAbstractItemModel *actionModel = ObjectBroker::model("com.kdab.GammaRay.ActionModel");

  QSortFilterProxyModel *searchFilterProxy = new KRecursiveFilterProxyModel(this);
  searchFilterProxy->setSourceModel(actionModel);
  searchFilterProxy->setDynamicSortFilter(true);
  m_proxy = searchFilterProxy;

  QVBoxLayout *vbox = new QVBoxLayout(this);

  KFilterProxySearchLine *objectSearchLine = new KFilterProxySearchLine(this);
  objectSearchLine->setProxy(searchFilterProxy);
  vbox->addWidget(objectSearchLine);

  QTreeView *objectTreeView = new QTreeView(this);
  objectTreeView->setModel(searchFilterProxy);
  objectTreeView->setSortingEnabled(true);
  objectTreeView->sortByColumn(ActionModel::ShortcutsPropColumn);
  objectTreeView->setRootIsDecorated(false);
  vbox->addWidget(objectTreeView);
  connect(objectTreeView, SIGNAL(doubleClicked(QModelIndex)), SLOT(triggerAction(QModelIndex)));
  mObjectTreeView = objectTreeView;
}
Exemple #7
0
void View::Private::slotCollapsed(const QModelIndex& _idx)
{
    QTreeView* tw = qobject_cast<QTreeView*>(leftWidget);
    if (!tw) return;

    bool blocked = gfxview->blockSignals( true );

    QModelIndex idx( _idx );
    const QAbstractItemModel* model = leftWidget->model();
    const QModelIndex pidx = ganttProxyModel.mapFromSource(idx);
    bool isMulti = false;
    for ( QModelIndex treewalkidx = pidx; treewalkidx.isValid(); treewalkidx = treewalkidx.parent() ) {
        if ( treewalkidx.data( ItemTypeRole ).toInt() == TypeMulti
             && !gfxview->rowController()->isRowExpanded( treewalkidx ) ) {
            isMulti = true;
            break;
        }
    }

    if ( !isMulti ) {
        for ( int i = 0; i < model->rowCount( idx ); ++i ) {
            gfxview->deleteSubtree( ganttProxyModel.index( i, 0, pidx ) );
        }
    } else {
        gfxview->updateRow(pidx);
    }
    //qDebug() << "Looking to update from " << idx;
    while ( ( idx=tw->indexBelow( idx ) ) != QModelIndex() &&
            gfxview->rowController()->isRowVisible( ganttProxyModel.mapFromSource(idx) ) ) {
        const QModelIndex proxyidx( ganttProxyModel.mapFromSource( idx ) );
        gfxview->updateRow(proxyidx);
    }
    gfxview->blockSignals( blocked );
    gfxview->updateSceneRect();
}
Exemple #8
0
int TreeView::isRowHidden(lua_State * L) // ( int row, const QModelIndex & parent ) const : bool 
{
    QTreeView* obj = QtObject<QTreeView>::check( L, 1);
    QModelIndex* parent = QtValue<QModelIndex>::check( L, 3 );
	Util::push( L, obj->isRowHidden( Util::toInt( L, 2 ), *parent ) );
	return 1;
}
Exemple #9
0
AddBookmarkDialog::AddBookmarkDialog(const QString &url, const QString &title, QWidget *parent, BookmarksManager *bookmarkManager)
    : QDialog(parent)
    , m_url(url)
    , m_bookmarksManager(bookmarkManager)
{
    setWindowFlags(Qt::Sheet);
    if (!m_bookmarksManager)
        m_bookmarksManager = BrowserApplication::bookmarksManager();
    setupUi(this);
    QTreeView *view = new QTreeView(this);
    m_proxyModel = new AddBookmarkProxyModel(this);
    BookmarksModel *model = m_bookmarksManager->bookmarksModel();
    m_proxyModel->setSourceModel(model);
    view->setModel(m_proxyModel);
    view->expandAll();
    view->header()->setStretchLastSection(true);
    view->header()->hide();
    view->setItemsExpandable(false);
    view->setRootIsDecorated(false);
    view->setIndentation(10);
    location->setModel(m_proxyModel);
    view->show();
    location->setView(view);
    BookmarkNode *menu = m_bookmarksManager->menu();
    QModelIndex idx = m_proxyModel->mapFromSource(model->index(menu));
    view->setCurrentIndex(idx);
    location->setCurrentIndex(idx.row());
    name->setText(title);
}
GraphViewer::GraphViewer(ProbeInterface *probe, QWidget *parent)
    : QWidget(parent),
      mWidget(new GraphWidget(this)),
      mProbeIface(probe)
{
    QSortFilterProxyModel *objectFilter = new KRecursiveFilterProxyModel(this);
    objectFilter->setSourceModel(probe->objectTreeModel());
    objectFilter->setDynamicSortFilter(true);

    QVBoxLayout *vbox = new QVBoxLayout;
    KFilterProxySearchLine *objectSearchLine = new KFilterProxySearchLine(this);
    objectSearchLine->setProxy(objectFilter);
    vbox->addWidget(objectSearchLine);
    QTreeView *objectTreeView = new QTreeView(this);
    objectTreeView->setModel(objectFilter);
    objectTreeView->setSortingEnabled(true);
    vbox->addWidget(objectTreeView);
    connect(objectTreeView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
            SLOT(handleRowChanged(QModelIndex)));
    mObjectTreeView = objectTreeView;

    QWidget *treeViewWidget = new QWidget(this);
    treeViewWidget->setLayout(vbox);

    QSplitter *splitter = new QSplitter(this);
    splitter->addWidget(treeViewWidget);
    splitter->addWidget(mWidget);
    QHBoxLayout *hbox = new QHBoxLayout(this);
    hbox->addWidget(splitter);

    QMetaObject::invokeMethod(this, "delayedInit", Qt::QueuedConnection);
}
Exemple #11
0
// ------------ ObjectInspector
ObjectInspector::ObjectInspector(QDesignerFormEditorInterface *core, QWidget *parent) :
    QDesignerObjectInspector(parent),
    m_impl(new ObjectInspectorPrivate(core))
{
    QVBoxLayout *vbox = new QVBoxLayout(this);
    vbox->setMargin(0);

    QTreeView *treeView = m_impl->treeView();
    vbox->addWidget(treeView);

    connect(treeView, SIGNAL(customContextMenuRequested(QPoint)),
            this, SLOT(slotPopupContextMenu(QPoint)));

    connect(treeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
            this, SLOT(slotSelectionChanged(QItemSelection,QItemSelection)));

    connect(treeView->header(), SIGNAL(sectionDoubleClicked(int)), this, SLOT(slotHeaderDoubleClicked(int)));
    setAcceptDrops(true);

    ItemViewFindWidget *findWidget = m_impl->findWidget();
    vbox->addWidget(findWidget);

    findWidget->setItemView(treeView);
    QAction *findAction = new QAction(
            ItemViewFindWidget::findIconSet(),
            tr("&Find in Text..."),
            this);
    findAction->setShortcut(QKeySequence::Find);
    findAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
    addAction(findAction);
    connect(findAction, SIGNAL(triggered(bool)), findWidget, SLOT(activate()));
}
Exemple #12
0
MainWindow::MainWindow(QWidget *parent) :
	QMainWindow(parent),
	ui(new Ui::MainWindow)
{
	ui->setupUi(this);

	m_pModel = new CBvhModel(this) ;

	QHBoxLayout *pLayout = new QHBoxLayout(ui->centralWidget) ;
	QSplitter *pSplitter = new QSplitter(ui->centralWidget) ;
	pLayout->addWidget(pSplitter);

	QTreeView *pTreeView = new QTreeView(this) ;
	pTreeView->setModel(m_pModel);
	pTreeView->header()->setHidden(true) ;

	m_pGlView = new CGLView(ui->centralWidget) ;
	m_pGlView->show();

	pSplitter->addWidget(pTreeView) ;
	pSplitter->addWidget(m_pGlView) ;

	ui->centralWidget->setLayout(pLayout) ;

	setAcceptDrops(true) ;

	QTimer *pTimer = new QTimer(this) ;
	pTimer->setInterval(1000/30);
	connect(pTimer, SIGNAL(timeout()), this, SLOT(slot_timerEvent())) ;
	m_oldTime.start() ;
	pTimer->start();
	m_bRead = false ;
}
Exemple #13
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();
}
Exemple #14
0
int main(int argc, char** argv) {
  QApplication app(argc, argv);
  const QString name("CConf Demo");
  app.setApplicationDisplayName(name);

  // CConf::Context *ctxt = new CConf::Context();
  // ctxt->addFile("example.json");
  // ctxt->addFile("example2.json");

  // TestModel model;

  QStandardItemModel model;

  QStandardItem item(QString("my item"));

  QList<QStandardItem*> myList;
  myList.append(&item);

  model.appendRow(myList);

  QTreeView* confView = new QTreeView();
  confView->setModel(&model);

  QMainWindow* win = new QMainWindow();
  win->addToolBar(name);
  win->setCentralWidget(confView);
  win->show();

  return app.exec();
}
Exemple #15
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();
}
Exemple #16
0
LessThanWidget::LessThanWidget(QWidget* parent, Qt::WindowFlags f)
    : QWidget(parent, f)
{
  QLabel *explanation = new QLabel(this);
  explanation->setText("The yellow items are 'less than' the selected item according to QModelIndex::operator<().\n"
                       "The red items are greater than the selected item (i.e, not less than and not equal).");

  m_coloredTreeModel = new ColoredTreeModel(this);
  QTreeView *treeView = new QTreeView(this);
  treeView->setModel(m_coloredTreeModel);
  treeView->setSelectionBehavior(QAbstractItemView::SelectItems);
  treeView->setSelectionMode(QTreeView::SingleSelection);

  m_coloredTreeModel->setSelectionModel(treeView->selectionModel());

  QVBoxLayout *layout = new QVBoxLayout(this);
  layout->addWidget(explanation);
  layout->addWidget(treeView);

  insertGrid(QList<int>());
  insertGrid(QList<int>() << 2);
  insertGrid(QList<int>() << 3);
  insertGrid(QList<int>() << 4);
  insertGrid(QList<int>() << 3 << 2);
  insertGrid(QList<int>() << 3 << 3);
  insertGrid(QList<int>() << 3 << 4);
}
Exemple #17
0
int TreeView::isExpanded(lua_State * L) // ( const QModelIndex & index ) const : bool 
{
    QTreeView* obj = QtObject<QTreeView>::check( L, 1);
    QModelIndex* index = QtValue<QModelIndex>::check( L, 2 );
	Util::push( L, obj->isExpanded( *index ) );
	return 1;
}
Exemple #18
0
int TreeView::setRowHidden(lua_State * L) // ( int row, const QModelIndex & parent, bool hide )
{
    QTreeView* obj = QtObject<QTreeView>::check( L, 1);
    QModelIndex* parent = QtValue<QModelIndex>::check( L, 3 );
	obj->setRowHidden( Util::toInt( L, 2 ), *parent, Util::toBool( L, 4 ) );
	return 0;
}
Exemple #19
0
void GLSLTextEditorWidget::createToolBar(GLSLEditorEditable *editable)
{
    m_outlineCombo = new QComboBox;
    m_outlineCombo->setMinimumContentsLength(22);

    // ### m_outlineCombo->setModel(m_outlineModel);

    QTreeView *treeView = new QTreeView;
    treeView->header()->hide();
    treeView->setItemsExpandable(false);
    treeView->setRootIsDecorated(false);
    m_outlineCombo->setView(treeView);
    treeView->expandAll();

    //m_outlineCombo->setSizeAdjustPolicy(QComboBox::AdjustToContents);

    // Make the combo box prefer to expand
    QSizePolicy policy = m_outlineCombo->sizePolicy();
    policy.setHorizontalPolicy(QSizePolicy::Expanding);
    m_outlineCombo->setSizePolicy(policy);

    QToolBar *toolBar = static_cast<QToolBar*>(editable->toolBar());

    QList<QAction*> actions = toolBar->actions();
    toolBar->insertWidget(actions.first(), m_outlineCombo);
}
Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
//! [0] //! [1]
        QTreeView *treeView = new QTreeView;
//! [0]
        MyItemModel *model = new MyItemModel(this);

        treeView->setModel(model);
//! [1]

//! [2]
        MyItemModel *sourceModel = new MyItemModel(this);
        QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this);

        proxyModel->setSourceModel(sourceModel);
        treeView->setModel(proxyModel);
//! [2]

//! [3]
        treeView->setSortingEnabled(true);
//! [3]

//! [4]
        proxyModel->sort(2, Qt::AscendingOrder);
//! [4] //! [5]
        proxyModel->setFilterRegExp(QRegExp(".png", Qt::CaseInsensitive,
                                            QRegExp::FixedString));
        proxyModel->setFilterKeyColumn(1);
//! [5]
}
void MainWindow::showSongsContextMenu(QPoint point)
{
    QTreeView *songs = (QTreeView*)ui->tvSongs;
    if(songs->indexAt(point).isValid()) {
        QList<QAction *> actions;

        QAction *action = new QAction(songs);
        action->setText(tr("Play"));
        connect(action, SIGNAL(triggered()), this, SLOT(playAudio()));
        actions.append(action);

        action = new QAction(songs);
        action->setText(tr("Delete"));
        connect(action, SIGNAL(triggered()), this, SLOT(deleteAudio()));
        actions.append(action);

        action = new QAction(songs);
        action->setSeparator(true);
        actions.append(action);

        QList<Playlist> pls = dp->getPlaylists();
        int n = pls.count();
        QSignalMapper* signalMapper = new QSignalMapper (this);
        for( int i=0; i<n; i++ )
        {
            action = new QAction(songs);
            action->setText("Add to " + pls[i].title);
            connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
            signalMapper->setMapping (action, pls[i].id) ;
            actions.append(action);
        }
        connect (signalMapper, SIGNAL(mapped(int)), this, SLOT(addAudioToPlaylist(int)));
        QMenu::exec(actions, songs->mapToGlobal(point));
    }
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();
}
Exemple #23
0
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:
    QTreeView *treeView = new QTreeView(this);
    treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
    treeView->setDragEnabled(true);
    treeView->setAcceptDrops(true);
    treeView->setDropIndicatorShown(true);

    this->treeView = treeView;

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

    setupItems();

    setCentralWidget(treeView);
    setWindowTitle(tr("Tree View"));
}
ctkDICOMHostMainLogic::ctkDICOMHostMainLogic(ctkHostedAppPlaceholderWidget* placeHolder, ctkDICOMAppWidget* dicomAppWidget, 
                                             QWidget* placeHolderForControls) : 
  QObject(placeHolder), 
  PlaceHolderForHostedApp(placeHolder),
  DicomAppWidget(dicomAppWidget),
  PlaceHolderForControls(placeHolderForControls),
  ValidSelection(false),
  SendData(false)
{
  this->Host = new ctkExampleDicomHost(PlaceHolderForHostedApp);
  this->HostControls = new ctkExampleHostControlWidget(Host, PlaceHolderForControls);

  Data = new ctkDicomAppHosting::AvailableData;

  disconnect(this->Host,SIGNAL(startProgress()),this->Host,SLOT(onStartProgress()));
  connect(this->Host,SIGNAL(appReady()),this,SLOT(onAppReady()), Qt::QueuedConnection);
  connect(this->Host,SIGNAL(startProgress()),this,SLOT(publishSelectedData()), Qt::QueuedConnection);
  connect(this->PlaceHolderForHostedApp,SIGNAL(resized()),this,SLOT(placeHolderResized()));

  QTreeView * treeview = dicomAppWidget->findChild<QTreeView*>("TreeView");
  QItemSelectionModel* selectionmodel = treeview->selectionModel();
  connect(selectionmodel, SIGNAL(selectionChanged ( const QItemSelection &, const QItemSelection & )),
    this, SLOT(onTreeSelectionChanged(const QItemSelection &, const QItemSelection &)));

  connect(this->Host, SIGNAL(dataAvailable()), this, SLOT(onDataAvailable()));

  connect( qApp, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()) );
}
//-----------------------------------------------------------------------------
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();
}
MessageLogWindow::MessageLogWindow(const string& id, QWidget* pParent) :
   DockWindowAdapter(id, "Message Log Window", pParent),
   mpLogCombo(NULL),
   mpModel(NULL),
   mpMsgLogMgr(Service<MessageLogMgr>().get())
{
   QWidget* pWidget = new QWidget(this);

   // Message log item model
   mpModel = new MessageLogWindowModel;

   // Message tree
   QTreeView* pMessageTree = new QTreeView(pWidget);
   pMessageTree->setModel(mpModel);
   pMessageTree->setSelectionMode(QAbstractItemView::NoSelection);
   pMessageTree->setRootIsDecorated(true);

   QHeaderView* pHeader = pMessageTree->header();
   if (pHeader != NULL)
   {
      pHeader->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
      pHeader->setSortIndicatorShown(false);
   }

   // Message log combo
   mpLogCombo = new QComboBox(pWidget);

   // Layout
   QVBoxLayout* pLayout = new QVBoxLayout(pWidget);
   pLayout->setMargin(10);
   pLayout->setSpacing(5);
   pLayout->addWidget(pMessageTree, 10);
   pLayout->addWidget(mpLogCombo);

   // Initialization
   setIcon(QIcon(":/icons/MessageLogWindow"));
   setWidget(pWidget);

   vector<MessageLog*> logs = mpMsgLogMgr->getLogs();
   for (vector<MessageLog*>::const_iterator iter = logs.begin(); iter != logs.end(); ++iter)
   {
      MessageLog* pLog = *iter;
      if (pLog != NULL)
      {
         QString logName = getLogDisplayName(pLog);
         if (logName.isEmpty() == false)
         {
            mpLogCombo->addItem(logName);
         }
      }
   }

   setLog(mpLogCombo->currentText());

   // Connections
   VERIFYNR(connect(mpLogCombo, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(setLog(const QString&))));
   mpMsgLogMgr.addSignal(SIGNAL_NAME(MessageLogMgr, LogAdded), Slot(this, &MessageLogWindow::messageLogAdded));
   mpMsgLogMgr.addSignal(SIGNAL_NAME(MessageLogMgr, LogRemoved), Slot(this, &MessageLogWindow::messageLogRemoved));
}
			void PackagesDelegate::invalidateWidgetPositions ()
			{
				QTreeView *view = qobject_cast<QTreeView*> (parent ());
				QAbstractItemModel *model = view->model ();
				for (int i = 0, rows = model->rowCount ();
						i < rows; ++i)
					emit sizeHintChanged (model->index (i, 0));
			}
Exemple #28
0
int TreeView::indexBelow(lua_State * L) // ( const QModelIndex & index ) const : QModelIndex 
{
    QTreeView* obj = QtObject<QTreeView>::check( L, 1);
    QModelIndex* index = QtValue<QModelIndex>::check( L, 2 );
    QModelIndex* res = QtValue<QModelIndex>::create( L );
	*res = obj->indexBelow( *index );
	return 1;
}
Exemple #29
0
void TreeCtrl::handleExpand(Root::Action & t)
{
	QTreeView* tv = wnd();
	QModelIndex i = tv->currentIndex();
	ENABLED_IF( t, i.isValid() && ! tv->isExpanded( i ) );

	tv->setExpanded( i, true );
}
Exemple #30
0
int TreeView::visualRect(lua_State * L) // ( const QModelIndex & index ) const : QRect 
{
    QTreeView* obj = QtObject<QTreeView>::check( L, 1);
    QModelIndex* index = QtValue<QModelIndex>::check( L, 2 );
    QRectF* res = QtValue<QRectF>::create( L );
	*res = obj->visualRect( *index );
	return 1;
}