// ----------------------------------------------------------------------------
// SatAppMenuProvider::setUpMenu
// constructs a menu in the main SAT application view
// ----------------------------------------------------------------------------
//
void SatAppMenuProvider::setUpMenu(SatAppAction &action)
{
    qDebug("SATAPP: SatAppMenuProvider::setUpMenu >");
    if (!mSetupMenuView) {
        loadMainView();
    }
    resetState();
    mCurrentAction = &action;
    switchView();
    action.setResponse(ESatSuccess);

    // The text is the application name
    // should be shown on the menu area always
    QString text = action.value(KeyText).toString();
    if (!text.isEmpty()) {
        mSetupMenuView->setTitle(text);
        mSelectItemView->setTitle(text);
    }
    qDebug() << "SATAPP: SetUpMenu title=" << text;

    // build the menu
    QList<QVariant> menu = action.value(KeyMenu).toList();
    mListWidget->clear();
    for(int i = 0; i < menu.count(); i++ ) {
        mListWidget->addItem(menu.at(i).toString());
    }
    qDebug() << "SATAPP: SetUpMenu menu=" << menu;

    // back-key quits the application
    mSetupMenuView->setNavigationAction(mSoftKeyQuitAction);
    // completes action with ESatSuccess and selected item
    connectItem();

    qDebug("SATAPP: SatAppMenuProvider::setUpMenu <");
}
void CntDefaultViewManager::back(const CntViewParameters aArgs, bool toRoot)
{
    CNT_ENTRY
    
    mArgs.clear();
    
    QFlags<Hb::ViewSwitchFlag> flags;
    int back = mNavigator->back( flags, toRoot );

    foreach( int k, aArgs.keys() )
    {
        mArgs.insert( k, aArgs.value(k) );
    }
    mArgs.insert(EViewId, back );

    if (mArgs.value(EViewId).toInt() != noView)
    {
        switchView( mArgs, flags );
    }
    else 
    {
        // exiting application
        cleanup();
        closeApp();
    }
    
    CNT_EXIT
}
Ejemplo n.º 3
0
RedditBrowser::RedditBrowser(RedditStory story_, QVariantHash& history_)
  : QWidget(NULL),
	story(story_),
	showingComments(false),
	firstShow(true),
	history(history_),
	loading(false),
	frame(-1)
{
	webview = new QWebView(this);	

	url = new QLineEdit(this);
	toggle = new QPushButton("Show Comments", this);
	openInBrowser = new QPushButton("Open In Browser", this);

	QBoxLayout* topLayout = new QBoxLayout(QBoxLayout::LeftToRight);
	topLayout->addWidget(url);
	topLayout->addWidget(toggle);
	topLayout->addWidget(openInBrowser);	

	QBoxLayout* mainLayout = new QBoxLayout(QBoxLayout::TopToBottom, this);
	mainLayout->addLayout(topLayout);
	mainLayout->addWidget(webview);

	setLayout(mainLayout);

	connect(toggle, SIGNAL(clicked()), this, SLOT(switchView()));
	connect(openInBrowser, SIGNAL(clicked()), this, SLOT(openBrowser()));
	connect(webview, SIGNAL(loadFinished(bool)), this,  SLOT(loadFinishedInt(bool)));
	connect(webview, SIGNAL(loadStarted()), this, SLOT(loadStartedInt()));
	connect(webview, SIGNAL(urlChanged(const QUrl&)), this, SLOT(urlChanged(const QUrl&)));

	webview->load(QUrl(story.link));
	url->setText(story.link);
}
void CntDefaultViewManager::changeView(const CntViewParameters aArgs)
{
    CNT_ENTRY
    
    QFlags<Hb::ViewSwitchFlag> flags;
    mNavigator->next(aArgs.value(EViewId).toInt(), flags);
    switchView(aArgs, flags);
    
    CNT_EXIT
}
Ejemplo n.º 5
0
bool KonqView::changePart(const QString &mimeType,
                          const QString &serviceName,
                          bool forceAutoEmbed)
{
    // Caller should call stop first.
    assert( !m_bLoading );

    //kDebug() << "mimeType=" << mimeType
    //             << "requested serviceName=" << serviceName
    //             << "current service name=" << m_service->desktopEntryName();

    if (serviceName == m_service->desktopEntryName()) {
        m_serviceType = mimeType;
        return true;
    }

    if (isLockedViewMode()) {
        //kDebug() << "This view's mode is locked - can't change";
        return false; // we can't do that if our view mode is locked
    }

    KService::List partServiceOffers, appServiceOffers;
    KService::Ptr service;
    KonqFactory konqFactory;
    KonqViewFactory viewFactory = konqFactory.createView( mimeType, serviceName, &service, &partServiceOffers, &appServiceOffers, forceAutoEmbed );

  if ( viewFactory.isNull() )
  {
    // Revert location bar's URL to the working one
    if(currentHistoryEntry())
      setLocationBarURL( currentHistoryEntry()->locationBarURL );
    return false;
  }

  m_serviceType = mimeType;
  m_partServiceOffers = partServiceOffers;
  m_appServiceOffers = appServiceOffers;

  // Check if that's already the kind of part we have -> no need to recreate it
  // Note: we should have an operator== for KService...
  if ( m_service && m_service->entryPath() == service->entryPath() )
  {
    kDebug() << "Reusing service. Service type set to" << m_serviceType;
    if (  m_pMainWindow->currentView() == this )
      m_pMainWindow->updateViewModeActions();
  }
  else
  {
    m_service = service;

    switchView( viewFactory );
  }

  return true;
}
Ejemplo n.º 6
0
void NetTree::TreeRefresh()
{
    m_siteGeneric = new MythGenericTree("site root", 0, false);
    m_currentNode = m_siteGeneric;

    m_grabberList = findAllDBTreeGrabbers();
    m_rssList = findAllDBRSS();

    fillTree();
    loadData();
    switchView();
}
Ejemplo n.º 7
0
KonqView::KonqView( KonqViewFactory &viewFactory,
                    KonqFrame* viewFrame,
                    KonqMainWindow *mainWindow,
                    const KService::Ptr &service,
                    const KService::List &partServiceOffers,
                    const KService::List &appServiceOffers,
                    const QString &serviceType,
                    bool passiveMode
                    )
{
  m_pKonqFrame = viewFrame;
  m_pKonqFrame->setView( this );

  m_sLocationBarURL = "";
  m_pageSecurity = KonqMainWindow::NotCrypted;
  m_bLockHistory = false;
  m_doPost = false;
  m_pMainWindow = mainWindow;
  m_pRun = NULL;
  m_pPart = NULL;

  m_randID = KRandom::random();

  m_service = service;
  m_partServiceOffers = partServiceOffers;
  m_appServiceOffers = appServiceOffers;
  m_serviceType = serviceType;

  m_bAllowHTML = m_pMainWindow->isHTMLAllowed();
  m_lstHistoryIndex = -1;
  m_bLoading = false;
  m_bPendingRedirection = false;
  m_bPassiveMode = passiveMode;
  m_bLockedLocation = false;
  m_bLinkedView = false;
  m_bAborted = false;
  m_bToggleView = false;
  m_bHierarchicalView = false;
  m_bDisableScrolling = false;
  m_bGotIconURL = false;
  m_bPopupMenuEnabled = true;
  m_browserIface = new KonqBrowserInterface( this );
  m_bFollowActive = false;
  m_bBuiltinView = false;
  m_bURLDropHandling = false;
  m_bErrorURL = false;

  switchView( viewFactory );
}
Ejemplo n.º 8
0
/***************************************************************************//**
 * @author Daniel Andrus, Johnny Ackerman
 * 
 * @par Description: Begins running the program. Initializes OpenGL, registers
 *		events, instantiates objects, and runs the game. Beware when
 *		calling this function, as it enters the OpenGL main loop, only
 *		to return at end of program execution.
 *
 * @returns Status code of the program. 0 means no problems.
*******************************************************************************/
int Fractals::run( int argc, char *argv[] )
{
	window_width = (int) view_width;
	window_height = (int) view_height;

	// perform various OpenGL initializations
    glutInit( &argc, argv );

	// Put window in center of screen
	int w = glutGet(GLUT_SCREEN_WIDTH);
	int h = glutGet(GLUT_SCREEN_HEIGHT);
	if (w != 0 && h != 0)
	{
		w = w / 2 - window_width / 2;
		h = h / 2 - window_height / 2;
	}

	// Initialize glut with 32-bit graphics, double buffering, and anti-aliasing
    glutInitDisplayMode( GLUT_RGBA /*| GLUT_DOUBLE*/ | GLUT_MULTISAMPLE );
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	// Set up the program window
    glutInitWindowSize( window_width, window_height);    // initial window size
    glutInitWindowPosition( w, h );                  // initial window position
    glutCreateWindow( window_name.c_str() );         // window title

	// Always clear screen to black
	glClearColor( 1.0, 1.0, 1.0, 1.0 );

	glutIgnoreKeyRepeat(1);

    // Register callbacks
    glutDisplayFunc( *::display );
    glutReshapeFunc( *::reshape );
    glutMouseFunc( *::mouseclick );
	glutMotionFunc( *::mousedrag );
	glutPassiveMotionFunc( *::mousemove );
	
	tabs[0]->active = true;
	switchView("Fractal");

    // Go into OpenGL/GLUT main loop
    glutMainLoop();

    return 0;

}
// ----------------------------------------------------------------------------
// SatAppMenuProvider::selectItem
// Constructs a SETECT ITEM view
// ----------------------------------------------------------------------------
//
void SatAppMenuProvider::selectItem( SatAppAction &action)
{
    qDebug("SATAPP: SatAppMenuProvider::selectItem >");
    
    if (!mSetupMenuView) {
        loadMainView();
    }
    
    resetState();
    mCurrentAction = &action;
    switchView();
    action.setResponse(ESatSuccess);

    // Set sub title
    QString text = action.value(KeyText).toString();
    if (!text.isEmpty()) {
        mSubTitle->setPlainText(text);
    } else {
        mSubTitle->setPlainText(hbTrId("txt_long_caption_sim_services"));
    }
    qDebug() << "SATAPP: selectItem text=" << text;

    // Set List widget
    QList<QVariant> menu = action.value(KeyMenu).toList();
    mSelectListWidget->clear();
    for(int i = 0; i < menu.count(); i++ ) {
        mSelectListWidget->addItem(menu.at( i ).toString());
    }
    qDebug() << "SATAPP: selectItem menu=" << menu;

    // timeout completes action with ESatNoResponseFromUser
    QTimer::singleShot(KDefaultSelectionTimeoutMseconds,
        mCurrentAction,SLOT(completeWithNoResponse()));
    // back-key completes action with ESatBackwardModeRequestedByUser
    mSelectItemView->setNavigationAction(mSoftKeyBackAction);
    SAT_ASSERT(connect(mSoftKeyBackAction, SIGNAL(triggered()),
        mCurrentAction, SLOT(completeWithBackRequested())));
    SAT_ASSERT(connect(mSelectItemView->menu()->actions().at(1), 
        SIGNAL(triggered()),
        mCurrentAction, SLOT(completeWithSessionTerminated())));
    
    // completes action with ESatSuccess and selected item
    connectItem();

    qDebug("SATAPP: SatAppMenuProvider::selectItem <");
}
Ejemplo n.º 10
0
FileDialog::FileDialog(QWidget *parent)
  : QDialog(parent)
{
  setupUi(this);

  dirModel = new QDirModel;
  selModel = new QItemSelectionModel(dirModel);
  
  listView->setModel(dirModel);
  treeView->setModel(dirModel);
  iconView->setModel(dirModel);

  listView->setSelectionModel(selModel);
  treeView->setSelectionModel(selModel);
  iconView->setSelectionModel(selModel);

  QModelIndex cwdIndex = 
      dirModel->index(QDir::rootPath());

  listView->setRootIndex(cwdIndex);
  treeView->setRootIndex(cwdIndex);
  iconView->setRootIndex(cwdIndex);
  for (int r = 0; r < dirModel->rowCount(QModelIndex()); ++r) {
    QModelIndex index = dirModel->index(r, 0, QModelIndex());
    if (index.isValid())
      comboBox->addItem(dirModel->fileIcon(index), 
       dirModel->filePath(index));
  }
  connect(listView, SIGNAL(activated(const QModelIndex&)), 
               SLOT(switchToDir(const QModelIndex&)));
  connect(treeView, SIGNAL(activated(const QModelIndex&)), 
               SLOT(switchToDir(const QModelIndex&)));
  connect(iconView, SIGNAL(activated(const QModelIndex&)), 
               SLOT(switchToDir(const QModelIndex&)));

  connect(listView, SIGNAL(clicked(const QModelIndex&)), 
               SLOT(syncActive(const QModelIndex&)));
  connect(treeView, SIGNAL(clicked(const QModelIndex&)), 
               SLOT(syncActive(const QModelIndex&)));
  connect(iconView, SIGNAL(clicked(const QModelIndex&)), 
               SLOT(syncActive(const QModelIndex&)));

  connect(switchButton, SIGNAL(clicked()), SLOT(switchView()));
}
Ejemplo n.º 11
0
void ViewerWindow::showObjectModel(uint16_t)
{
	// Switch to the model viewer
	switchView(ViewMode::Model);
	viewSwitcher->setCurrentIndex( viewSwitcher->indexOf(m_views[ViewMode::Model]) );
}
Ejemplo n.º 12
0
void NetTree::switchTreeView()
{
    m_type = DLG_TREE;
    switchView();
}
Ejemplo n.º 13
0
void NetTree::switchGalleryView()
{
    m_type = DLG_GALLERY;
    switchView();
}
Ejemplo n.º 14
0
AddressBook::AddressBook(QWidget *parent)
     : QMainWindow(parent)
 {

    
    // Init. de la BDD
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("addressbook.sqlite");

    if(!db.open()) { // Si l'ouverture du fichier de données est impossible on le notifie à l'utilisateur et on ferme le programme
         QMessageBox::warning(this, "Init.", "Impossible d'accèder à la base de données.\nImpossible de lancer le programme\n");
         exit(1);
     }
    // La table contient les données suivantes
    // id, nom, prénom, date de naissance, sexe, n° téléphone, n° téléphone portable,
    // n° téléphone professionnel, n° de fax, adresse e-mail, url du site internet,
    // adresse du domicile, ville du domicile, code postal du domicile
    // adresse du bureau, ville du bureau, code postal du bureau
    // l'id du 1er parent et du 2nd parent -- inutilisés mais dans les anciennes contraintes du programmes
    QSqlQuery query;
    query.exec("CREATE TABLE IF NOT EXISTS `addressbook` ("
            "`id` INTEGER PRIMARY KEY,"
            "`lastname` TEXT NOT NULL,"
            "`firstname` TEXT NOT NULL,"
            "`date` TEXT ,"
            "`gender` INTEGER ,"
            "`phone` TEXT ,"
            "`cellphone` TEXT ,"
            "`prophone` TEXT ,"
            "`fax` TEXT ,"
            "`email` TEXT ,"
            "`website` TEXT ,"
            "`homeaddress` TEXT ,"
            "`homecity` TEXT ,"
            "`homezip` INTEGER ,"
            "`proaddress` TEXT ,"
            "`procity` TEXT ,"
            "`prozip` INTEGER ,"
            "`id_parent1` INTEGER ,"
            "`id_parent2` INTEGER )");

     // Les éléments du formulaire d'ajout/modification de contact

// /!\ CETTE (ces) LIGNE(s) (et les éventuelles lignes semblables) A (ont) ETE INSPIREE PAR "LE TUTORIEL CARNET D'ADRESSES QT" (disponible à l'adresse "http://doc.qt.nokia.com/4.6/tutorials-addressbook-fr-part1.html"). LE CODE REPRIS EST DISPONIBLE A LA (aux) LIGNE(s) SUIVANTE(s)
     //  nameLine = new QLineEdit;
     nameLine = new QLineEdit; // Champ de saisie du prénom
     lastnameLine = new QLineEdit;
     dateLine = new QDateEdit;
     dateLine->setDisplayFormat("dd/MM/yyyy");
// /!\ CETTE (ces) LIGNE(s) (et les éventuelles lignes semblables) A (ont) ETE INSPIREE PAR "LA DOCUMENTATION QT - Line Edits Example" (disponible à l'adresse "http://doc.qt.nokia.com/4.6/widgets-lineedits.html"). LE CODE REPRIS EST DISPONIBLE A LA (aux) LIGNE(s) SUIVANTE(s)
  /* QComboBox *validatorComboBox = new QComboBox;
     validatorComboBox->addItem(tr("No validator"));
     validatorComboBox->addItem(tr("Integer validator")); */
     sexLine = new QComboBox; // Liste déroulante pour le sexe
      sexLine->addItem("Masculin");
      sexLine->addItem("Féminin");
     phoneLine = new QLineEdit;
     cellphoneLine = new QLineEdit;
     prophoneLine = new QLineEdit;
     faxLine = new QLineEdit;
     emailLine = new QLineEdit;
     websiteLine = new QLineEdit;
// /!\ CETTE (ces) LIGNE(s) (et les éventuelles lignes semblables) A (ont) ETE INSPIREEs PAR "LE TUTORIEL CARNET D'ADRESSES QT" (disponible à l'adresse "http://doc.qt.nokia.com/4.6/tutorials-addressbook-fr-part1.html"). LE CODE REPRIS EST DISPONIBLE A LA (aux) LIGNE(s) SUIVANTE(s)
      // addressText = new QTextEdit;
     homeaddressLine = new QTextEdit;  // Boîte de saise de l'adresse perso.
      homeaddressLine->setFixedHeight(48); // Définition d'une taille fixe pour la boîte de saisie pour ne pas avoir de problème lors du redimensionnement de la fenêtre
     homecityLine = new QLineEdit;
     homezipLine = new QLineEdit;
     proaddressLine = new QTextEdit;
     proaddressLine->setFixedHeight(48);
     procityLine = new QLineEdit;
     prozipLine = new QLineEdit;

// /!\ CETTE (ces) LIGNE(s) (et les éventuelles lignes semblables) A (ont) ETE INSPIREEs PAR "LE TUTORIEL CARNET D'ADRESSES QT" (disponible à l'adresse "http://doc.qt.nokia.com/4.6/tutorials-addressbook-fr-part1.html"). LE CODE REPRIS EST DISPONIBLE A LA (aux) LIGNE(s) SUIVANTE(s)
     // addButton = new QPushButton(tr("&Add"));
     addButton = new QPushButton(tr("&Ajouter")); // Bouton pour l'ajout d'une fiche nommé "Ajouter" -- également renommé pour la modification
     cancelButton = new QPushButton(tr("A&nnuler"));

// /!\ CETTE (ces) LIGNE(s) (et les éventuelles lignes semblables) A (ont) ETE INSPIREEs PAR "LE TUTORIEL CARNET D'ADRESSES QT" (disponible à l'adresse "http://doc.qt.nokia.com/4.6/tutorials-addressbook-fr-part2.html"). LE CODE REPRIS EST DISPONIBLE A LA (aux) LIGNE(s) SUIVANTE(s)
     // connect(addButton, SIGNAL(clicked()), this, SLOT(addContact()));
     connect(addButton, SIGNAL(clicked()), this, SLOT(submitContact())); // quand on clique sur addButton on exécute la fonction submitContact()
     connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));

     // Editeur de données.
      // Coordonnées pro.
// /!\ CETTE (ces) LIGNE(s) (et les éventuelles lignes semblables) A (ont) ETE INSPIREEs PAR "LA DOCUMENTATION QT - QFormLayout Class Reference" (disponible à l'adresse "http://doc.qt.nokia.com/4.6/qformlayout.html"). LE CODE REPRIS EST DISPONIBLE A LA (aux) LIGNE(s) SUIVANTE(s)
     // QFormLayout *formLayout = new QFormLayout;
     // formLayout->addRow(tr("&Name:"), nameLineEdit);
     EditorProfessionnalInfos = new QFormLayout; // Création du formulaire EditorProfessionnalInfos
      EditorProfessionnalInfos->addRow(tr("&Téléphone :"), prophoneLine); // Ajout de la ligne libellée "Téléphone" avec le widget prophoneLine
      EditorProfessionnalInfos->addRow(tr("&Fax :"), faxLine);
      EditorProfessionnalInfos->addRow(tr("&Adresse :"), proaddressLine);
      EditorProfessionnalInfos->addRow(tr("&Code postal :"), prozipLine);
      EditorProfessionnalInfos->addRow(tr("&Ville :"), procityLine);

      // Coordonnées perso.
     EditorPersonnalInfos = new QFormLayout;
      EditorPersonnalInfos->addRow(tr("&Téléphone :"), phoneLine);
      EditorPersonnalInfos->addRow(tr("&Portable :"), cellphoneLine);
      EditorPersonnalInfos->addRow(tr("&Adresse :"), homeaddressLine);
      EditorPersonnalInfos->addRow(tr("&Code postal :"), homezipLine);
      EditorPersonnalInfos->addRow(tr("&Ville :"), homecityLine);
      EditorPersonnalInfos->addRow(tr("&E-mail :"), emailLine);
      EditorPersonnalInfos->addRow(tr("&Site web :"), websiteLine);

      // Etat civil.
     EditorIdentity = new QFormLayout;
      EditorIdentity->addRow(tr("&Prénom :"), nameLine);
      EditorIdentity->addRow(tr("&Nom :"), lastnameLine);
      EditorIdentity->addRow(tr("&Sexe :"), sexLine);
      EditorIdentity->addRow(tr("&Date de naissance :"), dateLine);

// /!\ CETTE (ces) LIGNE(s) (et les éventuelles lignes semblables) A (ont) ETE INSPIREEs PAR "LE SITE DU ZERO - Apprenez à programmer en C++ ! > [Pratique] Créez vos propres fenêtres avec Qt > Les principaux widgets" (disponible à l'adresse "http://www.siteduzero.com/tutoriel-3-11316-les-principaux-widgets.html#ss_part_5"). LE CODE REPRIS EST DISPONIBLE A LA (aux) LIGNE(s) SUIVANTE(s)
/*
QFrame *frame = new QFrame(&fenetre);
    frame->setFrameShape(QFrame::StyledPanel);
    frame->setGeometry(30, 20, 120, 90);


    QLineEdit *lineEdit = new QLineEdit("Entrez votre nom");
    QPushButton *bouton1 = new QPushButton("Cliquez ici");
    QPushButton *bouton2 = new QPushButton("Ou là...");

    QVBoxLayout *vbox = new QVBoxLayout;
    vbox->addWidget(lineEdit);
    vbox->addWidget(bouton1);
    vbox->addWidget(bouton2);

    frame->setLayout(vbox);

  */
     Editor = new QTabWidget(); // Création du widget à onglets Editor
      Editor->setGeometry(30, 20, 240, 160); // définition de la position 30,20 et de la taille 240*160
      page1 = new QWidget; // Création du widget page1 - 1er onglet
       page1->setLayout(EditorIdentity); // Définition du contenu de page1
       Editor->addTab(page1, "Identité"); // Ajout et définition du titre du 3ème onglet : "Identité"
      page2 = new QWidget;
       page2->setLayout(EditorPersonnalInfos);
       Editor->addTab(page2, "Coordonnées perso.");
      page3 = new QWidget;
       page3->setLayout(EditorProfessionnalInfos);
       Editor->addTab(page3, "Coordonnées pro.");

     ActionsButtons = new QHBoxLayout; // Création d'un layout horizontal pour les boutons
      ActionsButtons->addWidget(addButton); // Ajout du bouton addButton au layout
      ActionsButtons->addWidget(cancelButton);

     ActionsButtonsWidget = new QWidget; // Création d'un widget pour les boutons
      ActionsButtonsWidget->setLayout(ActionsButtons); // Définition du layout ActionsButtons au widget ActionsButtonsWidget


     dockLayout = new QVBoxLayout; // Création d'un layout vertical pour le dock
      dockLayout->addWidget(Editor);
      dockLayout->addWidget(ActionsButtonsWidget);
     DockWidget = new QWidget; // Création d'un widget pour le dock
      DockWidget->setLayout(dockLayout); // Définition du layout dockLayout au widget DockWidget

      dockInfos = new QDockWidget(tr("Informations"), this); // Création d'un widget dock de titre "Informations"
       addDockWidget(Qt::LeftDockWidgetArea, dockInfos); // Ajout du dock dockInfos à la gauche de la fenêtre
        infosLabel = new QTextBrowser(this); // Création d'un nouveau widget QTextBrowser infoLabel
        infosLabel->setText("<h1>Bienvenue !</h1><p>Sélectionnez un contact pour en afficher les détails ou ajoutez une nouvelle fiche au carnet d'adresses.</p>"); // Définition du contenu du QTextBrowser. Il autorise le formatage du texte avec du HTML
        infosLabel->setAlignment(Qt::AlignTop); // Définition de l'alignement vertical du texte : haut
        infosLabel->setReadOnly(1); // Définition du widget en lecture seule : il est utilisé uniquement pour l'affichage
         infosLabel->setOpenExternalLinks(1); // Autoriser l'ouverture des liens externes dans un navigateur
         infosLabel->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse); // Autoriser les liens et la sélection de texte à la souris
         connect(infosLabel, SIGNAL(anchorClicked(QUrl)), this, SLOT(inContextLink(QUrl))); // signal pour l'ouverture des liens internes (ancres #blabla)
        dockInfos->setWidget(infosLabel);


     dock = new QDockWidget(tr("Editeur"), this);
     dock->setAllowedAreas(Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea | Qt::LeftDockWidgetArea);
      dock->setWidget(DockWidget);
      addDockWidget(Qt::RightDockWidgetArea, dock);




    // Modèle. Objet désignant la table "addressbook" de la BDD.
      // Couche d'abstraction destinée à faciliter les accès, éviter les injections etc.
    model = new QSqlTableModel;
      model->setTable("addressbook"); // définition de la table traitée
      model->setEditStrategy(QSqlTableModel::OnManualSubmit); // stratégie d'édition du modèle (= quand on enregistre le fichier ?) - réglé sur un déclenchement manuel
      model->select(); // mise à jour des données (on selectionne tout)
      model->setHeaderData(0, Qt::Horizontal, tr("id")); // modification du titre de la colonne 0
      model->setHeaderData(1, Qt::Horizontal, tr("Prénom"));
      model->setHeaderData(2, Qt::Horizontal, tr("Nom"));

     // Vue. Objet affichant le modèle
        // Widget proposé simplifiant les communications avec le modèle.
    view = new QTableView;
     view->setModel(model); // Définition du modèle sur model
     switchView(); // Appel de la fonction switchView de la classe. Elle retire la majeure partie des colonnes pour n'afficher que l'id, le nom et le prénom
     view->setShowGrid(0); // Ote la grille
     view->setEditTriggers(QAbstractItemView::NoEditTriggers); // Désactivation de l'édition au sein du tableau
     view->setSelectionBehavior(QAbstractItemView::SelectRows); // Permet la seule sélection d'une ligne
     view->setSelectionMode(QAbstractItemView::SingleSelection); // Permettre la sélection d'une seule ligne seulement
     view->sortByColumn(0,Qt::AscendingOrder); // Tri initial par id
     view->verticalHeader()->hide(); // Cache l'affichage des numéros de ligne
     view->setSortingEnabled(true); // Autorise le tri
     view->show(); // Affichage du tableau
     connect(view, SIGNAL(clicked(QModelIndex)), this, SLOT(retrieveContactData()));

      setCentralWidget(view); // défini view en tant que widget central de la fenêtre (celle de la classe)


      // Affichage de la barre de menu.
    menuFile = menuBar()->addMenu("&Fichier"); // Nouvelle barre de menu : Fichier
    menuitemNew = menuFile->addAction("&Nouvelle fiche"); // Nouvel élément de menu : Nouvelle fiche
     menuitemNew->setShortcut(QKeySequence::New); // Définition du raccourci clavier assigné à cette entrée du menu
     menuitemNew->setIcon(QIcon("./icons/list-add.png")); // Définition de l'icône associée à cette entrée du menu
      connect(menuitemNew, SIGNAL(triggered()), this, SLOT(editorClear()));
     menuitemDelete = menuFile->addAction("&Supprimer fiche");
     menuitemDelete->setShortcut(QKeySequence::Delete);
     menuitemDelete->setIcon(QIcon("./icons/list-remove.png"));
      connect(menuitemDelete, SIGNAL(triggered()), this, SLOT(deleteContact()));
     menuitemExport = menuFile->addAction("&Exporter");
      connect(menuitemExport, SIGNAL(triggered()), this, SLOT(csvExport()));
     menuitemQuit = menuFile->addAction("&Quitter");
     menuitemQuit->setShortcut(QKeySequence::Quit);
      connect(menuitemQuit, SIGNAL(triggered()), qApp, SLOT(quit()));
/*    menuView = menuBar()->addMenu("&Affichage");
     menuitemFullView = menuView->addAction("&Affichage complet");
      menuitemFullView->setCheckable(true);
      connect(menuitemFullView, SIGNAL(triggered()), this, SLOT(switchView()));*/
    menuHelp = menuBar()->addMenu("&Aide");
     menuitemAboutapp = menuHelp->addAction("&A propos...");
      connect(menuitemAboutapp, SIGNAL(triggered()), this, SLOT(aboutApp()));
     menuitemAboutQt = menuHelp->addAction("&A propos de Qt...");
      connect(menuitemAboutQt, SIGNAL(triggered()), this, SLOT(aboutQt()));

      // Affichage de la barre d'outils
    QToolBar *toolbar  = addToolBar("Barre d'outils"); // Nouvelle barre d'outils
     toolbar->addAction(menuitemNew); // ajout du bouton menuitemNew à la barre (même élément que celui du menu)
     toolbar->addAction(menuitemDelete);
     quicksearchLabel = new QLabel(tr("Recherche : "),this);
      toolbar->addWidget(quicksearchLabel); // ajout champ de recherche
     quicksearchLine = new QLineEdit;
      toolbar->addWidget(quicksearchLine);
      connect(quicksearchLine, SIGNAL(textChanged(QString)), this, SLOT(updateSearch(QString)));


      // TODO : Trouver un titre pour cette application.
     setWindowTitle(tr("Swithom"));
}
Ejemplo n.º 15
0
void            GUI::EverywhereWindow::createMenu() {
    AWidget     *widget = new GUI::Library(this);
    _menuWidgets["libraryButton"] = std::make_pair("library", widget);
    connect(ui->libraryButton, SIGNAL(clicked()), this, SLOT(switchView()));
    widget->hide();
    ui->gridLayout->addWidget(widget, 3, 0, 1, 2);

    AWidget     *widget2 = new GUI::News(this);
    _menuWidgets["newButton"] = std::make_pair("new", widget2);
    connect(ui->newButton, SIGNAL(clicked()), this, SLOT(switchView()));
    widget2->hide();
    ui->gridLayout->addWidget(widget2, 4, 0, 1, 2);

    AWidget     *widget3 = new GUI::Radio(this);
    _menuWidgets["radioButton"] = std::make_pair("radio", widget3);
    connect(ui->radioButton, SIGNAL(clicked()), this, SLOT(switchView()));
    widget3->hide();
    ui->gridLayout->addWidget(widget3, 5, 0, 1, 2);

    AWidget     *widget4 = new GUI::Download(this);
    _menuWidgets["downloadButton"] = std::make_pair("download", widget4);
    connect(ui->downloadButton, SIGNAL(clicked()), this, SLOT(switchView()));
    widget4->hide();
    ui->gridLayout->addWidget(widget4, 6, 0, 1, 2);

    AWidget     *widget5 = new GUI::Research(this);
    _menuWidgets["researchButton"] = std::make_pair("research", widget5);
    connect(ui->researchButton, SIGNAL(clicked()), this, SLOT(switchView()));
    widget5->hide();
    ui->gridLayout->addWidget(widget5, 6, 0, 1, 2);

    AWidget     *widget6 = new GUI::Stream(this);
    _menuWidgets["streamButton"] = std::make_pair("stream", widget6);
    connect(ui->streamButton, SIGNAL(clicked()), this, SLOT(switchView()));
    widget6->hide();
    ui->gridLayout->addWidget(widget6, 7, 0, 1, 2);

    AWidget     *widget7 = new GUI::Synchronization(this);
    _menuWidgets["synchronizationButton"] = std::make_pair("synchronization", widget7);
    connect(ui->synchronizationButton, SIGNAL(clicked()), this, SLOT(switchView()));
    widget7->hide();
    ui->gridLayout->addWidget(widget7, 8, 0, 1, 2);

    AWidget     *widget8 = new GUI::Profil(this);
    _menuWidgets["profilButton"] = std::make_pair("profil", widget8);
    connect(dynamic_cast<GUI::Profil *>(widget8), SIGNAL(deleted()), _parent, SLOT(showConnection()));
    connect(ui->profilButton, SIGNAL(clicked()), this, SLOT(switchView()));
    widget8->hide();
    ui->gridLayout->addWidget(widget8, 9, 0, 1, 2);

    AWidget     *widget9 = new GUI::Disconnect(this);
    _menuWidgets["disconnectButton"] = std::make_pair("disconnect", widget9);
    connect(ui->disconnectButton, SIGNAL(clicked()), this, SLOT(switchView()));
    widget9->hide();
    ui->gridLayout->addWidget(widget9, 10, 0, 1, 2);

    AWidget     *widget10 = new GUI::ResultSearch(this);
    _menuWidgets["searchButton"] = std::make_pair("resultSearch", widget10);
    connect(ui->searchButton, SIGNAL(clicked()), this, SLOT(getSearchResult()));
    connect(dynamic_cast<GUI::ResultSearch *>(widget10), SIGNAL(goToResult()), this, SLOT(showResult()));
    widget10->hide();
    ui->gridLayout->addWidget(widget10, 11, 0, 1, 2);

    AWidget     *widget11 = new GUI::Result(this);
    _menuWidgets["ResultView"] = std::make_pair("Result", widget11);
    widget11->hide();
    ui->gridLayout->addWidget(widget11, 12, 0, 1, 2);
}
Ejemplo n.º 16
0
ViewerWindow::ViewerWindow(QWidget* parent, Qt::WindowFlags flags)
	: QMainWindow(parent, flags)
	, gameData(nullptr)
	, gameWorld(nullptr)
	, renderer(nullptr)
{
	setMinimumSize(640, 480);

	QMenuBar* mb = this->menuBar();
	QMenu* file = mb->addMenu("&File");

	file->addAction("Open &Game", this, SLOT(loadGame()));

	file->addSeparator();
	for(int i = 0; i < MaxRecentGames; ++i) {
		QAction* r = file->addAction("");
		recentGames.append(r);
		connect(r, SIGNAL(triggered()), SLOT(openRecent()));
	}

	recentSep = file->addSeparator();
	auto ex = file->addAction("E&xit");
	ex->setShortcut(QKeySequence::Quit);
	connect(ex, SIGNAL(triggered()), QApplication::instance(), SLOT(closeAllWindows()));

	//----------------------- View Mode setup
	viewerWidget = new ViewerWidget;
	viewerWidget->context()->makeCurrent();
	connect(this, SIGNAL(loadedData(GameWorld*)), viewerWidget, SLOT(dataLoaded(GameWorld*)));

	//------------- Object Viewer
	m_views[ViewMode::Object] = new ObjectViewer(viewerWidget);
	m_viewNames[ViewMode::Object] = "Objects";

	//------------- Model Viewer
	m_views[ViewMode::Model]  = new ModelViewer(viewerWidget);
	m_viewNames[ViewMode::Model] = "Model";

	//------------- World Viewer
	m_views[ViewMode::World] = new WorldViewer(viewerWidget);
	m_viewNames[ViewMode::World] = "World";

	//------------- display mode switching
	viewSwitcher = new QStackedWidget;
	auto signalMapper = new QSignalMapper(this);
	auto switchPanel = new QVBoxLayout();
	int i = 0;
	for(auto viewer : m_views) {
		viewSwitcher->addWidget(viewer);
		connect(this, SIGNAL(loadedData(GameWorld*)), viewer, SLOT(showData(GameWorld*)));

		auto viewerButton = new QPushButton(m_viewNames[i].c_str());
		signalMapper->setMapping(m_views[i], i);
		signalMapper->setMapping(viewerButton, i);
		connect(viewerButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
		switchPanel->addWidget(viewerButton);
		i++;
	}
	// Map world viewer loading placements to switch to the world viewer
	connect(m_views[ViewMode::World], SIGNAL(placementsLoaded(QString)), signalMapper, SLOT(map()));

	switchView(ViewMode::Object);

	connect(m_views[ViewMode::Object], SIGNAL(showObjectModel(uint16_t)), this, SLOT(showObjectModel(uint16_t)));
	connect(m_views[ViewMode::Object], SIGNAL(showObjectModel(uint16_t)), m_views[ViewMode::Model], SLOT(showObject(uint16_t)));
	connect(this, SIGNAL(loadAnimations(QString)), m_views[ViewMode::Model], SLOT(loadAnimations(QString)));

	connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(switchView(int)));
	connect(signalMapper, SIGNAL(mapped(int)), viewSwitcher, SLOT(setCurrentIndex(int)));

	switchPanel->addStretch();
	auto mainlayout = new QHBoxLayout();
	mainlayout->addLayout(switchPanel);
	mainlayout->addWidget(viewSwitcher);
	auto mainwidget = new QWidget();
	mainwidget->setLayout(mainlayout);

	QMenu* data = mb->addMenu("&Data");
	//data->addAction("Export &Model", objectViewer, SLOT(exportModel()));

	QMenu* anim = mb->addMenu("&Animation");
	anim->addAction("Load &Animations", this, SLOT(openAnimations()));

	QMenu* map = mb->addMenu("&Map");
	map->addAction("Load IPL", m_views[ViewMode::World], SLOT(loadPlacements()));

	this->setCentralWidget(mainwidget);

	updateRecentGames();
}
Ejemplo n.º 17
0
void NetTree::switchBrowseView()
{
    m_type = DLG_BROWSER;
    switchView();
}