ArchiverWindow::ArchiverWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::ArchiverWindow)
    , m_busy(false)
{
    ui->setupUi(this);

    // Set the archive model
    m_model = new ArchiveModel(this);
    ui->treeView->setModel(m_model);

    connect(ui->actionFileNew, SIGNAL(triggered()),
            this, SLOT(slotFileNew()));
    connect(ui->actionFileOpen, SIGNAL(triggered()),
            this, SLOT(slotFileOpen()));
    connect(ui->actionFileSaveAs, SIGNAL(triggered()),
            this, SLOT(slotFileSaveAs()));
    connect(ui->actionFileQuit, SIGNAL(triggered()),
            this, SLOT(close()));
    connect(ui->actionActionAddFile, SIGNAL(triggered()),
            this, SLOT(slotActionAddFile()));
    connect(ui->actionActionAddFolder, SIGNAL(triggered()),
            this, SLOT(slotActionAddFolder()));
    connect(ui->actionActionDelete, SIGNAL(triggered()),
            this, SLOT(slotActionDelete()));
    connect(ui->actionActionExtract, SIGNAL(triggered()),
            this, SLOT(slotActionExtract()));
    connect(ui->actionHelpAbout, SIGNAL(triggered()),
            this, SLOT(slotHelpAbout()));
}
Exemplo n.º 2
0
void DialogMsgManage::init()
{
    setWindowFlags(Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
    setAttribute(Qt::WA_DeleteOnClose);
    //加载qss
    QFile file(":/qss/Dialog.qss");
    if (!file.open(QIODevice::ReadOnly)) {
        qDebug() << file.errorString() << __FILE__ << __LINE__;
    } else {
        setStyleSheet(file.readAll());
    }
    file.close();    
    connect(g_msgbox, SIGNAL(signMsgChanged(int,int,int))
            , this, SLOT(slotProcessMsgChange(int,int,int)), Qt::QueuedConnection);
    
    ui->btnFirstPage->setEnabled(false);
    ui->btnPrevPage->setEnabled(false);
    ui->btnNextPage->setEnabled(false);
    ui->btnLastPage->setEnabled(false);

    m_valid.setRange(0, 0);
    ui->lineEditCurPage->setValidator(&m_valid);
    ui->lineEditCurPage->setText("0");
    ui->lineEditCurPage->setAlignment(Qt::AlignCenter);
    ui->labelPageNum->setAlignment(Qt::AlignCenter);
    
    //信息列表菜单
    m_actRead = new QAction(this);
    connect(m_actRead, SIGNAL(triggered()), this, SLOT(slotActionRead()));
    m_actStopRead = new QAction(this);
    connect(m_actStopRead, SIGNAL(triggered()), this, SLOT(slotActionStopRead()));
    m_actForwarding = new QAction(this);
    connect(m_actForwarding, SIGNAL(triggered()), this, SLOT(slotActionForwarding()));
    m_actReply = new QAction(this);
    connect(m_actReply, SIGNAL(triggered()), this, SLOT(slotActionReply()));
//    m_actMoveToInbox = new QAction(this);
//    connect(m_actMoveToInbox, SIGNAL(triggered()), this, SLOT(slotActionMoveToInbox()));
//    m_actMoveToOutbox = new QAction(this);
//    connect(m_actMoveToOutbox, SIGNAL(triggered()), this, SLOT(slotActionMoveToOutbox()));
//    m_actMoveToDraftbox = new QAction(this);
//    connect(m_actMoveToDraftbox, SIGNAL(triggered()), this, SLOT(slotActionMoveToDraftbox()));
//    m_actMoveToDustbin = new QAction(this);
//    connect(m_actMoveToDustbin, SIGNAL(triggered()), this, SLOT(slotActionMoveToDustbin()));
    m_actRestore = new QAction(this);
    connect(m_actRestore, SIGNAL(triggered()), this, SLOT(slotActionRestore()));
    m_actAddIntoPhoneBook = new QAction(this);
    connect(m_actAddIntoPhoneBook, SIGNAL(triggered()), this, SLOT(slotActionAddIntoPhoneBook()));
    m_actDelete = new QAction(this);
    connect(m_actDelete, SIGNAL(triggered()), this, SLOT(slotActionDelete()));
    m_menuMsgList = new QMenu(this);
    m_menuMsgList->addAction(m_actRead);
    m_menuMsgList->addAction(m_actStopRead);
    m_menuMsgList->addAction(m_actForwarding);
    m_menuMsgList->addAction(m_actReply);
    m_menuMsgList->addSeparator();
    m_menuMsgList->addAction(m_actAddIntoPhoneBook);
    m_menuMsgList->addSeparator();
//    m_menuMsgList->addAction(m_actMoveToInbox);
//    m_menuMsgList->addAction(m_actMoveToOutbox);
//    m_menuMsgList->addAction(m_actMoveToDraftbox);
//    m_menuMsgList->addAction(m_actMoveToDustbin);
    m_menuMsgList->addAction(m_actRestore);
    m_menuMsgList->addSeparator();
    m_menuMsgList->addAction(m_actDelete);
    ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
    
    m_actSetAllRead = new QAction(this);
    connect(m_actSetAllRead, SIGNAL(triggered()), this, SLOT(slotActionSetAllRead()));
    m_actViewUnread = new QAction(this);
    connect(m_actViewUnread, SIGNAL(triggered()), this, SLOT(slotActionViewUnread()));
    m_actExport = new QAction(this);
    connect(m_actExport, SIGNAL(triggered()), this, SLOT(slotActionExport()));
    m_actDeleteAll = new QAction(this);
    connect(m_actDeleteAll, SIGNAL(triggered()), this, SLOT(slotActionDeleteAll()));
    m_actDeleteMoreSetting = new QAction(this);
    connect(m_actDeleteMoreSetting, SIGNAL(triggered()), this, SLOT(slotActionDeleteMoreSetting()));
    m_menuTree = new QMenu(this);
    m_menuTree->addAction(m_actViewUnread);
    m_menuTree->addAction(m_actSetAllRead);
    m_menuTree->addSeparator();
    m_menuTree->addAction(m_actExport);
    m_menuTree->addSeparator();
    m_menuTree->addAction(m_actDeleteAll);
    m_menuTree->addAction(m_actDeleteMoreSetting);
    ui->treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);

    ui->treeWidget->header()->hide();
    m_msgBoxTopItem = new QTreeWidgetItem(ui->treeWidget);
    m_msgBoxTopItem->setSizeHint(0, QSize(0, cons_tree_item_height));
    for (int i=0; i<=Message::Box_Dustbin; i++) {
        QTreeWidgetItem *twItem = new QTreeWidgetItem(m_msgBoxTopItem);
        twItem->setData(0, Qt::UserRole + DataIndex_Type, DataType_MessageBox);
        twItem->setData(0, Qt::UserRole + DataIndex_Value, i);
        twItem->setSizeHint(0, QSize(0, cons_tree_item_height));
        m_msgBoxItems << twItem;
    }
    m_phoneBookItem = new QTreeWidgetItem(ui->treeWidget);
    m_phoneBookItem->setSizeHint(0, QSize(0, cons_tree_item_height));
    for (int i=0; i<=Contact::Type_Stranger; i++) {
        QTreeWidgetItem *twItem = new QTreeWidgetItem(m_phoneBookItem);
        twItem->setSizeHint(0, QSize(0, cons_tree_item_height));
        QList<Contact> contacts = g_phoneBook->getContactsOfType((Contact::Type)i);
        foreach (Contact contact, contacts) {
            QTreeWidgetItem *twItemT = new QTreeWidgetItem(twItem);
            twItemT->setText(0, QString("%1(%2)").arg(contact.name).arg(contact.phonenum));
            twItemT->setData(0, Qt::UserRole + DataIndex_Type, DataType_PhoneBook);
            twItemT->setData(0, Qt::UserRole + DataIndex_Value, QVariant::fromValue<Contact>(contact));
            twItemT->setSizeHint(0, QSize(0, cons_tree_item_height));
        }
        m_contactTypeItems << twItem;
    }