]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/infosidebarpage.cpp
Dolphin is now a KUniqueApplication. A lot of thanks go to Oscar Blumberg, who submit...
[dolphin.git] / src / infosidebarpage.cpp
index d076d5a3284344f57f64e9d21f4544fa73dfc60c..f895a71d66e4ca645578280e001b26f711c20ce7 100644 (file)
@@ -14,7 +14,7 @@
  *   You should have received a copy of the GNU General Public License     *
  *   along with this program; if not, write to the                         *
  *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
  ***************************************************************************/
 
 #include "infosidebarpage.h"
@@ -132,7 +132,8 @@ void InfoSidebarPage::requestDelayedItemInfo(const KUrl& url)
 
     if (!url.isEmpty() && !m_multipleSelection) {
         m_urlCandidate = url;
-        m_timer->start(300, true);
+        m_timer->setSingleShot(true);
+        m_timer->start(300);
     }
 }
 
@@ -154,8 +155,8 @@ void InfoSidebarPage::showItemInfo()
 
     // show the preview...
     DolphinView* view = mainWindow()->activeView();
-    const KFileItemList* selectedItems = view->selectedItems();
-    if ((selectedItems != 0) && selectedItems->count() > 1) {
+    const KFileItemList selectedItems = view->selectedItems();
+    if (selectedItems.count() > 1) {
         m_multipleSelection = true;
     }
 
@@ -165,7 +166,7 @@ void InfoSidebarPage::showItemInfo()
                                            K3Icon::NoGroup,
                                            K3Icon::SizeEnormous);
         m_preview->setPixmap(icon);
-        m_name->setText(i18n("%1 items selected",selectedItems->count()));
+        m_name->setText(i18n("%1 items selected",selectedItems.count()));
     }
     else if (!applyBookmark()) {
         // try to get a preview pixmap from the item...
@@ -177,7 +178,13 @@ void InfoSidebarPage::showItemInfo()
 
         KIO::PreviewJob* job = KIO::filePreview(list,
                                                 m_preview->width(),
-                                                K3Icon::SizeEnormous);
+                                                K3Icon::SizeEnormous,
+                                                0,
+                                                0,
+                                                true,
+                                                false);
+        job->setIgnoreMaximumSize(true);
+
         connect(job, SIGNAL(gotPreview(const KFileItem*, const QPixmap&)),
                 this, SLOT(gotPreview(const KFileItem*, const QPixmap&)));
         connect(job, SIGNAL(failed(const KFileItem*)),
@@ -233,9 +240,9 @@ void InfoSidebarPage::connectToActiveView()
     cancelRequest();
 
     DolphinView* view = mainWindow()->activeView();
-    connect(view, SIGNAL(signalRequestItemInfo(const KUrl&)),
+    connect(view, SIGNAL(requestItemInfo(const KUrl&)),
             this, SLOT(requestDelayedItemInfo(const KUrl&)));
-    connect(view, SIGNAL(signalUrlChanged(const KUrl&)),
+    connect(view, SIGNAL(urlChanged(const KUrl&)),
             this, SLOT(requestItemInfo(const KUrl&)));
 
     m_shownUrl = view->url();
@@ -400,7 +407,8 @@ void InfoSidebarPage::addInfoLine(const QString& labelText, const QString& infoT
 
         QLabel* info = new QLabel(infoText, m_infoGrid);
         info->setTextFormat(Qt::RichText);
-        info->setAlignment(Qt::AlignTop | Qt::TextWordWrap);
+        info->setAlignment(Qt::AlignTop);
+        info->setWordWrap(true);
         info->show();
         m_infoWidgets.append(info);
 
@@ -429,12 +437,10 @@ void InfoSidebarPage::insertActions()
     // of KFileItems. If no selection is given, a temporary KFileItem
     // by the given Url 'url' is created and added to the list.
     KFileItem fileItem(S_IFDIR, KFileItem::Unknown, m_shownUrl);
-    KFileItemList localList;
-    const KFileItemList* itemList = mainWindow()->activeView()->selectedItems();
-    if ((itemList == 0) || itemList->isEmpty()) {
+    KFileItemList itemList = mainWindow()->activeView()->selectedItems();
+    if (itemList.isEmpty()) {
         fileItem.refresh();
-        localList.append(&fileItem);
-        itemList = &localList;
+        itemList.append(&fileItem);
     }
 
     // 'itemList' contains now all KFileItems, where an item information should be shown.
@@ -443,13 +449,13 @@ void InfoSidebarPage::insertActions()
     QStringList dirs = KGlobal::dirs()->findDirs("data", "dolphin/servicemenus/");
     for (QStringList::ConstIterator dirIt = dirs.begin(); dirIt != dirs.end(); ++dirIt) {
         QDir dir(*dirIt);
-        QStringList entries = dir.entryList("*.desktop", QDir::Files);
+        QStringList entries = dir.entryList(QStringList("*.desktop"), QDir::Files);
 
         for (QStringList::ConstIterator entryIt = entries.begin(); entryIt != entries.end(); ++entryIt) {
             KSimpleConfig cfg(*dirIt + *entryIt, true);
             cfg.setDesktopGroup();
             if ((cfg.hasKey("Actions") || cfg.hasKey("X-KDE-GetActionMenu")) && cfg.hasKey("ServiceTypes")) {
-                const QStringList types = cfg.readListEntry("ServiceTypes");
+                const QStringList types = cfg.readEntry("ServiceTypes", QStringList(), ',');
                 for (QStringList::ConstIterator it = types.begin(); it != types.end(); ++it) {
                     // check whether the mime type is equal or whether the
                     // mimegroup (e. g. image/*) is supported
@@ -458,7 +464,7 @@ void InfoSidebarPage::insertActions()
                     if ((*it) == "all/allfiles") {
                         // The service type is valid for all files, but not for directories.
                         // Check whether the selected items only consist of files...
-                        QListIterator<KFileItem*> mimeIt(*itemList);
+                        QListIterator<KFileItem*> mimeIt(itemList);
                         insert = true;
                         while (insert && mimeIt.hasNext()) {
                             KFileItem* item = mimeIt.next();
@@ -470,16 +476,16 @@ void InfoSidebarPage::insertActions()
                         // Check whether the MIME types of all selected files match
                         // to the mimetype of the service action. As soon as one MIME
                         // type does not match, no service menu is shown at all.
-                        QListIterator<KFileItem*> mimeIt(*itemList);
+                        QListIterator<KFileItem*> mimeIt(itemList);
                         insert = true;
                         while (insert && mimeIt.hasNext()) {
                             KFileItem* item = mimeIt.next();
                             const QString mimeType(item->mimetype());
-                            const QString mimeGroup(mimeType.left(mimeType.find('/')));
+                            const QString mimeGroup(mimeType.left(mimeType.indexOf('/')));
 
                             insert  = (*it == mimeType) ||
                                       ((*it).right(1) == "*") &&
-                                      ((*it).left((*it).find('/')) == mimeGroup);
+                                      ((*it).left((*it).indexOf('/')) == mimeGroup);
                         }
                     }
 
@@ -494,7 +500,7 @@ void InfoSidebarPage::insertActions()
 
                             QPushButton* button = new QPushButton(submenuName, m_actionBox);
                             button->setFlat(true);
-                            button->setPopup(popup);
+                            button->setMenu(popup);
                             button->show();
                             m_actionWidgets.append(button);
                         }
@@ -507,7 +513,7 @@ void InfoSidebarPage::insertActions()
                         for (serviceIt = userServices.begin(); serviceIt != userServices.end(); ++serviceIt) {
                             KDEDesktopMimeType::Service service = (*serviceIt);
                             if (popup == 0) {
-                                ServiceButton* button = new ServiceButton(SmallIcon(service.m_strIcon),
+                                ServiceButton* button = new ServiceButton(KIcon(service.m_strIcon),
                                                                           service.m_strName,
                                                                           m_actionBox,
                                                                           actionsIndex);
@@ -517,7 +523,7 @@ void InfoSidebarPage::insertActions()
                                 button->show();
                             }
                             else {
-                                popup->insertItem(SmallIcon(service.m_strIcon), service.m_strName, actionsIndex);
+                                popup->insertItem(KIcon(service.m_strIcon), service.m_strName, actionsIndex);
                             }
 
                             m_actionsVector.append(service);
@@ -538,7 +544,7 @@ ServiceButton::ServiceButton(const QIcon& icon,
     m_hover(false),
     m_index(index)
 {
-    setEraseColor(colorGroup().background());
+    setEraseColor(palette().brush(QPalette::Background).color());
     setFocusPolicy(Qt::NoFocus);
     connect(this, SIGNAL(released()),
             this, SLOT(slotReleased()));
@@ -561,7 +567,7 @@ void ServiceButton::paintEvent(QPaintEvent* event)
         foregroundColor = KGlobalSettings::highlightedTextColor();
     }
     else {
-        backgroundColor = colorGroup().background();
+        backgroundColor = palette().brush(QPalette::Background).color();
         foregroundColor = KGlobalSettings::buttonTextColor();
     }
 
@@ -575,9 +581,9 @@ void ServiceButton::paintEvent(QPaintEvent* event)
     // draw icon
     int x = spacing;
     const int y = (buttonHeight - K3Icon::SizeSmall) / 2;
-    const QIcon* set = iconSet();
-    if (set != 0) {
-        painter.drawPixmap(x, y, set->pixmap(QIcon::Small, QIcon::Normal));
+    const QIcon &set = icon();
+    if (!set.isNull()) {
+        painter.drawPixmap(x, y, set.pixmap(QIcon::Small, QIcon::Normal));
     }
     x += K3Icon::SizeSmall + spacing;